My solution are:
extending JSVGCanvas
implementing Scrollable interface
// ---------------- methods concerning Scrollable interface
------------------------------
/**
* @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;
}
it is necessary to do the next to retrieve an swing component wich fits perfect in a
scrollpane
/**
* this method will be called from constructor of JGVTComponent
*/
protected Listener createListener() {
return new ScrollableCanvasSVGListener();
}
/**
* This method avoid the problem, that the original methode in
CanvasSVGListener
* use pack() methode to rearrange the Swing componentes
*/
protected class ScrollableCanvasSVGListener extends CanvasSVGListener {
public void setMySize(Dimension d) {
setPreferredSize(d);
invalidate();
Container p = getParent();
while (p != null) {
if (p instanceof Window) {
Window w = (Window) p;
w.validate(); // im Orignial wurde hier pack() aufgerufen
break;
}
p = p.getParent();
}
}
}
In my application that works fine, but my batik package is a little bit outdated (3
month not updated from cvs).
Jan
-----Urspr�ngliche Nachricht-----
Von: Daniel Noll [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 8. Juli 2003 01:16
An: Batik Users
Betreff: JSVGCanvas inside JScrollPane
Hi.
Our application displays a potentially large SVG inside a scroll window,
to give a more
consistent method for the user to pan the image.
After calling setURI on the JSVGCanvas, and setting the canvas to be the
view for
the JScrollPane, the scrollbars do not appear. The image does pan,
using the arrow
keys, but I'm not sure if this is Batik or Swing doing the scrolling.
On resizing the window, the scrollbars do appear again, but I get an
OufOfMemoryError
after about a second of it trying to redraw. (Best guess without
further knowledge is it's
trying to render the entire SVG to a bitmap and runing out of memory
trying to store the
image in memory.)
Daniel
---------------------------------------------------------------------
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]