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 William Huang <sh...@xperient.net> on 2003/01/12 17:30:38 UTC

How can I implement Scrollbar functionality with Batik?

Dear Thomas,

I tried to implement Scrolling functionality with multiple JSVGCanvas components in a window. But I have the following problems:

1. The scrolling is slow even for small to medium size SVG file. When I scroll, the SVG display distorted and took noticeable delay to stabilize.

2. And for the scrolling to work, I need to know information about the actual SVG size and display scrollbar if the SVG size is larger than the current window size instead of enlarging the current window or zooming the SVG display. That is, I need is to display the part that can be accommodated in the designated window area and a scrollbar if necessary. The current Java scrollpane implementation only shows scrollbar when I resize the window to a smaller size. 

Batik does differently for directly loaded file and loaded file as linked image. The directly loaded file will be clipped if it does not cause the window to resize to its size (Specify width=100% and height=100% but do not specify the viewBox attribute). For loaded file as linked image, when I load another SVG file with width="10.278in", height="9.167in" using image tag to an area of the currently displayed SVG file, and specify size (800,600) for the image node, then I get 800 when I call getWidth of this image node. It seems that the image is not clipped although the image only show partly since I can use mouse events to see other parts that are not initially displayed in that area (offscreen image is not clipped?). Could you tell me how I get the correct image information so that the scrollbar will be displayed when necessary? 

For the Javascript approach, I also have questions. From the mailing list, I know currentScale, onzoom and currentTranslate are on the to do list of Batik. Does onscroll work already? If I can resolve the no.2 question, maybe the only one I need to extend is onscroll event processing since I can use mousedown and mouseup event together with onscroll to implement scrolling. Onzoom is not of my interest. Since my implementation will include several scrollbars in a window instead of just for the root element, Adobe currentScale of root element is also not of my interest. Could you give me some advice on how to implement onscoll? Thank you very much.

Have a good weekend.

With best regards,
William