Examples of OMSVGPaint


Examples of org.vectomatic.dom.svg.OMSVGPaint

      if (SVGConstants.CSS_NONE_VALUE.equals(cssText)) {
        // none
        if (uri == null) {
          return NONE;
        }
        OMSVGPaint paint = new OMSVGPaint(OMSVGPaint.SVG_PAINTTYPE_URI_NONE);
        paint.setPaint(OMSVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
        return paint;
      } else if (SVGConstants.CSS_INHERIT_VALUE.equals(cssText)) {
        // none
        return INHERIT;
      } else if (SVGConstants.CSS_CURRENTCOLOR_VALUE.equals(cssText)) {
        // currentColor
        if (uri == null) {
          return CURRENT_COLOR;
        }
        OMSVGPaint paint = new OMSVGPaint(OMSVGPaint.SVG_PAINTTYPE_URI_CURRENTCOLOR);
        paint.setPaint(OMSVGPaint.SVG_PAINTTYPE_URI_CURRENTCOLOR, uri, null, null);
        return paint;
      }
 
      COLORNAME.setLastIndex(0);
      MatchResult result = COLORNAME.exec(cssText);
      if (result != null && result.getGroupCount() == 2) {
        // color name
        rgbColor = getNamedColor(result.getGroup(1));
        if (rgbColor == null) {
          throw new JavaScriptException("Unknown color keyword: " + cssText)
        }
        iccColor = COLORNAME.getLastIndex() == cssText.length() ? null : cssText.substring(COLORNAME.getLastIndex());
      }
     
      if (rgbColor == null) {
        RGB255.setLastIndex(0);
        result = RGB255.exec(cssText);
        if (result != null && result.getGroupCount() == 4) {
          rgbColor = result.getGroup(0);
          iccColor = RGB255.getLastIndex() == cssText.length() ? null : cssText.substring(RGB255.getLastIndex());
        }
      }
      if (rgbColor == null) {
        RGBPCT.setLastIndex(0);
        result = RGBPCT.exec(cssText);
        if (result != null && result.getGroupCount() == 4) {
          rgbColor = result.getGroup(0);
          iccColor = RGBPCT.getLastIndex() == cssText.length() ? null : cssText.substring(RGBPCT.getLastIndex());
        }
      }
      if (rgbColor == null) {
        RGBHEX.setLastIndex(0);
        result = RGBHEX.exec(cssText);
        if (result != null && result.getGroupCount() == 2) {
          rgbColor = result.getGroup(0);
          iccColor = RGBHEX.getLastIndex() == cssText.length() ? null : cssText.substring(RGBHEX.getLastIndex());
        }
      }
    }

    short paintType;
    if (rgbColor != null) {
      if (uri != null) {
        paintType = iccColor == null ? OMSVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR : OMSVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR;
      } else {
        paintType = iccColor == null ? OMSVGPaint.SVG_PAINTTYPE_RGBCOLOR : OMSVGPaint.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR;
      }
    } else {
      if (uri != null) {
        paintType = OMSVGPaint.SVG_PAINTTYPE_URI;
      } else {
        throw new JavaScriptException("Invalid paint spec: " + cssText);
      }
    }
    OMSVGPaint paint = new OMSVGPaint(paintType);
    paint.setPaint(paintType, uri, rgbColor, iccColor);
    return paint;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.