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 Marios Depountis <de...@yahoo.com> on 2003/07/08 06:27:20 UTC

Re: JSVGCanvas ZoomIn Action problem.

Thank you very much your advice was very helpful.But what I have not managed to do yet is how can I ovewrite the AbstractZoomInteractor in order to add the functionality of zoom in a particular button or menuItem(for example a jbutton of my application). Is there any way that I can an action event instead of an input event in the class that extends AbstractZoomInteractor? Should I overwrite the startInteraction( InputEvent ie ) method or just define it
 
Thank you in advance
Marios
 
 
>By default, the zoom Interactor is bound to Ctrl-Mouse Button 1.

>You can turn this on and off with the call
>JSVGCanvas.setEnableZoomInteractor(boolean b)

>If you want to write your own, take a look at the way
>org.apache.batik.swing.gvt.AbstractZoomInteractor is invoked in the
>JSVGCanvas,

>Basically you need to provide a Interactor class that extends the
>AbstractZoomInteractor, define the
>startInteraction( InputEvent ie ) method, and add an instance of it to the
>canvas

>JSVGCanvas.getInteractors.add( < new Instance > );

>Anything fancier than the default interactor can be created by either
>writing your own interactor or extending the AbstractZoomInteractor class.

>You might want to look at both zoomInteractor and ImageZoomInteractor, one
>is a real time zoom, the other allows you to lasso an area to zoom in.

>-tomas

----- Original Message -----
From: Marios Depountis
To: batik-users@xml.apache.org
Sent: Saturday, July 05, 2003 8:14 PM
Subject: JSVGCanvas ZoomIn Action problem.


Hi,
I am trying to use the zoom in capability of JSVGCanvas but I cannot access
the protected class. Furthermore I tried to override the protected class but
still I could not make it work.
Could you please tell me how can I use the zoom capabilites of JSVGCanvas?
(If it easy send me some code) How can I access the class and how can I use
it?

Thanks in advance
Marios


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

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




---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: JSVGCanvas ZoomIn Action problem.

Posted by Thomas DeWeese <Th...@Kodak.com>.
Marios Depountis wrote:

> Hi Tomas,
>  
> First of all I want to thank for all your help. I followed exactly the 
> steps you have proposed to me but I still have not managed to make it 
> work properly. When I render the DOM object in my Canvas all the 
> capabilities of JSVGCanvas exist, so what I want to do is to add the 
> zoom functionality only when my JButton for zoom  is pressed. 

    The Interactors are ment for 'interactive' operations (like the pan 
or the 'interactive' zoom), if you want to
have a default zoom happen when the user presses a button you should use 
Actions. The JSVGCanvas
provides a good set of default actions:

    Action a = (Action)canvas.getActionMap().get(JSVGCanvas.ZOOM_IN_ACTION);

    JButton button = new JButton(a);

    What I changed is if you don't like the default action you can now 
create your own actions.

> I created the following class:The super call inside the mouseReleased 
> method cannot be compiled(Do you have any idea why this may happen?)
>
> abstract class  Zoomer extends AbstractZoomInteractor
>              
>       {
>             // end interaction defines the condition to end the zoom
>      
>                 
>          public boolean endInteraction()
>                 
>          {
>             return finished;
>          }
>      
>          // I want the zoom to end at the release of my mouse, can do 
> it anywhere else
>                 
>          public void mouseReleased( MouseEvent e )
>                 
>          {
>             //super(e);
>             finished = true;
>             System.out.println("finished"+finished);
>          }
> Then in the constructor of my class(where JSVGCanvas is defined) the 
> zoom interactor.
>  
>          zoomAInteractor =
>                       
>                new Zoomer(){        
>                       
>                   boolean finished = false;
>               
>                          
>                   public bo! olean startInteraction(InputEvent ie)
>                          
>                  
>                   {
>                      return doZoom;
>                   }};
>          svgCanvas.getInteractors().add(zoomAInteractor);
> Any time I click my JButton I make doZoom=true but when the mouse is 
> released the zoom doesn't stop. I have checked that the code never 
> access the mouseReleased method. Furthermore I cannot stop the zoom 
> after presing another button that makes the variable  doZoom=false.
>  
>  
> Have you any idea about what am I doing wrong?
>  
> Thanks a lot
> Marios
> ------------------------------------------------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL 
> <http://pa.yahoo.com/*http://rd.yahoo.com/evt=1207/*http://promo.yahoo.com/sbc/> 
> - Now only $29.95 per month! 





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


Re: JSVGCanvas ZoomIn Action problem.

Posted by Marios Depountis <de...@yahoo.com>.
Hi Tomas,
 
First of all I want to thank for all your help. I followed exactly the steps you have proposed to me but I still have not managed to make it work properly. When I render the DOM object in my Canvas all the capabilities of JSVGCanvas exist, so what I want to do is to add the zoom functionality only when my JButton for zoom  is pressed.
 
I created the following class:The super call inside the mouseReleased method cannot be compiled(Do you have any idea why this may happen?)

abstract class  Zoomer extends AbstractZoomInteractor 
              
      {
            // end interaction defines the condition to end the zoom
      
                 
         public boolean endInteraction()
                 
         {
            return finished;
         }
      
         // I want the zoom to end at the release of my mouse, can do it anywhere else
                 
         public void mouseReleased( MouseEvent e )
                 
         {
            //super(e);
            finished = true;
            System.out.println("finished"+finished);
         }

Then in the constructor of my class(where JSVGCanvas is defined) the zoom interactor.
 
         zoomAInteractor = 
                       
               new Zoomer(){         
                       
                  boolean finished = false;
               
                          
                  public boolean startInteraction(InputEvent ie)
                          
                  
                  {
                     return doZoom;
                  }};
         svgCanvas.getInteractors().add(zoomAInteractor);

Any time I click my JButton I make doZoom=true but when the mouse is released the zoom doesn't stop. I have checked that the code never access the mouseReleased method. Furthermore I cannot stop the zoom after presing another button that makes the variable  doZoom=false.
 
 
Have you any idea about what am I doing wrong?
 
Thanks a lot 
Marios


---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: JSVGCanvas ZoomIn Action problem.

Posted by tomas lin <to...@hotmail.com>.
Hey Marios,

Try something like this

1. assign JButton to action that sets and unsets

      boolean doZoom;


2. extend class

        abstract class Zoomer extends AbstractZoomInteractor(){
             ...
             ...

            // end interaction defines the condition to end the zoom
            public boolean endInteraction()
            {
                return finished;
             }

            // I want the zoom to end at the release of my mouse, but you
can do it anywhere else
             public void mouseReleased( MouseEvent e ){
                     super(e);
                     finished = true;
             }

        }

3. Create instance of zoomInteractor

      Interactor zoomInteractor = new Zoomer()
        {
            boolean finished = false;

            public boolean startInteraction(InputEvent ie)
            {
                  return doZoom;
             }
        };

4. Attach interactor
        svgCanvas.getInteractors().add( zoomInteactor );


That's what I did and it seems to work. You can probably try something else
as well.

cheers,

-tomas

----- Original Message -----
From: Marios Depountis
To: batik-users@xml.apache.org
Cc: tomaslin@hotmail.com
Sent: Tuesday, July 08, 2003 12:27 AM
Subject: Re: JSVGCanvas ZoomIn Action problem.


Thank you very much your advice was very helpful.But what I have not managed
to do yet is how can I ovewrite the AbstractZoomInteractor in order to add
the functionality of zoom in a particular button or menuItem(for example a
jbutton of my application). Is there any way that I can an action event
instead of an input event in the class that extends AbstractZoomInteractor?
Should I overwrite the startInteraction( InputEvent ie ) method or just
define it

Thank you in advance
Marios


>By default, the zoom Interactor is bound to Ctrl-Mouse Button 1.

>You can turn this on and off with the call
>JSVGCanvas.setEnableZoomInteractor(boolean b)

>If you want to write your own, take a look at the way
>org.apache.batik.swing.gvt.AbstractZoomInteractor is invoked in the
>JSVGCanvas,

>Basically you need to provide a Interactor class that extends the
>AbstractZoomInteractor, define the
>startInteraction( InputEvent ie ) method, and add an instance of it to the
>canvas

>JSVGCanvas.getInteractors.add( < new Instance > );

>Anything fancier than the default interactor can be created by either
>writing your own interactor or extending the AbstractZoomInteractor class.

>You might want to look at both zoomInteractor and ImageZoomInteractor, one
>is a real time zoom, the other allows you to lasso an area to zoom in.

>-tomas

----- Original Message -----
From: Marios Depountis
To: batik-users@xml.apache.org
Sent: Saturday, July 05, 2003 8:14 PM
Subject: JSVGCanvas ZoomIn Action problem.


Hi,
I am trying to use the zoom in capability of JSVGCanvas but I cannot access
the protected class. Furthermore I tried to override the protected class but
still I could not make it work.
Could you please tell me how can I use the zoom capabilites of JSVGCanvas?
(If it easy send me some code) How can I access the class and how can I use
it?

Thanks in advance
Marios


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

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




Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

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