Package org.w3c.dom.css

Examples of org.w3c.dom.css.CSSValueList


        // 'stroke-dasharray'
        CSSValue vv = decl.getPropertyCSSValue(CSS_STROKE_DASHARRAY_PROPERTY);
        float [] dashArray = null;
        float dashOffset = 0;
        if (vv.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
            CSSValueList l = (CSSValueList) vv;
            int length = l.getLength();
            dashArray = new float[length];
            for (int i=0; i < length; ++i) {
                v = (CSSPrimitiveValue) l.item(i);
                type = v.getPrimitiveType();
                dashArray[i] =
                    UnitProcessor.cssToUserSpace(type,
                                                 v.getFloatValue(type),
                                                 svgElement,
View Full Code Here


        fs = fs * ctx.getUserAgent().getPixelToMM() * 72f / 25.4f;

        result.put(TextAttribute.SIZE, new Float(fs));

        // Font family
        CSSValueList ff = (CSSValueList)cssDecl.getPropertyCSSValue
            (CSS_FONT_FAMILY_PROPERTY);
        String s = null;
        for (int i = 0; s == null && i < ff.getLength(); i++) {
            v = (CSSPrimitiveValue)ff.item(i);
            s = (String)fonts.get(v.getStringValue());
        }
        s = (s == null) ? "SansSerif" : s;
        result.put(TextAttribute.FAMILY, s);

        // Font weight
        // TODO: improve support for relative values
        // (e.g. "lighter", "bolder")
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_FONT_WEIGHT_PROPERTY);
        if (v.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
            if (v.getStringValue().charAt(0) == 'n') {
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_REGULAR);
            } else if (v.getStringValue().charAt(0) == 'l') {
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_LIGHT);
            } else {
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_BOLD);
            }
        } else {
            switch ((int)v.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)) {
            case 100:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_EXTRA_LIGHT);
                break;
            case 200:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_LIGHT);
                break;
            case 300:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_DEMILIGHT);
                break;
            case 400:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_REGULAR);
                break;
            case 500:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_SEMIBOLD);
                break;
            case 600:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_DEMIBOLD);
                break;
            case 700:
                result.put(TextAttribute.WEIGHT,
                           TextAttribute.WEIGHT_BOLD);
                break;
            case 800:
                result.put(TextAttribute.WEIGHT,
                           //TextAttribute.WEIGHT_EXTRABOLD);
                           TextAttribute.WEIGHT_BOLD);
                break;
            case 900:
                result.put(TextAttribute.WEIGHT,
                           //TextAttribute.WEIGHT_ULTRABOLD);
                           TextAttribute.WEIGHT_BOLD);
            }
        }

        // Text baseline adjustment.
        // TODO: support for <percentage> and <length> values.
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_BASELINE_SHIFT_PROPERTY);
        if (v.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
            s = v.getStringValue();
            switch (s.charAt(2)) {
            case 'p': //suPerscript
                result.put(TextAttribute.SUPERSCRIPT,
                       TextAttribute.SUPERSCRIPT_SUPER);
                break;
            case 'b': //suBscript
                result.put(TextAttribute.SUPERSCRIPT,
                       TextAttribute.SUPERSCRIPT_SUB);
                break;
            case 's': //baSeline
                result.put(TextAttribute.SUPERSCRIPT,
                       new Integer(0)); // XXX: jdk1.2 doesn't define
                                        // SUPERSCRIPT_NONE, 1.3 does
                break;
            }
        } else {
            // TODO
            float f = v.getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
            // result.put(TextAttribute.TRANSFORM,
            //           CSSUtilities.convertFloatToTranslation(0f, f));
        }

        // Unicode-bidi mode
        // XXX: below supports single override level only,
        // full support requires revision: see comments
        // below regarding 'direction'

        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_UNICODE_BIDI_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'e':
            result.put(TextAttribute.BIDI_EMBEDDING,
                       new Integer(1));
            break;
        case 'b':
            result.put(TextAttribute.BIDI_EMBEDDING,
                       new Integer(-1));
            break;
        case 'n':
            result.put(TextAttribute.BIDI_EMBEDDING,
                       new Integer(0));
        }

        // Text direction
        // XXX: this needs to coordinate with the unicode-bidi
        // property, so that when an explicit reversal
        // occurs, the BIDI_EMBEDDING level is
        // appropriately incremented or decremented.
        // Note that direction is implicitly handled by unicode
        // BiDI algorithm in most cases, this property
        // is only needed when one wants to override the
        // normal writing direction for a string/substring.

        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_DIRECTION_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'l':
            result.put(TextAttribute.RUN_DIRECTION,
                       TextAttribute.RUN_DIRECTION_LTR);
            break;
        case 'r':
            result.put(TextAttribute.RUN_DIRECTION,
                       TextAttribute.RUN_DIRECTION_RTL);
            break;
        }

        // Writing mode

        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_WRITING_MODE_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'l':
            result.put(TextAttribute.RUN_DIRECTION,
                       TextAttribute.RUN_DIRECTION_LTR);
            break;
        case 'r':
            result.put(TextAttribute.RUN_DIRECTION,
                       TextAttribute.RUN_DIRECTION_RTL);
            break;
        case 't':
            break;
        }

        // Font style
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_FONT_STYLE_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'n':
            result.put(TextAttribute.POSTURE,
                       TextAttribute.POSTURE_REGULAR);
            break;
        case 'o':
        case 'i':
            result.put(TextAttribute.POSTURE,
                       TextAttribute.POSTURE_OBLIQUE);
        }

        // Font stretch
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_FONT_STRETCH_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'u':
            if (s.charAt(6) == 'c') {
                result.put(TextAttribute.WIDTH,
                           TextAttribute.WIDTH_CONDENSED);
            } else {
                result.put(TextAttribute.WIDTH,
                           TextAttribute.WIDTH_EXTENDED);
            }
            break;
        case 'e':
            if (s.charAt(6) == 'c') {
                result.put(TextAttribute.WIDTH,
                           TextAttribute.WIDTH_CONDENSED);
            } else {
                if (s.length() == 8) {
                    result.put(TextAttribute.WIDTH,
                               TextAttribute.WIDTH_SEMI_EXTENDED);
                } else {
                    result.put(TextAttribute.WIDTH,
                               TextAttribute.WIDTH_EXTENDED);
                }
            }
            break;
        case 's':
            if (s.charAt(6) == 'c') {
                result.put(TextAttribute.WIDTH,
                           TextAttribute.WIDTH_SEMI_CONDENSED);
            } else {
                result.put(TextAttribute.WIDTH,
                           TextAttribute.WIDTH_SEMI_EXTENDED);
            }
            break;
        default:
            result.put(TextAttribute.WIDTH,
                       TextAttribute.WIDTH_REGULAR);
        }

        // Opacity
        CSSPrimitiveValue opacityVal =
            (CSSPrimitiveValue)cssDecl.getPropertyCSSValue(ATTR_OPACITY);
        if (opacityVal != null) {
            Composite composite =
                CSSUtilities.convertOpacityToComposite(opacityVal);
            result.put(GVTAttributedCharacterIterator.TextAttribute.OPACITY,
                                                                     composite);
        }

        // Fill
        Paint p = CSSUtilities.convertFillToPaint((SVGElement)element,
                                                  node,
                                                  ctx,
                                                  cssDecl,
                                                  uctx);

        if (p != null) {
            result.put(TextAttribute.FOREGROUND, p);
        }

        // Stroke Paint
        Paint sp = CSSUtilities.convertStrokeToPaint((SVGElement)element,
                                              node,
                                              ctx,
                                              cssDecl,
                                              uctx);

        if (sp != null) {
            result.put
                (GVTAttributedCharacterIterator.TextAttribute.STROKE_PAINT, sp);
        }

        // Stroke
        Stroke stroke
            = CSSUtilities.convertStrokeToBasicStroke((SVGElement)element,
                                                      ctx,
                                                      cssDecl,
                                                      uctx);

        if(stroke != null){
            result.put(GVTAttributedCharacterIterator.TextAttribute.STROKE,
                       stroke);
        }

        // Text decoration
        CSSValue cssVal = cssDecl.getPropertyCSSValue
            (CSS_TEXT_DECORATION_PROPERTY);
        short t = cssVal.getCssValueType();
        if (t == CSSValue.CSS_VALUE_LIST) {
            CSSValueList lst = (CSSValueList)cssVal;
            for (int i = 0; i < lst.getLength(); i++) {
                v = (CSSPrimitiveValue)lst.item(i);
                s = v.getStringValue();
                switch (s.charAt(0)) {
                case 'u':
                    result.put(
                        GVTAttributedCharacterIterator.TextAttribute.UNDERLINE,
View Full Code Here

        }

        //System.out.println("--- align = " + align);

        // Font family
        CSSValueList ff = (CSSValueList)cssDecl.getPropertyCSSValue
            (CSS_FONT_FAMILY_PROPERTY);
        s = null;
        for (int i = 0; s == null && i < ff.getLength(); i++) {
            v = (CSSPrimitiveValue)ff.item(i);
            s = (String)fonts.get(v.getStringValue());
        }
        s = (s == null) ? "SansSerif" : s;
        attrs.put(TextAttribute.FAMILY, s);

        // Font weight
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_FONT_WEIGHT_PROPERTY);
        if (v.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
            if (v.getStringValue().charAt(0) == 'n') {
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_REGULAR);
            } else {
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_BOLD);
            }
        } else {
            switch ((int)v.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)) {
            case 100:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_EXTRA_LIGHT);
                break;
            case 200:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_LIGHT);
                break;
            case 300:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_DEMILIGHT);
                break;
            case 400:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_REGULAR);
                break;
            case 500:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_SEMIBOLD);
                break;
            case 600:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_DEMIBOLD);
                break;
            case 700:
                attrs.put(TextAttribute.WEIGHT,
                                TextAttribute.WEIGHT_BOLD);
                break;
            case 800:
                attrs.put(TextAttribute.WEIGHT,
                                //TextAttribute.WEIGHT_EXTRABOLD);
                                TextAttribute.WEIGHT_BOLD);
                break;
            case 900:
                attrs.put(TextAttribute.WEIGHT,
                                //TextAttribute.WEIGHT_ULTRABOLD);
                                TextAttribute.WEIGHT_BOLD);
            }
        }

        // Font style
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_FONT_STYLE_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'n':
            attrs.put(TextAttribute.POSTURE,
                            TextAttribute.POSTURE_REGULAR);
            break;
        case 'o':
        case 'i':
            attrs.put(TextAttribute.POSTURE,
                            TextAttribute.POSTURE_OBLIQUE);
        }

        // Font stretch
        v = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_FONT_STRETCH_PROPERTY);
        s = v.getStringValue();
        switch (s.charAt(0)) {
        case 'u':
            if (s.charAt(6) == 'c') {
                attrs.put(TextAttribute.WIDTH,
                                TextAttribute.WIDTH_CONDENSED);
            } else {
                attrs.put(TextAttribute.WIDTH,
                                TextAttribute.WIDTH_EXTENDED);
            }
            break;
        case 'e':
            if (s.charAt(6) == 'c') {
                attrs.put(TextAttribute.WIDTH,
                                TextAttribute.WIDTH_CONDENSED);
            } else {
                if (s.length() == 8) {
                    attrs.put(TextAttribute.WIDTH,
                                    TextAttribute.WIDTH_SEMI_EXTENDED);
                } else {
                    attrs.put(TextAttribute.WIDTH,
                                    TextAttribute.WIDTH_EXTENDED);
                }
            }
            break;
        case 's':
            if (s.charAt(6) == 'c') {
                attrs.put(TextAttribute.WIDTH,
                                TextAttribute.WIDTH_SEMI_CONDENSED);
            } else {
                attrs.put(TextAttribute.WIDTH,
                                TextAttribute.WIDTH_SEMI_EXTENDED);
            }
            break;
        default:
            attrs.put(TextAttribute.WIDTH,
                            TextAttribute.WIDTH_REGULAR);
        }

        // Text decoration
        CSSValue cssVal = cssDecl.getPropertyCSSValue
            (CSS_TEXT_DECORATION_PROPERTY);
        short t = cssVal.getCssValueType();
        if (t == CSSValue.CSS_VALUE_LIST) {
            CSSValueList lst = (CSSValueList)cssVal;
            for (int i = 0; i < lst.getLength(); i++) {
                v = (CSSPrimitiveValue)lst.item(i);
                s = v.getStringValue();
                switch (s.charAt(0)) {
                case 'u':
                    attrs.put(TextAttribute.UNDERLINE,
                                    TextAttribute.UNDERLINE_ON);
View Full Code Here

                       TextAttribute.WIDTH_REGULAR);
        }


        // Font family
        CSSValueList ff = (CSSValueList)cssDecl.getPropertyCSSValueInternal
            (CSS_FONT_FAMILY_PROPERTY);

        //  make a list of GVTFontFamily objects
        Vector fontFamilyList = new Vector();
        for (int i = 0; i < ff.getLength(); i++) {
            v = (CSSPrimitiveValue)ff.item(i);
            String fontFamilyName = v.getStringValue();
            GVTFontFamily fontFamily
                = SVGFontUtilities.getFontFamily(element, ctx, fontFamilyName,
                   fontWeightString, fontStyleString);
            fontFamilyList.add(fontFamily);
View Full Code Here

        if (t == CSSValue.CSS_VALUE_LIST) {

            // first check to see if its a valid list,
            // ie. if it contains none then that is the only element
            CSSValueList lst = (CSSValueList)cssVal;

            Paint paint = PaintServer.convertFillPaint(element, node, ctx);
            Paint strokePaint = PaintServer.convertStrokePaint(element, node, ctx);
            Stroke stroke = PaintServer.convertStroke(element, ctx);

            for (int i = 0; i < lst.getLength(); i++) {
                CSSPrimitiveValue v = (CSSPrimitiveValue)lst.item(i);
                String s = v.getStringValue();
                switch (s.charAt(0)) {
                case 'u':
                    if (paint != null) {
                       textDecoration.underlinePaint = paint;
View Full Code Here

                       TextAttribute.WIDTH_REGULAR);
        }


        // Font family
        CSSValueList ff = (CSSValueList)cssDecl.getPropertyCSSValueInternal
            (CSS_FONT_FAMILY_PROPERTY);

        //
        // new code for SVGFonts:
        //

        //  make a list of GVTFontFamily objects
        Vector fontFamilyList = new Vector();
        for (int i = 0; i < ff.getLength(); i++) {
            v = (CSSPrimitiveValue)ff.item(i);
            String fontFamilyName = v.getStringValue();
            GVTFontFamily fontFamily
                = SVGFontUtilities.getFontFamily(element, ctx, fontFamilyName,
                   fontWeightString, fontStyleString);
            fontFamilyList.add(fontFamily);
View Full Code Here

        if (t == CSSValue.CSS_VALUE_LIST) {

            // first check to see if its a valid list,
            // ie. if it contains none then that is the only element
            CSSValueList lst = (CSSValueList)cssVal;

            Paint paint = PaintServer.convertFillPaint(element, node, ctx);
            Paint strokePaint = PaintServer.convertStrokePaint(element, node, ctx);
            Stroke stroke = PaintServer.convertStroke(element, ctx);

            for (int i = 0; i < lst.getLength(); i++) {
                CSSPrimitiveValue v = (CSSPrimitiveValue)lst.item(i);
                String s = v.getStringValue();
                switch (s.charAt(0)) {
                case 'u':
                    if (paint != null) {
                       textDecoration.underlinePaint = paint;
View Full Code Here

                       TextAttribute.WIDTH_REGULAR);
        }


        // Font family
        CSSValueList ff = (CSSValueList)cssDecl.getPropertyCSSValueInternal
            (CSS_FONT_FAMILY_PROPERTY);

        //  make a list of GVTFontFamily objects
        Vector fontFamilyList = new Vector();
        for (int i = 0; i < ff.getLength(); i++) {
            v = (CSSPrimitiveValue)ff.item(i);
            String fontFamilyName = v.getStringValue();
            GVTFontFamily fontFamily
                = SVGFontUtilities.getFontFamily(element, ctx, fontFamilyName,
                   fontWeightString, fontStyleString);
            fontFamilyList.add(fontFamily);
View Full Code Here

        if (t == CSSValue.CSS_VALUE_LIST) {

            // first check to see if its a valid list,
            // ie. if it contains none then that is the only element
            CSSValueList lst = (CSSValueList)cssVal;

            Paint paint = PaintServer.convertFillPaint(element, node, ctx);
            Paint strokePaint = PaintServer.convertStrokePaint(element, node, ctx);
            Stroke stroke = PaintServer.convertStroke(element, ctx);

            for (int i = 0; i < lst.getLength(); i++) {
                CSSPrimitiveValue v = (CSSPrimitiveValue)lst.item(i);
                String s = v.getStringValue();
                switch (s.charAt(0)) {
                case 'u':
                    if (paint != null) {
                       textDecoration.underlinePaint = paint;
View Full Code Here

                       TextAttribute.WIDTH_REGULAR);
        }


        // Font family
        CSSValueList ff = (CSSValueList)cssDecl.getPropertyCSSValueInternal
            (CSS_FONT_FAMILY_PROPERTY);

        //  make a list of GVTFontFamily objects
        Vector fontFamilyList = new Vector();
        for (int i = 0; i < ff.getLength(); i++) {
            v = (CSSPrimitiveValue)ff.item(i);
            String fontFamilyName = v.getStringValue();
            GVTFontFamily fontFamily
                = SVGFontUtilities.getFontFamily(element, ctx, fontFamilyName,
                   fontWeightString, fontStyleString);
            fontFamilyList.add(fontFamily);
View Full Code Here

TOP

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

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.