deweese 2003/10/05 17:56:01 Modified: samples/tests/spec/scripting visibility.svg sources/org/apache/batik/bridge AbstractGraphicsNodeBridge.java BridgeContext.java SVGDecoratedShapeElementBridge.java SVGGElementBridge.java SVGImageElementBridge.java SVGShapeElementBridge.java sources/org/apache/batik/gvt ImageNode.java sources/org/apache/batik/transcoder/image ImageTranscoder.java test-resources/org/apache/batik/test samplesRendering.xml xdocs index.xml installing.xml Log: 1) Dynamic modification of 'display' property now works correctly. 2) Multiple Image elements referencing the same SVG image should now correctly handle events (and may be more efficient). 3) Dynamic modificaiton of marker properties should now work. 4) Fixed a small bug in adding elements as siblings of elements with display none that could result in improper display order. Revision Changes Path 1.3 +66 -23 xml-batik/samples/tests/spec/scripting/visibility.svg Index: visibility.svg =================================================================== RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/visibility.svg,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- visibility.svg 8 Aug 2003 11:39:33 -0000 1.2 +++ visibility.svg 6 Oct 2003 00:56:00 -0000 1.3 @@ -62,32 +62,75 @@ <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> <svg id="body" width="450" height="500" viewBox="0 0 450 500"> - <title>'visibility' property on 'onload'</title> + <title>'visibility' property on 'onload'</title> - <text x="50%" y="45" class="title">'visibility' property on 'onload'</text> - - <script type="text/ecmascript"><![CDATA[ - function changeVisibility(evt, newValue) { - evt.target.setAttribute("style", "visibility:"+newValue); - } + <text x="50%" y="45" class="title">'visibility' property on 'onload'</text> + <script type="text/ecmascript"><![CDATA[ + function changeVisibility(evt, newValue) { + evt.target.getStyle().setProperty("visibility", newValue, ""); + } ]]></script> - <g id="test-content"> - - <g onload="changeVisibility(evt, 'hidden')" style="visibility:visible"> - <rect x="100" y="100" width="100" height="100" style="fill:#eee"/> - <rect x="150" y="100" width="100" height="100" style="fill:gold"/> - <rect x="200" y="100" width="100" height="100" style="fill:crimson"/> - <rect x="250" y="100" width="100" height="100" style="fill:orange"/> - </g> - - <g onload="changeVisibility(evt, 'visible')" style="visibility:hidden"> - <rect x="100" y="300" width="100" height="100" style="fill:#eee"/> - <rect x="150" y="300" width="100" height="100" style="fill:gold"/> - <rect x="200" y="300" width="100" height="100" style="fill:crimson"/> - <rect x="250" y="300" width="100" height="100" style="fill:orange"/> - </g> + <linearGradient id="grad"> + <stop style="stop-color:crimson" offset="0" /> + <stop style="stop-color:gold" offset="1" /> + </linearGradient> + + <g id="test-content" stroke="black" stroke-width="1"> + + <g onload="changeVisibility(evt, 'hidden')" style="visibility:visible"> + <rect x="100" y="100" width="100" height="50" style="fill:#eee"/> + <rect x="150" y="100" width="100" height="50" style="fill:gold"/> + <rect x="200" y="100" width="100" height="50" style="fill:crimson"/> + <rect x="250" y="100" width="100" height="50" style="fill:url(#grad)"/> + <image x="300" y="100" width="50" height="50" + xlink:href="../../resources/images/png2.png"/> + </g> + <g > + <rect x="100" y="175" width="100" height="50" + onload="changeVisibility(evt, 'hidden')" + style="fill:#eee; visibility:visible"/> + <rect x="150" y="175" width="100" height="50" + onload="changeVisibility(evt, 'hidden')" + style="fill:gold; visibility:visible"/> + <rect x="200" y="175" width="100" height="50" + onload="changeVisibility(evt, 'hidden')" + style="fill:crimson; visibility:visible"/> + <rect x="250" y="175" width="100" height="50" + onload="changeVisibility(evt, 'hidden')" + style="fill:url(#grad); visibility:visible"/> + <image x="300" y="175" width="50" height="50" + onload="changeVisibility(evt, 'hidden')" + xlink:href="../../resources/images/png2.png"/> + </g> + <g onload="changeVisibility(evt, 'visible')" style="visibility:hidden"> + <rect x="100" y="250" width="100" height="50" style="fill:#eee"/> + <rect x="150" y="250" width="100" height="50" style="fill:gold"/> + <rect x="200" y="250" width="100" height="50" style="fill:crimson"/> + <rect x="250" y="250" width="100" height="50" style="fill:url(#grad)"/> + <image x="300" y="250" width="50" height="50" + xlink:href="../../resources/images/png2.png"/> + </g> + <g > + <rect x="100" y="325" width="100" height="50" + onload="changeVisibility(evt, 'visible')" + style="fill:#eee; visibility:hidden"/> + <rect x="150" y="325" width="100" height="50" + onload="changeVisibility(evt, 'visible')" + style="fill:gold; visibility:hidden"/> + <rect x="200" y="325" width="100" height="50" + onload="changeVisibility(evt, 'visible')" + style="fill:crimson; visibility:hidden"/> + <rect x="250" y="325" width="100" height="50" + onload="changeVisibility(evt, 'visible')" + style="fill:url(#grad); visibility:hidden"/> + <image x="300" y="325" width="50" height="50" + xlink:href="../../resources/images/png2.png" + onload="changeVisibility(evt, 'visible')" + style="visibility:hidden"/> </g> + + </g> </svg> 1.33 +10 -1 xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java Index: AbstractGraphicsNodeBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- AbstractGraphicsNodeBridge.java 8 Aug 2003 11:38:50 -0000 1.32 +++ AbstractGraphicsNodeBridge.java 6 Oct 2003 00:56:00 -0000 1.33 @@ -317,6 +317,15 @@ case SVGCSSEngine.POINTER_EVENTS_INDEX: node.setPointerEventType(CSSUtilities.convertPointerEvents(e)); break; + case SVGCSSEngine.DISPLAY_INDEX: + if (!getDisplay(e)) { + // Remove the subtree. + CompositeGraphicsNode parent = node.getParent(); + int idx = parent.indexOf(node); + parent.remove(node); + disposeTree(e); + } + break; } } 1.73 +53 -3 xml-batik/sources/org/apache/batik/bridge/BridgeContext.java Index: BridgeContext.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- BridgeContext.java 11 Sep 2003 10:40:24 -0000 1.72 +++ BridgeContext.java 6 Oct 2003 00:56:00 -0000 1.73 @@ -71,6 +71,7 @@ import org.apache.batik.css.engine.CSSEngineEvent; import org.apache.batik.css.engine.CSSEngineListener; import org.apache.batik.css.engine.CSSEngineUserAgent; +import org.apache.batik.css.engine.SVGCSSEngine; import org.apache.batik.css.engine.SystemColorSupport; import org.apache.batik.css.engine.value.Value; import org.apache.batik.dom.svg.SVGContext; @@ -78,6 +79,7 @@ import org.apache.batik.dom.svg.SVGOMDocument; import org.apache.batik.dom.svg.SVGOMElement; import org.apache.batik.dom.svg.SVGStylableElement; +import org.apache.batik.gvt.CompositeGraphicsNode; import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.TextPainter; import org.apache.batik.script.Interpreter; @@ -1208,8 +1210,56 @@ * that have changed on a particular element. */ public void propertiesChanged(CSSEngineEvent evt) { - SVGContext ctx = getSVGContext(evt.getElement()); - if (ctx != null && (ctx instanceof BridgeUpdateHandler)) { + Element elem = evt.getElement(); + SVGContext ctx = getSVGContext(elem); + if (ctx == null) { + GraphicsNode pgn = getGraphicsNode + ((Element)elem.getParentNode()); + if ((pgn == null) || !(pgn instanceof CompositeGraphicsNode)) { + // Something changed in this element but we really don't + // care since it's parent isn't displayed either. + return; + } + CompositeGraphicsNode parent = (CompositeGraphicsNode)pgn; + // Check if 'display' changed on this element. + + int [] properties = evt.getProperties(); + for (int i=0; i < properties.length; ++i) { + if (properties[i] == SVGCSSEngine.DISPLAY_INDEX) { + if (!CSSUtilities.convertDisplay(elem)) { + // (Still) Not displayed + break; + } + // build the graphics node + GVTBuilder builder = getGVTBuilder(); + GraphicsNode childNode = builder.build + (BridgeContext.this, elem); + if (childNode == null) { + // the added element is not a graphic element? + break; + } + int idx = -1; + for(Node ps = elem.getPreviousSibling(); ps != null; + ps = ps.getPreviousSibling()) { + if (ps.getNodeType() != Node.ELEMENT_NODE) + continue; + Element pse = (Element)ps; + GraphicsNode gn = getGraphicsNode(pse); + if (gn == null) + continue; + idx = parent.indexOf(gn); + if (idx == -1) + continue; + break; + } + // insert after prevSibling, if + // it was -1 this becomes 0 (first slot) + idx++; + parent.add(idx, childNode); + break; + } + } + } if (ctx != null && (ctx instanceof BridgeUpdateHandler)) { ((BridgeUpdateHandler)ctx).handleCSSEngineEvent(evt); } } 1.8 +19 -1 xml-batik/sources/org/apache/batik/bridge/SVGDecoratedShapeElementBridge.java Index: SVGDecoratedShapeElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGDecoratedShapeElementBridge.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SVGDecoratedShapeElementBridge.java 8 Aug 2003 11:38:51 -0000 1.7 +++ SVGDecoratedShapeElementBridge.java 6 Oct 2003 00:56:00 -0000 1.8 @@ -52,6 +52,7 @@ import java.awt.Shape; +import org.apache.batik.css.engine.SVGCSSEngine; import org.apache.batik.gvt.CompositeShapePainter; import org.apache.batik.gvt.ShapeNode; import org.apache.batik.gvt.ShapePainter; @@ -121,4 +122,21 @@ } return painter; } + + protected void handleCSSPropertyChanged(int property) { + switch(property) { + case SVGCSSEngine.MARKER_START_INDEX: + case SVGCSSEngine.MARKER_MID_INDEX: + case SVGCSSEngine.MARKER_END_INDEX: + if (!hasNewShapePainter) { + hasNewShapePainter = true; + ShapeNode shapeNode = (ShapeNode)node; + shapeNode.setShapePainter(createShapePainter(ctx, e, shapeNode)); + } + break; + default: + super.handleCSSPropertyChanged(property); + } + } } + 1.24 +24 -22 xml-batik/sources/org/apache/batik/bridge/SVGGElementBridge.java Index: SVGGElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGGElementBridge.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- SVGGElementBridge.java 8 Aug 2003 11:38:51 -0000 1.23 +++ SVGGElementBridge.java 6 Oct 2003 00:56:00 -0000 1.24 @@ -153,28 +153,30 @@ if (childNode == null) { return; // the added element is not a graphic element } - // add the graphics node - Node n = parent.getFirstChild(); - Node lastChild = parent.getLastChild(); - if (n == childElt) { - // add at the beginning - gn.add(0, childNode); - } else if (lastChild == childElt) { - // append at the end - gn.add(childNode); - } else { - // find the index of the GraphicsNode to add - int index = 0; - while (n != lastChild && n != childElt) { - if (n.getNodeType() == Node.ELEMENT_NODE) { - if (ctx.hasGraphicsNodeBridge((Element)n)) { - index++; - } - } - n = n.getNextSibling(); + + // Find the index where the GraphicsNode should be added + int idx = -1; + for(Node ps = childElt.getPreviousSibling(); ps != null; + ps = ps.getPreviousSibling()) { + if (ps.getNodeType() != Node.ELEMENT_NODE) + continue; + Element pse = (Element)ps; + GraphicsNode psgn = ctx.getGraphicsNode(pse); + while ((psgn != null) && (psgn.getParent() != gn)) { + // In some cases the GN linked is + // a child (in particular for images). + psgn = psgn.getParent(); } - // insert at the index - gn.add(index, childNode); + if (psgn == null) + continue; + idx = gn.indexOf(psgn); + if (idx == -1) + continue; + break; } + // insert after prevSibling, if + // it was -1 this becomes 0 (first slot) + idx++; + gn.add(idx, childNode); } } 1.63 +3 -13 xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java Index: SVGImageElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- SVGImageElementBridge.java 25 Sep 2003 00:45:11 -0000 1.62 +++ SVGImageElementBridge.java 6 Oct 2003 00:56:00 -0000 1.63 @@ -404,12 +404,7 @@ // Bind the nodes for interactive and dynamic // HACK due to the way images are represented in GVT ImageNode imgNode = (ImageNode)node; - if (imgNode.getImage() instanceof RasterImageNode) { - // register the RasterImageNode instead - ctx.bind(e, imgNode.getImage()); - } else { - ctx.bind(e, node); - } + ctx.bind(e, node); if (ctx.isDynamic()) { // Only do this for dynamic not interactive. @@ -512,12 +507,7 @@ } ImageNode imgNode = (ImageNode)node; //HACK : see 'initializeDynamicSupport' - if (imgNode.getImage() instanceof RasterImageNode) { - // register the RasterImageNode instead - ctx.unbind(e); - ctx.bind(e, inode ); - } - else{ + if (!(imgNode.getImage() instanceof RasterImageNode)) { //it was an svg file referenced //dispose it if ( oldSVGDoc != null ){ 1.25 +2 -2 xml-batik/sources/org/apache/batik/bridge/SVGShapeElementBridge.java Index: SVGShapeElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGShapeElementBridge.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- SVGShapeElementBridge.java 9 Aug 2003 16:58:37 -0000 1.24 +++ SVGShapeElementBridge.java 6 Oct 2003 00:56:00 -0000 1.25 @@ -179,7 +179,7 @@ * This flag bit indicates if a new shape painter has already been created. * Avoid creating one ShapePainter per CSS property change */ - private boolean hasNewShapePainter; + protected boolean hasNewShapePainter; /** * Invoked when CSS properties have changed on an element. 1.15 +3 -2 xml-batik/sources/org/apache/batik/gvt/ImageNode.java Index: ImageNode.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ImageNode.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ImageNode.java 8 Aug 2003 11:39:14 -0000 1.14 +++ ImageNode.java 6 Oct 2003 00:56:00 -0000 1.15 @@ -109,7 +109,8 @@ * @param p the specified Point2D in the user space */ public GraphicsNode nodeHitAt(Point2D p) { - return (contains(p) ? super.nodeHitAt(p) : null); + // Used to return super.nodeHitAt(p); + return (contains(p) ? this : null); } // 1.46 +2 -1 xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java Index: ImageTranscoder.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- ImageTranscoder.java 8 Aug 2003 11:39:25 -0000 1.45 +++ ImageTranscoder.java 6 Oct 2003 00:56:00 -0000 1.46 @@ -128,6 +128,7 @@ // paint the SVG document using the bridge package // create the appropriate renderer ImageRendererFactory rendFactory = new ConcreteImageRendererFactory(); + // ImageRenderer renderer = rendFactory.createDynamicImageRenderer(); ImageRenderer renderer = rendFactory.createStaticImageRenderer(); renderer.updateOffScreen(w, h); renderer.setTransform(curTxf); 1.114 +2 -1 xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml Index: samplesRendering.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v retrieving revision 1.113 retrieving revision 1.114 diff -u -r1.113 -r1.114 --- samplesRendering.xml 27 Sep 2003 01:48:15 -0000 1.113 +++ samplesRendering.xml 6 Oct 2003 00:56:00 -0000 1.114 @@ -352,6 +352,7 @@ <testGroup id="tests.spec.scripting"> <test id="samples/tests/spec/scripting/add.svg" /> <test id="samples/tests/spec/scripting/circle.svg" /> + <test id="samples/tests/spec/scripting/display.svg" /> <test id="samples/tests/spec/scripting/ellipse.svg" /> <test id="samples/tests/spec/scripting/fill.svg" /> <test id="samples/tests/spec/scripting/image.svg" /> 1.49 +2 -2 xml-batik/xdocs/index.xml Index: index.xml =================================================================== RCS file: /home/cvs/xml-batik/xdocs/index.xml,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- index.xml 26 Sep 2003 10:38:01 -0000 1.48 +++ index.xml 6 Oct 2003 00:56:00 -0000 1.49 @@ -147,7 +147,7 @@ <p> You can get the Batik distribution (<link href="install.html#distributions">source</link> and <link href="install.html#distributions">binary</link>) on the - <link href="http://xml.apache.org/dyn/closer.cgi/xml/batik">download page</link>. + <link href="http://www.apache.org/dyn/closer.cgi/xml/batik">download page</link>. </p> <note> All other libraries needed by Batik are included in the distribution. 1.16 +25 -12 xml-batik/xdocs/installing.xml Index: installing.xml =================================================================== RCS file: /home/cvs/xml-batik/xdocs/installing.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- installing.xml 30 Sep 2003 00:13:26 -0000 1.15 +++ installing.xml 6 Oct 2003 00:56:01 -0000 1.16 @@ -125,7 +125,7 @@ the Javadoc for the Batik source code.</li> </ul> - <p>We make nightly copies of the source tree avaiable from the + <p>We make nightly copies of the source tree available from the <link href="http://cvs.apache.org/builds/xml-batik">Apache build</link> server. These builds represent the current state of development and may or may not be as stable as releases. @@ -144,13 +144,13 @@ <li><strong>batik-src-</strong><em>date</em><strong>.zip</strong> (e.g., <code>batik-src-03-09-26.zip</code>)<br/> - This contains all the source code an libraries needed to + This contains all the source code and libraries needed to build and run Batik from source. But does not include the testing facilities. </li> </ul> - <p>Older releases are avaiable from the <link + <p>Older releases are available from the <link href="http://archive.apache.org/dist/xml/batik">Apache archives</link>. However, we strongly recommend using the current release of Batik.</p> @@ -167,11 +167,23 @@ <li>Select the directory where he/she wants to download the distribution </li> + <li>Download the desired distribution from the <link href="http://www.apache.org/dyn/closer.cgi/xml/batik">download - area</link></li> <li>Open a console and go to the directory - where the distribution was downloaded. - </li> + area</link></li> + + <li>Download the associated PGP signature (.asc) and KEYS file + (preferable) or MD5 hash (.md5). This must be done directly + from the <link + href="http://www.apache.org/dist/xml/batik">Apache + download</link> area to mean anything.</li> + + <li>Open a console and go to the directory + where the distribution was downloaded.</li> + + <li><link href="#verify">Verify the integrity</link> of the + distribution</li> + <li>Unpack the distribution with Java's JAR utility:<br></br> <code>jar xvf <distribution></code><br /> For example, if you have downloaded batik-1.5.zip into /home/IamHere, type @@ -182,6 +194,7 @@ various Batik zip files, as this would not set the directories access rights properly. </li> + <li>From there, following the instructions specific to the application you want to use. For example, see the <link href="svgviewer.html">SVG Browser</link> page or the <link @@ -252,12 +265,12 @@ </p> <figure src="images/jarDependImg.png" alt="Batik Jar File Dependency Graph" /> - <note> Some jar file names are shortend for clarity.<br/> + <note> Some jar file names are shortened for clarity.<br/> All 'batik' package references are short for 'org.apache.batik'.<br/> </note> <p>It is worth pointing out that a determined/clever programmer - may be able to pair down some of these dependencies. For + may be able to pare down some of these dependencies. For example the 'batik-dom.jar' depends on 'xerces.jar' because of the SAXDocumentFactory class in 'org.apache.batik.dom.util'. If you didn't need to parse XML it would be possible to ignore or @@ -300,8 +313,8 @@ </p> <p> Alternatively, you can verify the MD5 signature on the files. - A unix program called <code>md5</code> or <code>md5sum</code> - is included in many unix distributions. It is also available + A UNIX program called <code>md5</code> or <code>md5sum</code> + is included in many UNIX distributions. It is also available as part of <link href="http://www.gnu.org/software/textutils/textutils.html">GNU Textutils</link> . Windows users can get binary md5 programs @@ -312,7 +325,7 @@ </p> <p> We recommend using PGP signatures as they can provide a much - higher level of assurance compaired with MD5. + higher level of assurance compared with MD5. </p> </s1> </body>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]