From f77e201a12813f266b7ba2a1b7d765a239062854 Mon Sep 17 00:00:00 2001 From: kitfox Date: Sun, 22 Feb 2009 20:03:40 +0000 Subject: Should now be possible to set id attribute even if element has not yet been associated with a diagram. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@59 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/SVGElement.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/kitfox/svg/SVGElement.java b/src/main/java/com/kitfox/svg/SVGElement.java index fe50dd5..7b73870 100644 --- a/src/main/java/com/kitfox/svg/SVGElement.java +++ b/src/main/java/com/kitfox/svg/SVGElement.java @@ -273,7 +273,7 @@ abstract public class SVGElement implements Serializable if (hasAttribute(name, attribType)) throw new SVGElementException(this, "Attribute " + name + "(" + AnimationElement.animationElementToString(attribType) + ") already exists"); //Alter layout for id attribute - if ("id".equals(name)) + if ("id".equals(name) && diagram != null) { diagram.removeElement(this.id); this.id = name; @@ -344,6 +344,7 @@ abstract public class SVGElement implements Serializable private void setDiagram(SVGDiagram diagram) { this.diagram = diagram; + diagram.setElement(id, this); for (Iterator it = children.iterator(); it.hasNext();) { SVGElement ele = (SVGElement)it.next(); -- cgit v1.2.3-55-g7522