summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/Polyline.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/svg/Polyline.java')
-rw-r--r--src/main/java/com/kitfox/svg/Polyline.java69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/main/java/com/kitfox/svg/Polyline.java b/src/main/java/com/kitfox/svg/Polyline.java
index b661e05..a62ea4c 100644
--- a/src/main/java/com/kitfox/svg/Polyline.java
+++ b/src/main/java/com/kitfox/svg/Polyline.java
@@ -33,56 +33,56 @@
*
* Created on January 26, 2004, 5:25 PM
*/
-
package com.kitfox.svg;
-import java.awt.geom.*;
-import java.awt.*;
-
-import com.kitfox.svg.xml.*;
+import com.kitfox.svg.xml.StyleAttribute;
+import com.kitfox.svg.xml.XMLParseUtil;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
/**
* @author Mark McKay
* @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
*/
-public class Polyline extends ShapeElement {
-
+public class Polyline extends ShapeElement
+{
+ public static final String TAG_NAME = "polyline";
+
int fillRule = GeneralPath.WIND_NON_ZERO;
String pointsStrn = "";
-// float[] points = null;
GeneralPath path;
- /** Creates a new instance of Rect */
- public Polyline() {
+ /**
+ * Creates a new instance of Rect
+ */
+ public Polyline()
+ {
}
- /*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
+ public String getTagName()
{
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
-
- points = XMLParseUtil.parseFloatList(attrs.getValue("points"));
-
- build();
+ return TAG_NAME;
}
- */
public void build() throws SVGException
{
super.build();
-
+
StyleAttribute sty = new StyleAttribute();
-
- if (getPres(sty.setName("points"))) pointsStrn = sty.getStringValue();
-
+
+ if (getPres(sty.setName("points")))
+ {
+ pointsStrn = sty.getStringValue();
+ }
+
String fillRuleStrn = getStyle(sty.setName("fill-rule")) ? sty.getStringValue() : "nonzero";
fillRule = fillRuleStrn.equals("evenodd") ? GeneralPath.WIND_EVEN_ODD : GeneralPath.WIND_NON_ZERO;
buildPath();
}
-
+
protected void buildPath()
{
float[] points = XMLParseUtil.parseFloatList(pointsStrn);
@@ -113,8 +113,9 @@ public class Polyline extends ShapeElement {
}
/**
- * 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
*/
@@ -126,11 +127,11 @@ public class Polyline extends ShapeElement {
//Get current values for parameters
StyleAttribute sty = new StyleAttribute();
boolean shapeChange = false;
-
+
if (getStyle(sty.setName("fill-rule")))
{
- int newVal = sty.getStringValue().equals("evenodd")
- ? GeneralPath.WIND_EVEN_ODD
+ int newVal = sty.getStringValue().equals("evenodd")
+ ? GeneralPath.WIND_EVEN_ODD
: GeneralPath.WIND_NON_ZERO;
if (newVal != fillRule)
{
@@ -138,7 +139,7 @@ public class Polyline extends ShapeElement {
shapeChange = true;
}
}
-
+
if (getPres(sty.setName("points")))
{
String newVal = sty.getStringValue();
@@ -148,15 +149,15 @@ public class Polyline extends ShapeElement {
shapeChange = true;
}
}
-
-
+
+
if (shapeChange)
{
build();
// buildPath();
// return true;
}
-
+
return changeState || shapeChange;
}
}