You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Maik Schürer <Ma...@proveo.de> on 2004/12/01 10:25:07 UTC

how to catch resize events in JSVGCanvas via shift + right mouse key

Hi there,
up to now I catch resize events in JSVGCanvas with a ComponentListener.
But it only works when the canvas (window) changes its size ....
Additional I want to catch events, when I change my SVG view via shift +
right mouse key + move (fast zoom in/out).
Ho can I do this ?
Thanks
Maik


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: mouse actions in JSVGCanvas changeable or deactivate ?

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Maik,

Maik Schürer wrote:

> 1) ist it possible to change e.g. the grop/zoom mouse action in JSVGCanvas
> from "Ctrl+left" mouse to "left mouse" ?
> 2) ist it possible to deactivate e.g. the rotate mouse action in JSVGCanvas
> ("Ctrl+right" mouse)

    These are all provided by the JSVGCanvas.  The JSVGCanvas is
a "light weight" subclass of JSVGComponent that simply tries to
provide some basic interaction.  It does two major things.

1) It provides all the interactors for pan, zoom, rotate.
2) It provides tool-tip support.

    You have two routes you could go here.

	1) subclass JSVGCanvas and use the setEnable...Interactor
to turn off the interactors you didn't like, and just install your
own.
	2) subclass JSVGComponent and provide your own interactors
keybindings etc.  While there is a fair bit of code in JSVGCanvas
it is all pretty simple interface stuff.



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: mouse actions in JSVGCanvas changeable or deactivate ?

Posted by Archie Cobbs <ar...@dellroad.org>.
Maik Schürer wrote:
> 1) ist it possible to change e.g. the grop/zoom mouse action in JSVGCanvas
> from "Ctrl+left" mouse to "left mouse" ?
> 2) ist it possible to deactivate e.g. the rotate mouse action in JSVGCanvas
> ("Ctrl+right" mouse)

Here's what we do (abridged for clarity :-). We just want pan and zoom,
using button1 and shift-button1, respectively...

         // Disable default interactors
         svgCanvas.setEnableImageZoomInteractor(false);
         svgCanvas.setEnablePanInteractor(false);
         svgCanvas.setEnableResetTransformInteractor(false);
         svgCanvas.setEnableRotateInteractor(false);
         svgCanvas.setEnableZoomInteractor(false);

         // Add my pan and zoom interactors
         svgCanvas.getInteractors().add(new PanInteractor());
         svgCanvas.getInteractors().add(new ZoomInteractor());

...

     class PanInteractor extends AbstractPanInteractor {
         public boolean startInteraction(InputEvent ie) {
             if (!(ie instanceof MouseEvent))
                 return false;
             MouseEvent me = (MouseEvent)ie;
             return me.getID() == MouseEvent.MOUSE_PRESSED
               && (me.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) == 0
               && me.getButton() == MouseEvent.BUTTON1;
         }
     }

Our custom ZoomInteractor is similar.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


mouse actions in JSVGCanvas changeable or deactivate ?

Posted by Maik Schürer <Ma...@proveo.de>.
1) ist it possible to change e.g. the grop/zoom mouse action in JSVGCanvas
from "Ctrl+left" mouse to "left mouse" ?
2) ist it possible to deactivate e.g. the rotate mouse action in JSVGCanvas
("Ctrl+right" mouse)
Maik


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: how to catch resize events in JSVGCanvas via shift + right mouse key

Posted by Thomas DeWeese <Th...@Kodak.com>.
Maik Schürer wrote:

> Thanks Kai and Thomas,
> t.addEventListener("SVGZoom", new OnZoomAction(), false);
> and
> JGVTComponentListener.componentTransformChanged()
> both works fine for me
> but I would prefer EventListener "SVGZoom" because JGVTComponentListener ist
> also raised after pan and rotate.
> Or should I use JGVTComponentListener ? (because of performance or other
> reasons)

    I would choose based on what I was trying to do.  If I was
doing 'swing' things I would use the Component Listener (since
it is called in the Swing thread), if it was DOM things I would
use the DOM method since it is called in the UpdateManager Thread.
If it really didn't matter then I would probably use the DOM
because as I said they are standard and hence much less likely
to change.

   As to performance they will be similar.  You can filter the
changes by using the code from JSVGComponent.JSVGComponentListener
which is what dispatches the DOM zoom event.

>  Maik
> 
> ----- Original Message ----- 
> From: "Thomas DeWeese" <Th...@Kodak.com>
> To: "Batik Users" <ba...@xml.apache.org>
> Sent: Wednesday, December 01, 2004 11:50 AM
> Subject: Re: how to catch resize events in JSVGCanvas via shift + right
> mouse key
> 
> 
> Hi Maik,
> 
> Maik Schürer wrote:
> 
> 
>>up to now I catch resize events in JSVGCanvas with a ComponentListener.
>>But it only works when the canvas (window) changes its size ....
> 
> 
>     Meves, gave a good answer to this using the DOM, which is
> definitely the preferred solution as the DOM interfaces are standard).
> There also exists an extension to the ComponentListener interface
> called the JGVTComponentListener which adds componentTransformChanged
> which is what the zoom event it built off of internally.
> 
> 
>>Additional I want to catch events, when I change my SVG view via shift +
>>right mouse key + move (fast zoom in/out).
>>Ho can I do this ?
> 
> 
>     There is no public interface for this.  The only solution would
> be to subclass either the canvas so you get events when the 'paint
> transform' changes as well, or the AbstractImageZoomInteractor so it
> notifies you or does the work directly.
> 
>     Incidentally this indicates why the DOM is preferred.  Now that
> you mention this I'm tempted to add either a new method to the
> JGVTComponentListener to track paint changes or perhaps a new
> event type (COMPONENT_PAINT_TRANSFORM_CHANGED).  Which could break
> existing code (or at least cause the code to be called much more
> than expected).
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: how to catch resize events in JSVGCanvas via shift + right mouse key

Posted by Maik Schürer <Ma...@proveo.de>.
Thanks Kai and Thomas,
t.addEventListener("SVGZoom", new OnZoomAction(), false);
and
JGVTComponentListener.componentTransformChanged()
both works fine for me
but I would prefer EventListener "SVGZoom" because JGVTComponentListener ist
also raised after pan and rotate.
Or should I use JGVTComponentListener ? (because of performance or other
reasons)
 Maik

----- Original Message ----- 
From: "Thomas DeWeese" <Th...@Kodak.com>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Wednesday, December 01, 2004 11:50 AM
Subject: Re: how to catch resize events in JSVGCanvas via shift + right
mouse key


Hi Maik,

Maik Schürer wrote:

> up to now I catch resize events in JSVGCanvas with a ComponentListener.
> But it only works when the canvas (window) changes its size ....

    Meves, gave a good answer to this using the DOM, which is
definitely the preferred solution as the DOM interfaces are standard).
There also exists an extension to the ComponentListener interface
called the JGVTComponentListener which adds componentTransformChanged
which is what the zoom event it built off of internally.

> Additional I want to catch events, when I change my SVG view via shift +
> right mouse key + move (fast zoom in/out).
> Ho can I do this ?

    There is no public interface for this.  The only solution would
be to subclass either the canvas so you get events when the 'paint
transform' changes as well, or the AbstractImageZoomInteractor so it
notifies you or does the work directly.

    Incidentally this indicates why the DOM is preferred.  Now that
you mention this I'm tempted to add either a new method to the
JGVTComponentListener to track paint changes or perhaps a new
event type (COMPONENT_PAINT_TRANSFORM_CHANGED).  Which could break
existing code (or at least cause the code to be called much more
than expected).


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: how to catch resize events in JSVGCanvas via shift + right mouse key

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Maik,

Maik Schürer wrote:

> up to now I catch resize events in JSVGCanvas with a ComponentListener.
> But it only works when the canvas (window) changes its size ....

    Meves, gave a good answer to this using the DOM, which is
definitely the preferred solution as the DOM interfaces are standard).
There also exists an extension to the ComponentListener interface
called the JGVTComponentListener which adds componentTransformChanged
which is what the zoom event it built off of internally.

> Additional I want to catch events, when I change my SVG view via shift +
> right mouse key + move (fast zoom in/out).
> Ho can I do this ?

    There is no public interface for this.  The only solution would
be to subclass either the canvas so you get events when the 'paint
transform' changes as well, or the AbstractImageZoomInteractor so it
notifies you or does the work directly.

    Incidentally this indicates why the DOM is preferred.  Now that
you mention this I'm tempted to add either a new method to the
JGVTComponentListener to track paint changes or perhaps a new
event type (COMPONENT_PAINT_TRANSFORM_CHANGED).  Which could break
existing code (or at least cause the code to be called much more
than expected).


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org