Class JGVTComponent

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
    Direct Known Subclasses:
    JSVGComponent

    public class JGVTComponent
    extends javax.swing.JComponent
    This class represents a component which can display a GVT tree.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  JGVTComponent.Listener
      To hide the listener methods.
      protected class  JGVTComponent.UnixTextSelectionListener  
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • 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 void addAWTListeners()
      Adds the AWT listeners.
      void addGVTTreeRendererListener​(GVTTreeRendererListener l)
      Adds a GVTTreeRendererListener to this component.
      void addJGVTComponentListener​(JGVTComponentListener listener)  
      protected boolean computeRenderingTransform()
      Computes the initial value of the transform used for rendering.
      protected AWTEventDispatcher createEventDispatcher()  
      protected ImageRenderer createImageRenderer()
      Creates a new renderer.
      protected JGVTComponent.Listener createListener()
      Creates an instance of Listener.
      protected TextSelectionManager createTextSelectionManager​(EventDispatcher ed)  
      void deselectAll()
      Deselects all.
      void flush()
      Flush any cached image data (preliminary interface, may be removed or modified in the future).
      void flush​(java.awt.Rectangle r)
      Flush a rectangle of cached image data (preliminary interface, may be removed or modified in the future).
      boolean getDisableInteractions()
      Returns true if all 'interactor' objects (pan, zoom, etc) are disabled.
      boolean getDoubleBufferedRendering()
      Tells whether this component use double buffering to render SVG documents.
      GraphicsNode getGraphicsNode()
      Returns the root of the GVT tree displayed by this component, if any.
      java.awt.geom.AffineTransform getInitialTransform()
      Returns the initial transform.
      java.util.List getInteractors()
      Returns the interactor list.
      java.awt.image.BufferedImage getOffScreen()
      Returns the off-screen image, if any.
      java.util.List getOverlays()
      Returns the overlay list.
      java.awt.geom.AffineTransform getPaintingTransform()
      Returns the current painting transform.
      boolean getProgressivePaint()
      Tells whether the progressive paint is enabled.
      java.awt.geom.AffineTransform getRenderingTransform()
      Returns the current rendering transform.
      java.awt.Rectangle getRenderRect()  
      java.awt.Color getSelectionOverlayColor()
      Returns the color of the selection overlay.
      java.awt.Color getSelectionOverlayStrokeColor()
      Returns the color of the outline of the selection overlay.
      TextSelectionManager getTextSelectionManager()
      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.
      protected void handleException​(java.lang.Exception e)
      Handles an exception.
      void immediateRepaint()
      Repaints immediately the component.
      protected void initializeEventHandling()
      Initializes the event handling classes.
      boolean isSelectionOverlayXORMode()
      Returns true if the selection overlay is painted in XOR mode, false otherwise.
      void paintComponent​(java.awt.Graphics g)
      Paints this component.
      protected void releaseRenderingReferences()
      Releases the references to the rendering resources,
      void removeGVTTreeRendererListener​(GVTTreeRendererListener l)
      Removes a GVTTreeRendererListener from this component.
      void removeJGVTComponentListener​(JGVTComponentListener listener)  
      protected void renderGVTTree()
      Renders the GVT tree.
      void resetRenderingTransform()
      Resets the rendering transform to its initial value.
      protected void scheduleGVTRendering()
      Schedules a new GVT rendering.
      void select​(Mark start, Mark end)
      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 setGraphicsNode​(GraphicsNode gn)
      Sets the GVT tree to display.
      protected void setGraphicsNode​(GraphicsNode gn, boolean createDispatcher)
      Sets the GVT tree to display.
      void setPaintingTransform​(java.awt.geom.AffineTransform at)
      Sets the painting transform.
      void setProgressivePaint​(boolean b)
      Whether to enable the progressive paint.
      void setRenderingTransform​(java.awt.geom.AffineTransform at)
      Sets the rendering transform.
      void setRenderingTransform​(java.awt.geom.AffineTransform at, boolean performRedraw)  
      void setSelectionOverlayColor​(java.awt.Color color)
      Sets the color of the selection overlay to the specified color.
      void setSelectionOverlayStrokeColor​(java.awt.Color color)
      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 stopProcessing()
      Stops the processing of the current tree.
      protected boolean updateRenderingTransform()
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • gvtTreeRenderer

        protected GVTTreeRenderer gvtTreeRenderer
        The GVT tree renderer.
      • gvtRoot

        protected GraphicsNode gvtRoot
        The GVT tree root.
      • 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.
      • 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

      • 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.
      • 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.
      • 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 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 java.awt.Rectangle getRenderRect()
      • immediateRepaint

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

        public void paintComponent​(java.awt.Graphics g)
        Paints this component.
        Overrides:
        paintComponent in class javax.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.