From a3164a1079b2caf136b629cd8614fe1a73215469 Mon Sep 17 00:00:00 2001 From: kitfox Date: Sat, 29 Sep 2012 05:21:33 +0000 Subject: Now avoiding reentering XML parser when USE tags reference other documents. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@126 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- nbproject/build-impl.xml | 688 ++++++++++++++++++++++---- nbproject/genfiles.properties | 4 +- src/main/java/com/kitfox/svg/SVGElement.java | 16 +- src/main/java/com/kitfox/svg/SVGLoader.java | 17 +- src/main/java/com/kitfox/svg/SVGUniverse.java | 6 +- src/main/java/com/kitfox/svg/Use.java | 48 +- 6 files changed, 661 insertions(+), 118 deletions(-) diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 3a71c95..2765c04 100755 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -12,18 +12,18 @@ is divided into following sections: - execution - debugging - javadoc - - junit compilation - - junit execution - - junit debugging + - test compilation + - test execution + - test debugging - applet - cleanup --> - + - + @@ -80,7 +80,14 @@ is divided into following sections: - + + + + + + + + @@ -95,8 +102,14 @@ is divided into following sections: + + + + + + @@ -109,41 +122,42 @@ is divided into following sections: - - - - - - - - - - - - + - + - + - + - + - + + + + + + + + + + + + + @@ -172,6 +186,7 @@ is divided into following sections: + @@ -203,9 +218,40 @@ is divided into following sections: - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -337,17 +383,61 @@ is divided into following sections: - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -356,21 +446,314 @@ is divided into following sections: - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + @@ -428,6 +811,7 @@ is divided into following sections: + @@ -444,6 +828,7 @@ is divided into following sections: + @@ -451,6 +836,7 @@ is divided into following sections: + @@ -465,6 +851,7 @@ is divided into following sections: + @@ -476,11 +863,14 @@ is divided into following sections: + + + - + @@ -521,7 +911,7 @@ is divided into following sections: - + - + - + @@ -625,44 +1015,53 @@ is divided into following sections: - To run this application from the command line without Ant, try: + To run this application from the command line without Ant, try: - java -cp "${run.classpath.with.dist.jar}" ${main.class} + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + - + + + + + + - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" + + + - - - - - - - To run this application from the command line without Ant, try: + + + To run this application from the command line without Ant, try: - java -jar "${dist.jar.resolved}" + java -jar "${dist.jar.resolved}" + + + + + + - + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + - + - + - + - + - + + + @@ -784,7 +1292,7 @@ is divided into following sections: @@ -797,7 +1305,7 @@ is divided into following sections: - + @@ -813,7 +1321,7 @@ is divided into following sections: - + Must select some files in the IDE or set javac.includes @@ -829,14 +1337,14 @@ is divided into following sections: - + Some tests failed; see details above. @@ -849,39 +1357,40 @@ is divided into following sections: Must select some files in the IDE or set test.includes - + Some tests failed; see details above. + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + - + Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + @@ -946,9 +1455,12 @@ is divided into following sections: - - - + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 49bff32..48f9095 100755 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=be360661 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=478066e1 -nbproject/build-impl.xml.script.CRC32=1ebb99f0 -nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 +nbproject/build-impl.xml.script.CRC32=b2cc318c +nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/src/main/java/com/kitfox/svg/SVGElement.java b/src/main/java/com/kitfox/svg/SVGElement.java index 7398ea9..4375a89 100644 --- a/src/main/java/com/kitfox/svg/SVGElement.java +++ b/src/main/java/com/kitfox/svg/SVGElement.java @@ -391,14 +391,14 @@ abstract public class SVGElement implements Serializable */ public void loaderEndElement(SVGLoaderHelper helper) throws SVGParseException { - try - { - build(); - } - catch (SVGException se) - { - throw new SVGParseException(se); - } +// try +// { +// build(); +// } +// catch (SVGException se) +// { +// throw new SVGParseException(se); +// } } /** diff --git a/src/main/java/com/kitfox/svg/SVGLoader.java b/src/main/java/com/kitfox/svg/SVGLoader.java index c86978d..857ff5b 100644 --- a/src/main/java/com/kitfox/svg/SVGLoader.java +++ b/src/main/java/com/kitfox/svg/SVGLoader.java @@ -228,16 +228,25 @@ public class SVGLoader extends DefaultHandler svgEle.loaderEndElement(helper); SVGElement parent = null; - if (buildStack.size() != 0) parent = (SVGElement)buildStack.getLast(); + if (buildStack.size() != 0) + { + parent = (SVGElement)buildStack.getLast(); + } //else loadRoot = (SVGElement)svgEle; - if (parent != null) parent.loaderAddChild(helper, svgEle); - else diagram.setRoot((SVGRoot)svgEle); + if (parent != null) + { + parent.loaderAddChild(helper, svgEle); + } + else + { + diagram.setRoot((SVGRoot)svgEle); + } } catch (Exception e) { -e.printStackTrace(); + e.printStackTrace(); throw new SAXException(e); } } diff --git a/src/main/java/com/kitfox/svg/SVGUniverse.java b/src/main/java/com/kitfox/svg/SVGUniverse.java index f59e0d1..c68dc79 100644 --- a/src/main/java/com/kitfox/svg/SVGUniverse.java +++ b/src/main/java/com/kitfox/svg/SVGUniverse.java @@ -431,7 +431,10 @@ public class SVGUniverse implements Serializable try { URI uri = new URI(docRoot.toString()); - if (loadedDocs.containsKey(uri) && !forceLoad) return uri; + if (loadedDocs.containsKey(uri) && !forceLoad) + { + return uri; + } InputStream is = docRoot.openStream(); return loadSVG(uri, new InputSource(createDocumentInputStream(is))); @@ -574,6 +577,7 @@ public class SVGUniverse implements Serializable // SAXParser saxParser = factory.newSAXParser(); // saxParser.parse(new InputSource(new BufferedReader(is)), handler); + handler.getLoadedDiagram().updateTime(curTime); return xmlBase; } catch (SAXParseException sex) diff --git a/src/main/java/com/kitfox/svg/Use.java b/src/main/java/com/kitfox/svg/Use.java index 3229482..897fdba 100644 --- a/src/main/java/com/kitfox/svg/Use.java +++ b/src/main/java/com/kitfox/svg/Use.java @@ -45,7 +45,8 @@ public class Use extends ShapeElement { float width = 1f; float height = 1f; - SVGElement href = null; +// SVGElement href = null; + URI href = null; AffineTransform refXform; @@ -94,18 +95,31 @@ public class Use extends ShapeElement { StyleAttribute sty = new StyleAttribute(); - if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits(); + if (getPres(sty.setName("x"))) + { + x = sty.getFloatValueWithUnits(); + } - if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits(); + if (getPres(sty.setName("y"))) + { + y = sty.getFloatValueWithUnits(); + } - if (getPres(sty.setName("width"))) width = sty.getFloatValueWithUnits(); + if (getPres(sty.setName("width"))) + { + width = sty.getFloatValueWithUnits(); + } - if (getPres(sty.setName("height"))) height = sty.getFloatValueWithUnits(); + if (getPres(sty.setName("height"))) + { + height = sty.getFloatValueWithUnits(); + } if (getPres(sty.setName("xlink:href"))) { URI src = sty.getURIValue(getXMLBase()); - href = diagram.getUniverse().getElement(src); + href = src; +// href = diagram.getUniverse().getElement(src); } //Determine use offset/scale @@ -121,9 +135,11 @@ public class Use extends ShapeElement { AffineTransform oldXform = g.getTransform(); g.transform(refXform); - if (href == null || !(href instanceof RenderableElement)) return; + SVGElement ref = diagram.getUniverse().getElement(href); + + if (ref == null || !(ref instanceof RenderableElement)) return; - RenderableElement rendEle = (RenderableElement)href; + RenderableElement rendEle = (RenderableElement)ref; rendEle.pushParentContext(this); rendEle.render(g); rendEle.popParentContext(); @@ -135,9 +151,10 @@ public class Use extends ShapeElement { public Shape getShape() { - if (href instanceof ShapeElement) + SVGElement ref = diagram.getUniverse().getElement(href); + if (ref instanceof ShapeElement) { - Shape shape = ((ShapeElement)href).getShape(); + Shape shape = ((ShapeElement)ref).getShape(); shape = refXform.createTransformedShape(shape); shape = shapeToParent(shape); return shape; @@ -148,9 +165,10 @@ public class Use extends ShapeElement { public Rectangle2D getBoundingBox() throws SVGException { - if (href instanceof ShapeElement) + SVGElement ref = diagram.getUniverse().getElement(href); + if (ref instanceof ShapeElement) { - ShapeElement shapeEle = (ShapeElement)href; + ShapeElement shapeEle = (ShapeElement)ref; shapeEle.pushParentContext(this); Rectangle2D bounds = shapeEle.getBoundingBox(); shapeEle.popParentContext(); @@ -222,10 +240,10 @@ public class Use extends ShapeElement { if (getPres(sty.setName("xlink:href"))) { URI src = sty.getURIValue(getXMLBase()); - SVGElement newVal = diagram.getUniverse().getElement(src); - if (newVal != href) +// SVGElement newVal = diagram.getUniverse().getElement(src); + if (!src.equals(href)) { - href = newVal; + href = src; shapeChange = true; } } -- cgit v1.2.3-55-g7522