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 --- .../java/com/kitfox/svg/TransformableElement.java | 65 ++++++++++++---------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'src/main/java/com/kitfox/svg/TransformableElement.java') diff --git a/src/main/java/com/kitfox/svg/TransformableElement.java b/src/main/java/com/kitfox/svg/TransformableElement.java index f506033..f5a3e58 100644 --- a/src/main/java/com/kitfox/svg/TransformableElement.java +++ b/src/main/java/com/kitfox/svg/TransformableElement.java @@ -33,7 +33,6 @@ * * Created on January 26, 2004, 9:00 AM */ - package com.kitfox.svg; import com.kitfox.svg.xml.StyleAttribute; @@ -41,20 +40,19 @@ import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; - /** * Maintains bounding box for this element * * @author Mark McKay * @author Mark McKay */ -public class TransformableElement extends SVGElement +abstract public class TransformableElement extends SVGElement { - AffineTransform xform = null; -// AffineTransform invXform = null; - /** Creates a new instance of BoundedElement */ + /** + * Creates a new instance of BoundedElement + */ public TransformableElement() { } @@ -65,8 +63,8 @@ public class TransformableElement extends SVGElement } /** - * Fetches a copy of the cached AffineTransform. Note that this - * value will only be valid after the node has been updated. + * Fetches a copy of the cached AffineTransform. Note that this value will + * only be valid after the node has been updated. * * @return */ @@ -74,54 +72,61 @@ public class TransformableElement extends SVGElement { return new AffineTransform(xform); } -/* - public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) - { - //Load style string - super.loaderStartElement(helper, attrs, parent); + /* + public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) + { + //Load style string + super.loaderStartElement(helper, attrs, parent); + + String transform = attrs.getValue("transform"); + if (transform != null) + { + xform = parseTransform(transform); + } + } + */ - String transform = attrs.getValue("transform"); - if (transform != null) - { - xform = parseTransform(transform); - } - } -*/ - protected void build() throws SVGException { super.build(); - + StyleAttribute sty = new StyleAttribute(); - + if (getPres(sty.setName("transform"))) { xform = parseTransform(sty.getStringValue()); } } - + protected Shape shapeToParent(Shape shape) { - if (xform == null) return shape; + if (xform == null) + { + return shape; + } return xform.createTransformedShape(shape); } protected Rectangle2D boundsToParent(Rectangle2D rect) { - if (xform == null) return rect; + if (xform == null) + { + return rect; + } return xform.createTransformedShape(rect).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 */ public boolean updateTime(double curTime) throws SVGException { StyleAttribute sty = new StyleAttribute(); - + if (getPres(sty.setName("transform"))) { AffineTransform newXform = parseTransform(sty.getStringValue()); @@ -131,7 +136,7 @@ public class TransformableElement extends SVGElement return true; } } - + return false; } } -- cgit v1.2.3-55-g7522