org.apache.batik.swing.gvt

Class AbstractJGVTComponent

public abstract class AbstractJGVTComponent extends JComponent

This class represents a component which can display a GVT tree. This class is made abstract so that concrete versions can be made for different JDK versions. In particular, this is for MouseWheelEvent support, which only exists in JDKs >= 1.4.
Nested Class Summary
protected classAbstractJGVTComponent.Listener
To hide the listener methods.
protected classAbstractJGVTComponent.UnixTextSelectionListener
Field Summary
protected booleandisableInteractions
Whether to unconditionally disable interactions.
protected booleandoubleBufferedRendering
Whether the double buffering is enabled.
protected AWTEventDispatchereventDispatcher
The event dispatcher.
protected booleaneventsEnabled
Whether the GVT tree should be reactive to mouse and key events.
protected GraphicsNodegvtRoot
The GVT tree root.
protected GVTTreeRenderergvtTreeRenderer
The GVT tree renderer.
protected ListgvtTreeRendererListeners
The GVT tree renderer listeners.
protected BufferedImageimage
The image to paint.
protected AffineTransforminitialTransform
The initial rendering transform.
protected Interactorinteractor
The current interactor.
protected Listinteractors
The interactor list.
protected ListjgvtListeners
The JGVTComponentListener list.
protected AbstractJGVTComponent.Listenerlistener
The listener.
protected booleanneedRender
Whether a render was requested.
protected Listoverlays
The overlays.
protected AffineTransformpaintingTransform
The transform used for painting.
protected booleanprogressivePaint
Whether to allow progressive paint.
protected HaltingThreadprogressivePaintThread
The progressive paint thread.
protected ImageRendererrenderer
The current renderer.
protected ImageRendererFactoryrendererFactory
The renderer factory.
protected AffineTransformrenderingTransform
The transform used for rendering.
protected booleanselectableText
Whether the text should be selectable if eventEnabled is false, this flag is ignored.
protected booleansuspendInteractions
Whether to suspend interactions.
protected TextSelectionManagertextSelectionManager
The text selection manager.
protected booleanuseUnixTextSelection
Whether the JGVTComponent should adhere to 'Unix' text selection semantics where as soon as text is selected it is copied to the clipboard.
Constructor Summary
AbstractJGVTComponent()
Creates a new AbstractJGVTComponent.
AbstractJGVTComponent(boolean eventsEnabled, boolean selectableText)
Creates a new abstract JGVTComponent.
Method Summary
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 ImageRenderercreateImageRenderer()
Creates a new renderer.
protected AbstractJGVTComponent.ListenercreateListener()
Creates an instance of Listener.
voiddeselectAll()
Deselects all.
voidflush()
Flush any cached image data (preliminary interface, may be removed or modified in the future).
voidflush(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.
AffineTransformgetInitialTransform()
Returns the initial transform.
ListgetInteractors()
Returns the interactor list.
BufferedImagegetOffScreen()
Returns the off-screen image, if any.
ListgetOverlays()
Returns the overlay list.
AffineTransformgetPaintingTransform()
Returns the current painting transform.
booleangetProgressivePaint()
Tells whether the progressive paint is enabled.
AffineTransformgetRenderingTransform()
Returns the current rendering transform.
RectanglegetRenderRect()
ColorgetSelectionOverlayColor()
Returns the color of the selection overlay.
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.
protected voidhandleException(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(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(AffineTransform at)
Sets the painting transform.
voidsetProgressivePaint(boolean b)
Whether to enable the progressive paint.
voidsetRenderingTransform(AffineTransform at)
Sets the rendering transform.
voidsetRenderingTransform(AffineTransform at, boolean performRedraw)
voidsetSelectionOverlayColor(Color color)
Sets the color of the selection overlay to the specified color.
voidsetSelectionOverlayStrokeColor(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.

Field Detail

disableInteractions

protected boolean disableInteractions
Whether to unconditionally disable interactions.

doubleBufferedRendering

protected boolean doubleBufferedRendering
Whether the double buffering is enabled.

eventDispatcher

protected AWTEventDispatcher eventDispatcher
The event dispatcher.

eventsEnabled

protected boolean eventsEnabled
Whether the GVT tree should be reactive to mouse and key events.

gvtRoot

protected GraphicsNode gvtRoot
The GVT tree root.

gvtTreeRenderer

protected GVTTreeRenderer gvtTreeRenderer
The GVT tree renderer.

gvtTreeRendererListeners

protected List gvtTreeRendererListeners
The GVT tree renderer listeners.

image

protected BufferedImage image
The image to paint.

initialTransform

protected AffineTransform initialTransform
The initial rendering transform.

interactor

protected Interactor interactor
The current interactor.

interactors

protected List interactors
The interactor list.

jgvtListeners

protected List jgvtListeners
The JGVTComponentListener list.

listener

protected AbstractJGVTComponent.Listener listener
The listener.

needRender

protected boolean needRender
Whether a render was requested.

overlays

protected List overlays
The overlays.

paintingTransform

protected AffineTransform paintingTransform
The transform used for painting.

progressivePaint

protected boolean progressivePaint
Whether to allow progressive paint.

progressivePaintThread

protected HaltingThread progressivePaintThread
The progressive paint thread.

renderer

protected ImageRenderer renderer
The current renderer.

rendererFactory

protected ImageRendererFactory rendererFactory
The renderer factory.

renderingTransform

protected AffineTransform renderingTransform
The transform used for rendering.

selectableText

protected boolean selectableText
Whether the text should be selectable if eventEnabled is false, this flag is ignored.

suspendInteractions

protected boolean suspendInteractions
Whether to suspend interactions.

textSelectionManager

protected TextSelectionManager textSelectionManager
The text selection manager.

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.

Constructor Detail

AbstractJGVTComponent

public AbstractJGVTComponent()
Creates a new AbstractJGVTComponent.

AbstractJGVTComponent

public AbstractJGVTComponent(boolean eventsEnabled, boolean selectableText)
Creates a new abstract 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

addAWTListeners

protected void addAWTListeners()
Adds the AWT listeners.

addGVTTreeRendererListener

public void addGVTTreeRendererListener(GVTTreeRendererListener l)
Adds a GVTTreeRendererListener to this component.

addJGVTComponentListener

public void addJGVTComponentListener(JGVTComponentListener listener)

computeRenderingTransform

protected boolean computeRenderingTransform()
Computes the initial value of the transform used for rendering. Return true if a repaint is required, otherwise false.

createImageRenderer

protected ImageRenderer createImageRenderer()
Creates a new renderer.

createListener

protected AbstractJGVTComponent.Listener createListener()
Creates an instance of Listener.

deselectAll

public void deselectAll()
Deselects all.

flush

public void flush()
Flush any cached image data (preliminary interface, may be removed or modified in the future).

flush

public void flush(Rectangle r)
Flush a rectangle of cached image data (preliminary interface, may be removed or modified in the future).

getDisableInteractions

public boolean getDisableInteractions()
Returns true if all 'interactor' objects (pan, zoom, etc) are disabled.

getDoubleBufferedRendering

public boolean getDoubleBufferedRendering()
Tells whether this component use double buffering to render SVG documents.

getGraphicsNode

public GraphicsNode getGraphicsNode()
Returns the root of the GVT tree displayed by this component, if any.

getInitialTransform

public AffineTransform getInitialTransform()
Returns the initial transform.

getInteractors

public List getInteractors()
Returns the interactor list.

getOffScreen

public BufferedImage getOffScreen()
Returns the off-screen image, if any.

getOverlays

public List getOverlays()
Returns the overlay list.

getPaintingTransform

public AffineTransform getPaintingTransform()
Returns the current painting transform.

getProgressivePaint

public boolean getProgressivePaint()
Tells whether the progressive paint is enabled.

getRenderingTransform

public AffineTransform getRenderingTransform()
Returns the current rendering transform.

getRenderRect

public Rectangle getRenderRect()

getSelectionOverlayColor

public Color getSelectionOverlayColor()
Returns the color of the selection overlay.

getSelectionOverlayStrokeColor

public Color getSelectionOverlayStrokeColor()
Returns the color of the outline of the selection overlay.

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.

getUseUnixTextSelection

public void getUseUnixTextSelection(boolean b)
Returns true if the canvas will copy selections to the clipboard when they are completed.

handleException

protected void handleException(Exception e)
Handles an exception.

immediateRepaint

public void immediateRepaint()
Repaints immediately the component.

initializeEventHandling

protected void initializeEventHandling()
Initializes the event handling classes.

isSelectionOverlayXORMode

public boolean isSelectionOverlayXORMode()
Returns true if the selection overlay is painted in XOR mode, false otherwise.

paintComponent

public void paintComponent(Graphics g)
Paints this component.

releaseRenderingReferences

protected void releaseRenderingReferences()
Releases the references to the rendering resources,

removeGVTTreeRendererListener

public void removeGVTTreeRendererListener(GVTTreeRendererListener l)
Removes a GVTTreeRendererListener from this component.

removeJGVTComponentListener

public void removeJGVTComponentListener(JGVTComponentListener listener)

renderGVTTree

protected void renderGVTTree()
Renders the GVT tree.

resetRenderingTransform

public void resetRenderingTransform()
Resets the rendering transform to its initial value.

scheduleGVTRendering

protected void scheduleGVTRendering()
Schedules a new GVT rendering.

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 starts end the mark used to define where the selection ends

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.

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.

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.

setPaintingTransform

public void setPaintingTransform(AffineTransform at)
Sets the painting transform. A null transform is the same as an identity transform. The next repaint will use the given transform.

setProgressivePaint

public void setProgressivePaint(boolean b)
Whether to enable the progressive paint.

setRenderingTransform

public void setRenderingTransform(AffineTransform at)
Sets the rendering transform. Calling this method causes a rendering to be performed.

setRenderingTransform

public void setRenderingTransform(AffineTransform at, boolean performRedraw)

setSelectionOverlayColor

public void setSelectionOverlayColor(Color color)
Sets the color of the selection overlay to the specified color.

Parameters: color the new color of the selection overlay

setSelectionOverlayStrokeColor

public void setSelectionOverlayStrokeColor(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

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

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).

stopProcessing

public void stopProcessing()
Stops the processing of the current tree.

updateRenderingTransform

protected boolean updateRenderingTransform()
Updates the value of the transform used for rendering. Return true if a repaint is required, otherwise false.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.