summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/Line.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/svg/Line.java')
-rw-r--r--src/main/java/com/kitfox/svg/Line.java72
1 files changed, 35 insertions, 37 deletions
diff --git a/src/main/java/com/kitfox/svg/Line.java b/src/main/java/com/kitfox/svg/Line.java
index c01e7a7..84486c9 100644
--- a/src/main/java/com/kitfox/svg/Line.java
+++ b/src/main/java/com/kitfox/svg/Line.java
@@ -33,7 +33,6 @@
*
* Created on January 26, 2004, 5:25 PM
*/
-
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
@@ -46,56 +45,56 @@ import java.awt.geom.Rectangle2D;
* @author Mark McKay
* @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
*/
-public class Line extends ShapeElement {
-
+public class Line extends ShapeElement
+{
+ public static final String TAG_NAME = "line";
+
float x1 = 0f;
float y1 = 0f;
float x2 = 0f;
float y2 = 0f;
-
Line2D.Float line;
-// RectangularShape rect;
- /** Creates a new instance of Rect */
- public Line() {
+ /**
+ * Creates a new instance of Rect
+ */
+ public Line()
+ {
}
- /*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
+ public String getTagName()
{
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
- String x1 = attrs.getValue("x1");
- String y1 = attrs.getValue("y1");
- String x2 = attrs.getValue("x2");
- String y2 = attrs.getValue("y2");
-
- this.x1 = XMLParseUtil.parseFloat(x1);
- this.y1 = XMLParseUtil.parseFloat(y1);
- this.x2 = XMLParseUtil.parseFloat(x2);
- this.y2 = XMLParseUtil.parseFloat(y2);
-
- build();
+ return TAG_NAME;
}
-*/
+
protected void build() throws SVGException
{
super.build();
-
+
StyleAttribute sty = new StyleAttribute();
-
- if (getPres(sty.setName("x1"))) x1 = sty.getFloatValueWithUnits();
- if (getPres(sty.setName("y1"))) y1 = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("x1")))
+ {
+ x1 = sty.getFloatValueWithUnits();
+ }
+
+ if (getPres(sty.setName("y1")))
+ {
+ y1 = sty.getFloatValueWithUnits();
+ }
- if (getPres(sty.setName("x2"))) x2 = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("x2")))
+ {
+ x2 = sty.getFloatValueWithUnits();
+ }
- if (getPres(sty.setName("y2"))) y2 = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("y2")))
+ {
+ y2 = sty.getFloatValueWithUnits();
+ }
line = new Line2D.Float(x1, y1, x2, y2);
}
-
public void render(Graphics2D g) throws SVGException
{
@@ -115,8 +114,9 @@ public class Line 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
*/
@@ -128,7 +128,7 @@ public class Line extends ShapeElement {
//Get current values for parameters
StyleAttribute sty = new StyleAttribute();
boolean shapeChange = false;
-
+
if (getPres(sty.setName("x1")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -172,10 +172,8 @@ public class Line extends ShapeElement {
if (shapeChange)
{
build();
-// line = new Line2D.Float(x1, y1, x2, y2);
-// return true;
}
-
+
return changeState || shapeChange;
}
}