org.apache.batik.gvt.renderer

Class StaticRenderer

public class StaticRenderer extends Object implements ImageRenderer

Simple implementation of the Renderer that simply does static rendering in an offscreen buffer image.
Field Summary
protected WritableRastercurrentBaseRaster
Offscreen image where the Renderer does its rendering
protected BufferedImagecurrentOffScreen
protected WritableRastercurrentRaster
protected static RenderingHintsdefaultRenderingHints
protected booleanisDoubleBuffered
Flag for double buffering.
protected SoftReferencelastCache
protected SoftReferencelastCR
protected intoffScreenHeight
protected intoffScreenWidth
protected RenderingHintsrenderingHints
Passed to the GVT tree to describe the rendering environment
protected CachableRedrootCR
protected FilterrootFilter
protected GraphicsNoderootGN
Tree this Renderer paints.
protected AffineTransformusr2dev
protected WritableRasterworkingBaseRaster
protected BufferedImageworkingOffScreen
protected WritableRasterworkingRaster
Constructor Summary
StaticRenderer(RenderingHints rh, AffineTransform at)
StaticRenderer()
Creates a new StaticRenderer object.
Method Summary
voidclearOffScreen()
Sets up and clears the current offscreen buffer.
voiddispose()
Disposes all resources of this renderer.
voidflush()
Flush any cached image data.
voidflush(Collection areas)
Flush a list of rectangles of cached image data.
voidflush(Rectangle r)
Flush a rectangle of cached image data.
BufferedImagegetOffScreen()
Returns the current offscreen image.
RenderingHintsgetRenderingHints()
AffineTransformgetTransform()
Returns the transform from the current user space (as defined by the top node of the GVT tree) to the device space.
GraphicsNodegetTree()
booleanisDoubleBuffered()
Returns true if the Renderer is currently doubleBuffering is rendering requests.
protected CachableRedrenderGNR()
voidrepaint(Shape area)
Repaints the associated GVT tree under area.
voidrepaint(RectListManager areas)
Repaints the associated GVT tree under the list of areas.
voidsetDoubleBuffered(boolean isDoubleBuffered)
Turns on/off double buffering in renderer.
voidsetRenderingHints(RenderingHints rh)
voidsetTransform(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.
voidsetTree(GraphicsNode rootGN)
This associates the given GVT Tree with this renderer.
protected CachableRedsetupCache(CachableRed img)
voidupdateOffScreen(int width, int height)
Update the size of the image to be returned by getOffScreen.
protected voidupdateWorkingBuffers()
Internal method used to synchronize local state in response to various set methods.

Field Detail

currentBaseRaster

protected WritableRaster currentBaseRaster
Offscreen image where the Renderer does its rendering

currentOffScreen

protected BufferedImage currentOffScreen

currentRaster

protected WritableRaster currentRaster

defaultRenderingHints

protected static RenderingHints defaultRenderingHints

isDoubleBuffered

protected boolean isDoubleBuffered
Flag for double buffering.

lastCache

protected SoftReference lastCache

lastCR

protected SoftReference lastCR

offScreenHeight

protected int offScreenHeight

offScreenWidth

protected int offScreenWidth

renderingHints

protected RenderingHints renderingHints
Passed to the GVT tree to describe the rendering environment

rootCR

protected CachableRed rootCR

rootFilter

protected Filter rootFilter

rootGN

protected GraphicsNode rootGN
Tree this Renderer paints.

usr2dev

protected AffineTransform usr2dev

workingBaseRaster

protected WritableRaster workingBaseRaster

workingOffScreen

protected BufferedImage workingOffScreen

workingRaster

protected WritableRaster workingRaster

Constructor Detail

StaticRenderer

public StaticRenderer(RenderingHints rh, AffineTransform at)

Parameters: rh Hints for rendering. at Starting user to device coordinate system transform.

StaticRenderer

public StaticRenderer()
Creates a new StaticRenderer object.

Method Detail

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.

dispose

public void dispose()
Disposes all resources of this renderer.

flush

public void flush()
Flush any cached image data.

flush

public void flush(Collection areas)
Flush a list of rectangles of cached image data.

flush

public void flush(Rectangle r)
Flush a rectangle of cached image data.

getOffScreen

public BufferedImage 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.

getRenderingHints

public RenderingHints getRenderingHints()

Returns: the RenderingHints which the Renderer is using for its rendering

getTransform

public AffineTransform getTransform()
Returns the transform from the current user space (as defined by the top node of the GVT tree) to the device space.

getTree

public GraphicsNode getTree()

Returns: the GVT tree associated with this renderer

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).

renderGNR

protected CachableRed renderGNR()

repaint

public void repaint(Shape area)
Repaints the associated GVT tree under area. 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.

Parameters: area region to be repainted, in the current user space coordinate system.

repaint

public void repaint(RectListManager areas)
Repaints the associated GVT tree under the list of areas. 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.

Parameters: areas a List of regions to be repainted, in the current user space coordinate system.

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.

Parameters: isDoubleBuffered the new value for double buffering

setRenderingHints

public void setRenderingHints(RenderingHints rh)

Parameters: rh Set of rendering hints to use for future renderings

setTransform

public 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.

Parameters: usr2dev the new user space to device space transform. If null, the identity transform will be set.

setTree

public void setTree(GraphicsNode rootGN)
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.

setupCache

protected CachableRed setupCache(CachableRed img)

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).

updateWorkingBuffers

protected void updateWorkingBuffers()
Internal method used to synchronize local state in response to various set methods.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.