Java 类org.w3c.dom.svg.SVGPaint 实例源码
项目:PDFReporter-Studio
文件:SVGUtils.java
public static Color toSWTColor(Element element, String attributeName) {
Document document = element.getOwnerDocument();
ViewCSS viewCSS = (ViewCSS) document.getDocumentElement();
CSSStyleDeclaration computedStyle = viewCSS.getComputedStyle(element, null);
SVGPaint svgPaint = (SVGPaint) computedStyle.getPropertyCSSValue(attributeName);
if (svgPaint.getPaintType() == SVGPaint.SVG_PAINTTYPE_RGBCOLOR) {
RGBColor rgb = svgPaint.getRGBColor();
float red = rgb.getRed().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE);
float green = rgb.getGreen().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE);
float blue = rgb.getBlue().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE);
return SWTResourceManager.getColor((int) red, (int) green, (int) blue);
}
return null;
}