I have a bug report to file against the following patch:
deweese 2004/11/29 19:23:58
> Modified: samples/solitaire/script util.js > samples/tests/spec/scripting rectResizeOnClick.svg > zeroSize.svg > samples/tests/spec12/text flowText.svg > sources/org/apache/batik/bridge > AbstractGraphicsNodeBridge.java > SVGUseElementBridge.java > sources/org/apache/batik/dom/svg SVGLocatableSupport.java > sources/org/apache/batik/ext/awt/geom SegmentList.java > sources/org/apache/batik/gvt CompositeGraphicsNode.java > ShapeNode.java > sources/org/apache/batik/gvt/flow LineInfo.java > sources/org/apache/batik/swing/gvt JGVTComponent.java > test-references/samples/tests/spec/scripting > text_content.png zeroSize.png > test-resources/org/apache/batik/test samplesRendering.xml > Added: samples/tests/spec/scripting bbox.svg > test-references/samples/tests/spec/scripting bbox.png > Log: > 1) getBBox should now work per the specification. > a) fill="none" will still give bbox > b) It is now the tight bounds of the geometry > c) It does not include the stroke anymore. > d) When called on 'undisplayed' elements returns null (not sure > what the spec really says about this). > 2) Modification of use element's width/height now works. > 3) Some fixes for flowText with soft-hyphens and the like. > > Revision Changes Path > 1.3 +3 -1 xml-batik/samples/solitaire/script/util.js
Since this patch, I notice problems when changing the "visibility" property in dynamic documents. I've attached a testcase that demonstrates the problem. It creates a document consisting of several <g> elements, each containing a single horizontal line. The visibility attribute of each line is initially set to "hidden". Then after a pause, I set visibility="visible".
What *should* happen is that the page is initially blank, and then after the pause the lines become visible. Instead, what happens is that usually the first line becomes visible, but the rest do not become visible unless the canvas is resized (repaint.) If you run this code with batik prior to the 2004/11/29 patch, the code displays correctly. Unless I've misinterpreted something in the spec, I believe this is a bug.
import javax.swing.*; import java.awt.Dimension; import java.io.*;
import org.w3c.dom.*; import org.w3c.dom.svg.*; import org.w3c.dom.DOMImplementation; import org.apache.batik.swing.svg.*; import org.apache.batik.dom.svg.*; import org.apache.batik.util.*; public class Broken { private JSVGComponent canvas; private SVGDocument doc; private Element root; private int width = 500; private int height = 500; public Broken() { } // called from Swing: set up frame, canvas, and document // public void createAndShowGUI() throws IOException { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory svgFactory = new SAXSVGDocumentFactory(parser); canvas = new JSVGComponent(null, true, false); canvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC); JFrame frame = new JFrame("Broken"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(canvas); frame.pack(); frame.setSize(new Dimension(width, height)); frame.setVisible(true); doc = createSVGDocument(width, height); // create and add our line groups to the document- the lines // contained therein will initially be hidden createAndAddGroups(); canvas.setSVGDocument(doc); } // fill the length of the document with horizontal lines, each line // in its own group. Initial line visibility set to "hidden". private void createAndAddGroups() { for (int y = 0; y < height; y += 10) { Element group = createGroup(y); root.appendChild(group); } } // create a <g> group with a single <line> element at the specified // y offset, initial visibility set to "hidden" private Element createGroup(int y) { Element group = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "g"); group.setAttributeNS(null, "style", "stroke:black; " + "stroke-opacity:1; " + "stroke-linejoin:round; " + "stroke-linecap:round; " + "fill:black; "); Element line = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "line"); line.setAttributeNS(null, "x1", "0"); line.setAttributeNS(null, "y1", Integer.toString(y)); line.setAttributeNS(null, "x2", Integer.toString(width)); line.setAttributeNS(null, "y2", Integer.toString(y)); // initial visibility is hidden line.setAttributeNS(null, "visibility", "hidden"); group.appendChild(line); return group; } // enable visibility for each <g> tag contained in root public void animateGroups() { NodeList groups = root.getElementsByTagName("g"); for (int i = 0; i < groups.getLength(); i++) { Element group = (Element) groups.item(i); animateLines(group); } } // set visibility = "visible" for any <line> elements contained in // the given group private void animateLines(Element group) { NodeList lines = group.getElementsByTagName("line"); for (int i = 0; i < lines.getLength(); i++) { Element line = (Element) lines.item(i); System.err.println("animating: " + line); setLineVisible(line); } } public SVGDocument createSVGDocument(int width, int height) { DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); SVGDocument doc = (SVGDocument) impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null); root = doc.getDocumentElement(); root.setAttributeNS(null, "width", "8in"); root.setAttributeNS(null, "height", "5in"); root.setAttributeNS(null, "viewBox", "0 0 " + width + " " + height); return doc; } // make the element visible public void setLineVisible(final Element line) { RunnableQueue rq = canvas.getUpdateManager().getUpdateRunnableQueue(); final Runnable r = new Runnable() { public void run() { System.err.println("setting to visible"); line.setAttributeNS(null, "visibility", "visible"); } }; rq.invokeLater(r); } public static void main(String[] args) throws Exception { final Broken broken = new Broken(); SwingUtilities.invokeLater(new Runnable() { public void run() { try { broken.createAndShowGUI(); } catch (IOException e) { e.printStackTrace(System.err); } } }); Thread.sleep(5000); broken.animateGroups(); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]