Package org.apache.batik.bridge
Class UpdateManager
- java.lang.Object
-
- org.apache.batik.bridge.UpdateManager
-
public class UpdateManager extends java.lang.ObjectThis 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 Classes Modifier and Type Class Description protected static classUpdateManager.RepaintTimerTaskprotected static classUpdateManager.SuspensionInfoprotected classUpdateManager.UpdateManagerRunHander
-
Field Summary
Fields Modifier and Type Field Description (package private) longallResumeTimeprotected BridgeContextbridgeContextThe bridge context.protected org.w3c.dom.DocumentdocumentThe document to manage.protected GraphicsNodegraphicsNodeThe GraphicsNode whose updates are to be tracked.protected java.util.ListlistenersThe listeners.(package private) static intMIN_REPAINT_TIMEprotected intminRepaintTimeThe current minRepaintTime(package private) intnextSuspensionIndex(package private) longoutOfDateTimeThis tracks when the rendering first got 'out of date' with respect to the document.protected RepaintManagerrepaintManagerThe repaint manager.(package private) java.util.TimerTaskrepaintTimerTask(package private) java.util.TimerrepaintTriggerTimer(package private) static EventDispatcher.DispatcherresumedDispatcherDispatches a UpdateManagerEvent to notify that the manager was resumed.protected RunnableQueue.RunHandlerrunHandlerThe RunHandler for the RunnableQueue.protected booleanrunningWhether the update manager is running.protected ScriptingEnvironmentscriptingEnvironmentThe scripting environment.protected BridgeContext[]secondaryBridgeContextsArray of resource documents' BridgeContexts.protected ScriptingEnvironment[]secondaryScriptingEnvironmentsArray of resource documents' ScriptingEnvironments that should have their SVGLoad event dispatched.protected booleanstartedWhether the manager was started.(package private) static EventDispatcher.DispatcherstartedDispatcherDispatches a UpdateManagerEvent to notify that the manager was started(package private) static EventDispatcher.DispatcherstoppedDispatcherDispatches a UpdateManagerEvent to notify that the manager was stopped.protected booleansuspendCalledWhether the suspend() method was called.(package private) static EventDispatcher.DispatchersuspendedDispatcherDispatches a UpdateManagerEvent to notify that the manager was suspended.(package private) java.util.ListsuspensionList(package private) static EventDispatcher.DispatcherupdateCompletedDispatcherDispatches a UpdateManagerEvent to notify that an update completed(package private) static EventDispatcher.DispatcherupdateFailedDispatcherDispatches a UpdateManagerEvent to notify that an update failedprotected RunnableQueueupdateRunnableQueueThe update RunnableQueue.(package private) static EventDispatcher.DispatcherupdateStartedDispatcherDispatches a UpdateManagerEvent to notify that an update startedprotected UpdateTrackerupdateTrackerThe update tracker.
-
Constructor Summary
Constructors Constructor Description UpdateManager(BridgeContext ctx, GraphicsNode gn, org.w3c.dom.Document doc)Creates a new update manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intaddRedrawSuspension(int max_wait_milliseconds)voidaddUpdateManagerListener(UpdateManagerListener l)Adds a UpdateManagerListener to this UpdateManager.(package private) voidcreateRepaintTimer()protected RunnableQueue.RunHandlercreateRunHandler()voiddispatchSVGLoadEvent()Dispatches an 'SVGLoad' event to the document.protected voiddispatchSVGLoadEvent(BridgeContext ctx, ScriptingEnvironment se)Dispatches an 'SVGLoad' event to the document.voiddispatchSVGResizeEvent()Dispatches an "SVGZoom" event to the document.voiddispatchSVGScrollEvent()Dispatches an "SVGZoom" event to the document.voiddispatchSVGUnLoadEvent()Dispatches an 'SVGUnLoad' event to the document.voiddispatchSVGZoomEvent()Dispatches an "SVGZoom" event to the document.(package private) longfindNewAllResumeTime()protected voidfireEvent(EventDispatcher.Dispatcher dispatcher, java.lang.Object event)voidforceRepaint()Users of Batik should essentially never call this directly from Java.BridgeContextgetBridgeContext()Returns the bridge context.org.w3c.dom.DocumentgetDocument()Returns the current Document.intgetMinRepaintTime()RepaintManagergetRepaintManager()Returns the repaint manager.ScriptingEnvironmentgetScriptingEnvironment()Returns the scripting environment.RunnableQueuegetUpdateRunnableQueue()Returns the update RunnableQueue.UpdateTrackergetUpdateTracker()Returns the GVT update tracker.protected ScriptingEnvironmentinitializeScriptingEnvironment(BridgeContext ctx)Creates an appropriate ScriptingEnvironment and XBL manager for the given document.voidinterrupt()Interrupts the manager tasks.booleanisRunning()Tells whether the update manager is currently running.voidmanageUpdates(ImageRenderer r)Finishes the UpdateManager initialization.(package private) voidreleaseAllRedrawSuspension()(package private) booleanreleaseRedrawSuspension(int index)voidremoveUpdateManagerListener(UpdateManagerListener l)Removes a UpdateManagerListener from this UpdateManager.protected voidrepaint()Repaints the dirty areas, if needed.(package private) voidresetRepaintTimer()Sets up a timer that will trigger a repaint when it fires.voidresume()Resumes the update manager.voidsetMinRepaintTime(int minRepaintTime)voidsuspend()Suspends the update manager.voidupdateRendering(java.awt.geom.AffineTransform u2d, boolean dbr, boolean cpt, java.awt.Shape aoi, int width, int height)Updates the rendering buffer.voidupdateRendering(java.awt.geom.AffineTransform u2d, boolean dbr, java.awt.Shape aoi, int width, int height)Updates the rendering buffer.protected voidupdateRendering(java.util.List areas, boolean clearPaintingTransform)Updates the rendering buffer.
-
-
-
Field Detail
-
MIN_REPAINT_TIME
static final int MIN_REPAINT_TIME
-
bridgeContext
protected BridgeContext bridgeContext
The bridge context.
-
document
protected org.w3c.dom.Document document
The document to manage.
-
updateRunnableQueue
protected RunnableQueue updateRunnableQueue
The update RunnableQueue.
-
runHandler
protected RunnableQueue.RunHandler runHandler
The RunHandler for the RunnableQueue.
-
running
protected volatile boolean running
Whether the update manager is running.
-
suspendCalled
protected volatile boolean suspendCalled
Whether the suspend() method was called.
-
listeners
protected java.util.List listeners
The listeners.
-
scriptingEnvironment
protected ScriptingEnvironment scriptingEnvironment
The scripting environment.
-
repaintManager
protected RepaintManager repaintManager
The repaint manager.
-
updateTracker
protected UpdateTracker updateTracker
The update tracker.
-
graphicsNode
protected GraphicsNode graphicsNode
The GraphicsNode whose updates are to be tracked.
-
started
protected boolean started
Whether the manager was started.
-
secondaryBridgeContexts
protected BridgeContext[] secondaryBridgeContexts
Array of resource documents' BridgeContexts.
-
secondaryScriptingEnvironments
protected ScriptingEnvironment[] secondaryScriptingEnvironments
Array of resource documents' ScriptingEnvironments that should have their SVGLoad event dispatched.
-
minRepaintTime
protected int minRepaintTime
The current minRepaintTime
-
outOfDateTime
long outOfDateTime
This tracks when the rendering first got 'out of date' with respect to the document.
-
suspensionList
java.util.List suspensionList
-
nextSuspensionIndex
int nextSuspensionIndex
-
allResumeTime
long allResumeTime
-
repaintTriggerTimer
java.util.Timer repaintTriggerTimer
-
repaintTimerTask
java.util.TimerTask repaintTimerTask
-
startedDispatcher
static EventDispatcher.Dispatcher startedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was started
-
stoppedDispatcher
static EventDispatcher.Dispatcher stoppedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was stopped.
-
suspendedDispatcher
static EventDispatcher.Dispatcher suspendedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was suspended.
-
resumedDispatcher
static EventDispatcher.Dispatcher resumedDispatcher
Dispatches a UpdateManagerEvent to notify that the manager was resumed.
-
updateStartedDispatcher
static EventDispatcher.Dispatcher updateStartedDispatcher
Dispatches a UpdateManagerEvent to notify that an update started
-
updateCompletedDispatcher
static EventDispatcher.Dispatcher updateCompletedDispatcher
Dispatches a UpdateManagerEvent to notify that an update completed
-
updateFailedDispatcher
static EventDispatcher.Dispatcher updateFailedDispatcher
Dispatches a UpdateManagerEvent to notify that an update failed
-
-
Constructor Detail
-
UpdateManager
public UpdateManager(BridgeContext ctx, GraphicsNode gn, org.w3c.dom.Document doc)
Creates a new update manager.- Parameters:
ctx- The bridge context.gn- GraphicsNode whose updates are to be tracked.doc- The document to manage.
-
-
Method Detail
-
getMinRepaintTime
public int getMinRepaintTime()
-
setMinRepaintTime
public void setMinRepaintTime(int minRepaintTime)
-
initializeScriptingEnvironment
protected ScriptingEnvironment initializeScriptingEnvironment(BridgeContext ctx)
Creates an appropriate ScriptingEnvironment and XBL manager for the given document.
-
dispatchSVGLoadEvent
public void dispatchSVGLoadEvent() throws java.lang.InterruptedExceptionDispatches an 'SVGLoad' event to the document.- Throws:
java.lang.InterruptedException
-
dispatchSVGLoadEvent
protected void dispatchSVGLoadEvent(BridgeContext ctx, ScriptingEnvironment se)
Dispatches an 'SVGLoad' event to the document.
-
dispatchSVGZoomEvent
public void dispatchSVGZoomEvent() throws java.lang.InterruptedExceptionDispatches an "SVGZoom" event to the document.- Throws:
java.lang.InterruptedException
-
dispatchSVGScrollEvent
public void dispatchSVGScrollEvent() throws java.lang.InterruptedExceptionDispatches an "SVGZoom" event to the document.- Throws:
java.lang.InterruptedException
-
dispatchSVGResizeEvent
public void dispatchSVGResizeEvent() throws java.lang.InterruptedExceptionDispatches an "SVGZoom" event to the document.- Throws:
java.lang.InterruptedException
-
manageUpdates
public void manageUpdates(ImageRenderer r)
Finishes the UpdateManager initialization.
-
getBridgeContext
public BridgeContext getBridgeContext()
Returns the bridge context.
-
getUpdateRunnableQueue
public RunnableQueue getUpdateRunnableQueue()
Returns the update RunnableQueue.
-
getRepaintManager
public RepaintManager getRepaintManager()
Returns the repaint manager.
-
getUpdateTracker
public UpdateTracker getUpdateTracker()
Returns the GVT update tracker.
-
getDocument
public org.w3c.dom.Document getDocument()
Returns the current Document.
-
getScriptingEnvironment
public ScriptingEnvironment 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
public void updateRendering(java.awt.geom.AffineTransform u2d, boolean dbr, java.awt.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.aoi- The area of interest in the renderer space units.width- The offscreen buffer width.height- The offscreen buffer height.
-
updateRendering
public void updateRendering(java.awt.geom.AffineTransform u2d, boolean dbr, boolean cpt, java.awt.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
protected void updateRendering(java.util.List areas, boolean clearPaintingTransform)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
public void addUpdateManagerListener(UpdateManagerListener l)
Adds a UpdateManagerListener to this UpdateManager.
-
removeUpdateManagerListener
public void removeUpdateManagerListener(UpdateManagerListener l)
Removes a UpdateManagerListener from this UpdateManager.
-
fireEvent
protected void fireEvent(EventDispatcher.Dispatcher dispatcher, java.lang.Object event)
-
createRunHandler
protected RunnableQueue.RunHandler createRunHandler()
-
-