summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/Marker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/svg/Marker.java')
-rw-r--r--src/main/java/com/kitfox/svg/Marker.java79
1 files changed, 46 insertions, 33 deletions
diff --git a/src/main/java/com/kitfox/svg/Marker.java b/src/main/java/com/kitfox/svg/Marker.java
index 1c1755c..f195c07 100644
--- a/src/main/java/com/kitfox/svg/Marker.java
+++ b/src/main/java/com/kitfox/svg/Marker.java
@@ -31,7 +31,6 @@
* Mark McKay can be contacted at mark@kitfox.com. Salamander and other
* projects can be found at http://www.kitfox.com
*/
-
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
@@ -49,10 +48,11 @@ import java.util.ArrayList;
*/
public class Marker extends Group
{
+ public static final String TAG_NAME = "marker";
+
AffineTransform viewXform;
AffineTransform markerXform;
Rectangle2D viewBox;
-
float refX;
float refY;
float markerWidth = 3;
@@ -60,24 +60,40 @@ public class Marker extends Group
float orient = Float.NaN;
boolean markerUnitsStrokeWidth = true; //if set to false 'userSpaceOnUse' is assumed
+ public String getTagName()
+ {
+ return TAG_NAME;
+ }
+
protected void build() throws SVGException
{
super.build();
StyleAttribute sty = new StyleAttribute();
- if (getPres(sty.setName("refX"))) refX = sty.getFloatValueWithUnits();
- if (getPres(sty.setName("refY"))) refY = sty.getFloatValueWithUnits();
- if (getPres(sty.setName("markerWidth"))) markerWidth = sty.getFloatValueWithUnits();
- if (getPres(sty.setName("markerHeight"))) markerHeight = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("refX")))
+ {
+ refX = sty.getFloatValueWithUnits();
+ }
+ if (getPres(sty.setName("refY")))
+ {
+ refY = sty.getFloatValueWithUnits();
+ }
+ if (getPres(sty.setName("markerWidth")))
+ {
+ markerWidth = sty.getFloatValueWithUnits();
+ }
+ if (getPres(sty.setName("markerHeight")))
+ {
+ markerHeight = sty.getFloatValueWithUnits();
+ }
if (getPres(sty.setName("orient")))
{
if ("auto".equals(sty.getStringValue()))
{
orient = Float.NaN;
- }
- else
+ } else
{
orient = sty.getFloatValue();
}
@@ -169,8 +185,9 @@ public class Marker extends Group
}
/**
- * Updates all attributes in this diagram associated with a time event.
- * Ie, all attributes with track information.
+ * Updates all attributes in this diagram associated with a time event. Ie,
+ * all attributes with track information.
+ *
* @return - true if this node has changed state as a result of the time
* update
*/
@@ -181,7 +198,7 @@ public class Marker extends Group
//Marker properties do not change
return changeState;
}
-
+
//--------------------------------
public static final int MARKER_START = 0;
public static final int MARKER_MID = 1;
@@ -189,6 +206,7 @@ public class Marker extends Group
public static class MarkerPos
{
+
int type;
double x;
double y;
@@ -207,6 +225,7 @@ public class Marker extends Group
public static class MarkerLayout
{
+
private ArrayList markerList = new ArrayList();
boolean started = false;
@@ -216,7 +235,7 @@ public class Marker extends Group
double py = 0;
double[] coords = new double[6];
for (PathIterator it = shape.getPathIterator(null);
- !it.isDone(); it.next())
+ !it.isDone(); it.next())
{
switch (it.currentSegment(coords))
{
@@ -244,28 +263,26 @@ public class Marker extends Group
double k0y = coords[1];
double x = coords[2];
double y = coords[3];
-
-
+
+
//Best in tangent
if (px != k0x || py != k0y)
{
markerIn(px, py, k0x - px, k0y - py);
- }
- else
+ } else
{
markerIn(px, py, x - px, y - py);
}
-
+
//Best out tangent
if (x != k0x || y != k0y)
{
markerOut(x, y, x - k0x, y - k0y);
- }
- else
+ } else
{
markerOut(x, y, x - px, y - py);
}
-
+
markerIn(px, py, k0x - px, k0y - py);
markerOut(x, y, x - k0x, y - k0y);
px = x;
@@ -280,31 +297,27 @@ public class Marker extends Group
double k1y = coords[3];
double x = coords[4];
double y = coords[5];
-
+
//Best in tangent
if (px != k0x || py != k0y)
{
markerIn(px, py, k0x - px, k0y - py);
- }
- else if (px != k1x || py != k1y)
+ } else if (px != k1x || py != k1y)
{
markerIn(px, py, k1x - px, k1y - py);
- }
- else
+ } else
{
markerIn(px, py, x - px, y - py);
}
-
+
//Best out tangent
if (x != k1x || y != k1y)
{
markerOut(x, y, x - k1x, y - k1y);
- }
- else if (x != k0x || y != k0y)
+ } else if (x != k0x || y != k0y)
{
markerOut(x, y, x - k0x, y - k0y);
- }
- else
+ } else
{
markerOut(x, y, x - px, y - py);
}
@@ -317,15 +330,15 @@ public class Marker extends Group
for (int i = 1; i < markerList.size(); ++i)
{
- MarkerPos prev = (MarkerPos)markerList.get(i - 1);
- MarkerPos cur = (MarkerPos)markerList.get(i);
+ MarkerPos prev = (MarkerPos) markerList.get(i - 1);
+ MarkerPos cur = (MarkerPos) markerList.get(i);
if (cur.type == MARKER_START)
{
prev.type = MARKER_END;
}
}
- MarkerPos last = (MarkerPos)markerList.get(markerList.size() - 1);
+ MarkerPos last = (MarkerPos) markerList.get(markerList.size() - 1);
last.type = MARKER_END;
}