Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 that can display SVG documents. This component also lets you translate, zoom and rotate the document being displayed. This is the fundamental class for rendering SVG documents in a swing application.

## Rendering Process

The rendering process can be broken down into five phases. Not all of those steps are required - depending on the method used to specify the SVG document to display, but basically the steps in the rendering process are:

1. Building a DOM tree

   > If the ``loadSVGDocument(String)`` method is used, the SVG file is parsed and an SVG DOM Tree is built.

2. Building a GVT tree

   > Once an SVGDocument is created (using the step 1 or if the ``setSVGDocument(SVGDocument)`` method has been used) - a GVT tree is constructed. The GVT tree is the data structure used internally to render an SVG document. see the ``org.apache.batik.gvt` package.`

3. Executing the SVGLoad event handlers

   > If the document is dynamic, the scripts are initialized and the SVGLoad event is dispatched before the initial rendering.

4. Rendering the GVT tree

   > Then the GVT tree is rendered. see the ``org.apache.batik.gvt.renderer`` package.

5. Running the document

   > If the document is dynamic, the update threads are started.

Those steps are performed in a separate thread. To be notified to what happens and eventually perform some operations - such as resizing the window to the size of the document or get the SVGDocument built via a URI, five different listeners are provided (one per step): ``SVGDocumentLoaderListener``, ``GVTTreeBuilderListener``, ``SVGLoadEventDispatcherListener``, ``GVTTreeRendererListener``, ``UpdateManagerListener``.

Each listener has methods to be notified of the start of a phase, and methods to be notified of the end of a phase. A phase cannot start before the preceding has finished.

The following example shows how you can get the size of an SVG document. Note that due to how SVG is designed (units, percentages...), the size of an SVG document can be known only once the SVGDocument has been analyzed (ie. the GVT tree has been constructed).

     final JSVGComponent svgComp = new JSVGComponent();
     svgComp.loadSVGDocument("foo.svg");
     svgComp.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
         public void gvtBuildCompleted(GVTTreeBuilderEvent evt) {
             Dimension2D size = svgComp.getSVGDocumentSize();
             // ...
         }
     });

The second example shows how you can access to the DOM tree when a URI has been used to display an SVG document.

     final JSVGComponent svgComp = new JSVGComponent();
     svgComp.loadSVGDocument("foo.svg");
     svgComp.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
         public void documentLoadingCompleted(SVGDocumentLoaderEvent evt) {
             SVGDocument svgDoc = svgComp.getSVGDocument();
             //...
         }
     });

Conformed to the single thread rule of swing, the listeners are executed in the swing thread. The sequence of the method calls for a particular listener and the order of the listeners themselves are guaranteed.

## User Agent

The `JSVGComponent` can pick up some informations to a user agent. The ``SVGUserAgent`` provides a way to control the resolution used to display an SVG document (controling the pixel to millimeter conversion factor), perform an operation in respond to a click on an hyperlink, control the default language to use, or specify a user stylesheet, or how to display errors when an error occured while building/rendering a document (invalid XML file, missing attributes...).

See Also:
  Serialized Form

Nested Class Summary
`protected class` | `JSVGComponent.BridgeUserAgent` To hide the user-agent methods.
`protected static class` | `JSVGComponent.BridgeUserAgentWrapper` The user-agent wrapper, which call the methods in the event thread.
`protected class` | `JSVGComponent.JSVGComponentListener`
`protected class` | `JSVGComponent.SVGListener` To hide the listener methods.

Nested classes inherited from class org.apache.batik.swing.gvt.JGVTComponent
`JGVTComponent.Listener`

Nested classes inherited from class javax.swing.JComponent
`javax.swing.JComponent.AccessibleJComponent`

Nested classes inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Nested classes inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

Field Summary
`protected java.lang.Runnable` | `afterStopRunnable`
`static int` | `ALWAYS_DYNAMIC` Means that all document must be considered as dynamic.
`static int` | `ALWAYS_INTERACTIVE` Means that all document must be considered as interactive.
`static int` | `ALWAYS_STATIC` Means that all document must be considered as static.
`static int` | `AUTODETECT` Means that the component must auto detect whether the current document is static or dynamic.
`protected BridgeContext` | `bridgeContext` The current bridge context.
`protected SVGDocumentLoader` | `documentLoader` The document loader.
`protected int` | `documentState` The document state.
`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 boolean` | `isDynamicDocument` Whether the current document has dynamic features.
`protected boolean` | `isInteractiveDocument` Whether the current document has dynamic features.
`protected JSVGComponent.JSVGComponentListener` | `jsvgComponentListener` The JGVTComponentListener.
`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 UpdateManager` | `nextUpdateManager` The next update manager.
`protected java.awt.Dimension` | `prevComponentSize`
`protected boolean` | `recenterOnResize`
`protected SVGDocument` | `svgDocument` The current SVG document.
`protected java.util.List` | `svgDocumentLoaderListeners` The document loader listeners.
`protected SVGLoadEventDispatcher` | `svgLoadEventDispatcher` The SVGLoadEventDispatcher.
`protected java.util.List` | `svgLoadEventDispatcherListeners` The SVG onload dispatcher listeners.
`protected SVGUserAgent` | `svgUserAgent` The SVG user agent.
`protected UpdateManager` | `updateManager` The update manager.
`protected java.util.List` | `updateManagerListeners` The update manager listeners.
`protected SVGUpdateOverlay` | `updateOverlay`
`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, jgvtListeners, 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.
`void` | `addSVGLoadEventDispatcherListener(SVGLoadEventDispatcherListener l)` Adds a SVGLoadEventDispatcherListener to this component.
`void` | `addUpdateManagerListener(UpdateManagerListener l)` Adds a UpdateManagerListener to this component.
`protected java.awt.geom.AffineTransform` | `calculateViewingTransform(java.lang.String fragIdent, SVGSVGElement svgElt)`
`protected boolean` | `computeRenderingTransform()` Computes the transform used for rendering.
`protected BridgeContext` | `createBridgeContext()` Creates a new bridge context.
`protected ImageRenderer` | `createImageRenderer()` Creates a new renderer.
`protected JGVTComponent.Listener` | `createListener()` Creates an instance of Listener.
`protected UserAgent` | `createUserAgent()` Creates a UserAgent.
`void` | `dispose()`
`void` | `flushImageCache()` Removes all images from the image cache.
`CanvasGraphicsNode` | `getCanvasGraphicsNode()`
`protected CanvasGraphicsNode` | `getCanvasGraphicsNode(GraphicsNode gn)`
`java.lang.String` | `getFragmentIdentifier()` Returns the current's document fragment identifier.
`boolean` | `getRecenterOnResize()` Indicates if the canvas should recenter the content after the canvas is resized.
`SVGDocument` | `getSVGDocument()` Returns the current SVG document.
`java.awt.geom.Dimension2D` | `getSVGDocumentSize()` Returns the size of the SVG document.
`UpdateManager` | `getUpdateManager()` Returns the current update manager.
`java.awt.geom.AffineTransform` | `getViewBoxTransform()` Returns the transform from viewBox coords to screen coords
`protected void` | `handleException(java.lang.Exception e)` Handles an exception.
`protected void` | `installSVGDocument(SVGDocument doc)` 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'.
`boolean` | `isDynamic()` Tells whether the component use dynamic features to process the current document.
`boolean` | `isInteractive()` Tells whether the component use dynamic features to process the current document.
`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` | `removeSVGLoadEventDispatcherListener(SVGLoadEventDispatcherListener l)` Removes a SVGLoadEventDispatcherListener from this component.
`void` | `removeUpdateManagerListener(UpdateManagerListener l)` Removes a UpdateManagerListener from this component.
`protected void` | `renderGVTTree()` Renders the GVT tree.
`void` | `resumeProcessing()` Resumes the processing of the current document.
`void` | `setDocument(org.w3c.dom.Document doc)` Sets the Document to display.
`void` | `setDocumentState(int state)` Sets the document state.
`void` | `setFragmentIdentifier(java.lang.String fi)` Sets the current fragment identifier.
`void` | `setGraphicsNode(GraphicsNode gn, boolean createDispatcher)` Sets the GVT tree to display.
`void` | `setMySize(java.awt.Dimension d)` This method is called when the component knows the desired size of the window (based on width/height of outermost SVG element).
`void` | `setRecenterOnResize(boolean recenterOnResize)` Returns sate of the recenter on resize flag.
`void` | `setSVGDocument(SVGDocument doc)` Sets the SVGDocument to display.
`void` | `showAlert(java.lang.String message)` Shows an alert dialog box.
`boolean` | `showConfirm(java.lang.String message)` Shows a confirm dialog box.
`java.lang.String` | `showPrompt(java.lang.String message)` Shows a prompt dialog box.
`java.lang.String` | `showPrompt(java.lang.String message, java.lang.String defaultValue)` Shows a prompt dialog box.
`protected void` | `startSVGLoadEventDispatcher(GraphicsNode root)` Starts a SVGLoadEventDispatcher thread.
`void` | `stopProcessing()` Stops the processing of the current document.
`protected void` | `stopThenRun(java.lang.Runnable r)` This method calls stop processing waits for all threads to die then runs the Runnable in the event queue thread.
`void` | `suspendProcessing()` Suspend the processing of the current document.
`protected boolean` | `updateRenderingTransform()` Updates the value of the transform used for rendering.

Methods inherited from class org.apache.batik.swing.gvt.JGVTComponent
`addGVTTreeRendererListener, addJGVTComponentListener, deselectAll, flush, flush, getDisableInteractions, getDoubleBufferedRendering, getGraphicsNode, getInitialTransform, getInteractors, getOffScreen, getOverlays, getPaintingTransform, getProgressivePaint, getRenderingTransform, getRenderRect, getSelectionOverlayColor, getSelectionOverlayStrokeColor, immediateRepaint, initializeEventHandling, isSelectionOverlayXORMode, paintComponent, releaseRenderingReferences, removeGVTTreeRendererListener, removeJGVTComponentListener, resetRenderingTransform, scheduleGVTRendering, select, setDisableInteractions, setDoubleBufferedRendering, setGraphicsNode, setPaintingTransform, setProgressivePaint, setRenderingTransform, setRenderingTransform, setSelectionOverlayColor, setSelectionOverlayStrokeColor, setSelectionOverlayXORMode`

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, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### AUTODETECT

    public static final int AUTODETECT

  Means that the component must auto detect whether the current document is static or dynamic.

  See Also:
    Constant Field Values

### ALWAYS_DYNAMIC

    public static final int ALWAYS_DYNAMIC

  Means that all document must be considered as dynamic.

  See Also:
    Constant Field Values

### ALWAYS_STATIC

    public static final int ALWAYS_STATIC

  Means that all document must be considered as static.

  See Also:
    Constant Field Values

### ALWAYS_INTERACTIVE

    public static final int ALWAYS_INTERACTIVE

  Means that all document must be considered as interactive.

  See Also:
    Constant Field Values

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

### svgLoadEventDispatcher

    protected SVGLoadEventDispatcher svgLoadEventDispatcher

  The SVGLoadEventDispatcher.

### updateManager

    protected UpdateManager updateManager

  The update manager.

### nextUpdateManager

    protected UpdateManager nextUpdateManager

  The next update manager.

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

### svgLoadEventDispatcherListeners

    protected java.util.List svgLoadEventDispatcherListeners

  The SVG onload dispatcher listeners.

### linkActivationListeners

    protected java.util.List linkActivationListeners

  The link activation listeners.

### updateManagerListeners

    protected java.util.List updateManagerListeners

  The update manager 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.

### isDynamicDocument

    protected boolean isDynamicDocument

  Whether the current document has dynamic features.

### isInteractiveDocument

    protected boolean isInteractiveDocument

  Whether the current document has dynamic features.

### documentState

    protected int documentState

  The document state.

### prevComponentSize

    protected java.awt.Dimension prevComponentSize

### afterStopRunnable

    protected java.lang.Runnable afterStopRunnable

### updateOverlay

    protected SVGUpdateOverlay updateOverlay

### recenterOnResize

    protected boolean recenterOnResize

### jsvgComponentListener

    protected JSVGComponent.JSVGComponentListener jsvgComponentListener

  The JGVTComponentListener.

### 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.
  `selectableText` - Whether the text should be selectable.

Method Detail

### dispose

    public void dispose()

### getRecenterOnResize

    public boolean getRecenterOnResize()

  Indicates if the canvas should recenter the content after the canvas is resized. If true it will try and keep the point that was at the center at the center after resize. Otherwise the upper left corner will be kept at the same point.

### setRecenterOnResize

    public void setRecenterOnResize(boolean recenterOnResize)

  Returns sate of the recenter on resize flag.

### isDynamic

    public boolean isDynamic()

  Tells whether the component use dynamic features to process the current document.

### isInteractive

    public boolean isInteractive()

  Tells whether the component use dynamic features to process the current document.

### setDocumentState

    public void setDocumentState(int state)

  Sets the document state. The given value must be one of AUTODETECT, ALWAYS_DYNAMIC or ALWAYS_STATIC. This only effects the loading of subsequent documents, it has no effect on the currently loaded document.

### getUpdateManager

    public UpdateManager getUpdateManager()

  Returns the current update manager. The update manager becomes available after the first rendering completes. You can be notifed when the rendering completes by registering a GVTTreeRendererListener with the component and waiting for the `gvtRenderingCompleted` event. An UpdateManager is only created for Dynamic documents. By default the Canvas attempts to autodetect dynamic documents by looking for script elements and/or event attributes in the document, if it does not find these it assumes the document is static. Callers of this method will almost certainly want to call setDocumentState(ALWAYS_DYNAMIC) before loading the document (with setURI, setDocument, setSVGDocument etc.) so that an UpdateManager is always created (even for apparently static documents).

### resumeProcessing

    public void resumeProcessing()

  Resumes the processing of the current document.

### suspendProcessing

    public void suspendProcessing()

  Suspend the processing of the current document.

### 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 `SVGDocumentLoaderEvent`s.

### setDocument

    public void setDocument(org.w3c.dom.Document doc)

  Sets the Document to display. If the document does not use Batik's SVG DOM Implemenation it will be cloned into that implementation. In this case you should use 'getSVGDocument()' to get the actual DOM that is attached to the rendering interface. Note that the prepartation for rendering and the rendering it's self occur asynchronously so you need to register event handlers if you want to know when the document is truely displayed. Notes for documents that you want to change in Java: From this point on you may only modify the the document in the UpdateManager thread @see #getUpdateManager. In many cases you also need to tell Batik to treat the document as a dynamic document by calling setDocumentState(ALWAYS_DYNAMIC).

### setSVGDocument

    public void setSVGDocument(SVGDocument doc)

  Sets the SVGDocument to display. If the document does not use Batik's SVG DOM Implemenation it will be cloned into that implementation. In this case you should use 'getSVGDocument()' to get the actual DOM that is attached to the rendering interface. Note that the prepartation for rendering and the rendering it's self occur asynchronously so you need to register event handlers if you want to know when the document is truely displayed. Notes for documents that you want to change in Java. From this point on you may only modify the the document in the UpdateManager thread @see #getUpdateManager. In many cases you also need to tell Batik to treat the document as a dynamic document by calling setDocumentState(ALWAYS_DYNAMIC).

### stopThenRun

    protected void stopThenRun(java.lang.Runnable r)

  This method calls stop processing waits for all threads to die then runs the Runnable in the event queue thread. It returns immediately.

### installSVGDocument

    protected void installSVGDocument(SVGDocument doc)

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

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

### flushImageCache

    public void flushImageCache()

  Removes all images from the image cache.

### setGraphicsNode

    public void setGraphicsNode(GraphicsNode gn,
                                boolean createDispatcher)

  Description copied from class: `JGVTComponent`
  Sets the GVT tree to display.

  Overrides:
    `setGraphicsNode` in class `JGVTComponent`

### createBridgeContext

    protected BridgeContext createBridgeContext()

  Creates a new bridge context.

### startSVGLoadEventDispatcher

    protected void startSVGLoadEventDispatcher(GraphicsNode root)

  Starts a SVGLoadEventDispatcher thread.

### createImageRenderer

    protected ImageRenderer createImageRenderer()

  Creates a new renderer.

  Overrides:
    `createImageRenderer` in class `JGVTComponent`

### getCanvasGraphicsNode

    public CanvasGraphicsNode getCanvasGraphicsNode()

### getCanvasGraphicsNode

    protected CanvasGraphicsNode getCanvasGraphicsNode(GraphicsNode gn)

### getViewBoxTransform

    public java.awt.geom.AffineTransform getViewBoxTransform()

  Returns the transform from viewBox coords to screen coords

### computeRenderingTransform

    protected boolean computeRenderingTransform()

  Computes the transform used for rendering. Returns true if the component needs to be repainted.

  Overrides:
    `computeRenderingTransform` in class `JGVTComponent`

### calculateViewingTransform

    protected java.awt.geom.AffineTransform calculateViewingTransform(java.lang.String fragIdent,
                                                                      SVGSVGElement svgElt)

### updateRenderingTransform

    protected boolean updateRenderingTransform()

  Updates the value of the transform used for rendering. Return true if a repaint is required, otherwise false.

  Overrides:
    `updateRenderingTransform` in class `JGVTComponent`

### renderGVTTree

    protected void renderGVTTree()

  Renders the GVT tree.

  Overrides:
    `renderGVTTree` 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.

### addSVGLoadEventDispatcherListener

    public void addSVGLoadEventDispatcherListener(SVGLoadEventDispatcherListener l)

  Adds a SVGLoadEventDispatcherListener to this component.

### removeSVGLoadEventDispatcherListener

    public void removeSVGLoadEventDispatcherListener(SVGLoadEventDispatcherListener l)

  Removes a SVGLoadEventDispatcherListener 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.

### addUpdateManagerListener

    public void addUpdateManagerListener(UpdateManagerListener l)

  Adds a UpdateManagerListener to this component.

### removeUpdateManagerListener

    public void removeUpdateManagerListener(UpdateManagerListener l)

  Removes a UpdateManagerListener from this component.

### showAlert

    public void showAlert(java.lang.String message)

  Shows an alert dialog box.

### showPrompt

    public java.lang.String showPrompt(java.lang.String message)

  Shows a prompt dialog box.

### showPrompt

    public java.lang.String showPrompt(java.lang.String message,
                                       java.lang.String defaultValue)

  Shows a prompt dialog box.

### showConfirm

    public boolean showConfirm(java.lang.String message)

  Shows a confirm dialog box.

### setMySize

    public void setMySize(java.awt.Dimension d)

  This method is called when the component knows the desired size of the window (based on width/height of outermost SVG element). The default implementation simply calls setPreferredSize, and invalidate. However it is often useful to pack the window containing this component.

### createListener

    protected JGVTComponent.Listener createListener()

  Creates an instance of Listener.

  Overrides:
    `createListener` in class `JGVTComponent`

### createUserAgent

    protected UserAgent createUserAgent()

  Creates a UserAgent.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 Apache Software Foundation. All Rights Reserved.