Hello,

As I wasn't really satisfied of JSVGCanvas scrolling I decide dto
implement my own.
The principle is that the scroll is constantly a fraction of the
displayed areaeither in the X or Y direction.
I've also implemented it as an inner class of my subclass of JSVGCanvas
called MapView
(I'm working on maps that why the name of the classes).
The corresponding code is given below.
To use it I've just to do the following in MapView instance:

getActionMap().put(SCROLL_RIGHT_ACTION, new MapScrollAction( -1, 0));
getActionMap().put(SCROLL_LEFT_ACTION, new MapScrollAction( 1, 0));
getActionMap().put(SCROLL_UP_ACTION, new MapScrollAction( 0, 1));
getActionMap().put(SCROLL_DOWN_ACTION, new MapScrollAction( 0, -1));

That's all.
Thought it could be of some help. I find this kind of scrolling more
practical in the user point of view.

Gerard


  public class MapScrollAction extends AbstractAction {
    protected int _xFactor;

    protected int _yFactor;


    /**
     * Default constructor
     *
     * @param a_XFactor
     * @param a_YFactor
     */
    public MapScrollAction() {
      super();
    }

    /**
     * Useable constructor
     *
     * @param a_XFactor
     * @param a_YFactor
     */
    public MapScrollAction ( int a_XFactor, int a_YFactor) {
     this();
      _xFactor = a_XFactor;
      _yFactor = a_YFactor;
    }

    /**
     * default Action
     *
     * @param evt
     */
    public void actionPerformed ( ActionEvent evt) {
      if (gvtRoot == null) {
        return;
      }
      int incX = (getWidth()/4)*_xFactor;
      int incY = (getHeight()/4)*_yFactor;;
      AffineTransform at = new AffineTransform(getRenderingTransform());

      double dx = at.getTranslateX() + incX;
      double dy = at.getTranslateY() + incY;
      double sx = at.getScaleX();
      double sy = at.getScaleY();
      at = new AffineTransform( sx, 0.0, 0.0, sy, dx, dy);
      setRenderingTransform(at);
    }
  } /* End of class: MapScrollAction */


--
[EMAIL PROTECTED] - Atlantide - http://www.ago.fr/atlantide/
Technopole Brest Iroise BP 80802 - 29608 Brest cedex - France -
Tel. : +33 (0)2 98 05 43 21 - Fax. : +33 (0)2 98 05 20 34 - e-mail:
[EMAIL PROTECTED]
Centre Affaires Oberthur - 74D, rue de Paris -  35700 Rennes - France
Tel. : +33 (0)2 99 84 15 84 - Fax : +33 (0)2 99 84 15 85 - e-mail:
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to