summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/kitfox/svg/Marker.java16
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);