diff options
author | kitfox | 2012-01-16 12:47:46 +0100 |
---|---|---|
committer | kitfox | 2012-01-16 12:47:46 +0100 |
commit | 2ef04997c94ff3f104a76fb4bb70221b30c8ed60 (patch) | |
tree | e699f44ee72a7d471f180e541cb816408cf66393 | |
parent | If a Graphics2D has no clip region, clipping will now be ignored. (diff) | |
download | svg-salamander-core-2ef04997c94ff3f104a76fb4bb70221b30c8ed60.tar.gz svg-salamander-core-2ef04997c94ff3f104a76fb4bb70221b30c8ed60.tar.xz svg-salamander-core-2ef04997c94ff3f104a76fb4bb70221b30c8ed60.zip |
MarkerElement now respects markerUnits attribute.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@106 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rw-r--r-- | src/main/java/com/kitfox/svg/Marker.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/com/kitfox/svg/Marker.java b/src/main/java/com/kitfox/svg/Marker.java index 42e3ce8..6909f68 100644 --- a/src/main/java/com/kitfox/svg/Marker.java +++ b/src/main/java/com/kitfox/svg/Marker.java @@ -29,6 +29,7 @@ public class Marker extends Group float markerWidth = 3; float markerHeight = 3; float orient = Float.NaN; + boolean markerUnitsStrokeWidth = true; //if set to false 'userSpaceOnUse' is assumed protected void build() throws SVGException { @@ -64,6 +65,15 @@ public class Marker extends Group viewBox = new Rectangle(0, 0, 1, 1); } + if (getPres(sty.setName("markerUnits"))) + { + String markerUnits = sty.getStringValue(); + if (markerUnits != null && markerUnits.equals("userSpaceOnUse")) + { + markerUnitsStrokeWidth = false; + } + } + //Transform pattern onto unit square viewXform = new AffineTransform(); viewXform.scale(1.0 / viewBox.getWidth(), 1.0 / viewBox.getHeight()); @@ -103,7 +113,11 @@ public class Marker extends Group AffineTransform cacheXform = g.getTransform(); g.translate(pos.x, pos.y); - g.scale(strokeWidth, strokeWidth); + if (markerUnitsStrokeWidth) + { + g.scale(strokeWidth, strokeWidth); + } + g.rotate(Math.atan2(pos.dy, pos.dx)); g.transform(markerXform); |