org.apache.batik.swing
Class JSVGCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.apache.batik.swing.gvt.JGVTComponent
                          |
                          +--org.apache.batik.swing.svg.JSVGComponent
                                |
                                +--org.apache.batik.swing.JSVGCanvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

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.

See Also:
Serialized Form

Inner Class Summary
protected  class JSVGCanvas.CanvasSVGListener
          To hide the listener methods.
protected  class JSVGCanvas.CanvasUserAgent
          The CanvasUserAgent only adds tooltips to the behavior of the default BridgeUserAgent.
A tooltip will be displayed wheneven the mouse lingers over an element which has a <title> or a <desc> child element.
protected  class JSVGCanvas.LocationListener
          Helper class.
protected  class JSVGCanvas.ResetTransformAction
          A swing action to reset the rendering transform of the canvas.
protected  class JSVGCanvas.ScrollDownAction
          A swing action to scroll the canvas down.
protected  class JSVGCanvas.ScrollLeftAction
          A swing action to scroll the canvas to the left.
protected  class JSVGCanvas.ScrollRightAction
          A swing action to scroll the canvas to the right.
protected  class JSVGCanvas.ScrollUpAction
          A swing action to scroll the canvas up.
protected  class JSVGCanvas.ToolTipModifier
          Sets a specific tooltip on the JSVGCanvas when a given event occurs.
protected  class JSVGCanvas.ZoomInAction
          A swing action to zoom in the canvas.
protected  class JSVGCanvas.ZoomOutAction
          A swing action to zoom out the canvas.
 
Inner classes inherited from class org.apache.batik.swing.svg.JSVGComponent
JSVGComponent.BridgeUserAgent, JSVGComponent.BridgeUserAgentWrapper, JSVGComponent.SVGListener
 
Inner classes inherited from class org.apache.batik.swing.gvt.JGVTComponent
JGVTComponent.Listener
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.lang.String FAST_SCROLL_DOWN_ACTION
          The key for the Action to quickly scroll down.
static java.lang.String FAST_SCROLL_LEFT_ACTION
          The key for the Action to quickly scroll left.
static java.lang.String FAST_SCROLL_RIGHT_ACTION
          The key for the Action to quickly scroll right.
static java.lang.String FAST_SCROLL_UP_ACTION
          The key for the Action to quickly scroll up.
protected  Interactor imageZoomInteractor
          An interactor to perform a realtime zoom.
protected  JSVGCanvas.LocationListener locationListener
          Keeps track of the last known mouse position over the canvas.
protected  Interactor panInteractor
          An interactor to perform a translation.
protected  java.beans.PropertyChangeSupport pcs
          The PropertyChangeSupport used to fire PropertyChangeEvent.
static java.lang.String RESET_TRANSFORM_ACTION
          The key for the Action to reset the transform.
protected  Interactor resetTransformInteractor
          An interactor to reset the rendering transform.
protected  Interactor rotateInteractor
          An interactor to perform a rotation.
static java.lang.String SCROLL_DOWN_ACTION
          The key for the Action to scroll down.
static java.lang.String SCROLL_LEFT_ACTION
          The key for the Action to scroll left.
static java.lang.String SCROLL_RIGHT_ACTION
          The key for the Action to scroll right.
static java.lang.String SCROLL_UP_ACTION
          The key for the Action to scroll up.
protected  java.lang.String uri
          The URI of the current document being displayed.
static java.lang.String ZOOM_IN_ACTION
          The key for the Action to zoom in.
static java.lang.String ZOOM_OUT_ACTION
          The key for the Action to zoom out.
protected  Interactor zoomInteractor
          An interactor to perform a zoom.
 
Fields inherited from class org.apache.batik.swing.svg.JSVGComponent
ALWAYS_DYNAMIC, ALWAYS_STATIC, AUTODETECT, bridgeContext, documentLoader, documentState, FEATURES, fragmentIdentifier, gvtTreeBuilder, gvtTreeBuilderListeners, isDynamicDocument, linkActivationListeners, loader, nextDocumentLoader, nextGVTTreeBuilder, nextUpdateManager, svgDocument, svgDocumentLoaderListeners, svgLoadEventDispatcher, svgLoadEventDispatcherListeners, svgUserAgent, updateManager, updateManagerListeners, userAgent
 
Fields inherited from class org.apache.batik.swing.gvt.JGVTComponent
disableInteractions, doubleBufferedRendering, eventDispatcher, eventsEnabled, gvtRoot, gvtTreeRenderer, gvtTreeRendererListeners, image, initialTransform, interactor, interactors, listener, needRender, overlays, paintingTransform, progressivePaint, progressivePaintThread, renderer, rendererFactory, renderingTransform, selectableText, suspendInteractions, textSelectionManager
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JSVGCanvas()
          Creates a new JSVGCanvas.
JSVGCanvas(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText)
          Creates a new JSVGCanvas.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Adds the specified PropertyChangeListener.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
          Adds the specified PropertyChangeListener for the specified property.
protected  JGVTComponent.Listener createListener()
          Creates an instance of Listener.
protected  UserAgent createUserAgent()
          Creates a UserAgent.
 boolean getEnableImageZoomInteractor()
          Returns true if the image zoom interactor is enabled, false otherwise.
 boolean getEnablePanInteractor()
          Returns true if the pan interactor is enabled, false otherwise.
 boolean getEnableResetTransformInteractor()
          Returns true if the reset transform interactor is enabled, false otherwise.
 boolean getEnableRotateInteractor()
          Returns true if the rotate interactor is enabled, false otherwise.
 boolean getEnableZoomInteractor()
          Returns true if the zoom interactor is enabled, false otherwise.
 java.lang.String getURI()
          Returns the URI of the current document.
protected  void installActions()
          Builds the ActionMap of this canvas with a set of predefined Actions.
protected  void installKeyboardActions()
          Builds the InputMap of this canvas with a set of predefined Actions.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Removes the specified PropertyChangeListener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
          Removes the specified PropertyChangeListener for the specified property.
 void setEnableImageZoomInteractor(boolean b)
          Determines whether the image zoom interactor is enabled or not.
 void setEnablePanInteractor(boolean b)
          Determines whether the pan interactor is enabled or not.
 void setEnableResetTransformInteractor(boolean b)
          Determines whether the reset transform interactor is enabled or not.
 void setEnableRotateInteractor(boolean b)
          Determines whether the rotate interactor is enabled or not.
 void setEnableZoomInteractor(boolean b)
          Determines whether the zoom interactor is enabled or not.
 void setURI(java.lang.String newURI)
          Sets the URI to the specified uri.
 
Methods inherited from class org.apache.batik.swing.svg.JSVGComponent
addGVTTreeBuilderListener, addLinkActivationListener, addSVGDocumentLoaderListener, addSVGLoadEventDispatcherListener, addUpdateManagerListener, computeRenderingTransform, createBridgeContext, createImageRenderer, flushImageCache, getFragmentIdentifier, getSVGDocument, getSVGDocumentSize, getUpdateManager, handleException, isDynamic, loadSVGDocument, mergeRectangles, removeGVTTreeBuilderListener, removeLinkActivationListener, removeSVGDocumentLoaderListener, removeSVGLoadEventDispatcherListener, removeUpdateManagerListener, renderGVTTree, resumeProcessing, setDocumentState, setFragmentIdentifier, setSVGDocument, showAlert, showConfirm, showPrompt, showPrompt, startSVGLoadEventDispatcher, stopProcessing, suspendProcessing, updateRenderingTransform
 
Methods inherited from class org.apache.batik.swing.gvt.JGVTComponent
addGVTTreeRendererListener, deselectAll, flush, flush, getDoubleBufferedRendering, getGraphicsNode, getInitialTransform, getInteractors, getOffScreen, getOverlays, getPaintingTransform, getProgressivePaint, getRenderingTransform, getSelectionOverlayColor, getSelectionOverlayStrokeColor, immediateRepaint, initializeEventHandling, isSelectionOverlayXORMode, paintComponent, releaseRenderingReferences, removeGVTTreeRendererListener, resetRenderingTransform, scheduleGVTRendering, select, setDoubleBufferedRendering, setGraphicsNode, setGraphicsNode, setPaintingTransform, setProgressivePaint, setRenderingTransform, setSelectionOverlayColor, setSelectionOverlayStrokeColor, setSelectionOverlayXORMode
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCROLL_RIGHT_ACTION

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

SCROLL_LEFT_ACTION

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

SCROLL_UP_ACTION

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

SCROLL_DOWN_ACTION

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

FAST_SCROLL_RIGHT_ACTION

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

FAST_SCROLL_LEFT_ACTION

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

FAST_SCROLL_UP_ACTION

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

FAST_SCROLL_DOWN_ACTION

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

ZOOM_IN_ACTION

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

ZOOM_OUT_ACTION

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

RESET_TRANSFORM_ACTION

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

pcs

protected java.beans.PropertyChangeSupport pcs
The PropertyChangeSupport used to fire PropertyChangeEvent.

uri

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

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.

zoomInteractor

protected Interactor zoomInteractor
An interactor to perform a zoom.

Binding: BUTTON1 + CTRL Key


imageZoomInteractor

protected Interactor imageZoomInteractor
An interactor to perform a realtime zoom.

Binding: BUTTON3 + SHIFT Key


panInteractor

protected Interactor panInteractor
An interactor to perform a translation.

Binding: BUTTON1 + SHIFT Key


rotateInteractor

protected Interactor rotateInteractor
An interactor to perform a rotation.

Binding: BUTTON3 + CTRL Key


resetTransformInteractor

protected Interactor resetTransformInteractor
An interactor to reset the rendering transform.

Binding: CTRL+SHIFT+BUTTON3

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.
eventEnabled - Whether the GVT tree should be reactive to mouse and key events.
selectableText - Whether the text should be selectable.
Method Detail

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.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds the specified PropertyChangeListener.
Overrides:
addPropertyChangeListener in class javax.swing.JComponent
Parameters:
pcl - the property change listener to add

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Removes the specified PropertyChangeListener.
Overrides:
removePropertyChangeListener in class javax.swing.JComponent
Parameters:
pcl - the property change listener to remove

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener pcl)
Adds the specified PropertyChangeListener for the specified property.
Overrides:
addPropertyChangeListener in class javax.swing.JComponent
Parameters:
propertyName - the name of the property to listen on
pcl - the property change listener to add

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener pcl)
Removes the specified PropertyChangeListener for the specified property.
Overrides:
removePropertyChangeListener in class javax.swing.JComponent
Parameters:
propertyName - the name of the property that was listened on
pcl - the property change listener to remove

setEnableZoomInteractor

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

getEnableZoomInteractor

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

setEnableImageZoomInteractor

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

getEnableImageZoomInteractor

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

setEnablePanInteractor

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

getEnablePanInteractor

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

setEnableRotateInteractor

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

getEnableRotateInteractor

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

setEnableResetTransformInteractor

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

getEnableResetTransformInteractor

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

getURI

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

setURI

public void setURI(java.lang.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

createUserAgent

protected UserAgent createUserAgent()
Creates a UserAgent.
Overrides:
createUserAgent in class JSVGComponent

createListener

protected JGVTComponent.Listener createListener()
Creates an instance of Listener.
Overrides:
createListener in class JSVGComponent


Copyright © 2002 Apache Software Foundation. All Rights Reserved.