summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/kitfox/svg/SVGDiagram.java1
-rw-r--r--src/main/java/com/kitfox/svg/SVGElement.java22
2 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/com/kitfox/svg/SVGDiagram.java b/src/main/java/com/kitfox/svg/SVGDiagram.java
index c28e6e6..236de83 100644
--- a/src/main/java/com/kitfox/svg/SVGDiagram.java
+++ b/src/main/java/com/kitfox/svg/SVGDiagram.java
@@ -202,6 +202,7 @@ public class SVGDiagram implements Serializable
public void setRoot(SVGRoot root)
{
this.root = root;
+ root.setDiagram(this);
}
public boolean ignoringClipHeuristic() { return ignoreClipHeuristic; }
diff --git a/src/main/java/com/kitfox/svg/SVGElement.java b/src/main/java/com/kitfox/svg/SVGElement.java
index 08cb36c..08a801c 100644
--- a/src/main/java/com/kitfox/svg/SVGElement.java
+++ b/src/main/java/com/kitfox/svg/SVGElement.java
@@ -286,11 +286,14 @@ 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) && diagram != null)
+ if ("id".equals(name))
{
- diagram.removeElement(this.id);
- this.id = name;
- diagram.setElement(this.id, this);
+ if (diagram != null)
+ {
+ diagram.removeElement(id);
+ diagram.setElement(value, this);
+ }
+ this.id = value;
}
switch (attribType)
@@ -354,7 +357,7 @@ abstract public class SVGElement implements Serializable
}
}
- private void setDiagram(SVGDiagram diagram)
+ protected void setDiagram(SVGDiagram diagram)
{
this.diagram = diagram;
diagram.setElement(id, this);
@@ -510,9 +513,12 @@ abstract public class SVGElement implements Serializable
//Alter layout for relevant attributes
if ("id".equals(styAttr.getName()))
{
- diagram.removeElement(this.id);
- this.id = name;
- diagram.setElement(this.id, this);
+ if (diagram != null)
+ {
+ diagram.removeElement(this.id);
+ diagram.setElement(value, this);
+ }
+ this.id = value;
}
styAttr.setStringValue(value);