From 7d54babdb92f3c4f7ab25b565075f0c1554e946f Mon Sep 17 00:00:00 2001 From: kitfox Date: Wed, 25 Apr 2012 16:03:27 +0000 Subject: Support for non-scaling stroke added. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@112 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/ShapeElement.java | 42 ++++++++++++++++++++------ 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/com/kitfox/svg/ShapeElement.java b/src/main/java/com/kitfox/svg/ShapeElement.java index 092fc59..7fdc671 100644 --- a/src/main/java/com/kitfox/svg/ShapeElement.java +++ b/src/main/java/com/kitfox/svg/ShapeElement.java @@ -328,26 +328,50 @@ abstract public class ShapeElement extends RenderableElement stroke = new BasicStroke(strokeWidth, strokeLinecap, strokeLinejoin, strokeMiterLimit, strokeDashArray, strokeDashOffset); } - Shape strokeShape = stroke.createStrokedShape(shape); + Shape strokeShape; + AffineTransform cacheXform = g.getTransform(); + if (vectorEffect == VECTOR_EFFECT_NON_SCALING_STROKE) + { + strokeShape = cacheXform.createTransformedShape(shape); + strokeShape = stroke.createStrokedShape(strokeShape); + } + else + { + strokeShape = stroke.createStrokedShape(shape); + } if (strokeOpacity <= 0) { //Do nothing } - else if (strokeOpacity < 1f) + else { Composite cachedComposite = g.getComposite(); - g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, strokeOpacity)); - g.setPaint(strokePaint); - g.fill(strokeShape); + if (strokeOpacity < 1f) + { + g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, strokeOpacity)); + } + + if (vectorEffect == VECTOR_EFFECT_NON_SCALING_STROKE) + { + //Set to identity + g.setTransform(new AffineTransform()); + } - g.setComposite(cachedComposite); - } - else - { g.setPaint(strokePaint); g.fill(strokeShape); + + if (vectorEffect == VECTOR_EFFECT_NON_SCALING_STROKE) + { + //Set to identity + g.setTransform(cacheXform); + } + + if (strokeOpacity < 1f) + { + g.setComposite(cachedComposite); + } } } -- cgit v1.2.3-55-g7522