From 72cd62e664ba92bf4c3c7ca187fa115cad334834 Mon Sep 17 00:00:00 2001 From: kitfox Date: Sun, 19 Feb 2012 20:17:51 +0000 Subject: Shape elements now handing currentColor attribute. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@107 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/ShapeElement.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/kitfox/svg/ShapeElement.java b/src/main/java/com/kitfox/svg/ShapeElement.java index eaa4832..092fc59 100644 --- a/src/main/java/com/kitfox/svg/ShapeElement.java +++ b/src/main/java/com/kitfox/svg/ShapeElement.java @@ -95,6 +95,26 @@ abstract public class ShapeElement extends RenderableElement } } + private Paint handleCurrentColor(StyleAttribute styleAttrib) throws SVGException + { + if (styleAttrib.getStringValue().equals("currentColor")) + { + StyleAttribute currentColorAttrib = new StyleAttribute(); + if (getStyle(currentColorAttrib.setName("color"))) + { + if (!currentColorAttrib.getStringValue().equals("none")) + { + return currentColorAttrib.getColorValue(); + } + } + return null; + } + else + { + return styleAttrib.getColorValue(); + } + } + protected void renderShape(Graphics2D g, Shape shape) throws SVGException { //g.setColor(Color.green); @@ -119,7 +139,7 @@ abstract public class ShapeElement extends RenderableElement if (styleAttrib.getStringValue().equals("none")) fillPaint = null; else { - fillPaint = styleAttrib.getColorValue(); + fillPaint = handleCurrentColor(styleAttrib); if (fillPaint == null) { URI uri = styleAttrib.getURIValue(getXMLBase()); @@ -158,7 +178,7 @@ abstract public class ShapeElement extends RenderableElement if (styleAttrib.getStringValue().equals("none")) strokePaint = null; else { - strokePaint = styleAttrib.getColorValue(); + strokePaint = handleCurrentColor(styleAttrib); if (strokePaint == null) { URI uri = styleAttrib.getURIValue(getXMLBase()); -- cgit v1.2.3-55-g7522