From 6776ed9f1a81e517139d85eb6d2e28911fd0fc35 Mon Sep 17 00:00:00 2001 From: kitfox Date: Tue, 19 Mar 2013 05:20:37 +0000 Subject: Adding support for style sheets. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@153 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/Line.java | 72 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'src/main/java/com/kitfox/svg/Line.java') 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 Mark McKay */ -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; } } -- cgit v1.2.3-55-g7522