X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fg2d%2Fnodes%2FSVGNode.java;h=f8f692e1d88b70ee080c6adb1591ba5a24d3a70c;hp=42ae2e4c93d34c9b8cdb48f502fb653a6975856f;hb=81e3522f6cb5822f701b66a9fbf9be9f9bf97ec9;hpb=0a40f3664e55387464c9490bbbcd563fddefd451 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..f8f692e1d 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 @@ -56,6 +56,8 @@ import org.simantics.scenegraph.utils.VRamBufferedImage; import org.simantics.scl.runtime.function.Function1; import org.simantics.scl.runtime.function.Function2; import org.simantics.utils.threads.AWTThread; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -77,6 +79,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { private static final long serialVersionUID = 8508750881358776559L; + private static final Logger LOGGER = LoggerFactory.getLogger(SVGNode.class); protected String data = null; protected String defaultData = null; protected Point targetSize = null; @@ -111,6 +114,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { SVGDiagram d = diagramCache; if (d != null) { diagramCache = null; + dataHash = null; SVGUniverse univ = SVGCache.getSVGUniverse(); if (univ.decRefCountAndClear(d.getXMLBase()) == 0) { // Cleared! @@ -131,6 +135,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { } this.data = cached; this.defaultData = cached; + cleanDiagramCache(); } @SyncField("targetSize") @@ -208,7 +213,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 +327,8 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { } else { e.setAttribute(ass.attributeNameOrId, ass.value); } + } else { + LOGGER.warn("Element with id='" + ass.elementId + " was not found."); } } @@ -345,6 +352,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 +381,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 +461,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(); } @@ -464,7 +477,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode { if (!data.equals(documentCache) || diagramCache == null) { dataHash = parseSVG(); if (diagramCache == null) { - System.err.println("UNABLE TO PARSE SVG:\n" + data); + LOGGER.warn("UNABLE TO PARSE SVG:\n" + data); return; } }