org.apache.batik.bridge

Class UpdateManager

public class UpdateManager extends Object

This class provides features to manage the update of an SVG document.
Nested Class Summary
protected classUpdateManager.RepaintTimerTask
protected classUpdateManager.SuspensionInfo
protected classUpdateManager.UpdateManagerRunHander
Field Summary
protected BridgeContextbridgeContext
The bridge context.
protected Documentdocument
The document to manage.
protected GraphicsNodegraphicsNode
The GraphicsNode whose updates are to be tracked.
protected Listlisteners
The listeners.
protected intminRepaintTime
The current minRepaintTime
protected RepaintManagerrepaintManager
The repaint manager.
protected RunnableQueue.RunHandlerrunHandler
The RunHandler for the RunnableQueue.
protected booleanrunning
Whether the update manager is running.
protected ScriptingEnvironmentscriptingEnvironment
The scripting environment.
protected BridgeContext[]secondaryBridgeContexts
Array of resource documents' BridgeContexts.
protected ScriptingEnvironment[]secondaryScriptingEnvironments
Array of resource documents' ScriptingEnvironments that should have their SVGLoad event dispatched.
protected booleanstarted
Whether the manager was started.
protected booleansuspendCalled
Whether the suspend() method was called.
protected RunnableQueueupdateRunnableQueue
The update RunnableQueue.
protected UpdateTrackerupdateTracker
The update tracker.
Constructor Summary
UpdateManager(BridgeContext ctx, GraphicsNode gn, Document doc)
Creates a new update manager.
Method Summary
voidaddUpdateManagerListener(UpdateManagerListener l)
Adds a UpdateManagerListener to this UpdateManager.
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.
protected voidfireEvent(EventDispatcher.Dispatcher dispatcher, Object event)
voidforceRepaint()
Users of Batik should essentially never call this directly from Java.
BridgeContextgetBridgeContext()
Returns the bridge context.
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.
voidremoveUpdateManagerListener(UpdateManagerListener l)
Removes a UpdateManagerListener from this UpdateManager.
protected voidrepaint()
Repaints the dirty areas, if needed.
voidresume()
Resumes the update manager.
voidsetMinRepaintTime(int minRepaintTime)
voidsuspend()
Suspends the update manager.
voidupdateRendering(AffineTransform u2d, boolean dbr, Shape aoi, int width, int height)
Updates the rendering buffer.
voidupdateRendering(AffineTransform u2d, boolean dbr, boolean cpt, Shape aoi, int width, int height)
Updates the rendering buffer.
protected voidupdateRendering(List areas, boolean clearPaintingTransform)
Updates the rendering buffer.

Field Detail

bridgeContext

protected BridgeContext bridgeContext
The bridge context.

document

protected Document document
The document to manage.

graphicsNode

protected GraphicsNode graphicsNode
The GraphicsNode whose updates are to be tracked.

listeners

protected List listeners
The listeners.

minRepaintTime

protected int minRepaintTime
The current minRepaintTime

repaintManager

protected RepaintManager repaintManager
The repaint manager.

runHandler

protected RunnableQueue.RunHandler runHandler
The RunHandler for the RunnableQueue.

running

protected volatile boolean running
Whether the update manager is running.

scriptingEnvironment

protected ScriptingEnvironment scriptingEnvironment
The scripting environment.

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.

started

protected boolean started
Whether the manager was started.

suspendCalled

protected volatile boolean suspendCalled
Whether the suspend() method was called.

updateRunnableQueue

protected RunnableQueue updateRunnableQueue
The update RunnableQueue.

updateTracker

protected UpdateTracker updateTracker
The update tracker.

Constructor Detail

UpdateManager

public UpdateManager(BridgeContext ctx, GraphicsNode gn, 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

addUpdateManagerListener

public void addUpdateManagerListener(UpdateManagerListener l)
Adds a UpdateManagerListener to this UpdateManager.

createRunHandler

protected RunnableQueue.RunHandler createRunHandler()

dispatchSVGLoadEvent

public void dispatchSVGLoadEvent()
Dispatches an 'SVGLoad' event to the document.

dispatchSVGLoadEvent

protected void dispatchSVGLoadEvent(BridgeContext ctx, ScriptingEnvironment se)
Dispatches an 'SVGLoad' event to the document.

dispatchSVGResizeEvent

public void dispatchSVGResizeEvent()
Dispatches an "SVGZoom" event to the document.

dispatchSVGScrollEvent

public void dispatchSVGScrollEvent()
Dispatches an "SVGZoom" event to the document.

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.

dispatchSVGZoomEvent

public void dispatchSVGZoomEvent()
Dispatches an "SVGZoom" event to the document.

fireEvent

protected void fireEvent(EventDispatcher.Dispatcher dispatcher, Object event)

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.

getBridgeContext

public BridgeContext getBridgeContext()
Returns the bridge context.

getDocument

public Document getDocument()
Returns the current Document.

getMinRepaintTime

public int getMinRepaintTime()

getRepaintManager

public RepaintManager getRepaintManager()
Returns the repaint manager.

getScriptingEnvironment

public ScriptingEnvironment getScriptingEnvironment()
Returns the scripting environment.

getUpdateRunnableQueue

public RunnableQueue getUpdateRunnableQueue()
Returns the update RunnableQueue.

getUpdateTracker

public UpdateTracker getUpdateTracker()
Returns the GVT update tracker.

initializeScriptingEnvironment

protected ScriptingEnvironment initializeScriptingEnvironment(BridgeContext ctx)
Creates an appropriate ScriptingEnvironment and XBL manager for the given document.

interrupt

public void interrupt()
Interrupts the manager tasks.

isRunning

public boolean isRunning()
Tells whether the update manager is currently running.

manageUpdates

public void manageUpdates(ImageRenderer r)
Finishes the UpdateManager initialization.

removeUpdateManagerListener

public void removeUpdateManagerListener(UpdateManagerListener l)
Removes a UpdateManagerListener from this UpdateManager.

repaint

protected void repaint()
Repaints the dirty areas, if needed.

resume

public void resume()
Resumes the update manager.

setMinRepaintTime

public void setMinRepaintTime(int minRepaintTime)

suspend

public void suspend()
Suspends the update manager.

updateRendering

public void updateRendering(AffineTransform u2d, boolean dbr, 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(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 complets aoi The area of interest in the renderer space units. width The offscreen buffer width. height The offscreen buffer height.

updateRendering

protected void updateRendering(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.

Copyright B) 2008 Apache Software Foundation. All Rights Reserved.