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:
ImageObserver
,MenuContainer
,Serializable
- Direct Known Subclasses:
JSVGComponent
This class represents a component which can display a GVT tree.
- Version:
- $Id: JGVTComponent.java 1839938 2018-09-03 11:22:05Z ssteiner $
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
To hide the listener methods.protected class
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether to unconditionally disable interactions.protected boolean
Whether the double buffering is enabled.protected AWTEventDispatcher
The event dispatcher.protected boolean
Whether the GVT tree should be reactive to mouse and key events.protected GraphicsNode
The GVT tree root.protected GVTTreeRenderer
The GVT tree renderer.protected List
The GVT tree renderer listeners.protected BufferedImage
The image to paint.protected AffineTransform
The initial rendering transform.protected Interactor
The current interactor.protected List
The interactor list.protected List
The JGVTComponentListener list.protected JGVTComponent.Listener
The listener.protected boolean
Whether a render was requested.protected List
The overlays.protected AffineTransform
The transform used for painting.protected boolean
Whether to allow progressive paint.protected HaltingThread
The progressive paint thread.protected ImageRenderer
The current renderer.protected ImageRendererFactory
The renderer factory.protected AffineTransform
The transform used for rendering.protected boolean
Whether the text should be selectable if eventEnabled is false, this flag is ignored.protected boolean
Whether to suspend interactions.protected TextSelectionManager
The text selection manager.protected boolean
Whether 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
Fields inherited from class java.awt.Component
accessibleContext, 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
ConstructorsConstructorDescriptionCreates a new JGVTComponent.JGVTComponent
(boolean eventsEnabled, boolean selectableText) Creates a new JGVTComponent. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds the AWT listeners.void
Adds a GVTTreeRendererListener to this component.void
protected boolean
Computes the initial value of the transform used for rendering.protected AWTEventDispatcher
protected ImageRenderer
Creates a new renderer.protected JGVTComponent.Listener
Creates an instance of Listener.protected TextSelectionManager
void
Deselects all.void
flush()
Flush any cached image data (preliminary interface, may be removed or modified in the future).void
Flush a rectangle of cached image data (preliminary interface, may be removed or modified in the future).boolean
Returns true if all 'interactor' objects (pan, zoom, etc) are disabled.boolean
Tells whether this component use double buffering to render SVG documents.Returns the root of the GVT tree displayed by this component, if any.Returns the initial transform.Returns the interactor list.Returns the off-screen image, if any.Returns the overlay list.Returns the current painting transform.boolean
Tells whether the progressive paint is enabled.Returns the current rendering transform.Returns the color of the selection overlay.Returns the color of the outline of the selection overlay.Returns the current Text selection manager for the Component.void
getUseUnixTextSelection
(boolean b) Returns true if the canvas will copy selections to the clipboard when they are completed.private void
protected void
Handles an exception.void
Repaints immediately the component.protected void
Initializes the event handling classes.boolean
Returns true if the selection overlay is painted in XOR mode, false otherwise.void
Paints this component.protected void
Releases the references to the rendering resources,void
Removes a GVTTreeRendererListener from this component.void
protected void
Renders the GVT tree.void
Resets the rendering transform to its initial value.protected void
Schedules a new GVT rendering.void
Sets the selection to the specified start and end mark.void
setDisableInteractions
(boolean b) Turn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.void
setDoubleBufferedRendering
(boolean b) Sets whether this component should use double buffering to render SVG documents.void
Sets the GVT tree to display.protected void
setGraphicsNode
(GraphicsNode gn, boolean createDispatcher) Sets the GVT tree to display.void
Sets the painting transform.void
setProgressivePaint
(boolean b) Whether to enable the progressive paint.void
Sets the rendering transform.void
setRenderingTransform
(AffineTransform at, boolean performRedraw) void
setSelectionOverlayColor
(Color color) Sets the color of the selection overlay to the specified color.void
Sets the color of the outline of the selection overlay to the specified color.void
setSelectionOverlayXORMode
(boolean state) Sets whether or not the selection overlay will be painted in XOR mode, depending on the specified parameter.void
setUseUnixTextSelection
(boolean b) If 'b' is true text selections will copied to the clipboard immediately.void
Stops the processing of the current tree.protected boolean
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 Details
-
listener
The listener. -
gvtTreeRenderer
The GVT tree renderer. -
gvtRoot
The GVT tree root. -
rendererFactory
The renderer factory. -
renderer
The current renderer. -
gvtTreeRendererListeners
The GVT tree renderer listeners. -
needRender
protected boolean needRenderWhether a render was requested. -
progressivePaint
protected boolean progressivePaintWhether to allow progressive paint. -
progressivePaintThread
The progressive paint thread. -
image
The image to paint. -
initialTransform
The initial rendering transform. -
renderingTransform
The transform used for rendering. -
paintingTransform
The transform used for painting. -
interactors
The interactor list. -
interactor
The current interactor. -
overlays
The overlays. -
jgvtListeners
The JGVTComponentListener list. -
eventDispatcher
The event dispatcher. -
textSelectionManager
The text selection manager. -
doubleBufferedRendering
protected boolean doubleBufferedRenderingWhether the double buffering is enabled. -
eventsEnabled
protected boolean eventsEnabledWhether the GVT tree should be reactive to mouse and key events. -
selectableText
protected boolean selectableTextWhether the text should be selectable if eventEnabled is false, this flag is ignored. -
useUnixTextSelection
protected boolean useUnixTextSelectionWhether 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 suspendInteractionsWhether to suspend interactions. -
disableInteractions
protected boolean disableInteractionsWhether to unconditionally disable interactions.
-
-
Constructor Details
-
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 Details
-
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
Returns the interactor list. -
getOverlays
Returns the overlay list. -
getOffScreen
Returns the off-screen image, if any. -
addJGVTComponentListener
-
removeJGVTComponentListener
-
resetRenderingTransform
public void resetRenderingTransform()Resets the rendering transform to its initial value. -
stopProcessing
public void stopProcessing()Stops the processing of the current tree. -
getGraphicsNode
Returns the root of the GVT tree displayed by this component, if any. -
setGraphicsNode
Sets the GVT tree to display. -
setGraphicsNode
Sets the GVT tree to display. -
initializeEventHandling
protected void initializeEventHandling()Initializes the event handling classes. -
createEventDispatcher
-
createTextSelectionManager
-
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
Sets the color of the selection overlay to the specified color.- Parameters:
color
- the new color of the selection overlay
-
getSelectionOverlayColor
Returns the color of the selection overlay. -
setSelectionOverlayStrokeColor
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
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
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
-
immediateRepaint
public void immediateRepaint()Repaints immediately the component. -
paintComponent
Paints this component.- Overrides:
paintComponent
in classJComponent
-
setPaintingTransform
Sets the painting transform. A null transform is the same as an identity transform. The next repaint will use the given transform. -
getPaintingTransform
Returns the current painting transform. -
setRenderingTransform
Sets the rendering transform. Calling this method causes a rendering to be performed. -
setRenderingTransform
-
getInitialTransform
Returns the initial transform. -
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
Adds a GVTTreeRendererListener to this component. -
removeGVTTreeRendererListener
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
Flush a rectangle of cached image data (preliminary interface, may be removed or modified in the future). -
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
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()
-