Package org.apache.batik.bridge
Class UpdateManager
java.lang.Object
org.apache.batik.bridge.UpdateManager
This class provides features to manage the update of an SVG document.
- Version:
- $Id: UpdateManager.java 1851346 2019-01-15 13:41:00Z ssteiner $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
protected static class
protected class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) long
protected BridgeContext
The bridge context.protected Document
The document to manage.protected GraphicsNode
The GraphicsNode whose updates are to be tracked.protected List
The listeners.(package private) static final int
protected int
The current minRepaintTime(package private) int
(package private) long
This tracks when the rendering first got 'out of date' with respect to the document.protected RepaintManager
The repaint manager.(package private) TimerTask
(package private) Timer
(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that the manager was resumed.protected RunnableQueue.RunHandler
The RunHandler for the RunnableQueue.protected boolean
Whether the update manager is running.protected ScriptingEnvironment
The scripting environment.protected BridgeContext[]
Array of resource documents' BridgeContexts.protected ScriptingEnvironment[]
Array of resource documents' ScriptingEnvironments that should have their SVGLoad event dispatched.protected boolean
Whether the manager was started.(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that the manager was started(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that the manager was stopped.protected boolean
Whether the suspend() method was called.(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that the manager was suspended.(package private) List
(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that an update completed(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that an update failedprotected RunnableQueue
The update RunnableQueue.(package private) static EventDispatcher.Dispatcher
Dispatches a UpdateManagerEvent to notify that an update startedprotected UpdateTracker
The update tracker. -
Constructor Summary
ConstructorsConstructorDescriptionUpdateManager
(BridgeContext ctx, GraphicsNode gn, Document doc) Creates a new update manager. -
Method Summary
Modifier and TypeMethodDescription(package private) int
addRedrawSuspension
(int max_wait_milliseconds) void
Adds a UpdateManagerListener to this UpdateManager.(package private) void
protected RunnableQueue.RunHandler
void
Dispatches an 'SVGLoad' event to the document.protected void
Dispatches an 'SVGLoad' event to the document.void
Dispatches an "SVGZoom" event to the document.void
Dispatches an "SVGZoom" event to the document.void
Dispatches an 'SVGUnLoad' event to the document.void
Dispatches an "SVGZoom" event to the document.(package private) long
protected void
fireEvent
(EventDispatcher.Dispatcher dispatcher, Object event) void
Users of Batik should essentially never call this directly from Java.Returns the bridge context.Returns the current Document.int
Returns the repaint manager.Returns the scripting environment.Returns the update RunnableQueue.Returns the GVT update tracker.protected ScriptingEnvironment
Creates an appropriate ScriptingEnvironment and XBL manager for the given document.void
Interrupts the manager tasks.boolean
Tells whether the update manager is currently running.void
Finishes the UpdateManager initialization.(package private) void
(package private) boolean
releaseRedrawSuspension
(int index) void
Removes a UpdateManagerListener from this UpdateManager.protected void
repaint()
Repaints the dirty areas, if needed.(package private) void
Sets up a timer that will trigger a repaint when it fires.void
resume()
Resumes the update manager.void
setMinRepaintTime
(int minRepaintTime) void
suspend()
Suspends the update manager.void
updateRendering
(AffineTransform u2d, boolean dbr, boolean cpt, Shape aoi, int width, int height) Updates the rendering buffer.void
updateRendering
(AffineTransform u2d, boolean dbr, Shape aoi, int width, int height) Updates the rendering buffer.protected void
updateRendering
(List areas, boolean clearPaintingTransform) Updates the rendering buffer.
-
Field Details
-
MIN_REPAINT_TIME
static final int MIN_REPAINT_TIME -
bridgeContext
The bridge context. -
document
The document to manage. -
updateRunnableQueue
The update RunnableQueue. -
runHandler
The RunHandler for the RunnableQueue. -
running
protected volatile boolean runningWhether the update manager is running. -
suspendCalled
protected volatile boolean suspendCalledWhether the suspend() method was called. -
listeners
The listeners. -
scriptingEnvironment
The scripting environment. -
repaintManager
The repaint manager. -
updateTracker
The update tracker. -
graphicsNode
The GraphicsNode whose updates are to be tracked. -
started
protected boolean startedWhether the manager was started. -
secondaryBridgeContexts
Array of resource documents' BridgeContexts. -
secondaryScriptingEnvironments
Array of resource documents' ScriptingEnvironments that should have their SVGLoad event dispatched. -
minRepaintTime
protected int minRepaintTimeThe current minRepaintTime -
outOfDateTime
long outOfDateTimeThis tracks when the rendering first got 'out of date' with respect to the document. -
suspensionList
List suspensionList -
nextSuspensionIndex
int nextSuspensionIndex -
allResumeTime
long allResumeTime -
repaintTriggerTimer
Timer repaintTriggerTimer -
repaintTimerTask
TimerTask repaintTimerTask -
startedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was started -
stoppedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was stopped. -
suspendedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was suspended. -
resumedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was resumed. -
updateStartedDispatcher
Dispatches a UpdateManagerEvent to notify that an update started -
updateCompletedDispatcher
Dispatches a UpdateManagerEvent to notify that an update completed -
updateFailedDispatcher
Dispatches a UpdateManagerEvent to notify that an update failed
-
-
Constructor Details
-
UpdateManager
Creates a new update manager.- Parameters:
ctx
- The bridge context.gn
- GraphicsNode whose updates are to be tracked.doc
- The document to manage.
-
-
Method Details
-
getMinRepaintTime
public int getMinRepaintTime() -
setMinRepaintTime
public void setMinRepaintTime(int minRepaintTime) -
initializeScriptingEnvironment
Creates an appropriate ScriptingEnvironment and XBL manager for the given document. -
dispatchSVGLoadEvent
Dispatches an 'SVGLoad' event to the document.- Throws:
InterruptedException
-
dispatchSVGLoadEvent
Dispatches an 'SVGLoad' event to the document. -
dispatchSVGZoomEvent
Dispatches an "SVGZoom" event to the document.- Throws:
InterruptedException
-
dispatchSVGScrollEvent
Dispatches an "SVGZoom" event to the document.- Throws:
InterruptedException
-
dispatchSVGResizeEvent
Dispatches an "SVGZoom" event to the document.- Throws:
InterruptedException
-
manageUpdates
Finishes the UpdateManager initialization. -
getBridgeContext
Returns the bridge context. -
getUpdateRunnableQueue
Returns the update RunnableQueue. -
getRepaintManager
Returns the repaint manager. -
getUpdateTracker
Returns the GVT update tracker. -
getDocument
Returns the current Document. -
getScriptingEnvironment
Returns the scripting environment. -
isRunning
public boolean isRunning()Tells whether the update manager is currently running. -
suspend
public void suspend()Suspends the update manager. -
resume
public void resume()Resumes the update manager. -
interrupt
public void interrupt()Interrupts the manager tasks. -
dispatchSVGUnLoadEvent
public void dispatchSVGUnLoadEvent()Dispatches an 'SVGUnLoad' event to the document. This method interrupts the update manager threads. NOTE: this method must be called outside the update thread. -
updateRendering
Updates the rendering buffer. Only to be called from the update thread.- Parameters:
u2d
- The user to device transform.dbr
- Whether the double buffering should be used.aoi
- The area of interest in the renderer space units.width
- The offscreen buffer width.height
- The offscreen buffer height.
-
updateRendering
public void updateRendering(AffineTransform u2d, boolean dbr, boolean cpt, Shape aoi, int width, int height) Updates the rendering buffer. Only to be called from the update thread.- Parameters:
u2d
- The user to device transform.dbr
- Whether the double buffering should be used.cpt
- If the canvas painting transform should be cleared when the update completsaoi
- The area of interest in the renderer space units.width
- The offscreen buffer width.height
- The offscreen buffer height.
-
updateRendering
Updates the rendering buffer.- Parameters:
areas
- List of areas of interest in rederer space units.clearPaintingTransform
- Indicates if the painting transform should be cleared as a result of this update.
-
repaint
protected void repaint()Repaints the dirty areas, if needed. -
forceRepaint
public void forceRepaint()Users of Batik should essentially never call this directly from Java. If the Canvas is not updating when you change the SVG Document it is almost certainly because you are not making your changes in the RunnableQueue (getUpdateRunnableQueue()). You will have problems if you are not making all changes to the document in the UpdateManager's RunnableQueue. This method exists to implement the 'SVGSVGElement.forceRedraw()' method. -
createRepaintTimer
void createRepaintTimer() -
resetRepaintTimer
void resetRepaintTimer()Sets up a timer that will trigger a repaint when it fires. If create is true it will construct a timer even if one -
addRedrawSuspension
int addRedrawSuspension(int max_wait_milliseconds) -
releaseAllRedrawSuspension
void releaseAllRedrawSuspension() -
releaseRedrawSuspension
boolean releaseRedrawSuspension(int index) -
findNewAllResumeTime
long findNewAllResumeTime() -
addUpdateManagerListener
Adds a UpdateManagerListener to this UpdateManager. -
removeUpdateManagerListener
Removes a UpdateManagerListener from this UpdateManager. -
fireEvent
-
createRunHandler
-