Package org.apache.batik.swing.gvt
Class JGVTComponent
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- org.apache.batik.swing.gvt.JGVTComponent
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable
- Direct Known Subclasses:
JSVGComponent
public class JGVTComponent extends javax.swing.JComponentThis class represents a component which can display a GVT tree.- Version:
- $Id: JGVTComponent.java 1839938 2018-09-03 11:22:05Z ssteiner $
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJGVTComponent.ListenerTo hide the listener methods.protected classJGVTComponent.UnixTextSelectionListener-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandisableInteractionsWhether to unconditionally disable interactions.protected booleandoubleBufferedRenderingWhether the double buffering is enabled.protected AWTEventDispatchereventDispatcherThe event dispatcher.protected booleaneventsEnabledWhether the GVT tree should be reactive to mouse and key events.protected GraphicsNodegvtRootThe GVT tree root.protected GVTTreeRenderergvtTreeRendererThe GVT tree renderer.protected java.util.ListgvtTreeRendererListenersThe GVT tree renderer listeners.protected java.awt.image.BufferedImageimageThe image to paint.protected java.awt.geom.AffineTransforminitialTransformThe initial rendering transform.protected InteractorinteractorThe current interactor.protected java.util.ListinteractorsThe interactor list.protected java.util.ListjgvtListenersThe JGVTComponentListener list.protected JGVTComponent.ListenerlistenerThe listener.protected booleanneedRenderWhether a render was requested.protected java.util.ListoverlaysThe overlays.protected java.awt.geom.AffineTransformpaintingTransformThe transform used for painting.protected booleanprogressivePaintWhether to allow progressive paint.protected HaltingThreadprogressivePaintThreadThe progressive paint thread.protected ImageRendererrendererThe current renderer.protected ImageRendererFactoryrendererFactoryThe renderer factory.protected java.awt.geom.AffineTransformrenderingTransformThe transform used for rendering.protected booleanselectableTextWhether the text should be selectable if eventEnabled is false, this flag is ignored.protected booleansuspendInteractionsWhether to suspend interactions.protected TextSelectionManagertextSelectionManagerThe text selection manager.protected booleanuseUnixTextSelectionWhether the JGVTComponent should adhere to 'Unix' text selection semantics where as soon as text is selected it is copied to the clipboard.-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description JGVTComponent()Creates a new JGVTComponent.JGVTComponent(boolean eventsEnabled, boolean selectableText)Creates a new JGVTComponent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAWTListeners()Adds the AWT listeners.voidaddGVTTreeRendererListener(GVTTreeRendererListener l)Adds a GVTTreeRendererListener to this component.voidaddJGVTComponentListener(JGVTComponentListener listener)protected booleancomputeRenderingTransform()Computes the initial value of the transform used for rendering.protected AWTEventDispatchercreateEventDispatcher()protected ImageRenderercreateImageRenderer()Creates a new renderer.protected JGVTComponent.ListenercreateListener()Creates an instance of Listener.protected TextSelectionManagercreateTextSelectionManager(EventDispatcher ed)voiddeselectAll()Deselects all.voidflush()Flush any cached image data (preliminary interface, may be removed or modified in the future).voidflush(java.awt.Rectangle r)Flush a rectangle of cached image data (preliminary interface, may be removed or modified in the future).booleangetDisableInteractions()Returns true if all 'interactor' objects (pan, zoom, etc) are disabled.booleangetDoubleBufferedRendering()Tells whether this component use double buffering to render SVG documents.GraphicsNodegetGraphicsNode()Returns the root of the GVT tree displayed by this component, if any.java.awt.geom.AffineTransformgetInitialTransform()Returns the initial transform.java.util.ListgetInteractors()Returns the interactor list.java.awt.image.BufferedImagegetOffScreen()Returns the off-screen image, if any.java.util.ListgetOverlays()Returns the overlay list.java.awt.geom.AffineTransformgetPaintingTransform()Returns the current painting transform.booleangetProgressivePaint()Tells whether the progressive paint is enabled.java.awt.geom.AffineTransformgetRenderingTransform()Returns the current rendering transform.java.awt.RectanglegetRenderRect()java.awt.ColorgetSelectionOverlayColor()Returns the color of the selection overlay.java.awt.ColorgetSelectionOverlayStrokeColor()Returns the color of the outline of the selection overlay.TextSelectionManagergetTextSelectionManager()Returns the current Text selection manager for the Component.voidgetUseUnixTextSelection(boolean b)Returns true if the canvas will copy selections to the clipboard when they are completed.private voidhaltProgressivePaintThread()protected voidhandleException(java.lang.Exception e)Handles an exception.voidimmediateRepaint()Repaints immediately the component.protected voidinitializeEventHandling()Initializes the event handling classes.booleanisSelectionOverlayXORMode()Returns true if the selection overlay is painted in XOR mode, false otherwise.voidpaintComponent(java.awt.Graphics g)Paints this component.protected voidreleaseRenderingReferences()Releases the references to the rendering resources,voidremoveGVTTreeRendererListener(GVTTreeRendererListener l)Removes a GVTTreeRendererListener from this component.voidremoveJGVTComponentListener(JGVTComponentListener listener)protected voidrenderGVTTree()Renders the GVT tree.voidresetRenderingTransform()Resets the rendering transform to its initial value.protected voidscheduleGVTRendering()Schedules a new GVT rendering.voidselect(Mark start, Mark end)Sets the selection to the specified start and end mark.voidsetDisableInteractions(boolean b)Turn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.voidsetDoubleBufferedRendering(boolean b)Sets whether this component should use double buffering to render SVG documents.voidsetGraphicsNode(GraphicsNode gn)Sets the GVT tree to display.protected voidsetGraphicsNode(GraphicsNode gn, boolean createDispatcher)Sets the GVT tree to display.voidsetPaintingTransform(java.awt.geom.AffineTransform at)Sets the painting transform.voidsetProgressivePaint(boolean b)Whether to enable the progressive paint.voidsetRenderingTransform(java.awt.geom.AffineTransform at)Sets the rendering transform.voidsetRenderingTransform(java.awt.geom.AffineTransform at, boolean performRedraw)voidsetSelectionOverlayColor(java.awt.Color color)Sets the color of the selection overlay to the specified color.voidsetSelectionOverlayStrokeColor(java.awt.Color color)Sets the color of the outline of the selection overlay to the specified color.voidsetSelectionOverlayXORMode(boolean state)Sets whether or not the selection overlay will be painted in XOR mode, depending on the specified parameter.voidsetUseUnixTextSelection(boolean b)If 'b' is true text selections will copied to the clipboard immediately.voidstopProcessing()Stops the processing of the current tree.protected booleanupdateRenderingTransform()Updates the value of the transform used for rendering.-
Methods inherited from class javax.swing.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, updateUI
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, 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, validateTree
-
Methods inherited from class java.awt.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, removePropertyChangeListener, removePropertyChangeListener, 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 Detail
-
listener
protected JGVTComponent.Listener listener
The listener.
-
gvtTreeRenderer
protected GVTTreeRenderer gvtTreeRenderer
The GVT tree renderer.
-
gvtRoot
protected GraphicsNode gvtRoot
The GVT tree root.
-
rendererFactory
protected ImageRendererFactory rendererFactory
The renderer factory.
-
renderer
protected ImageRenderer renderer
The current renderer.
-
gvtTreeRendererListeners
protected java.util.List gvtTreeRendererListeners
The GVT tree renderer listeners.
-
needRender
protected boolean needRender
Whether a render was requested.
-
progressivePaint
protected boolean progressivePaint
Whether to allow progressive paint.
-
progressivePaintThread
protected HaltingThread progressivePaintThread
The progressive paint thread.
-
image
protected java.awt.image.BufferedImage image
The image to paint.
-
initialTransform
protected java.awt.geom.AffineTransform initialTransform
The initial rendering transform.
-
renderingTransform
protected java.awt.geom.AffineTransform renderingTransform
The transform used for rendering.
-
paintingTransform
protected java.awt.geom.AffineTransform paintingTransform
The transform used for painting.
-
interactors
protected java.util.List interactors
The interactor list.
-
interactor
protected Interactor interactor
The current interactor.
-
overlays
protected java.util.List overlays
The overlays.
-
jgvtListeners
protected java.util.List jgvtListeners
The JGVTComponentListener list.
-
eventDispatcher
protected AWTEventDispatcher eventDispatcher
The event dispatcher.
-
textSelectionManager
protected TextSelectionManager textSelectionManager
The text selection manager.
-
doubleBufferedRendering
protected boolean doubleBufferedRendering
Whether the double buffering is enabled.
-
eventsEnabled
protected boolean eventsEnabled
Whether the GVT tree should be reactive to mouse and key events.
-
selectableText
protected boolean selectableText
Whether the text should be selectable if eventEnabled is false, this flag is ignored.
-
useUnixTextSelection
protected boolean useUnixTextSelection
Whether the JGVTComponent should adhere to 'Unix' text selection semantics where as soon as text is selected it is copied to the clipboard. If users want Mac/Windows behaviour they need to handle selections them selves.
-
suspendInteractions
protected boolean suspendInteractions
Whether to suspend interactions.
-
disableInteractions
protected boolean disableInteractions
Whether to unconditionally disable interactions.
-
-
Constructor Detail
-
JGVTComponent
public JGVTComponent()
Creates a new JGVTComponent.
-
JGVTComponent
public JGVTComponent(boolean eventsEnabled, boolean selectableText)Creates a new JGVTComponent.- Parameters:
eventsEnabled- Whether the GVT tree should be reactive to mouse and key events.selectableText- Whether the text should be selectable. if eventEnabled is false, this flag is ignored.
-
-
Method Detail
-
createListener
protected JGVTComponent.Listener createListener()
Creates an instance of Listener.
-
addAWTListeners
protected void addAWTListeners()
Adds the AWT listeners.
-
setDisableInteractions
public void setDisableInteractions(boolean b)
Turn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.
-
getDisableInteractions
public boolean getDisableInteractions()
Returns true if all 'interactor' objects (pan, zoom, etc) are disabled.
-
setUseUnixTextSelection
public void setUseUnixTextSelection(boolean b)
If 'b' is true text selections will copied to the clipboard immediately. If 'b' is false then nothing will be done when selections are made (the application is responsable for copying the selection in response to user actions).
-
getUseUnixTextSelection
public void getUseUnixTextSelection(boolean b)
Returns true if the canvas will copy selections to the clipboard when they are completed.
-
getInteractors
public java.util.List getInteractors()
Returns the interactor list.
-
getOverlays
public java.util.List getOverlays()
Returns the overlay list.
-
getOffScreen
public java.awt.image.BufferedImage getOffScreen()
Returns the off-screen image, if any.
-
addJGVTComponentListener
public void addJGVTComponentListener(JGVTComponentListener listener)
-
removeJGVTComponentListener
public void removeJGVTComponentListener(JGVTComponentListener listener)
-
resetRenderingTransform
public void resetRenderingTransform()
Resets the rendering transform to its initial value.
-
stopProcessing
public void stopProcessing()
Stops the processing of the current tree.
-
getGraphicsNode
public GraphicsNode getGraphicsNode()
Returns the root of the GVT tree displayed by this component, if any.
-
setGraphicsNode
public void setGraphicsNode(GraphicsNode gn)
Sets the GVT tree to display.
-
setGraphicsNode
protected void setGraphicsNode(GraphicsNode gn, boolean createDispatcher)
Sets the GVT tree to display.
-
initializeEventHandling
protected void initializeEventHandling()
Initializes the event handling classes.
-
createEventDispatcher
protected AWTEventDispatcher createEventDispatcher()
-
createTextSelectionManager
protected TextSelectionManager createTextSelectionManager(EventDispatcher ed)
-
getTextSelectionManager
public TextSelectionManager getTextSelectionManager()
Returns the current Text selection manager for the Component. Users can register with this to be notifed of changes in the text selection.
-
setSelectionOverlayColor
public void setSelectionOverlayColor(java.awt.Color color)
Sets the color of the selection overlay to the specified color.- Parameters:
color- the new color of the selection overlay
-
getSelectionOverlayColor
public java.awt.Color getSelectionOverlayColor()
Returns the color of the selection overlay.
-
setSelectionOverlayStrokeColor
public void setSelectionOverlayStrokeColor(java.awt.Color color)
Sets the color of the outline of the selection overlay to the specified color.- Parameters:
color- the new color of the outline of the selection overlay
-
getSelectionOverlayStrokeColor
public java.awt.Color getSelectionOverlayStrokeColor()
Returns the color of the outline of the selection overlay.
-
setSelectionOverlayXORMode
public void setSelectionOverlayXORMode(boolean state)
Sets whether or not the selection overlay will be painted in XOR mode, depending on the specified parameter.- Parameters:
state- true implies the selection overlay will be in XOR mode
-
isSelectionOverlayXORMode
public boolean isSelectionOverlayXORMode()
Returns true if the selection overlay is painted in XOR mode, false otherwise.
-
select
public void select(Mark start, Mark end)
Sets the selection to the specified start and end mark.- Parameters:
start- the mark used to define where the selection startsend- the mark used to define where the selection ends
-
deselectAll
public void deselectAll()
Deselects all.
-
setProgressivePaint
public void setProgressivePaint(boolean b)
Whether to enable the progressive paint.
-
getProgressivePaint
public boolean getProgressivePaint()
Tells whether the progressive paint is enabled.
-
getRenderRect
public java.awt.Rectangle getRenderRect()
-
immediateRepaint
public void immediateRepaint()
Repaints immediately the component.
-
paintComponent
public void paintComponent(java.awt.Graphics g)
Paints this component.- Overrides:
paintComponentin classjavax.swing.JComponent
-
setPaintingTransform
public void setPaintingTransform(java.awt.geom.AffineTransform at)
Sets the painting transform. A null transform is the same as an identity transform. The next repaint will use the given transform.
-
getPaintingTransform
public java.awt.geom.AffineTransform getPaintingTransform()
Returns the current painting transform.
-
setRenderingTransform
public void setRenderingTransform(java.awt.geom.AffineTransform at)
Sets the rendering transform. Calling this method causes a rendering to be performed.
-
setRenderingTransform
public void setRenderingTransform(java.awt.geom.AffineTransform at, boolean performRedraw)
-
getInitialTransform
public java.awt.geom.AffineTransform getInitialTransform()
Returns the initial transform.
-
getRenderingTransform
public java.awt.geom.AffineTransform getRenderingTransform()
Returns the current rendering transform.
-
setDoubleBufferedRendering
public void setDoubleBufferedRendering(boolean b)
Sets whether this component should use double buffering to render SVG documents. The change will be effective during the next rendering.
-
getDoubleBufferedRendering
public boolean getDoubleBufferedRendering()
Tells whether this component use double buffering to render SVG documents.
-
addGVTTreeRendererListener
public void addGVTTreeRendererListener(GVTTreeRendererListener l)
Adds a GVTTreeRendererListener to this component.
-
removeGVTTreeRendererListener
public void removeGVTTreeRendererListener(GVTTreeRendererListener l)
Removes a GVTTreeRendererListener from this component.
-
flush
public void flush()
Flush any cached image data (preliminary interface, may be removed or modified in the future).
-
flush
public void flush(java.awt.Rectangle r)
Flush a rectangle of cached image data (preliminary interface, may be removed or modified in the future).
-
createImageRenderer
protected ImageRenderer createImageRenderer()
Creates a new renderer.
-
renderGVTTree
protected void renderGVTTree()
Renders the GVT tree.
-
computeRenderingTransform
protected boolean computeRenderingTransform()
Computes the initial value of the transform used for rendering. Return true if a repaint is required, otherwise false.
-
updateRenderingTransform
protected boolean updateRenderingTransform()
Updates the value of the transform used for rendering. Return true if a repaint is required, otherwise false.
-
handleException
protected void handleException(java.lang.Exception e)
Handles an exception.
-
releaseRenderingReferences
protected void releaseRenderingReferences()
Releases the references to the rendering resources,
-
scheduleGVTRendering
protected void scheduleGVTRendering()
Schedules a new GVT rendering.
-
haltProgressivePaintThread
private void haltProgressivePaintThread()
-
-