org.apache.batik.swing

Class JSVGScrollPane

public class JSVGScrollPane extends JPanel

A Swing component that consists of a JSVGCanvas with optional scroll bars.

Reimplementation, rather than imlementing the Scrollable interface, provides several advantages. The main advantage is the ability to control more precisely ScrollBar events; fewer JSVGCanvas updates are required when scrolling. This creates a significant performance (reflected by an increase in scroll speed) advantage compared to implementing the Scrollable interface.

Nested Class Summary
protected classJSVGScrollPane.SBListener
Advanced JScrollBar listener.
protected classJSVGScrollPane.ScrollListener
Handle scroll, zoom, and resize events
Field Summary
protected JSVGCanvascanvas
protected ComponentcornerBox
protected JScrollBarhorizontal
protected JPanelhorizontalPanel
protected JSVGScrollPane.SBListenerhsbListener
protected booleanignoreScrollChange
protected booleanscrollbarsAlwaysVisible
protected JScrollBarvertical
protected Rectangle2DviewBox
protected JSVGScrollPane.SBListenervsbListener
Constructor Summary
JSVGScrollPane(JSVGCanvas canvas)
Creates a JSVGScrollPane, which will scroll an JSVGCanvas.
Method Summary
protected voidcheckAndSetViewBoxRect()
Derives the SVG Viewbox from the SVG root element.
protected SVGDocumentLoaderListenercreateLoadListener()
Factory method so subclasses can override the default load listener.
protected JSVGScrollPane.SBListenercreateScrollBarListener(boolean isVertical)
Scrollbar listener factory method so subclasses can override the default SBListener behaviour.
protected JSVGScrollPane.ScrollListenercreateScrollListener()
Factory method so subclasses can override the default listener behaviour
JSVGCanvasgetCanvas()
booleangetScrollbarsAlwaysVisible()
protected Rectangle2DgetViewBoxRect()
voidreset()
Resets this object (for reloads), releasing any cached data and recomputing scroll extents.
protected voidresizeScrollBars()
Compute the scrollbar extents, and determine if scrollbars should be visible.
voidscaleChange(float scale)
Called when the scale size changes.
voidsetScrollbarsAlwaysVisible(boolean vis)
protected voidsetScrollPosition()
Sets the translation portion of the transform based upon the current scroll bar position
protected voidupdateScrollbarState(boolean hNeeded, boolean vNeeded)
protected DimensionupdateScrollbarVisibility(int tx, int ty, int maxW, int maxH)

Field Detail

canvas

protected JSVGCanvas canvas

cornerBox

protected Component cornerBox

horizontal

protected JScrollBar horizontal

horizontalPanel

protected JPanel horizontalPanel

hsbListener

protected JSVGScrollPane.SBListener hsbListener

ignoreScrollChange

protected boolean ignoreScrollChange

scrollbarsAlwaysVisible

protected boolean scrollbarsAlwaysVisible

vertical

protected JScrollBar vertical

viewBox

protected Rectangle2D viewBox

vsbListener

protected JSVGScrollPane.SBListener vsbListener

Constructor Detail

JSVGScrollPane

public JSVGScrollPane(JSVGCanvas canvas)
Creates a JSVGScrollPane, which will scroll an JSVGCanvas.

Method Detail

checkAndSetViewBoxRect

protected void checkAndSetViewBoxRect()
Derives the SVG Viewbox from the SVG root element. Caches it. Assumes that it will not change.

createLoadListener

protected SVGDocumentLoaderListener createLoadListener()
Factory method so subclasses can override the default load listener.

createScrollBarListener

protected JSVGScrollPane.SBListener createScrollBarListener(boolean isVertical)
Scrollbar listener factory method so subclasses can override the default SBListener behaviour.

createScrollListener

protected JSVGScrollPane.ScrollListener createScrollListener()
Factory method so subclasses can override the default listener behaviour

getCanvas

public JSVGCanvas getCanvas()

getScrollbarsAlwaysVisible

public boolean getScrollbarsAlwaysVisible()

getViewBoxRect

protected Rectangle2D getViewBoxRect()

reset

public void reset()
Resets this object (for reloads), releasing any cached data and recomputing scroll extents.

resizeScrollBars

protected void resizeScrollBars()
Compute the scrollbar extents, and determine if scrollbars should be visible.

scaleChange

public void scaleChange(float scale)
Called when the scale size changes. The scale factor (1.0 == original size). By default, this method does nothing, but may be overidden to display a scale (zoom) factor in a status bar, for example.

setScrollbarsAlwaysVisible

public void setScrollbarsAlwaysVisible(boolean vis)

setScrollPosition

protected void setScrollPosition()
Sets the translation portion of the transform based upon the current scroll bar position

updateScrollbarState

protected void updateScrollbarState(boolean hNeeded, boolean vNeeded)

updateScrollbarVisibility

protected Dimension updateScrollbarVisibility(int tx, int ty, int maxW, int maxH)
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.