Class JGVTComponent

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JSVGComponent

public class JGVTComponent extends JComponent
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:
  • Field Details

    • 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 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 BufferedImage image
      The image to paint.
    • initialTransform

      protected AffineTransform initialTransform
      The initial rendering transform.
    • renderingTransform

      protected AffineTransform renderingTransform
      The transform used for rendering.
    • paintingTransform

      protected AffineTransform paintingTransform
      The transform used for painting.
    • interactors

      protected List interactors
      The interactor list.
    • interactor

      protected Interactor interactor
      The current interactor.
    • overlays

      protected List overlays
      The overlays.
    • jgvtListeners

      protected 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 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

      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 List getInteractors()
      Returns the interactor list.
    • getOverlays

      public List getOverlays()
      Returns the overlay list.
    • getOffScreen

      public 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(Color color)
      Sets the color of the selection overlay to the specified color.
      Parameters:
      color - the new color of the selection overlay
    • getSelectionOverlayColor

      public Color getSelectionOverlayColor()
      Returns the 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
    • getSelectionOverlayStrokeColor

      public 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 starts
      end - 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 Rectangle getRenderRect()
    • immediateRepaint

      public void immediateRepaint()
      Repaints immediately the component.
    • paintComponent

      public void paintComponent(Graphics g)
      Paints this component.
      Overrides:
      paintComponent in class JComponent
    • 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.
    • getPaintingTransform

      public AffineTransform getPaintingTransform()
      Returns the current painting transform.
    • 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)
    • getInitialTransform

      public AffineTransform getInitialTransform()
      Returns the initial transform.
    • getRenderingTransform

      public 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(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(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()