Package org.apache.batik.gvt.renderer
Class StaticRenderer
java.lang.Object
org.apache.batik.gvt.renderer.StaticRenderer
- All Implemented Interfaces:
ImageRenderer
,Renderer
- Direct Known Subclasses:
DynamicRenderer
Simple implementation of the Renderer that simply does static
rendering in an offscreen buffer image.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WritableRaster
Offscreen image where the Renderer does its renderingprotected BufferedImage
protected WritableRaster
protected static RenderingHints
protected boolean
Flag for double buffering.protected SoftReference
protected SoftReference
protected int
protected int
protected RenderingHints
Passed to the GVT tree to describe the rendering environmentprotected CachableRed
protected Filter
protected GraphicsNode
Tree this Renderer paints.protected AffineTransform
protected WritableRaster
protected BufferedImage
protected WritableRaster
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new StaticRenderer object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets up and clears the current offscreen buffer.void
dispose()
Disposes all resources of this renderer.void
flush()
Flush any cached image data.void
Flush a rectangle of cached image data.void
flush
(Collection areas) Flush a list of rectangles of cached image data.Returns the current offscreen image.Returns the rendering hints this ImageRenderer is using for its rendering.Returns the transform from the current user space (as defined by the top node of the GVT tree) to the device space.getTree()
Returns the GVT tree associated with this rendererboolean
Returns true if the Renderer is currently doubleBuffering is rendering requests.protected CachableRed
void
Repaints the associated GVT tree underarea
.void
repaint
(RectListManager areas) Repaints the associated GVT tree under the list ofareas
.void
setDoubleBuffered
(boolean isDoubleBuffered) Turns on/off double buffering in renderer.void
Sets the specified rendering hints to be used for future renderings.void
setTransform
(AffineTransform usr2dev) Sets the transform from the current user space (as defined by the top node of the GVT tree, to the associated device space.void
setTree
(GraphicsNode rootGN) This associates the given GVT Tree with this renderer.protected CachableRed
setupCache
(CachableRed img) void
updateOffScreen
(int width, int height) Update the size of the image to be returned by getOffScreen.protected void
Internal method used to synchronize local state in response to various set methods.
-
Field Details
-
rootGN
Tree this Renderer paints. -
rootFilter
-
rootCR
-
lastCR
-
lastCache
-
isDoubleBuffered
protected boolean isDoubleBufferedFlag for double buffering. -
currentBaseRaster
Offscreen image where the Renderer does its rendering -
currentRaster
-
currentOffScreen
-
workingBaseRaster
-
workingRaster
-
workingOffScreen
-
offScreenWidth
protected int offScreenWidth -
offScreenHeight
protected int offScreenHeight -
renderingHints
Passed to the GVT tree to describe the rendering environment -
usr2dev
-
defaultRenderingHints
-
-
Constructor Details
-
StaticRenderer
- Parameters:
rh
- Hints for rendering.at
- Starting user to device coordinate system transform.
-
StaticRenderer
public StaticRenderer()Creates a new StaticRenderer object.
-
-
Method Details
-
dispose
public void dispose()Disposes all resources of this renderer.- Specified by:
dispose
in interfaceImageRenderer
- Specified by:
dispose
in interfaceRenderer
-
setTree
This associates the given GVT Tree with this renderer. Any previous tree association is forgotten. Not certain if this should be just GraphicsNode, or CanvasGraphicsNode. -
getTree
Description copied from interface:Renderer
Returns the GVT tree associated with this renderer -
setRenderingHints
Description copied from interface:ImageRenderer
Sets the specified rendering hints to be used for future renderings. This replaces current set of rendering hints.- Specified by:
setRenderingHints
in interfaceImageRenderer
- Parameters:
rh
- Set of rendering hints to use for future renderings
-
getRenderingHints
Description copied from interface:ImageRenderer
Returns the rendering hints this ImageRenderer is using for its rendering.- Specified by:
getRenderingHints
in interfaceImageRenderer
- Returns:
- the RenderingHints which the Renderer is using for its rendering
-
setTransform
Sets the transform from the current user space (as defined by the top node of the GVT tree, to the associated device space.- Specified by:
setTransform
in interfaceImageRenderer
- Specified by:
setTransform
in interfaceRenderer
- Parameters:
usr2dev
- the new user space to device space transform. If null, the identity transform will be set.
-
getTransform
Returns the transform from the current user space (as defined by the top node of the GVT tree) to the device space.- Specified by:
getTransform
in interfaceImageRenderer
- Specified by:
getTransform
in interfaceRenderer
-
isDoubleBuffered
public boolean isDoubleBuffered()Returns true if the Renderer is currently doubleBuffering is rendering requests. If it is then getOffscreen will only return completed renderings (or null if nothing is available).- Specified by:
isDoubleBuffered
in interfaceRenderer
-
setDoubleBuffered
public void setDoubleBuffered(boolean isDoubleBuffered) Turns on/off double buffering in renderer. Turning off double buffering makes it possible to see the ongoing results of a render operation.- Specified by:
setDoubleBuffered
in interfaceRenderer
- Parameters:
isDoubleBuffered
- the new value for double buffering
-
updateOffScreen
public void updateOffScreen(int width, int height) Update the size of the image to be returned by getOffScreen. Note that this change will not be reflected by calls to getOffscreen until either clearOffScreen has completed (when isDoubleBuffered is false) or reapint has completed (when isDoubleBuffered is true).- Specified by:
updateOffScreen
in interfaceImageRenderer
-
getOffScreen
Returns the current offscreen image. The exact symantics of this vary base on the value of isDoubleBuffered. If isDoubleBuffered is false this will return the image currently being worked on as soon as it is available. if isDoubleBuffered is false this will return the most recently completed result of repaint.- Specified by:
getOffScreen
in interfaceImageRenderer
-
clearOffScreen
public void clearOffScreen()Sets up and clears the current offscreen buffer. When not double buffering one should call this method before calling getOffscreen to get the offscreen being drawn into. This ensures the buffer is up to date and doesn't contain junk. When double buffering this call can effectively be skipped, since getOffscreen will only refect the new rendering after repaint completes.- Specified by:
clearOffScreen
in interfaceImageRenderer
-
repaint
Repaints the associated GVT tree underarea
. If double buffered is true and this method completes cleanly it will set the result of the repaint as the image returned by getOffscreen otherwise the old image will still be returned. If double buffered is false it is possible some effects of the failed rendering will be visible in the image returned by getOffscreen. -
repaint
Repaints the associated GVT tree under the list ofareas
. If double buffered is true and this method completes cleanly it will set the result of the repaint as the image returned by getOffscreen otherwise the old image will still be returned. If double buffered is false it is possible some effects of the failed rendering will be visible in the image returned by getOffscreen. -
flush
public void flush()Flush any cached image data.- Specified by:
flush
in interfaceImageRenderer
-
flush
Flush a list of rectangles of cached image data.- Specified by:
flush
in interfaceImageRenderer
-
flush
Flush a rectangle of cached image data.- Specified by:
flush
in interfaceImageRenderer
-
setupCache
-
renderGNR
-
updateWorkingBuffers
protected void updateWorkingBuffers()Internal method used to synchronize local state in response to various set methods.
-