I have solved these problem.
At first overwrite JSVGCanvas.
2. implement Scrollable: here my implementation...

    /**
     * @see javax.swing.Scrollable#getPreferredScrollableViewportSize()
     */
    public Dimension getPreferredScrollableViewportSize() {
        return getPreferredSize();
    }

    /**
     * @see javax.swing.Scrollable#getScrollableUnitIncrement(java.awt.Rectangle, int, 
int)
     */
    public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int 
direction) {
        return 10;
    }

    /**
     * @see javax.swing.Scrollable#getScrollableBlockIncrement(java.awt.Rectangle, 
int, int)
     */
    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int 
direction) {
        return 10;
    }

    /**
     * Methode return true if component do not need vertical scrollbar-support 
     *         and         false if vertical scrollbar are needed if component
     * bigger than viewport
     */
    public boolean getScrollableTracksViewportWidth() {
        return false;
    }

    /**
     * Methode return true if component do not need horizontal scrollbar-support
     */
    public boolean getScrollableTracksViewportHeight() {
        return false;
    }

3. be awareabout the viewport has no BorderLayout-Manager !

here is a code snippet:
I added my own JSVGCanvas in a splitpane at left and on the right side my own DOM-view.

        public MyFrame() {
        ....
        editorScrollPane.getViewport().add(canvas); // editorScrollPane carried my 
canvas class
          getContentPane().add(toolBarPanel, BorderLayout.NORTH);
          getContentPane().add(splitpane,BorderLayout.CENTER);
        getContentPane().add(statusBar,BorderLayout.SOUTH);
        splitpane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        splitpane.add(editorScrollPane, JSplitPane.LEFT);
        domPanel = new DOMPanel(this);
        splitpane.add(domPanel, JSplitPane.RIGHT);
        ....
        pack();
      }

Jan

-----Ursprungliche Nachricht-----
Von: Gerard BUNEL [mailto:[EMAIL PROTECTED]]
Gesendet: Donnerstag, 20. Februar 2003 14:42
An: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Betreff: smoother JSVGCanvas


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]

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

Reply via email to