summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/Ellipse.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/svg/Ellipse.java')
-rw-r--r--src/main/java/com/kitfox/svg/Ellipse.java112
1 files changed, 46 insertions, 66 deletions
diff --git a/src/main/java/com/kitfox/svg/Ellipse.java b/src/main/java/com/kitfox/svg/Ellipse.java
index 59cd635..6051d3f 100644
--- a/src/main/java/com/kitfox/svg/Ellipse.java
+++ b/src/main/java/com/kitfox/svg/Ellipse.java
@@ -33,87 +33,66 @@
*
* Created on January 26, 2004, 5:25 PM
*/
-
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
-import com.kitfox.svg.xml.*;
-import org.xml.sax.*;
-
-import java.awt.*;
-import java.awt.geom.*;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Rectangle2D;
/**
* @author Mark McKay
* @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
*/
-public class Ellipse extends ShapeElement {
+public class Ellipse extends ShapeElement
+{
+ public static final String TAG_NAME = "ellipse";
float cx = 0.0f;
float cy = 0.0f;
float rx = 0.0f;
float ry = 0.0f;
-
Ellipse2D.Float ellipse = new Ellipse2D.Float();
- /** Creates a new instance of Rect */
- public Ellipse() {
+ /**
+ * Creates a new instance of Rect
+ */
+ public Ellipse()
+ {
}
-/*
- protected void init(String idIn, Style parentStyle, String cx, String cy, String rx, String ry) {
- super.init(idIn, parentStyle);
-
- this.cx = parseDouble(cx);
- this.cy = parseDouble(cy);
- this.rx = parseDouble(rx);
- this.ry = parseDouble(ry);
- setBounds(this.cx - this.rx, this.cy - this.ry, this.rx * 2.0, this.ry * 2.0);
- }
-*/
- /*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
+ public String getTagName()
{
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
- String cx = attrs.getValue("cx");
- String cy = attrs.getValue("cy");
- String rx = attrs.getValue("rx");
- String ry = attrs.getValue("ry");
-
- this.cx = XMLParseUtil.parseDouble(cx);
- this.cy = XMLParseUtil.parseDouble(cy);
- this.rx = XMLParseUtil.parseDouble(rx);
- this.ry = XMLParseUtil.parseDouble(ry);
-
- build();
+ return TAG_NAME;
}
- */
-
- /*
- public void loaderEndElement(SVGLoaderHelper helper)
- {
- super.loaderEndElement(helper);
- build();
- }
- */
-
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("rx"))) rx = sty.getFloatValueWithUnits();
-
- if (getPres(sty.setName("ry"))) ry = sty.getFloatValueWithUnits();
-
+
+ if (getPres(sty.setName("cx")))
+ {
+ cx = sty.getFloatValueWithUnits();
+ }
+
+ if (getPres(sty.setName("cy")))
+ {
+ cy = sty.getFloatValueWithUnits();
+ }
+
+ if (getPres(sty.setName("rx")))
+ {
+ rx = sty.getFloatValueWithUnits();
+ }
+
+ if (getPres(sty.setName("ry")))
+ {
+ ry = sty.getFloatValueWithUnits();
+ }
+
ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f);
}
@@ -133,10 +112,11 @@ public class Ellipse extends ShapeElement {
{
return boundsToParent(includeStrokeInBounds(ellipse.getBounds2D()));
}
-
+
/**
- * 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
*/
@@ -148,7 +128,7 @@ public class Ellipse extends ShapeElement {
//Get current values for parameters
StyleAttribute sty = new StyleAttribute();
boolean shapeChange = false;
-
+
if (getPres(sty.setName("cx")))
{
float newCx = sty.getFloatValueWithUnits();
@@ -158,7 +138,7 @@ public class Ellipse extends ShapeElement {
shapeChange = true;
}
}
-
+
if (getPres(sty.setName("cy")))
{
float newCy = sty.getFloatValueWithUnits();
@@ -168,7 +148,7 @@ public class Ellipse extends ShapeElement {
shapeChange = true;
}
}
-
+
if (getPres(sty.setName("rx")))
{
float newRx = sty.getFloatValueWithUnits();
@@ -178,7 +158,7 @@ public class Ellipse extends ShapeElement {
shapeChange = true;
}
}
-
+
if (getPres(sty.setName("ry")))
{
float newRy = sty.getFloatValueWithUnits();
@@ -188,14 +168,14 @@ public class Ellipse extends ShapeElement {
shapeChange = true;
}
}
-
+
if (shapeChange)
{
build();
// ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f);
// return true;
}
-
+
return changeState || shapeChange;
}
}