Package org.w3c.dom.css

Examples of org.w3c.dom.css.CSSStyleDeclaration


                     new Object [] {SVG_ORIENT_ATTRIBUTE, s});
            }
        }

        // 'stroke-width' property
        CSSStyleDeclaration decl
            = CSSUtilities.getComputedStyle(paintedElement);
        CSSValue v = decl.getPropertyCSSValue(CSS_STROKE_WIDTH_PROPERTY);
        float strokeWidth = UnitProcessor.cssOtherLengthToUserSpace
            (v, CSS_STROKE_WIDTH_PROPERTY, uctx);

        // 'markerUnits' attribute - default is 'strokeWidth'
        short unitsType;
View Full Code Here


        String value = null;
        final List<CSSStyleRule> rules = getRules(getStyleSheet(cssFile));
        final Optional<CSSStyleDeclaration> styleMaybe = getStyle(rules,
                selector);
        if (styleMaybe.isPresent()) {
            final CSSStyleDeclaration style = styleMaybe.get();
            final CSSValue val = style.getPropertyCSSValue(property);
            if (val == null) {
                // The property might be a CSS shorthand property
                final String strVal = style.getPropertyValue(property);
                if (!strVal.isEmpty()) {
                    value = strVal;
                }
            } else {
                value = val.getCssText();
View Full Code Here

        final CSSStyleSheet styleSheet = getStyleSheet(cssFile);
        final List<CSSStyleRule> rules = getRules(styleSheet);
        final Optional<CSSStyleDeclaration> styleMaybe = getStyle(rules,
                selector);
        if (styleMaybe.isPresent()) {
            final CSSStyleDeclaration style = styleMaybe.get();
            style.setProperty(property, newValue, priority);
            success = IOUtil.write(styleSheet.toString(), cssFile);
        }
        return success;
    }
View Full Code Here

     * @return The style declaration of the rule wrapped in an {@code Optional}
     *         in case the rule wasn't found.
     */
    private static Optional<CSSStyleDeclaration> getStyle(
            final List<CSSStyleRule> rules, final String selector) {
        CSSStyleDeclaration styleDeclaration = null;
        for (final CSSStyleRule rule : rules) {
            final String currSelector = rule.getSelectorText();
            if (currSelector.equals(selector)) {
                styleDeclaration = rule.getStyle();
                break;
View Full Code Here

        }
        StyleObjectModel model = null;

        Reader reader = new StringReader(cssString);
        CSSOMParser parser2 = new CSSOMParser();
        CSSStyleDeclaration n;

        try {
            n = parser2.parseStyleDeclaration(new InputSource(reader));
            model = new StyleObjectModel();
            model.setBorder(new StyleBorderModel());

            boolean isItalic = false;
            boolean isBold = false;

            for (int i = 0; i < n.getLength(); i++) {
                String name = n.item(i);

                if (n.getPropertyCSSValue(name) instanceof CSSPrimitiveValue) {

                    CSSPrimitiveValue value = (CSSPrimitiveValue) n.getPropertyCSSValue(name);

                    if (name.equalsIgnoreCase("color")) {
                        model.setColor(getColor(value));
                    }

                    if (name.equalsIgnoreCase("border-color")) {
                        model.getBorder().setColor(getColor(value));
                    }

                    if (name.equalsIgnoreCase("border-width")) {
                        model.getBorder().setWidth(getSize(value));
                    }

                    if (name.equalsIgnoreCase("width")) {
                        model.setWidth(getSize(value));
                    }

                    if (name.equalsIgnoreCase("height")) {
                        model.setHeight(getSize(value));
                    }

                    if (name.equalsIgnoreCase("border")) {
                        CSSValueList list = (CSSValueList) n.getPropertyCSSValue(name);
                        model.setBorder(getBorder(list));
                    }

                    if (name.equalsIgnoreCase("margin")) {
                        CSSValueList list = (CSSValueList) n.getPropertyCSSValue(name);
                        model.setMargings(getMargins(list));
                    }

                    if (name.equalsIgnoreCase("border-style")) {
                        model.getBorder().setStyle(value.getStringValue());
                    }

                    if (name.equalsIgnoreCase("background")) {
                        model.setBackground(getColor(value));
                    }

                    if (name.equalsIgnoreCase("background-color")) {
                        model.setBackground(getColor(value));
                    }

                    if (name.equalsIgnoreCase("font")) {
                        if (model.getFont() == null) model.setFont(new StyleFontModel());
                        CSSValueList list = (CSSValueList) n.getPropertyCSSValue(name);
                        model.setFont(getFont(model, list));
                    }

                    if (name.equalsIgnoreCase("font-family")) {
                        if (model.getFont() == null) model.setFont(new StyleFontModel());
View Full Code Here

    }

    public void decorateSelection(Element elem,boolean selected)
    {
        ElementCSSInlineStyle elemCSS = (ElementCSSInlineStyle)elem;
        CSSStyleDeclaration elemStyle = elemCSS.getStyle();

        if (selected)
        {
            elemStyle.setProperty("background","rgb(0,0,255)",null);
            elemStyle.setProperty("color","white",null);
        }
        else
        {
            elemStyle.removeProperty("background");
            elemStyle.removeProperty("color");
        }
    }
View Full Code Here

    }

    public void setStyleProperty(Element elem,String name,String value)
    {
        ElementCSSInlineStyle elemCSS = (ElementCSSInlineStyle)elem;
        CSSStyleDeclaration elemStyle = elemCSS.getStyle();
        elemStyle.setProperty(name,value,null);
    }
View Full Code Here

    }

    public void removeStyleProperty(Element elem,String name)
    {
        ElementCSSInlineStyle elemCSS = (ElementCSSInlineStyle)elem;
        CSSStyleDeclaration elemStyle = elemCSS.getStyle();
        elemStyle.removeProperty(name);
    }
View Full Code Here

    public void handleEvent(Event evt)
    {
        Element currTarget = (Element)evt.getCurrentTarget();

        ElementCSSInlineStyle styleElem = (ElementCSSInlineStyle)currTarget;
        CSSStyleDeclaration cssDec = styleElem.getStyle();

        CSSValueList border = (CSSValueList)cssDec.getPropertyCSSValue("border");
        int len = border.getLength();
        String cssText = "";
        for(int i = 0; i < len; i++)
        {
            CSSValue value = border.item(i);
            if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE)
            {
                CSSPrimitiveValue primValue = (CSSPrimitiveValue)value;
                if (primValue.getPrimitiveType() == CSSPrimitiveValue.CSS_RGBCOLOR)
                {
                    RGBColor rgb = primValue.getRGBColorValue();
                    log("Current border color: rgb(" + rgb.getRed().getCssText() + "," + rgb.getGreen().getCssText() + "," + rgb.getBlue().getCssText() + ")");
                }
                else cssText += primValue.getCssText() + " ";
            }
            else cssText += value.getCssText() + " ";
        }
        cssDec.setProperty("border",cssText,null); // Removed border color

        CSS2Properties cssDec2 = (CSS2Properties)styleElem.getStyle();
        String newColor = "rgb(255,100,150)";
        cssDec2.setBorderColor(newColor);// border-color property
        log("New border color: " + cssDec2.getBorderColor());
View Full Code Here

        ItsNatDocument itsNatDoc = itsNatRequest.getItsNatDocument();
        Document doc = itsNatDoc.getDocument();
        Element errorElem = doc.getElementById("errorId");
        ItsNatDOMUtil.setTextContent(errorElem,msg);
        ElementCSSInlineStyle errorCSS = (ElementCSSInlineStyle)errorElem;
        CSSStyleDeclaration style = errorCSS.getStyle();
        style.removeProperty("display"); // makes visible
    }
View Full Code Here

TOP

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

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.