vhardy 2002/06/21 07:20:40 Modified: test-resources/org/apache/batik/test samplesRendering.xml sources/org/apache/batik/bridge SVGUseElementBridge.java Added: samples/tests/spec/scripting use.svg Log: Fixed bug #10066, transform issue. Implemented x/y update on <use>. Added <use> test: samples/tests/spec/scripting/use.svg Revision Changes Path 1.78 +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.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- samplesRendering.xml 20 Jun 2002 21:35:09 -0000 1.77 +++ samplesRendering.xml 21 Jun 2002 14:20:40 -0000 1.78 @@ -321,6 +321,7 @@ <test id="samples/tests/spec/scripting/maskClipUpdate.svg" /> <test id="samples/tests/spec/scripting/markerUpdate.svg" /> <test id="samples/tests/spec/scripting/filterPatternUpdate.svg" /> + <test id="samples/tests/spec/scripting/use.svg" /> </testGroup> </testSuite> 1.25 +32 -18 xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java Index: SVGUseElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- SVGUseElementBridge.java 20 Mar 2002 16:34:43 -0000 1.24 +++ SVGUseElementBridge.java 21 Jun 2002 14:20:40 -0000 1.25 @@ -149,12 +149,31 @@ CompositeGraphicsNode gn = new CompositeGraphicsNode(); gn.getChildren().add(refNode); + gn.setTransform(computeTransform(e)); + + // set an affine transform to take into account the (x, y) + // coordinates of the <use> element + + // 'visibility' + gn.setVisible(CSSUtilities.convertVisibility(e)); + + // 'enable-background' + Rectangle2D r = CSSUtilities.convertEnableBackground(e); + if (r != null) { + gn.setBackgroundEnable(r); + } + return gn; + } + + /** + * Computes the AffineTransform for the node + */ + protected AffineTransform computeTransform(Element e) { UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e); - String s; // 'x' attribute - default is 0 float x = 0; - s = e.getAttributeNS(null, SVG_X_ATTRIBUTE); + String s = e.getAttributeNS(null, SVG_X_ATTRIBUTE); if (s.length() != 0) { x = UnitProcessor.svgHorizontalCoordinateToUserSpace (s, SVG_X_ATTRIBUTE, uctx); @@ -178,21 +197,9 @@ at.preConcatenate (SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s)); } - gn.setTransform(at); - - // set an affine transform to take into account the (x, y) - // coordinates of the <use> element - // 'visibility' - gn.setVisible(CSSUtilities.convertVisibility(e)); - - // 'enable-background' - Rectangle2D r = CSSUtilities.convertEnableBackground(e); - if (r != null) { - gn.setBackgroundEnable(r); - } - return gn; - } + return at; + } /** * Creates the GraphicsNode depending on the GraphicsNodeBridge @@ -215,6 +222,13 @@ * Invoked when an MutationEvent of type 'DOMAttrModified' is fired. */ public void handleDOMAttrModifiedEvent(MutationEvent evt) { - super.handleDOMAttrModifiedEvent(evt); + String attrName = evt.getAttrName(); + if (attrName.equals(SVG_X_ATTRIBUTE) || + attrName.equals(SVG_Y_ATTRIBUTE) || + attrName.equals(SVG_TRANSFORM_ATTRIBUTE)) { + String s = evt.getNewValue(); + node.setTransform(computeTransform(e)); + handleGeometryChanged(); + } } } 1.1 xml-batik/samples/tests/spec/scripting/use.svg Index: use.svg =================================================================== <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- ========================================================================= --> <!-- Copyright (C) The Apache Software Foundation. All rights reserved. --> <!-- --> <!-- This software is published under the terms of the Apache Software License --> <!-- version 1.1, a copy of which has been included with this distribution in --> <!-- the LICENSE file. --> <!-- ========================================================================= --> <!-- ========================================================================= --> <!-- Dynamic update for use --> <!-- --> <!-- @author [EMAIL PROTECTED] --> <!-- @version $Id: use.svg,v 1.1 2002/06/21 14:20:40 vhardy Exp $ --> <!-- ========================================================================= --> <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="body" width="450" height="500" viewBox="0 0 450 500"> <title>Update on <use></title> <text x="50%" y="45" class="title">x/y/transform update on <use></text> <script type="text/ecmascript"> <![CDATA[ function runTest(){ document.getElementById('x').setAttributeNS(null, 'x', '20'); document.getElementById('y').setAttributeNS(null, 'y', '15'); document.getElementById('transform').setAttributeNS(null, 'transform', 'rotate(20)'); } ]]> </script> <defs> <rect id="symbol" x="-10" y="-10" width="20" height="20" /> <rect id="titleCell" x="-60" y="-15" width="120" height="20" /> <rect id="tableCell" x="-60" y="-20" width="120" height="40" /> <rect id="button" x="-30" y="-15" width="60" height="20" /> </defs> <style type="text/css"><![CDATA[ use.tableHeader { fill: #eeeeee; stroke: black; } text.tableHeader { text-anchor: middle; stroke: none; fill: black; } use.tableCell { fill: white; stroke: black; } text.tableCell { text-anchor: middle; stroke: none; fill: black; } use.button { fill: #eeeeee; stroke: black; } text.button { fill: black; stroke: none; text-anchor: middle; } .reference { fill: none; stroke: black; } .symbol { fill: gold; stroke: crimson; stroke-width: 4; } ]]></style> <g transform="translate(165, 160)"> <g id="tableHeader" class="tableHeader"> <g> <use class="tableHeader" xlink:href="#titleCell" /> <text class="tableHeader">Attribute</text> </g> <g transform="translate(120,0)"> <use class="tableHeader" xlink:href="#titleCell" /> <text class="tableHeader"><use> and ref</text> </g> </g> <g id="xRow" transform="translate(0,25)"> <g> <use class="tableCell" xlink:href="#tableCell" /> <text class="tableCell">x</text> </g> <g transform="translate(120,0)" > <use class="tableCell" xlink:href="#tableCell" /> <use id="x" x="10" y="5" class="symbol" xlink:href="#symbol"/> <use x="20" y="5" class="reference" xlink:href="#symbol"/> </g> </g> <g id="yRow" transform="translate(0,65)"> <g> <use class="tableCell" xlink:href="#tableCell" /> <text class="tableCell">y</text> </g> <g transform="translate(120,0)" > <use class="tableCell" xlink:href="#tableCell" /> <use id="y" x="10" y="0" class="symbol" xlink:href="#symbol"/> <use x="10" y="15" class="reference" xlink:href="#symbol"/> </g> </g> <g id="transformRow" transform="translate(0,105)"> <g> <use class="tableCell" xlink:href="#tableCell" /> <text class="tableCell">transform</text> </g> <g transform="translate(120,0)" > <use class="tableCell" xlink:href="#tableCell" /> <use id="transform" x="10" y="5" class="symbol" xlink:href="#symbol"/> <use x="10" y="5" transform="rotate(20)" class="reference" xlink:href="#symbol"/> </g> </g> <a onclick="runTest()"> <use class="button" xlink:href="#button" x="60" y="200" /> <text class="button" x="60" y="200">Run Test</text> </a> </g> <!-- <use id="use" xlink:href="#Rect" x="20" y="40" width="100" height="80" transform="scale(1.2)" onclick="scale('use')" /> <a onclick="removeChangeAdd('use')"> <text x="80" y="35" text-anchor="middle">Remove, modify, add</text> </a> <a onclick="removeChangeAdd('rect')" transform="translate(160,0)"> <text x="80" y="35" text-anchor="middle">Remove, modify, add</text> </a> <rect id="rect" x="150" y="40" width="100" height="80" transform="scale(1.2)" style="fill:green; stroke:yellow" onclick="scale('rect')" /> <text x="175" y="190" style="font-size:20pt; text-anchor:middle"> Transform problem. </text> --> </svg>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]