Package org.w3c.dom.css

Examples of org.w3c.dom.css.CSSStyleDeclaration


     * @param pe The pseudo-element to match.
     * @param rd The result style declaration.
     */
    protected void addOverrideStyleProperties
        (Element e, String pe, CSSOMReadOnlyStyleDeclaration rd) {
  CSSStyleDeclaration overrideDecl;
  overrideDecl = ((DocumentCSS)document).getOverrideStyle(e, pe);
  if ((pe == null || pe.equals("")) &&
      overrideDecl != null) {
      int len = overrideDecl.getLength();
      for (int i = 0; i < len; i++) {
    setAuthorProperty(overrideDecl.item(i), overrideDecl, rd);
      }
  }
    }
View Full Code Here


                                                     SVGDocument imgDocument) {

        // viewport is automatically created by the svg element of the image
        SVGSVGElement svgElement = imgDocument.getRootElement();
        CompositeGraphicsNode result = new CompositeGraphicsNode();
        CSSStyleDeclaration decl = CSSUtilities.getComputedStyle(element);
        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);

        Rectangle2D r
            = CSSUtilities.convertEnableBackground(element, uctx);
        if (r != null) {
View Full Code Here

     * @param ctx the bridge context
     */
    protected static ICCColorSpaceExt extractColorSpace(Element element,
                                                        BridgeContext ctx) {

        CSSStyleDeclaration decl = CSSUtilities.getComputedStyle(element);
        String colorProfileProperty
            = ((CSSPrimitiveValue)decl.getPropertyCSSValue
               (CSS_COLOR_PROFILE_PROPERTY)).getStringValue();

        // The only cases that need special handling are 'sRGB' and 'name'
        ICCColorSpaceExt colorSpace = null;
        if (CSS_SRGB_VALUE.equalsIgnoreCase(colorProfileProperty)) {
View Full Code Here

    /**
     * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGStylable#getStyle()}.
     */
    public CSSStyleDeclaration getStyle() {
        CSSStyleDeclaration result =
            (CSSStyleDeclaration)getLiveAttributeValue(null,
                                                       SVG_STYLE_ATTRIBUTE);
        if (result == null) {
            CSSEngine eng = ((SVGOMDocument)getOwnerDocument()).getCSSEngine();
            result = new StyleDeclaration(eng);
View Full Code Here

    /**
     * Updates a property value in this target.
     */
    public void updatePropertyValue(String pn, AnimatableValue val) {
        CSSStyleDeclaration over = getOverrideStyle();
        if (val == null) {
            over.removeProperty(pn);
        } else {
            over.setProperty(pn, val.getCssText(), "");
        }
    }
View Full Code Here

                throw new BridgeException
                    (ctx, animElt, "attribute.not.animatable",
                     new Object[] { target.getElement().getNodeName(), pn });
            }
            SVGStylableElement e = (SVGStylableElement) target.getElement();
            CSSStyleDeclaration over = e.getOverrideStyle();
            String oldValue = over.getPropertyValue(pn);
            if (oldValue != null) {
                over.removeProperty(pn);
            }
            Value v = cssEngine.getComputedStyle(e, null, idx);
            if (oldValue != null && !oldValue.equals("")) {
                over.setProperty(pn, oldValue, null);
            }
            return factories[type].createValue(target, pn, v);
        }
        // XXX Doesn't handle shorthands.
        return null;
View Full Code Here

  public static String escapeIFrameCss(String orig) {
    String rule = "";
    CSSOMParser parser = new CSSOMParser();
    try {
      List<String> rules = Lists.newArrayList();
      CSSStyleDeclaration decl = parser.parseStyleDeclaration(new InputSource(new StringReader(orig)));

      for (int i = 0; i < decl.getLength(); i++) {
        String property = decl.item(i);
        String value = decl.getPropertyValue(property);
        if (StringUtils.isBlank(property) || StringUtils.isBlank(value)) {
          continue;
        }

        if (ALLOWED_IFRAME_CSS_RULES.contains(property) && StringUtils.containsNone(value, FORBIDDEN_CSS_RULE_CHARACTERS)) {
          rules.add(property + ":" + decl.getPropertyValue(property) + ";");
        }
      }
      rule = StringUtils.join(rules, "");
    } catch (Exception e) {
      log.error(e.getMessage(), e);
View Full Code Here

  public static String escapeImgCss(String orig) {
    String rule = "";
    CSSOMParser parser = new CSSOMParser();
    try {
      List<String> rules = Lists.newArrayList();
      CSSStyleDeclaration decl = parser.parseStyleDeclaration(new InputSource(new StringReader(orig)));

      for (int i = 0; i < decl.getLength(); i++) {
        String property = decl.item(i);
        String value = decl.getPropertyValue(property);
        if (StringUtils.isBlank(property) || StringUtils.isBlank(value)) {
          continue;
        }

        if (ALLOWED_IMG_CSS_RULES.contains(property) && StringUtils.containsNone(value, FORBIDDEN_CSS_RULE_CHARACTERS)) {
          rules.add(property + ":" + decl.getPropertyValue(property) + ";");
        }
      }
      rule = StringUtils.join(rules, "");
    } catch (Exception e) {
      log.error(e.getMessage(), e);
View Full Code Here

            SVGUtilities.convertAffineTransform(paintElement,
                                                ATTR_PATTERN_TRANSFORM,
                                                ctx.getParserFactory());

        // Get the overflow property on the pattern element
        CSSStyleDeclaration cssDecl
            = ctx.getViewCSS().getComputedStyle(paintElement, null);

        CSSPrimitiveValue vbOverflow =
            (CSSPrimitiveValue)cssDecl.getPropertyCSSValue(CSS_OVERFLOW_PROPERTY);

        String overFlowValue = vbOverflow.getStringValue();
        if(overFlowValue.length() == 0){
            overFlowValue = CSS_HIDDEN_VALUE;
        }

        boolean overflow = true;
        if(CSS_HIDDEN_VALUE.equals(overFlowValue)){
            overflow = false;
        }

        // Get pattern region. This is from the paintedElement, as
        // percentages are from the referencing element.
        CSSStyleDeclaration cssDeclPainted
            = ctx.getViewCSS().getComputedStyle(paintedElement, null);
        UnitProcessor.Context uctx
            = new DefaultUnitProcessorContext(ctx, cssDecl);

        Rectangle2D patternRegion
View Full Code Here

                                Element paintedElement,
                                Element paintElement) {
        //
        // Get unit processor to compute gradient control points
        //
        CSSStyleDeclaration cssDecl
            = ctx.getViewCSS().getComputedStyle(paintElement, null);

        UnitProcessor.Context uctx
            = new DefaultUnitProcessorContext(ctx, cssDecl);

        // parse the gradientUnits attribute, (default is 'objectBoundingBox')
        String units = paintElement.getAttributeNS(null, ATTR_GRADIENT_UNITS);
        if(units.length() == 0){
            units = VALUE_OBJECT_BOUNDING_BOX;
        }

        // parse the x1 attribute, (default is 0%)
        String x1 = paintElement.getAttributeNS(null, ATTR_X1);
        if (x1.length() == 0){
            x1 = "0%";
        }

        // parse the y1 attribute, (default is 0%)
        String y1 = paintElement.getAttributeNS(null, ATTR_Y1);
        if (y1.length() == 0){
            y1 = "0%";
        }

        // parse the x2 attribute, (default is 100%)
        String x2 = paintElement.getAttributeNS(null, ATTR_X2);
        if (x2.length() == 0){
            x2 = "100%";
        }

        // parse the y2 attribute, (default is 0%)
        String y2 = paintElement.getAttributeNS(null, ATTR_Y2);
        if (y2.length() == 0){
            y2 = "0%";
        }

        int unitsType;
        try {
            unitsType = SVGUtilities.parseCoordinateSystem(units);
        } catch (IllegalArgumentException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("linearGradient.units.invalid",
                                       new Object[] {units,
                                                     ATTR_GRADIENT_UNITS}));
        }
        SVGElement svgPaintedElement = (SVGElement) paintedElement;
        Point2D p1
            = SVGUtilities.convertGradientPoint(svgPaintedElement,
                                                ATTR_X1, x1,
                                                ATTR_Y1, y1,
                                                unitsType, uctx);
        Point2D p2
            = SVGUtilities.convertGradientPoint(svgPaintedElement,
                                                ATTR_X2, x2,
                                                ATTR_Y2, y2,
                                                unitsType, uctx);

        // parse the 'spreadMethod' attribute, (default is PAD)
        String spreadMethod =
            paintElement.getAttributeNS(null, ATTR_SPREAD_METHOD);
        if (spreadMethod.length() == 0) {
            spreadMethod = VALUE_PAD;
        }

        LinearGradientPaint.CycleMethodEnum cycleMethod =
            convertSpreadMethod(spreadMethod);

        // Extract gradient transform
        AffineTransform at =
            SVGUtilities.convertAffineTransform(paintElement,
                                                ATTR_GRADIENT_TRANSFORM,
                                                ctx.getParserFactory());

        at  = SVGUtilities.convertAffineTransform(at, paintedNode, unitsType);

        // Extract stop colors and intervals
        Vector stopVector = extractGradientStops(paintElement, ctx);

        // if no stop, fill is 'none'
        if (stopVector.size() == 0) {
            return null;
        }

        // if one stop, the fill is just one color
        if (stopVector.size() == 1) {
            return ((GradientStop) stopVector.get(0)).stopColor;
        }

        // Convert the stop offsets to intervals
        int nStops = stopVector.size();
        float curOffset = 0;
        if (nStops > 0) {
            GradientStop stop = (GradientStop) stopVector.elementAt(0);
            curOffset = stop.offset;
        }
        for (int i=1; i < nStops; i++) {
            GradientStop stop = (GradientStop)stopVector.elementAt(i);
            if(stop.offset < curOffset){
                stop.offset = curOffset;
            }
            curOffset = stop.offset;
        }

        // Extract the color interpolation property
        CSSPrimitiveValue colorInterpolation =
            (CSSPrimitiveValue)cssDecl.getPropertyCSSValue
            (CSS_COLOR_INTERPOLATION_PROPERTY);

        LinearGradientPaint.ColorSpaceEnum colorSpace
            = LinearGradientPaint.SRGB;
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.