From: Antti Villberg Date: Fri, 27 Oct 2017 17:15:15 +0000 (+0300) Subject: SVGNode assignments are not always applied in rendering X-Git-Tag: v1.31.0~87 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1e8cc7e5285c2a27fc9c0dab2a0b3358d8c759f4;p=simantics%2Fplatform.git SVGNode assignments are not always applied in rendering refs #7580 Change-Id: Ib9cc914ea37466825bbec964393083e17deab5b4 --- diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java index 42ae2e4c9..6fd25e6f8 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java @@ -131,6 +131,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { } this.data = cached; this.defaultData = cached; + cleanDiagramCache(); } @SyncField("targetSize") @@ -208,7 +209,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { diagramCache = null; } - // Lets check for rootAssignment that contributes the whole SVG + // Lets check for rootAssignment that contributes the whole SVG SVGNodeAssignment rootAssignment = null; if (!assignments.isEmpty()) { for (SVGNodeAssignment ass : assignments) { @@ -322,6 +323,8 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { } else { e.setAttribute(ass.attributeNameOrId, ass.value); } + } else { + System.err.println("Element with id='" + ass.elementId + " was not found."); } } @@ -345,6 +348,9 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { boolean changed = false; + // Without this elements are sometimes not found by id! + diagram.updateTime(0); + for (SVGNodeAssignment ass : assignments) { SVGElement e = diagram.getElement(ass.elementId); if (e != null) { @@ -371,6 +377,9 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { } } + // Without this the attribute values are not correctly reflected in rendering + diagram.updateTime(0); + return changed; } @@ -448,7 +457,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { URI uri = univ.loadSVG(new ByteArrayInputStream(dataBytes), digest); diagramCache = univ.getDiagram(uri, false); if (diagramCache != null) { - SVGRoot root = diagramCache.getRoot(); + SVGRoot root = diagramCache.getRoot(); if (root == null) return new Rectangle2D.Double(); return (Rectangle2D)root.getBoundingBox().clone(); } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNodeAssignment.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNodeAssignment.java index ac292bc4a..13ce8137b 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNodeAssignment.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNodeAssignment.java @@ -48,4 +48,8 @@ public class SVGNodeAssignment { return false; return true; } + @Override + public String toString() { + return "SVGNodeAssignment eid=" + elementId + " attributeNameOrId=" + attributeNameOrId + " value=" + value; + } } \ No newline at end of file