org.apache.batik.swing.svg
Class JSVGComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.apache.batik.swing.gvt.JGVTComponent
                          |
                          +--org.apache.batik.swing.svg.JSVGComponent
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
JSVGCanvas

public class JSVGComponent
extends JGVTComponent

This class represents a Swing component which can display SVG.

See Also:
Serialized Form

Inner Class Summary
protected  class JSVGComponent.BridgeUserAgent
          To hide the user-agent methods.
protected  class JSVGComponent.SVGListener
          To hide the listener methods.
 
Inner classes inherited from class org.apache.batik.swing.gvt.JGVTComponent
JGVTComponent.Listener
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  BridgeContext bridgeContext
          The current bridge context.
protected  SVGDocumentLoader documentLoader
          The document loader.
protected static java.util.Set FEATURES
           
protected  java.lang.String fragmentIdentifier
          The current document fragment identifier.
protected  GVTTreeBuilder gvtTreeBuilder
          The GVT tree builder.
protected  java.util.List gvtTreeBuilderListeners
          The GVT tree builder listeners.
protected  java.util.List linkActivationListeners
          The link activation listeners.
protected  DocumentLoader loader
          The concrete bridge document loader.
protected  SVGDocumentLoader nextDocumentLoader
          The next document loader to run.
protected  GVTTreeBuilder nextGVTTreeBuilder
          The next GVT tree builder to run.
protected  SVGDocument svgDocument
          The current SVG document.
protected  java.util.List svgDocumentLoaderListeners
          The document loader listeners.
protected  SVGUserAgent svgUserAgent
          The SVG user agent.
protected  UserAgent userAgent
          The user agent.
 
Fields inherited from class org.apache.batik.swing.gvt.JGVTComponent
disableInteractions, doubleBufferedRendering, eventDispatcher, eventsEnabled, gvtRoot, gvtTreeRenderer, gvtTreeRendererListeners, image, initialTransform, interactor, interactors, listener, needRender, overlays, paintingTransform, progressivePaint, progressivePaintThread, renderer, rendererFactory, renderingTransform, selectableText, suspendInteractions, textSelectionManager
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
JSVGComponent()
          Creates a new JSVGComponent.
JSVGComponent(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText)
          Creates a new JSVGComponent.
 
Method Summary
 void addGVTTreeBuilderListener(GVTTreeBuilderListener l)
          Adds a GVTTreeBuilderListener to this component.
 void addLinkActivationListener(LinkActivationListener l)
          Adds a LinkActivationListener to this component.
 void addSVGDocumentLoaderListener(SVGDocumentLoaderListener l)
          Adds a SVGDocumentLoaderListener to this component.
protected  void computeRenderingTransform()
          Computes the transform used for rendering.
protected  BridgeContext createBridgeContext()
          Creates a new bridge context.
protected  JGVTComponent.Listener createListener()
          Creates an instance of Listener.
protected  UserAgent createUserAgent()
          Creates a UserAgent.
 java.lang.String getFragmentIdentifier()
          Returns the current's document fragment identifier.
 SVGDocument getSVGDocument()
          Returns the current SVG document.
 java.awt.geom.Dimension2D getSVGDocumentSize()
          Returns the size of the SVG document.
protected  void handleException(java.lang.Exception e)
          Handles an exception.
 void loadSVGDocument(java.lang.String url)
          Loads a SVG document from the given URL.
 void removeGVTTreeBuilderListener(GVTTreeBuilderListener l)
          Removes a GVTTreeBuilderListener from this component.
 void removeLinkActivationListener(LinkActivationListener l)
          Removes a LinkActivationListener from this component.
 void removeSVGDocumentLoaderListener(SVGDocumentLoaderListener l)
          Removes a SVGDocumentLoaderListener from this component.
 void setFragmentIdentifier(java.lang.String fi)
          Sets the current fragment identifier.
 void setSVGDocument(SVGDocument doc)
          Sets the SVG document to display.
 void stopProcessing()
          Stops the processing of the current document.
protected  void updateRenderingTransform()
          Updates the value of the transform used for rendering.
 
Methods inherited from class org.apache.batik.swing.gvt.JGVTComponent
addGVTTreeRendererListener, getDoubleBufferedRendering, getGraphicsNode, getInteractors, getOffScreen, getOverlays, getPaintingTransform, getProgressivePaint, getRenderContext, getRenderingTransform, immediateRepaint, initializeEventHandling, paintComponent, releaseRenderingReferences, removeGVTTreeRendererListener, renderGVTTree, resetRenderingTransform, scheduleGVTRendering, setDoubleBufferedRendering, setGraphicsNode, setGraphicsNode, setPaintingTransform, setProgressivePaint, setRenderingTransform
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

documentLoader

protected SVGDocumentLoader documentLoader
The document loader.

nextDocumentLoader

protected SVGDocumentLoader nextDocumentLoader
The next document loader to run.

loader

protected DocumentLoader loader
The concrete bridge document loader.

gvtTreeBuilder

protected GVTTreeBuilder gvtTreeBuilder
The GVT tree builder.

nextGVTTreeBuilder

protected GVTTreeBuilder nextGVTTreeBuilder
The next GVT tree builder to run.

svgDocument

protected SVGDocument svgDocument
The current SVG document.

svgDocumentLoaderListeners

protected java.util.List svgDocumentLoaderListeners
The document loader listeners.

gvtTreeBuilderListeners

protected java.util.List gvtTreeBuilderListeners
The GVT tree builder listeners.

linkActivationListeners

protected java.util.List linkActivationListeners
The link activation listeners.

userAgent

protected UserAgent userAgent
The user agent.

svgUserAgent

protected SVGUserAgent svgUserAgent
The SVG user agent.

bridgeContext

protected BridgeContext bridgeContext
The current bridge context.

fragmentIdentifier

protected java.lang.String fragmentIdentifier
The current document fragment identifier.

FEATURES

protected static final java.util.Set FEATURES
Constructor Detail

JSVGComponent

public JSVGComponent()
Creates a new JSVGComponent.

JSVGComponent

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

stopProcessing

public void stopProcessing()
Stops the processing of the current document.
Overrides:
stopProcessing in class JGVTComponent

loadSVGDocument

public void loadSVGDocument(java.lang.String url)
Loads a SVG document from the given URL. Note: Because the loading is multi-threaded, the current SVG document is not garanteed to be updated after this method returns. The only way to be notified a document has been loaded is to listen to the SVGDocumentLoaderEvents.

setSVGDocument

public void setSVGDocument(SVGDocument doc)
Sets the SVG document to display.

getSVGDocument

public SVGDocument getSVGDocument()
Returns the current SVG document.

getSVGDocumentSize

public java.awt.geom.Dimension2D getSVGDocumentSize()
Returns the size of the SVG document.

getFragmentIdentifier

public java.lang.String getFragmentIdentifier()
Returns the current's document fragment identifier.

setFragmentIdentifier

public void setFragmentIdentifier(java.lang.String fi)
Sets the current fragment identifier.

createBridgeContext

protected BridgeContext createBridgeContext()
Creates a new bridge context.

computeRenderingTransform

protected void computeRenderingTransform()
Computes the transform used for rendering.
Overrides:
computeRenderingTransform in class JGVTComponent

updateRenderingTransform

protected void updateRenderingTransform()
Updates the value of the transform used for rendering.
Overrides:
updateRenderingTransform in class JGVTComponent

handleException

protected void handleException(java.lang.Exception e)
Handles an exception.
Overrides:
handleException in class JGVTComponent

addSVGDocumentLoaderListener

public void addSVGDocumentLoaderListener(SVGDocumentLoaderListener l)
Adds a SVGDocumentLoaderListener to this component.

removeSVGDocumentLoaderListener

public void removeSVGDocumentLoaderListener(SVGDocumentLoaderListener l)
Removes a SVGDocumentLoaderListener from this component.

addGVTTreeBuilderListener

public void addGVTTreeBuilderListener(GVTTreeBuilderListener l)
Adds a GVTTreeBuilderListener to this component.

removeGVTTreeBuilderListener

public void removeGVTTreeBuilderListener(GVTTreeBuilderListener l)
Removes a GVTTreeBuilderListener from this component.

addLinkActivationListener

public void addLinkActivationListener(LinkActivationListener l)
Adds a LinkActivationListener to this component.

removeLinkActivationListener

public void removeLinkActivationListener(LinkActivationListener l)
Removes a LinkActivationListener from this component.

createListener

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

createUserAgent

protected UserAgent createUserAgent()
Creates a UserAgent.


Copyright © 2001 Apache Software Foundation. All Rights Reserved.