Class JSVGCanvas

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JSVGViewerFrame.Canvas

public class JSVGCanvas extends JSVGComponent
This class represents a general-purpose swing SVG component. The JSVGCanvas does not provided additional functionalities compared to the JSVGComponent but simply provides an API conformed to the JavaBean specification. The only major change between the JSVGComponent and this component is that interactors and text selection are activated by default.
See Also:
  • Field Details

    • SCROLL_RIGHT_ACTION

      public static final String SCROLL_RIGHT_ACTION
      The key for the Action to scroll right.
      See Also:
    • SCROLL_LEFT_ACTION

      public static final String SCROLL_LEFT_ACTION
      The key for the Action to scroll left.
      See Also:
    • SCROLL_UP_ACTION

      public static final String SCROLL_UP_ACTION
      The key for the Action to scroll up.
      See Also:
    • SCROLL_DOWN_ACTION

      public static final String SCROLL_DOWN_ACTION
      The key for the Action to scroll down.
      See Also:
    • FAST_SCROLL_RIGHT_ACTION

      public static final String FAST_SCROLL_RIGHT_ACTION
      The key for the Action to quickly scroll right.
      See Also:
    • FAST_SCROLL_LEFT_ACTION

      public static final String FAST_SCROLL_LEFT_ACTION
      The key for the Action to quickly scroll left.
      See Also:
    • FAST_SCROLL_UP_ACTION

      public static final String FAST_SCROLL_UP_ACTION
      The key for the Action to quickly scroll up.
      See Also:
    • FAST_SCROLL_DOWN_ACTION

      public static final String FAST_SCROLL_DOWN_ACTION
      The key for the Action to quickly scroll down.
      See Also:
    • ZOOM_IN_ACTION

      public static final String ZOOM_IN_ACTION
      The key for the Action to zoom in.
      See Also:
    • ZOOM_OUT_ACTION

      public static final String ZOOM_OUT_ACTION
      The key for the Action to zoom out.
      See Also:
    • RESET_TRANSFORM_ACTION

      public static final String RESET_TRANSFORM_ACTION
      The key for the Action to reset the transform.
      See Also:
    • pcs

      protected PropertyChangeSupport pcs
      The PropertyChangeSupport used to fire PropertyChangeEvent.
    • uri

      protected String uri
      The URI of the current document being displayed.
    • locationListener

      protected JSVGCanvas.LocationListener locationListener
      Keeps track of the last known mouse position over the canvas. This is used for displaying tooltips at the right location.
    • toolTipMap

      protected Map toolTipMap
      Mapping of elements to listeners so they can be removed, if the tooltip is removed.
    • toolTipListener

      protected EventListener toolTipListener
    • lastTarget

      protected EventTarget lastTarget
    • toolTipDocs

      protected Map toolTipDocs
    • MAP_TOKEN

      protected static final Object MAP_TOKEN
      This is used as the value in the toolTipDocs WeakHashMap. This way we can tell if a document has already been added.
    • lastToolTipEventTimeStamp

      protected long lastToolTipEventTimeStamp
      The time of the last tool tip event.
    • lastToolTipEventTarget

      protected EventTarget lastToolTipEventTarget
      The target for which the last tool tip event was fired.
    • zoomInteractor

      protected Interactor zoomInteractor
      An interactor to perform a zoom.

      Binding: BUTTON1 + CTRL Key

    • imageZoomInteractor

      protected Interactor imageZoomInteractor
      An interactor to perform a realtime zoom.

      Binding: BUTTON3 + SHIFT Key

    • panInteractor

      protected Interactor panInteractor
      An interactor to perform a translation.

      Binding: BUTTON1 + SHIFT Key

    • rotateInteractor

      protected Interactor rotateInteractor
      An interactor to perform a rotation.

      Binding: BUTTON3 + CTRL Key

    • resetTransformInteractor

      protected Interactor resetTransformInteractor
      An interactor to reset the rendering transform.

      Binding: CTRL+SHIFT+BUTTON3

  • Constructor Details

    • JSVGCanvas

      public JSVGCanvas()
      Creates a new JSVGCanvas.
    • JSVGCanvas

      public JSVGCanvas(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText)
      Creates a new JSVGCanvas.
      Parameters:
      ua - a SVGUserAgent instance or null.
      eventsEnabled - Whether the GVT tree should be reactive to mouse and key events.
      selectableText - Whether the text should be selectable.
  • Method Details

    • installActions

      protected void installActions()
      Builds the ActionMap of this canvas with a set of predefined Actions.
    • setDisableInteractions

      public void setDisableInteractions(boolean b)
      Description copied from class: JGVTComponent
      Turn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.
      Overrides:
      setDisableInteractions in class JSVGComponent
    • installKeyboardActions

      protected void installKeyboardActions()
      Builds the InputMap of this canvas with a set of predefined Actions.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener pcl)
      Adds the specified PropertyChangeListener.
      Overrides:
      addPropertyChangeListener in class Container
      Parameters:
      pcl - the property change listener to add
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener pcl)
      Removes the specified PropertyChangeListener.
      Overrides:
      removePropertyChangeListener in class Component
      Parameters:
      pcl - the property change listener to remove
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener pcl)
      Adds the specified PropertyChangeListener for the specified property.
      Overrides:
      addPropertyChangeListener in class Container
      Parameters:
      propertyName - the name of the property to listen on
      pcl - the property change listener to add
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propertyName, PropertyChangeListener pcl)
      Removes the specified PropertyChangeListener for the specified property.
      Overrides:
      removePropertyChangeListener in class Component
      Parameters:
      propertyName - the name of the property that was listened on
      pcl - the property change listener to remove
    • setEnableZoomInteractor

      public void setEnableZoomInteractor(boolean b)
      Determines whether the zoom interactor is enabled or not.
    • getEnableZoomInteractor

      public boolean getEnableZoomInteractor()
      Returns true if the zoom interactor is enabled, false otherwise.
    • setEnableImageZoomInteractor

      public void setEnableImageZoomInteractor(boolean b)
      Determines whether the image zoom interactor is enabled or not.
    • getEnableImageZoomInteractor

      public boolean getEnableImageZoomInteractor()
      Returns true if the image zoom interactor is enabled, false otherwise.
    • setEnablePanInteractor

      public void setEnablePanInteractor(boolean b)
      Determines whether the pan interactor is enabled or not.
    • getEnablePanInteractor

      public boolean getEnablePanInteractor()
      Returns true if the pan interactor is enabled, false otherwise.
    • setEnableRotateInteractor

      public void setEnableRotateInteractor(boolean b)
      Determines whether the rotate interactor is enabled or not.
    • getEnableRotateInteractor

      public boolean getEnableRotateInteractor()
      Returns true if the rotate interactor is enabled, false otherwise.
    • setEnableResetTransformInteractor

      public void setEnableResetTransformInteractor(boolean b)
      Determines whether the reset transform interactor is enabled or not.
    • getEnableResetTransformInteractor

      public boolean getEnableResetTransformInteractor()
      Returns true if the reset transform interactor is enabled, false otherwise.
    • getURI

      public String getURI()
      Returns the URI of the current document.
    • setURI

      public void setURI(String newURI)
      Sets the URI to the specified uri. If the input 'newURI' string is null, then the canvas will display an empty document.
      Parameters:
      newURI - the new uri of the document to display
    • createUserAgent

      protected UserAgent createUserAgent()
      Creates a UserAgent.
      Overrides:
      createUserAgent in class JSVGComponent
    • createListener

      protected JGVTComponent.Listener createListener()
      Creates an instance of Listener.
      Overrides:
      createListener in class JSVGComponent
    • installSVGDocument

      protected void installSVGDocument(org.w3c.dom.svg.SVGDocument doc)
      Description copied from class: JSVGComponent
      This does the real work of installing the SVG Document after the update manager from the previous document (if any) has been properly 'shut down'.
      Overrides:
      installSVGDocument in class JSVGComponent
    • setLastToolTipEvent

      public void setLastToolTipEvent(long t, EventTarget et)
      Sets the time and element of the last tool tip event handled.
    • matchLastToolTipEvent

      public boolean matchLastToolTipEvent(long t, EventTarget et)
      Checks if the specified event time and element are the same as the last tool tip event.