Attached patch seems to do the trick ok.
There is just one (cosmetic) thing : batik does not repaint the shape straight away after you've partially panned it off the canvas, and then pan it back in. The part that panned off the canvas only gets redrawn when you stop panning.
I don't know if this can be easily fixed somehow.
WDYT about the approach? I don't know how to run the testsuite so i don't know whether this patch introduces any regressions.
Regards Jorg
Jorg Heymans wrote:
Hi,
I have an issue with the default panning functionality of JSVGCanvas.
Using shift-leftmouse you can pan the content of the canvas around, but as soon as you move the mouse outside of the canvas the shapes jump straight back to where they were before the panning started.
Now i experimented a bit with other gfx programs, most of them stop panning the panned object as soon as the mouse pointer leaves the canvas. If you then release the mousebutton the object just stays where it was when the panning stopped. It seems to me this is fairly intuitive behaviour.
I am looking at producing a patch for this, it is not that trivial. For example mouse entered and mouse exited events are not always delivered (seems to depend just how quick you hover the mouse over edge).
Any comments before i proceed with this?
Regards Jorg
Index: AbstractPanInteractor.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/swing/gvt/AbstractPanInteractor.java,v retrieving revision 1.5 diff -u -r1.5 AbstractPanInteractor.java --- AbstractPanInteractor.java 18 Aug 2004 07:15:32 -0000 1.5 +++ AbstractPanInteractor.java 3 Mar 2005 00:12:16 -0000 @@ -67,6 +67,11 @@ protected Cursor previousCursor; /** + * Track whether we're inside the component. + */ + private boolean insideComponent = true; + + /** * Tells whether the interactor has finished. */ public boolean endInteraction() { @@ -85,7 +90,8 @@ } finished = false; - + insideComponent = true; + xStart = e.getX(); yStart = e.getY(); @@ -99,15 +105,14 @@ * Invoked when a mouse button has been released on a component. */ public void mouseReleased(MouseEvent e) { - if (finished) { - return; - } finished = true; JGVTComponent c = (JGVTComponent)e.getSource(); - xCurrent = e.getX(); - yCurrent = e.getY(); + if (insideComponent){ + xCurrent = e.getX(); + yCurrent = e.getY(); + } AffineTransform at = AffineTransform.getTranslateInstance(xCurrent - xStart, @@ -126,13 +131,14 @@ * Invoked when the mouse exits a component. */ public void mouseExited(MouseEvent e) { - finished = true; - - JGVTComponent c = (JGVTComponent)e.getSource(); - c.setPaintingTransform(null); - if (c.getCursor() == PAN_CURSOR) { - c.setCursor(previousCursor); - } + insideComponent=false; + } + + /** + * Invoked when the mouse enters a component. + */ + public void mouseEntered(MouseEvent e) { + insideComponent=true; } // MouseMotionListener ///////////////////////////////////////////////// @@ -147,8 +153,10 @@ public void mouseDragged(MouseEvent e) { JGVTComponent c = (JGVTComponent)e.getSource(); - xCurrent = e.getX(); - yCurrent = e.getY(); + if (insideComponent){ + xCurrent = e.getX(); + yCurrent = e.getY(); + } AffineTransform at = AffineTransform.getTranslateInstance(xCurrent - xStart,
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]