org.apache.batik.swing

Class JSVGCanvas

public class JSVGCanvas extends JSVGComponent

This class represents a general-purpose swing SVG component. The JSVGCanvas does not provided additional functionalities compared to the JSVGComponent but simply provides an API conformed to the JavaBean specification. The only major change between the JSVGComponent and this component is that interactors and text selection are activated by default.
Nested Class Summary
classJSVGCanvas.AffineAction
A swing action to append an affine transform to the current rendering transform.
protected classJSVGCanvas.CanvasSVGListener
To hide the listener methods.
protected classJSVGCanvas.CanvasUserAgent
The CanvasUserAgent only adds tooltips to the behavior of the default BridgeUserAgent.
protected classJSVGCanvas.LocationListener
Helper class.
classJSVGCanvas.ResetTransformAction
A swing action to reset the rendering transform of the canvas.
classJSVGCanvas.RotateAction
A swing action to Rotate the canvas.
classJSVGCanvas.ScrollAction
A swing action to Pan/scroll the canvas.
classJSVGCanvas.ScrollDownAction
A swing action to scroll the canvas down, by a fixed amount
classJSVGCanvas.ScrollLeftAction
A swing action to scroll the canvas to the left, by a fixed amount
classJSVGCanvas.ScrollRightAction
A swing action to scroll the canvas to the right, by a fixed amount
classJSVGCanvas.ScrollUpAction
A swing action to scroll the canvas up, by a fixed amount
protected classJSVGCanvas.ToolTipModifier
Sets a specific tooltip on the JSVGCanvas when a given event occurs.
protected classJSVGCanvas.ToolTipRunnable
classJSVGCanvas.ZoomAction
A swing action to apply a zoom factor to the canvas.
classJSVGCanvas.ZoomInAction
A swing action to zoom in the canvas.
classJSVGCanvas.ZoomOutAction
A swing action to zoom out the canvas.
Field Summary
static StringFAST_SCROLL_DOWN_ACTION
The key for the Action to quickly scroll down.
static StringFAST_SCROLL_LEFT_ACTION
The key for the Action to quickly scroll left.
static StringFAST_SCROLL_RIGHT_ACTION
The key for the Action to quickly scroll right.
static StringFAST_SCROLL_UP_ACTION
The key for the Action to quickly scroll up.
protected InteractorimageZoomInteractor
An interactor to perform a realtime zoom.
protected EventTargetlastTarget
protected EventTargetlastToolTipEventTarget
The target for which the last tool tip event was fired.
protected longlastToolTipEventTimeStamp
The time of the last tool tip event.
protected JSVGCanvas.LocationListenerlocationListener
Keeps track of the last known mouse position over the canvas.
protected static ObjectMAP_TOKEN
This is used as the value in the toolTipDocs WeakHashMap.
protected InteractorpanInteractor
An interactor to perform a translation.
protected PropertyChangeSupportpcs
The PropertyChangeSupport used to fire PropertyChangeEvent.
protected InteractorresetTransformInteractor
An interactor to reset the rendering transform.
protected InteractorrotateInteractor
An interactor to perform a rotation.
static StringRESET_TRANSFORM_ACTION
The key for the Action to reset the transform.
static StringSCROLL_DOWN_ACTION
The key for the Action to scroll down.
static StringSCROLL_LEFT_ACTION
The key for the Action to scroll left.
static StringSCROLL_RIGHT_ACTION
The key for the Action to scroll right.
static StringSCROLL_UP_ACTION
The key for the Action to scroll up.
protected MaptoolTipDocs
protected EventListenertoolTipListener
protected MaptoolTipMap
Mapping of elements to listeners so they can be removed, if the tooltip is removed.
protected Stringuri
The URI of the current document being displayed.
protected InteractorzoomInteractor
An interactor to perform a zoom.
static StringZOOM_IN_ACTION
The key for the Action to zoom in.
static StringZOOM_OUT_ACTION
The key for the Action to zoom out.
Constructor Summary
JSVGCanvas()
Creates a new JSVGCanvas.
JSVGCanvas(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText)
Creates a new JSVGCanvas.
Method Summary
voidaddPropertyChangeListener(PropertyChangeListener pcl)
Adds the specified PropertyChangeListener.
voidaddPropertyChangeListener(String propertyName, PropertyChangeListener pcl)
Adds the specified PropertyChangeListener for the specified property.
protected ListenercreateListener()
Creates an instance of Listener.
protected UserAgentcreateUserAgent()
Creates a UserAgent.
booleangetEnableImageZoomInteractor()
Returns true if the image zoom interactor is enabled, false otherwise.
booleangetEnablePanInteractor()
Returns true if the pan interactor is enabled, false otherwise.
booleangetEnableResetTransformInteractor()
Returns true if the reset transform interactor is enabled, false otherwise.
booleangetEnableRotateInteractor()
Returns true if the rotate interactor is enabled, false otherwise.
booleangetEnableZoomInteractor()
Returns true if the zoom interactor is enabled, false otherwise.
StringgetURI()
Returns the URI of the current document.
protected voidinstallActions()
Builds the ActionMap of this canvas with a set of predefined Actions.
protected voidinstallKeyboardActions()
Builds the InputMap of this canvas with a set of predefined Actions.
protected voidinstallSVGDocument(SVGDocument doc)
booleanmatchLastToolTipEvent(long t, EventTarget et)
Checks if the specified event time and element are the same as the last tool tip event.
voidremovePropertyChangeListener(PropertyChangeListener pcl)
Removes the specified PropertyChangeListener.
voidremovePropertyChangeListener(String propertyName, PropertyChangeListener pcl)
Removes the specified PropertyChangeListener for the specified property.
voidsetDisableInteractions(boolean b)
voidsetEnableImageZoomInteractor(boolean b)
Determines whether the image zoom interactor is enabled or not.
voidsetEnablePanInteractor(boolean b)
Determines whether the pan interactor is enabled or not.
voidsetEnableResetTransformInteractor(boolean b)
Determines whether the reset transform interactor is enabled or not.
voidsetEnableRotateInteractor(boolean b)
Determines whether the rotate interactor is enabled or not.
voidsetEnableZoomInteractor(boolean b)
Determines whether the zoom interactor is enabled or not.
voidsetLastToolTipEvent(long t, EventTarget et)
Sets the time and element of the last tool tip event handled.
voidsetURI(String newURI)
Sets the URI to the specified uri.

Field Detail

FAST_SCROLL_DOWN_ACTION

public static final String FAST_SCROLL_DOWN_ACTION
The key for the Action to quickly scroll down.

FAST_SCROLL_LEFT_ACTION

public static final String FAST_SCROLL_LEFT_ACTION
The key for the Action to quickly scroll left.

FAST_SCROLL_RIGHT_ACTION

public static final String FAST_SCROLL_RIGHT_ACTION
The key for the Action to quickly scroll right.

FAST_SCROLL_UP_ACTION

public static final String FAST_SCROLL_UP_ACTION
The key for the Action to quickly scroll up.

imageZoomInteractor

protected Interactor imageZoomInteractor
An interactor to perform a realtime zoom.

Binding: BUTTON3 + SHIFT Key

lastTarget

protected EventTarget lastTarget

lastToolTipEventTarget

protected EventTarget lastToolTipEventTarget
The target for which the last tool tip event was fired.

lastToolTipEventTimeStamp

protected long lastToolTipEventTimeStamp
The time of the last tool tip event.

locationListener

protected JSVGCanvas.LocationListener locationListener
Keeps track of the last known mouse position over the canvas. This is used for displaying tooltips at the right location.

MAP_TOKEN

protected static final Object MAP_TOKEN
This is used as the value in the toolTipDocs WeakHashMap. This way we can tell if a document has already been added.

panInteractor

protected Interactor panInteractor
An interactor to perform a translation.

Binding: BUTTON1 + SHIFT Key

pcs

protected PropertyChangeSupport pcs
The PropertyChangeSupport used to fire PropertyChangeEvent.

resetTransformInteractor

protected Interactor resetTransformInteractor
An interactor to reset the rendering transform.

Binding: CTRL+SHIFT+BUTTON3

rotateInteractor

protected Interactor rotateInteractor
An interactor to perform a rotation.

Binding: BUTTON3 + CTRL Key

RESET_TRANSFORM_ACTION

public static final String RESET_TRANSFORM_ACTION
The key for the Action to reset the transform.

SCROLL_DOWN_ACTION

public static final String SCROLL_DOWN_ACTION
The key for the Action to scroll down.

SCROLL_LEFT_ACTION

public static final String SCROLL_LEFT_ACTION
The key for the Action to scroll left.

SCROLL_RIGHT_ACTION

public static final String SCROLL_RIGHT_ACTION
The key for the Action to scroll right.

SCROLL_UP_ACTION

public static final String SCROLL_UP_ACTION
The key for the Action to scroll up.

toolTipDocs

protected Map toolTipDocs

toolTipListener

protected EventListener toolTipListener

toolTipMap

protected Map toolTipMap
Mapping of elements to listeners so they can be removed, if the tooltip is removed.

uri

protected String uri
The URI of the current document being displayed.

zoomInteractor

protected Interactor zoomInteractor
An interactor to perform a zoom.

Binding: BUTTON1 + CTRL Key

ZOOM_IN_ACTION

public static final String ZOOM_IN_ACTION
The key for the Action to zoom in.

ZOOM_OUT_ACTION

public static final String ZOOM_OUT_ACTION
The key for the Action to zoom out.

Constructor Detail

JSVGCanvas

public JSVGCanvas()
Creates a new JSVGCanvas.

JSVGCanvas

public JSVGCanvas(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText)
Creates a new JSVGCanvas.

Parameters: ua a SVGUserAgent instance or null. eventsEnabled Whether the GVT tree should be reactive to mouse and key events. selectableText Whether the text should be selectable.

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Adds the specified PropertyChangeListener.

Parameters: pcl the property change listener to add

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName, PropertyChangeListener pcl)
Adds the specified PropertyChangeListener for the specified property.

Parameters: propertyName the name of the property to listen on pcl the property change listener to add

createListener

protected Listener createListener()
Creates an instance of Listener.

createUserAgent

protected UserAgent createUserAgent()
Creates a UserAgent.

getEnableImageZoomInteractor

public boolean getEnableImageZoomInteractor()
Returns true if the image zoom interactor is enabled, false otherwise.

getEnablePanInteractor

public boolean getEnablePanInteractor()
Returns true if the pan interactor is enabled, false otherwise.

getEnableResetTransformInteractor

public boolean getEnableResetTransformInteractor()
Returns true if the reset transform interactor is enabled, false otherwise.

getEnableRotateInteractor

public boolean getEnableRotateInteractor()
Returns true if the rotate interactor is enabled, false otherwise.

getEnableZoomInteractor

public boolean getEnableZoomInteractor()
Returns true if the zoom interactor is enabled, false otherwise.

getURI

public String getURI()
Returns the URI of the current document.

installActions

protected void installActions()
Builds the ActionMap of this canvas with a set of predefined Actions.

installKeyboardActions

protected void installKeyboardActions()
Builds the InputMap of this canvas with a set of predefined Actions.

installSVGDocument

protected void installSVGDocument(SVGDocument doc)

matchLastToolTipEvent

public boolean matchLastToolTipEvent(long t, EventTarget et)
Checks if the specified event time and element are the same as the last tool tip event.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Removes the specified PropertyChangeListener.

Parameters: pcl the property change listener to remove

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName, PropertyChangeListener pcl)
Removes the specified PropertyChangeListener for the specified property.

Parameters: propertyName the name of the property that was listened on pcl the property change listener to remove

setDisableInteractions

public void setDisableInteractions(boolean b)

setEnableImageZoomInteractor

public void setEnableImageZoomInteractor(boolean b)
Determines whether the image zoom interactor is enabled or not.

setEnablePanInteractor

public void setEnablePanInteractor(boolean b)
Determines whether the pan interactor is enabled or not.

setEnableResetTransformInteractor

public void setEnableResetTransformInteractor(boolean b)
Determines whether the reset transform interactor is enabled or not.

setEnableRotateInteractor

public void setEnableRotateInteractor(boolean b)
Determines whether the rotate interactor is enabled or not.

setEnableZoomInteractor

public void setEnableZoomInteractor(boolean b)
Determines whether the zoom interactor is enabled or not.

setLastToolTipEvent

public void setLastToolTipEvent(long t, EventTarget et)
Sets the time and element of the last tool tip event handled.

setURI

public void setURI(String newURI)
Sets the URI to the specified uri. If the input 'newURI' string is null, then the canvas will display an empty document.

Parameters: newURI the new uri of the document to display

Copyright B) 2008 Apache Software Foundation. All Rights Reserved.