Class JSVGComponent
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
- Direct Known Subclasses:
JSVGCanvas
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:
- Building a DOM tree
If the
method is used, the SVG file is parsed and an SVG DOM Tree is built.loadSVGDocument(String)
- Building a GVT tree
Once an SVGDocument is created (using the step 1 or if the
method has been used) - a GVT tree is constructed. The GVT tree is the data structure used internally to render an SVG document. see thesetSVGDocument(SVGDocument)
org.apache.batik.gvt
package. - Executing the SVGLoad event handlers
If the document is dynamic, the scripts are initialized and the SVGLoad event is dispatched before the initial rendering.
- Rendering the GVT tree
Then the GVT tree is rendered. see the
package.org.apache.batik.gvt.renderer
- 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
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...).SVGUserAgent
- Version:
- $Id: JSVGComponent.java 1831615 2018-05-15 09:50:53Z ssteiner $
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
To hide the user-agent methods.protected static class
The user-agent wrapper, which call the methods in the event thread.protected class
protected class
To hide the listener methods.Nested classes/interfaces inherited from class org.apache.batik.swing.gvt.JGVTComponent
JGVTComponent.Listener, JGVTComponent.UnixTextSelectionListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Runnable
static final int
Means that all document must be considered as dynamic.static final int
Means that all document must be considered as interactive.static final int
Means that all document must be considered as static.protected float
The amount of animation limiting.protected int
The animation limiting mode.static final int
Means that the component must auto detect whether the current document is static or dynamic.protected BridgeContext
The current bridge context.static final String
String constant for the resource with the text for the title of the info tooltip for brokin link images.protected SVGDocumentLoader
The document loader.protected int
The document state.protected static final Set
protected String
The current document fragment identifier.protected GVTTreeBuilder
The GVT tree builder.protected List
The GVT tree builder listeners.protected boolean
Whether the current document has dynamic features.protected boolean
Whether the current document has dynamic features.protected JSVGComponent.JSVGComponentListener
The JGVTComponentListener.protected List
The link activation listeners.protected DocumentLoader
The concrete bridge document loader.protected SVGDocumentLoader
The next document loader to run.protected GVTTreeBuilder
The next GVT tree builder to run.protected UpdateManager
The next update manager.protected Dimension
protected boolean
static final String
String constant for the resource with the text for a script alert dialog.static final String
String constant for the resource with the text for a script confim dialog.static final String
String constant for the resource with the text for a script prompt dialog.protected boolean
Set to true before component calls setDisableInteractors so it knows that the users isn't the one calling it.protected org.w3c.dom.svg.SVGDocument
The current SVG document.protected List
The document loader listeners.protected SVGLoadEventDispatcher
The SVGLoadEventDispatcher.protected List
The SVG onload dispatcher listeners.protected SVGUserAgent
The SVG user agent.protected UpdateManager
The update manager.protected List
The update manager listeners.protected SVGUpdateOverlay
protected UserAgent
The user agent.protected boolean
Set to true if the user ever calls setDisableInteractionsprotected AffineTransform
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, useUnixTextSelection
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
ConstructorsConstructorDescriptionCreates a new JSVGComponent.JSVGComponent
(SVGUserAgent ua, boolean eventsEnabled, boolean selectableText) Creates a new JSVGComponent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a GVTTreeBuilderListener to this component.void
Adds a LinkActivationListener to this component.void
Adds a SVGDocumentLoaderListener to this component.void
Adds a SVGLoadEventDispatcherListener to this component.void
Adds a UpdateManagerListener to this component.protected AffineTransform
calculateViewingTransform
(String fragIdent, org.w3c.dom.svg.SVGSVGElement svgElt) void
Clears the boolean that indicates the 'user' has set disable interactions so that the canvas uses the value from documents.protected boolean
Computes the transform used for rendering.protected BridgeContext
Creates a new bridge context.protected ImageRenderer
Creates a new renderer.protected JGVTComponent.Listener
Creates an instance of Listener.protected UserAgent
Creates a UserAgent.void
dispose()
void
Removes all images from the image cache.protected CanvasGraphicsNode
Returns the current's document fragment identifier.getInterpreter
(String type) Returns theInterpreter
being used for script of the given MIME type.boolean
Indicates if the canvas should recenter the content after the canvas is resized.org.w3c.dom.svg.SVGDocument
Returns the current SVG document.Returns the size of the SVG document.Returns the current update manager.Returns the transform from viewBox coords to screen coordsprotected void
Handles an exception.protected void
installSVGDocument
(org.w3c.dom.svg.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
Tells whether the component use dynamic features to process the current document.boolean
Tells whether the component use dynamic features to process the current document.void
loadSVGDocument
(String url) Loads a SVG document from the given URL.void
Removes a GVTTreeBuilderListener from this component.void
Removes a LinkActivationListener from this component.void
Removes a SVGDocumentLoaderListener from this component.void
Removes a SVGLoadEventDispatcherListener from this component.void
Removes a UpdateManagerListener from this component.protected void
Renders the GVT tree.void
Resumes the processing of the current document.void
setAnimationLimitingCPU
(float pc) Sets the animation limiting mode to a percentage of CPU.void
setAnimationLimitingFPS
(float fps) Sets the animation limiting mode to a number of frames per second.void
Sets the animation limiting mode to "none".protected void
Sets the animation limiting mode on the current bridge context.void
setDisableInteractions
(boolean b) Turn off all 'interactor' objects (pan, zoom, etc) if 'b' is true, turn them on if 'b' is false.void
setDocument
(Document doc) Sets the Document to display.void
setDocumentState
(int state) Sets the document state.void
Sets the current fragment identifier.void
setGraphicsNode
(GraphicsNode gn, boolean createDispatcher) Sets the GVT tree to display.void
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
(org.w3c.dom.svg.SVGDocument doc) Sets the SVGDocument to display.void
Shows an alert dialog box.boolean
showConfirm
(String message) Shows a confirm dialog box.showPrompt
(String message) Shows a prompt dialog box.showPrompt
(String message, String defaultValue) Shows a prompt dialog box.private void
Starts a loading thread.protected void
Starts a tree builder.protected void
Starts a SVGLoadEventDispatcher thread.void
Stops the processing of the current document.protected void
This method calls stop processing waits for all threads to die then runs the Runnable in the event queue thread.void
Suspend the processing of the current document.protected boolean
Updates the value of the transform used for rendering.void
Enables/Disables Zoom And Pan based on the zoom and pan attribute of the currently installed document, Unless the user has set the Interactions State.Methods inherited from class org.apache.batik.swing.gvt.JGVTComponent
addAWTListeners, addGVTTreeRendererListener, addJGVTComponentListener, createEventDispatcher, createTextSelectionManager, deselectAll, flush, flush, getDisableInteractions, getDoubleBufferedRendering, getGraphicsNode, getInitialTransform, getInteractors, getOffScreen, getOverlays, getPaintingTransform, getProgressivePaint, getRenderingTransform, getRenderRect, getSelectionOverlayColor, getSelectionOverlayStrokeColor, getTextSelectionManager, getUseUnixTextSelection, immediateRepaint, initializeEventHandling, isSelectionOverlayXORMode, paintComponent, releaseRenderingReferences, removeGVTTreeRendererListener, removeJGVTComponentListener, resetRenderingTransform, scheduleGVTRendering, select, setDoubleBufferedRendering, setGraphicsNode, setPaintingTransform, setProgressivePaint, setRenderingTransform, setRenderingTransform, setSelectionOverlayColor, setSelectionOverlayStrokeColor, setSelectionOverlayXORMode, setUseUnixTextSelection
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
-
Field Details
-
AUTODETECT
public static final int AUTODETECTMeans that the component must auto detect whether the current document is static or dynamic.- See Also:
-
ALWAYS_DYNAMIC
public static final int ALWAYS_DYNAMICMeans that all document must be considered as dynamic. Indicates that all DOM listeners should be registered. This supports 'interactivity' (anchors and cursors), as well as DOM modifications listeners to update the GVT rendering tree.- See Also:
-
ALWAYS_STATIC
public static final int ALWAYS_STATICMeans that all document must be considered as static. Indicates that no DOM listeners should be registered. In this case the generated GVT tree should be totally independent of the DOM tree (in practice text holds references to the source text elements for font resolution).- See Also:
-
ALWAYS_INTERACTIVE
public static final int ALWAYS_INTERACTIVEMeans that all document must be considered as interactive. Indicates that DOM listeners should be registered to support, 'interactivity' this includes anchors and cursors, but does not include support for DOM modifications.- See Also:
-
SCRIPT_ALERT
String constant for the resource with the text for a script alert dialog. Must have a substitution for one string.- See Also:
-
SCRIPT_PROMPT
String constant for the resource with the text for a script prompt dialog. Must have a substitution for one string.- See Also:
-
SCRIPT_CONFIRM
String constant for the resource with the text for a script confim dialog. Must have a substitution for one string.- See Also:
-
BROKEN_LINK_TITLE
String constant for the resource with the text for the title of the info tooltip for brokin link images. No string substitution.- See Also:
-
documentLoader
The document loader. -
nextDocumentLoader
The next document loader to run. -
loader
The concrete bridge document loader. -
gvtTreeBuilder
The GVT tree builder. -
nextGVTTreeBuilder
The next GVT tree builder to run. -
svgLoadEventDispatcher
The SVGLoadEventDispatcher. -
updateManager
The update manager. -
nextUpdateManager
The next update manager. -
svgDocument
protected org.w3c.dom.svg.SVGDocument svgDocumentThe current SVG document. -
svgDocumentLoaderListeners
The document loader listeners. -
gvtTreeBuilderListeners
The GVT tree builder listeners. -
svgLoadEventDispatcherListeners
The SVG onload dispatcher listeners. -
linkActivationListeners
The link activation listeners. -
updateManagerListeners
The update manager listeners. -
userAgent
The user agent. -
svgUserAgent
The SVG user agent. -
bridgeContext
The current bridge context. -
fragmentIdentifier
The current document fragment identifier. -
isDynamicDocument
protected boolean isDynamicDocumentWhether the current document has dynamic features. -
isInteractiveDocument
protected boolean isInteractiveDocumentWhether the current document has dynamic features. -
selfCallingDisableInteractions
protected boolean selfCallingDisableInteractionsSet to true before component calls setDisableInteractors so it knows that the users isn't the one calling it. -
userSetDisableInteractions
protected boolean userSetDisableInteractionsSet to true if the user ever calls setDisableInteractions -
documentState
protected int documentStateThe document state. -
prevComponentSize
-
afterStopRunnable
-
updateOverlay
-
recenterOnResize
protected boolean recenterOnResize -
viewingTransform
-
animationLimitingMode
protected int animationLimitingModeThe animation limiting mode. -
animationLimitingAmount
protected float animationLimitingAmountThe amount of animation limiting. -
jsvgComponentListener
The JGVTComponentListener. -
FEATURES
-
-
Constructor Details
-
JSVGComponent
public JSVGComponent()Creates a new JSVGComponent. -
JSVGComponent
Creates a new JSVGComponent.- 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
-
dispose
public void dispose() -
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 classJGVTComponent
-
clearUserSetDisableInteractions
public void clearUserSetDisableInteractions()Clears the boolean that indicates the 'user' has set disable interactions so that the canvas uses the value from documents. -
updateZoomAndPanEnable
Enables/Disables Zoom And Pan based on the zoom and pan attribute of the currently installed document, Unless the user has set the Interactions State. -
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
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 thegvtRenderingCompleted
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 classJGVTComponent
-
loadSVGDocument
Loads a SVG document from the given URL. Note: Because the loading is multi-threaded, the current SVG document is not guaranteed to be updated after this method returns. The only way to be notified a document has been loaded is to listen to theSVGDocumentLoaderEvent
s. -
startDocumentLoader
private void startDocumentLoader()Starts a loading thread. -
setDocument
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 preparation for rendering and the rendering itself occur asynchronously so you need to register event handlers if you want to know when the document is truly 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(org.w3c.dom.svg.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 preparation for rendering and the rendering itself occur asynchronously so you need to register event handlers if you want to know when the document is truly 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
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(org.w3c.dom.svg.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'. -
startGVTTreeBuilder
protected void startGVTTreeBuilder()Starts a tree builder. -
getSVGDocument
public org.w3c.dom.svg.SVGDocument getSVGDocument()Returns the current SVG document. -
getSVGDocumentSize
Returns the size of the SVG document. -
getFragmentIdentifier
Returns the current's document fragment identifier. -
setFragmentIdentifier
Sets the current fragment identifier. -
flushImageCache
public void flushImageCache()Removes all images from the image cache. -
setGraphicsNode
Description copied from class:JGVTComponent
Sets the GVT tree to display.- Overrides:
setGraphicsNode
in classJGVTComponent
-
createBridgeContext
Creates a new bridge context. -
startSVGLoadEventDispatcher
Starts a SVGLoadEventDispatcher thread. -
createImageRenderer
Creates a new renderer.- Overrides:
createImageRenderer
in classJGVTComponent
-
getCanvasGraphicsNode
-
getCanvasGraphicsNode
-
getViewingTransform
-
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 classJGVTComponent
-
calculateViewingTransform
protected AffineTransform calculateViewingTransform(String fragIdent, org.w3c.dom.svg.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 classJGVTComponent
-
renderGVTTree
protected void renderGVTTree()Renders the GVT tree.- Overrides:
renderGVTTree
in classJGVTComponent
-
handleException
Handles an exception.- Overrides:
handleException
in classJGVTComponent
-
addSVGDocumentLoaderListener
Adds a SVGDocumentLoaderListener to this component. -
removeSVGDocumentLoaderListener
Removes a SVGDocumentLoaderListener from this component. -
addGVTTreeBuilderListener
Adds a GVTTreeBuilderListener to this component. -
removeGVTTreeBuilderListener
Removes a GVTTreeBuilderListener from this component. -
addSVGLoadEventDispatcherListener
Adds a SVGLoadEventDispatcherListener to this component. -
removeSVGLoadEventDispatcherListener
Removes a SVGLoadEventDispatcherListener from this component. -
addLinkActivationListener
Adds a LinkActivationListener to this component. -
removeLinkActivationListener
Removes a LinkActivationListener from this component. -
addUpdateManagerListener
Adds a UpdateManagerListener to this component. -
removeUpdateManagerListener
Removes a UpdateManagerListener from this component. -
showAlert
Shows an alert dialog box. -
showPrompt
Shows a prompt dialog box. -
showPrompt
Shows a prompt dialog box. -
showConfirm
Shows a confirm dialog box. -
setMySize
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. -
setAnimationLimitingNone
public void setAnimationLimitingNone()Sets the animation limiting mode to "none". -
setAnimationLimitingCPU
public void setAnimationLimitingCPU(float pc) Sets the animation limiting mode to a percentage of CPU.- Parameters:
pc
- the maximum percentage of CPU to use (0 < pc ≤ 1)
-
setAnimationLimitingFPS
public void setAnimationLimitingFPS(float fps) Sets the animation limiting mode to a number of frames per second.- Parameters:
fps
- the maximum number of frames per second (fps > 0)
-
getInterpreter
Returns theInterpreter
being used for script of the given MIME type.- Parameters:
type
- The MIME type the returnedInterpreter
handles.
-
setBridgeContextAnimationLimitingMode
protected void setBridgeContextAnimationLimitingMode()Sets the animation limiting mode on the current bridge context. -
createListener
Creates an instance of Listener.- Overrides:
createListener
in classJGVTComponent
-
createUserAgent
Creates a UserAgent.
-