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:
ImageObserver, MenuContainer, Serializable
- Direct Known Subclasses:
JSVGViewerFrame.Canvas
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA swing action to append an affine transform to the current rendering transform.protected classTo hide the listener methods.protected classTheCanvasUserAgentonly adds tooltips to the behavior of the defaultBridgeUserAgent.protected static classHelper class.classA swing action to reset the rendering transform of the canvas.classA swing action to Rotate the canvas.classA swing action to Pan/scroll the canvas.classA swing action to scroll the canvas down, by a fixed amountclassA swing action to scroll the canvas to the left, by a fixed amountclassA swing action to scroll the canvas to the right, by a fixed amountclassA swing action to scroll the canvas up, by a fixed amountprotected classSets a specific tooltip on the JSVGCanvas when a given event occurs.protected classclassA swing action to apply a zoom factor to the canvas.classA swing action to zoom in the canvas.classA swing action to zoom out the canvas.Nested classes/interfaces inherited from class JSVGComponent
JSVGComponent.BridgeUserAgent, JSVGComponent.BridgeUserAgentWrapper, JSVGComponent.JSVGComponentListener, JSVGComponent.SVGListenerNested classes/interfaces inherited from class JGVTComponent
JGVTComponent.Listener, JGVTComponent.UnixTextSelectionListenerNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key for the Action to quickly scroll down.static final StringThe key for the Action to quickly scroll left.static final StringThe key for the Action to quickly scroll right.static final StringThe key for the Action to quickly scroll up.protected InteractorAn interactor to perform a realtime zoom.protected EventTargetprotected EventTargetThe target for which the last tool tip event was fired.protected longThe time of the last tool tip event.protected JSVGCanvas.LocationListenerKeeps track of the last known mouse position over the canvas.protected static final ObjectThis is used as the value in the toolTipDocs WeakHashMap.protected InteractorAn interactor to perform a translation.protected PropertyChangeSupportThePropertyChangeSupportused to firePropertyChangeEvent.static final StringThe key for the Action to reset the transform.protected InteractorAn interactor to reset the rendering transform.protected InteractorAn interactor to perform a rotation.static final StringThe key for the Action to scroll down.static final StringThe key for the Action to scroll left.static final StringThe key for the Action to scroll right.static final StringThe key for the Action to scroll up.protected Mapprotected EventListenerprotected MapMapping of elements to listeners so they can be removed, if the tooltip is removed.protected StringThe URI of the current document being displayed.static final StringThe key for the Action to zoom in.static final StringThe key for the Action to zoom out.protected InteractorAn interactor to perform a zoom.Fields inherited from class JSVGComponent
afterStopRunnable, ALWAYS_DYNAMIC, ALWAYS_INTERACTIVE, ALWAYS_STATIC, animationLimitingAmount, animationLimitingMode, AUTODETECT, bridgeContext, BROKEN_LINK_TITLE, documentLoader, documentState, FEATURES, fragmentIdentifier, gvtTreeBuilder, gvtTreeBuilderListeners, isDynamicDocument, isInteractiveDocument, jsvgComponentListener, linkActivationListeners, loader, nextDocumentLoader, nextGVTTreeBuilder, nextUpdateManager, prevComponentSize, recenterOnResize, SCRIPT_ALERT, SCRIPT_CONFIRM, SCRIPT_PROMPT, selfCallingDisableInteractions, svgDocument, svgDocumentLoaderListeners, svgLoadEventDispatcher, svgLoadEventDispatcherListeners, svgUserAgent, updateManager, updateManagerListeners, updateOverlay, userAgent, userSetDisableInteractions, viewingTransformFields inherited from class JGVTComponent
disableInteractions, doubleBufferedRendering, eventDispatcher, eventsEnabled, gvtRoot, gvtTreeRenderer, gvtTreeRendererListeners, image, initialTransform, interactor, interactors, jgvtListeners, listener, needRender, overlays, paintingTransform, progressivePaint, progressivePaintThread, renderer, rendererFactory, renderingTransform, selectableText, suspendInteractions, textSelectionManager, useUnixTextSelectionFields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new JSVGCanvas.JSVGCanvas(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText) Creates a new JSVGCanvas. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specifiedPropertyChangeListener.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener pcl) Adds the specifiedPropertyChangeListenerfor the specified property.protected JGVTComponent.ListenerCreates an instance of Listener.protected UserAgentCreates a UserAgent.booleanReturns true if the image zoom interactor is enabled, false otherwise.booleanReturns true if the pan interactor is enabled, false otherwise.booleanReturns true if the reset transform interactor is enabled, false otherwise.booleanReturns true if the rotate interactor is enabled, false otherwise.booleanReturns true if the zoom interactor is enabled, false otherwise.getURI()Returns the URI of the current document.protected voidBuilds the ActionMap of this canvas with a set of predefinedActions.protected voidBuilds the InputMap of this canvas with a set of predefinedActions.protected voidinstallSVGDocument(org.w3c.dom.svg.SVGDocument doc) This does the real work of installing the SVG Document after the update manager from the previous document (if any) has been properly 'shut down'.booleanmatchLastToolTipEvent(long t, EventTarget et) Checks if the specified event time and element are the same as the last tool tip event.voidRemoves the specifiedPropertyChangeListener.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener pcl) Removes the specifiedPropertyChangeListenerfor the specified property.voidsetDisableInteractions(boolean b) Turn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.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.voidSets the URI to the specified uri.Methods inherited from class JSVGComponent
addGVTTreeBuilderListener, addLinkActivationListener, addSVGDocumentLoaderListener, addSVGLoadEventDispatcherListener, addUpdateManagerListener, calculateViewingTransform, clearUserSetDisableInteractions, computeRenderingTransform, createBridgeContext, createImageRenderer, dispose, flushImageCache, getCanvasGraphicsNode, getCanvasGraphicsNode, getFragmentIdentifier, getInterpreter, getRecenterOnResize, getSVGDocument, getSVGDocumentSize, getUpdateManager, getViewBoxTransform, getViewingTransform, handleException, isDynamic, isInteractive, loadSVGDocument, removeGVTTreeBuilderListener, removeLinkActivationListener, removeSVGDocumentLoaderListener, removeSVGLoadEventDispatcherListener, removeUpdateManagerListener, renderGVTTree, resumeProcessing, setAnimationLimitingCPU, setAnimationLimitingFPS, setAnimationLimitingNone, setBridgeContextAnimationLimitingMode, setDocument, setDocumentState, setFragmentIdentifier, setGraphicsNode, setMySize, setRecenterOnResize, setSVGDocument, showAlert, showConfirm, showPrompt, showPrompt, startGVTTreeBuilder, startSVGLoadEventDispatcher, stopProcessing, stopThenRun, suspendProcessing, updateRenderingTransform, updateZoomAndPanEnableMethods inherited from class JGVTComponent
addAWTListeners, addGVTTreeRendererListener, addJGVTComponentListener, createEventDispatcher, createTextSelectionManager, deselectAll, flush, flush, getDisableInteractions, getDoubleBufferedRendering, getGraphicsNode, getInitialTransform, getInteractors, getOffScreen, getOverlays, getPaintingTransform, getProgressivePaint, getRenderingTransform, getRenderRect, getSelectionOverlayColor, getSelectionOverlayStrokeColor, getTextSelectionManager, getUseUnixTextSelection, immediateRepaint, initializeEventHandling, isSelectionOverlayXORMode, paintComponent, releaseRenderingReferences, removeGVTTreeRendererListener, removeJGVTComponentListener, resetRenderingTransform, scheduleGVTRendering, select, setDoubleBufferedRendering, setGraphicsNode, setPaintingTransform, setProgressivePaint, setRenderingTransform, setRenderingTransform, setSelectionOverlayColor, setSelectionOverlayStrokeColor, setSelectionOverlayXORMode, setUseUnixTextSelectionMethods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIMethods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
SCROLL_RIGHT_ACTION
-
SCROLL_LEFT_ACTION
-
SCROLL_UP_ACTION
-
SCROLL_DOWN_ACTION
-
FAST_SCROLL_RIGHT_ACTION
The key for the Action to quickly scroll right.- See Also:
-
FAST_SCROLL_LEFT_ACTION
The key for the Action to quickly scroll left.- See Also:
-
FAST_SCROLL_UP_ACTION
The key for the Action to quickly scroll up.- See Also:
-
FAST_SCROLL_DOWN_ACTION
The key for the Action to quickly scroll down.- See Also:
-
ZOOM_IN_ACTION
-
ZOOM_OUT_ACTION
-
RESET_TRANSFORM_ACTION
The key for the Action to reset the transform.- See Also:
-
pcs
ThePropertyChangeSupportused to firePropertyChangeEvent. -
uri
The URI of the current document being displayed. -
locationListener
Keeps track of the last known mouse position over the canvas. This is used for displaying tooltips at the right location. -
toolTipMap
Mapping of elements to listeners so they can be removed, if the tooltip is removed. -
toolTipListener
-
lastTarget
-
toolTipDocs
-
MAP_TOKEN
This is used as the value in the toolTipDocs WeakHashMap. This way we can tell if a document has already been added. -
lastToolTipEventTimeStamp
protected long lastToolTipEventTimeStampThe time of the last tool tip event. -
lastToolTipEventTarget
The target for which the last tool tip event was fired. -
zoomInteractor
An interactor to perform a zoom.Binding: BUTTON1 + CTRL Key
-
imageZoomInteractor
An interactor to perform a realtime zoom.Binding: BUTTON3 + SHIFT Key
-
panInteractor
An interactor to perform a translation.Binding: BUTTON1 + SHIFT Key
-
rotateInteractor
An interactor to perform a rotation.Binding: BUTTON3 + CTRL Key
-
resetTransformInteractor
An interactor to reset the rendering transform.Binding: CTRL+SHIFT+BUTTON3
-
-
Constructor Details
-
JSVGCanvas
public JSVGCanvas()Creates a new JSVGCanvas. -
JSVGCanvas
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 Details
-
installActions
protected void installActions()Builds the ActionMap of this canvas with a set of predefinedActions. -
setDisableInteractions
public void setDisableInteractions(boolean b) Description copied from class:JGVTComponentTurn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.- Overrides:
setDisableInteractionsin classJSVGComponent
-
installKeyboardActions
protected void installKeyboardActions()Builds the InputMap of this canvas with a set of predefinedActions. -
addPropertyChangeListener
Adds the specifiedPropertyChangeListener.- Overrides:
addPropertyChangeListenerin classContainer- Parameters:
pcl- the property change listener to add
-
removePropertyChangeListener
Removes the specifiedPropertyChangeListener.- Overrides:
removePropertyChangeListenerin classComponent- Parameters:
pcl- the property change listener to remove
-
addPropertyChangeListener
Adds the specifiedPropertyChangeListenerfor the specified property.- Overrides:
addPropertyChangeListenerin classContainer- Parameters:
propertyName- the name of the property to listen onpcl- the property change listener to add
-
removePropertyChangeListener
Removes the specifiedPropertyChangeListenerfor the specified property.- Overrides:
removePropertyChangeListenerin classComponent- Parameters:
propertyName- the name of the property that was listened onpcl- 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
Returns the URI of the current document. -
setURI
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
Creates a UserAgent.- Overrides:
createUserAgentin classJSVGComponent
-
createListener
Creates an instance of Listener.- Overrides:
createListenerin classJSVGComponent
-
installSVGDocument
protected void installSVGDocument(org.w3c.dom.svg.SVGDocument doc) Description copied from class:JSVGComponentThis does the real work of installing the SVG Document after the update manager from the previous document (if any) has been properly 'shut down'.- Overrides:
installSVGDocumentin classJSVGComponent
-
setLastToolTipEvent
Sets the time and element of the last tool tip event handled. -
matchLastToolTipEvent
Checks if the specified event time and element are the same as the last tool tip event.
-