summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/Circle.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/svg/Circle.java')
-rw-r--r--src/main/java/com/kitfox/svg/Circle.java85
1 files changed, 35 insertions, 50 deletions
diff --git a/src/main/java/com/kitfox/svg/Circle.java b/src/main/java/com/kitfox/svg/Circle.java
index 7c76b9f..6c2eff8 100644
--- a/src/main/java/com/kitfox/svg/Circle.java
+++ b/src/main/java/com/kitfox/svg/Circle.java
@@ -33,7 +33,6 @@
*
* Created on January 26, 2004, 5:25 PM
*/
-
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
@@ -46,59 +45,48 @@ import java.awt.geom.Rectangle2D;
* @author Mark McKay
* @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
*/
-public class Circle extends ShapeElement
+public class Circle extends ShapeElement
{
+ public static final String TAG_NAME = "circle";
float cx = 0f;
float cy = 0f;
float r = 0f;
-
-
Ellipse2D.Float circle = new Ellipse2D.Float();
- /** Creates a new instance of Rect */
- public Circle() {
- }
-/*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
+ /**
+ * Creates a new instance of Rect
+ */
+ public Circle()
{
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
- String cx = attrs.getValue("cx");
- String cy = attrs.getValue("cy");
- String r = attrs.getValue("r");
-
- this.cx = XMLParseUtil.parseFloat(cx);
- this.cy = XMLParseUtil.parseFloat(cy);
- this.r = XMLParseUtil.parseFloat(r);
-
- build();
-
- //setBounds(this.cx - this.r, this.cy - this.r, this.r * 2.0, this.r * 2.0);
}
-*/
- /*
- public void loaderEndElement(SVGLoaderHelper helper)
- {
-// super.loaderEndElement(helper);
-// build();
+ public String getTagName()
+ {
+ return TAG_NAME;
}
- */
-
+
protected void build() throws SVGException
{
super.build();
-
+
StyleAttribute sty = new StyleAttribute();
-
- if (getPres(sty.setName("cx"))) cx = sty.getFloatValueWithUnits();
-
- if (getPres(sty.setName("cy"))) cy = sty.getFloatValueWithUnits();
-
- if (getPres(sty.setName("r"))) r = sty.getFloatValueWithUnits();
-
+
+ if (getPres(sty.setName("cx")))
+ {
+ cx = sty.getFloatValueWithUnits();
+ }
+
+ if (getPres(sty.setName("cy")))
+ {
+ cy = sty.getFloatValueWithUnits();
+ }
+
+ if (getPres(sty.setName("r")))
+ {
+ r = sty.getFloatValueWithUnits();
+ }
+
circle.setFrame(cx - r, cy - r, r * 2f, r * 2f);
}
@@ -120,8 +108,9 @@ public class Circle 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
*/
@@ -133,7 +122,7 @@ public class Circle extends ShapeElement
//Get current values for parameters
StyleAttribute sty = new StyleAttribute();
boolean shapeChange = false;
-
+
if (getPres(sty.setName("cx")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -143,7 +132,7 @@ public class Circle extends ShapeElement
shapeChange = true;
}
}
-
+
if (getPres(sty.setName("cy")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -153,7 +142,7 @@ public class Circle extends ShapeElement
shapeChange = true;
}
}
-
+
if (getPres(sty.setName("r")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -163,18 +152,14 @@ public class Circle extends ShapeElement
shapeChange = true;
}
}
-
+
if (shapeChange)
{
build();
// circle.setFrame(cx - r, cy - r, r * 2f, r * 2f);
// return true;
}
-
+
return changeState || shapeChange;
}
-
}
-
-
-