deweese 2004/02/04 18:53:45 Modified: contrib/scroll ScrollExample.java sources/org/apache/batik/bridge BridgeEventSupport.java Log: 1) Fixed a bug in mouse coords for text events that caused the incorrect element to be used as the target of the events. Revision Changes Path 1.2 +135 -135 xml-batik/contrib/scroll/ScrollExample.java Index: ScrollExample.java =================================================================== RCS file: /home/cvs/xml-batik/contrib/scroll/ScrollExample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ScrollExample.java 23 Nov 2003 20:54:24 -0000 1.1 +++ ScrollExample.java 5 Feb 2004 02:53:44 -0000 1.2 @@ -1,135 +1,135 @@ -/* - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Batik" and "Apache Software Foundation" must not be - used to endorse or promote products derived from this software without - prior written permission. For written permission, please contact - [EMAIL PROTECTED] - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation. For more information on the - Apache Software Foundation, please see <http://www.apache.org/>. - -*/ - -package org.test; - -import java.awt.Dimension; -import java.io.File; -import java.net.URL; -import java.net.MalformedURLException; -import javax.swing.JFrame; -import javax.swing.WindowConstants; - -import org.apache.batik.swing.*; - -/** -* A very simple example class that demonstrates the -* XJSVGCanvas and XJSVGScroller classes. -* <p> -* Usage: ScrollExample [svg file name] -* <p> -* @author Zach DelProposto -* -* -* -*/ -public class ScrollExample -{ - - /** Command-line start */ - public static void main(String args[]) - { - if(args.length != 1) - { - System.out.println("No or multiple SVG files were specified."); - System.out.println("Usage: ScrollExample svgFileName"); - System.exit(1); - } - - // get the file - File file = new File(args[0]); - if(!file.exists()) - { - System.out.println("File "+file+" does not exist!"); - System.exit(1); - } - - try - { - new ScrollExample(file.toURL()); - } - catch(MalformedURLException e) - { - System.out.println("Cannot convert file to a valid URL..."); - System.out.println(e); - System.exit(1); - } - - }// main() - - - /** Construct the Example */ - private ScrollExample(URL url) - { - JFrame frame = new JFrame("ScrollExample: "+url.getFile()); - frame.setResizable(true); - frame.setSize(new Dimension(500,500)); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing - (java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - - // frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - JSVGCanvas canvas = new JSVGCanvas(); - JSVGScrollPane scroller = new JSVGScrollPane(canvas); - canvas.setURI(url.toString()); - - frame.getContentPane().add(scroller); - frame.setVisible(true); - }// ScrollExample() - - - - -}// class ScrollExample - +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Batik" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation. For more information on the + Apache Software Foundation, please see <http://www.apache.org/>. + +*/ + +package org.test; + +import java.awt.Dimension; +import java.io.File; +import java.net.URL; +import java.net.MalformedURLException; +import javax.swing.JFrame; +import javax.swing.WindowConstants; + +import org.apache.batik.swing.*; + +/** +* A very simple example class that demonstrates the +* XJSVGCanvas and XJSVGScroller classes. +* <p> +* Usage: ScrollExample [svg file name] +* <p> +* @author Zach DelProposto +* +* +* +*/ +public class ScrollExample +{ + + /** Command-line start */ + public static void main(String args[]) + { + if(args.length != 1) + { + System.out.println("No or multiple SVG files were specified."); + System.out.println("Usage: ScrollExample svgFileName"); + System.exit(1); + } + + // get the file + File file = new File(args[0]); + if(!file.exists()) + { + System.out.println("File "+file+" does not exist!"); + System.exit(1); + } + + try + { + new ScrollExample(file.toURL()); + } + catch(MalformedURLException e) + { + System.out.println("Cannot convert file to a valid URL..."); + System.out.println(e); + System.exit(1); + } + + }// main() + + + /** Construct the Example */ + private ScrollExample(URL url) + { + JFrame frame = new JFrame("ScrollExample: "+url.getFile()); + frame.setResizable(true); + frame.setSize(new Dimension(500,500)); + frame.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing + (java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + + // frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + JSVGCanvas canvas = new JSVGCanvas(); + JSVGScrollPane scroller = new JSVGScrollPane(canvas); + canvas.setURI(url.toString()); + + frame.getContentPane().add(scroller); + frame.setVisible(true); + }// ScrollExample() + + + + +}// class ScrollExample + 1.53 +4 -4 xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java Index: BridgeEventSupport.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- BridgeEventSupport.java 5 Dec 2003 18:32:37 -0000 1.52 +++ BridgeEventSupport.java 5 Feb 2004 02:53:44 -0000 1.53 @@ -305,8 +305,8 @@ boolean cancelable) { Point clientXY = evt.getClientPoint(); GraphicsNode node = evt.getGraphicsNode(); - Element targetElement = getEventTarget(node, - (Point)clientXY.clone()); + Element targetElement = getEventTarget + (node, new Point2D.Float(evt.getX(), evt.getY())); Element relatedElement = getRelatedElement(evt); dispatchMouseEvent(eventType, targetElement, @@ -423,7 +423,7 @@ if (target != null && node instanceof TextNode) { TextNode textNode = (TextNode)node; List list = textNode.getTextRuns(); - Point pt = (Point)coords.clone(); + Point2D pt = (Point2D)coords.clone(); // place coords in text node coordinate system try { node.getGlobalTransform().createInverse().transform(pt, pt);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]