Package org.w3c.dom.css

Examples of org.w3c.dom.css.CSSPrimitiveValue


     * @param v the value to convert
     * @param d HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
     * @param ctx the context
     */
    protected static float emsToPixels(float v, short d, Context ctx) {
        CSSPrimitiveValue fontSize = ctx.getFontSize();
        short type = fontSize.getPrimitiveType();
        switch (type) {
            case CSSPrimitiveValue.CSS_IDENT:
                float fs = ctx.getMediumFontSize();
                fs = TextUtilities.parseFontSize(fontSize.getStringValue(), fs);
                return v * cssToUserSpace(fs,
                                          CSSPrimitiveValue.CSS_PT,
                                          d,
                                          ctx);
            default:
                return v * cssToUserSpace(fontSize.getFloatValue(type),
                                          type,
                                          d,
                                          ctx.getParentElementContext());
        }
    }
View Full Code Here


     * @param v the value to convert
     * @param d HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
     * @param ctx the context
     */
    protected static float pixelsToExs(float v, short d, Context ctx) {
        CSSPrimitiveValue fontSize = ctx.getFontSize();
        short type = fontSize.getPrimitiveType();
        float fontSizeVal;
        switch (type) {
            case CSSPrimitiveValue.CSS_IDENT:
                float fs = ctx.getMediumFontSize();
                fs = TextUtilities.parseFontSize(fontSize.getStringValue(), fs);
                fontSizeVal = cssToUserSpace(fs,
                                             CSSPrimitiveValue.CSS_PT,
                                             d,
                                             ctx);
                break;
            default:
                fontSizeVal = cssToUserSpace(fontSize.getFloatValue(type),
               type,
                                             d,
                                             ctx.getParentElementContext());
        }
        float xh = ctx.getXHeight();
View Full Code Here

     * @param v the value to convert
     * @param d HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
     * @param ctx the context
     */
    protected static float exsToPixels(float v, short d, Context ctx) {
        CSSPrimitiveValue fontSize = ctx.getFontSize();
        short type = fontSize.getPrimitiveType();
        float fontSizeVal;
        switch (type) {
            case CSSPrimitiveValue.CSS_IDENT:
                float fs = ctx.getMediumFontSize();
                fs = TextUtilities.parseFontSize(fontSize.getStringValue(), fs);
                fontSizeVal = cssToUserSpace(fs,
                                             CSSPrimitiveValue.CSS_PT,
                                             d,
                                             ctx);
                break;
            default:
                fontSizeVal = cssToUserSpace(fontSize.getFloatValue(type),
               type,
                                             d,
                                             ctx.getParentElementContext());
        }
        float xh = ctx.getXHeight();
View Full Code Here

            }
            return super.createValue(lu);
        case LexicalUnit.SAC_RGBCOLOR:
            LexicalUnit l = lu.getParameters();
            ValueFactory ph = new ColorComponentFactory(getParser());
            CSSPrimitiveValue r = new CSSOMValue(ph, createColorValue(l));
            l = l.getNextLexicalUnit().getNextLexicalUnit();
            CSSPrimitiveValue g = new CSSOMValue(ph, createColorValue(l));
            l = l.getNextLexicalUnit().getNextLexicalUnit();
            CSSPrimitiveValue b = new CSSOMValue(ph, createColorValue(l));
            lu = lu.getNextLexicalUnit();
            if (lu == null) {
                return new ImmutableRGBColor(r, g, b);
            }
            if (lu.getLexicalUnitType() != LexicalUnit.SAC_FUNCTION) {
View Full Code Here

        this.textElement = textElement;

        this.language = XMLSupport.getXMLLang(textElement);

        CSSOMReadOnlyStyleDeclaration cssDecl = CSSUtilities.getComputedStyle(textElement);
        CSSPrimitiveValue v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValueInternal(CSS_WRITING_MODE_PROPERTY);
        if (v.getStringValue().startsWith(CSS_TB_VALUE)) {
            // top to bottom, so set orientation to "v"
            this.orientation = SVG_V_VALUE;
        } else {
            this.orientation = SVG_H_VALUE;
        }
View Full Code Here

        //
        // The CSS engine will give us a SVGPaint in any cases. We also
        // should also be able to use strong typing on convertXXX methods.
        //
        if (paintDef.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
            CSSPrimitiveValue v = (CSSPrimitiveValue)paintDef;
            switch (v.getPrimitiveType()) {
            case CSSPrimitiveValue.CSS_IDENT:
                return null; // none
            case CSSPrimitiveValue.CSS_RGBCOLOR:
                return convertColor(v.getRGBColorValue(), opacity);
            case CSSPrimitiveValue.CSS_URI:
                return convertURIPaint(paintedElement,
                                       paintedNode,
                                       paintDef,
                                       opacity,
View Full Code Here

            if (!lu.getFunctionName().equalsIgnoreCase("rect")) {
                break;
            }
        case LexicalUnit.SAC_RECT_FUNCTION:
            lu = lu.getParameters();
            CSSPrimitiveValue t;
            t = (CSSPrimitiveValue)factory.createCSSValue(lu);
            lu = lu.getNextLexicalUnit();
            if (lu == null ||
                lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
                throw new DOMException
                    (DOMException.INVALID_ACCESS_ERR,
                     StyleAttributeParser.LOCALIZABLE_SUPPORT.formatMessage
                     ("invalid.lexical.unit",
                      new Object[] { new Integer(lu.getLexicalUnitType()) }));
            }
            lu = lu.getNextLexicalUnit();
            CSSPrimitiveValue r;
            r = (CSSPrimitiveValue)factory.createCSSValue(lu);
            lu = lu.getNextLexicalUnit();
            if (lu == null ||
                lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
                throw new DOMException
                    (DOMException.INVALID_ACCESS_ERR,
                     StyleAttributeParser.LOCALIZABLE_SUPPORT.formatMessage
                     ("invalid.lexical.unit",
                      new Object[] { new Integer(lu.getLexicalUnitType()) }));
            }
            lu = lu.getNextLexicalUnit();
            CSSPrimitiveValue b;
            b = (CSSPrimitiveValue)factory.createCSSValue(lu);
            lu = lu.getNextLexicalUnit();
            if (lu == null ||
                lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
                throw new DOMException
                    (DOMException.INVALID_ACCESS_ERR,
                     StyleAttributeParser.LOCALIZABLE_SUPPORT.formatMessage
                     ("invalid.lexical.unit",
                      new Object[] { new Integer(lu.getLexicalUnitType()) }));
            }
            lu = lu.getNextLexicalUnit();
            CSSPrimitiveValue l;
            l = (CSSPrimitiveValue)factory.createCSSValue(lu);
            return new CSSRectValue(t, r, b, l);
        }
        throw new DOMException
            (DOMException.INVALID_ACCESS_ERR,
View Full Code Here

    public static float convertFontSize(Element svgElement,
                                        BridgeContext ctx,
                                        CSSOMReadOnlyStyleDeclaration decl,
                                        UnitProcessor.Context uctx) {

        CSSPrimitiveValue v
            = (CSSPrimitiveValue)decl.getPropertyCSSValueInternal
            (CSS_FONT_SIZE_PROPERTY);

        short t = v.getPrimitiveType();
        switch (t) {
        case CSSPrimitiveValue.CSS_IDENT:
            float fs = uctx.getMediumFontSize();
            fs = parseFontSize(v.getStringValue(), fs);
            return UnitProcessor.cssToUserSpace(fs,
                                                CSSPrimitiveValue.CSS_PT,
                                                UnitProcessor.VERTICAL_LENGTH,
                                                uctx);
        default:
            return UnitProcessor.cssToUserSpace(v.getFloatValue(t),
                                                t,
                                                UnitProcessor.VERTICAL_LENGTH,
                                                uctx);
        }
    }
View Full Code Here

                                       Context c) {
        if (e == null) {
            throw new RuntimeException
                (Messages.formatMessage("element.needed", null));
        }
        CSSPrimitiveValue val = c.getFontSize(e);
        short type = val.getPrimitiveType();
        return v / cssToUserSpace
            (type,
             val.getFloatValue(type),
             (SVGElement)HiddenChildElementSupport.getParentElement(e),
             d,
             c);
    }
View Full Code Here

                                       Context c) {
        if (e == null) {
            throw new RuntimeException
                (Messages.formatMessage("element.needed", null));
        }
        CSSPrimitiveValue val = c.getFontSize(e);
        short type = val.getPrimitiveType();
        return v * cssToUserSpace
            (type,
             val.getFloatValue(type),
             (SVGElement)HiddenChildElementSupport.getParentElement(e),
             d,
             c);
    }
View Full Code Here

TOP

Related Classes of org.w3c.dom.css.CSSPrimitiveValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.