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
public class StaticRenderer extends java.lang.Object implements ImageRenderer
Simple implementation of the Renderer that simply does static rendering in an offscreen buffer image.- Version:
- $Id: StaticRenderer.java 1804130 2017-08-04 14:41:11Z ssteiner $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.image.WritableRastercurrentBaseRasterOffscreen image where the Renderer does its renderingprotected java.awt.image.BufferedImagecurrentOffScreenprotected java.awt.image.WritableRastercurrentRasterprotected static java.awt.RenderingHintsdefaultRenderingHintsprotected booleanisDoubleBufferedFlag for double buffering.protected java.lang.ref.SoftReferencelastCacheprotected java.lang.ref.SoftReferencelastCRprotected intoffScreenHeightprotected intoffScreenWidthprotected java.awt.RenderingHintsrenderingHintsPassed to the GVT tree to describe the rendering environmentprotected CachableRedrootCRprotected FilterrootFilterprotected GraphicsNoderootGNTree this Renderer paints.protected java.awt.geom.AffineTransformusr2devprotected java.awt.image.WritableRasterworkingBaseRasterprotected java.awt.image.BufferedImageworkingOffScreenprotected java.awt.image.WritableRasterworkingRaster
-
Constructor Summary
Constructors Constructor Description StaticRenderer()Creates a new StaticRenderer object.StaticRenderer(java.awt.RenderingHints rh, java.awt.geom.AffineTransform at)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearOffScreen()Sets up and clears the current offscreen buffer.voiddispose()Disposes all resources of this renderer.voidflush()Flush any cached image data.voidflush(java.awt.Rectangle r)Flush a rectangle of cached image data.voidflush(java.util.Collection areas)Flush a list of rectangles of cached image data.java.awt.image.BufferedImagegetOffScreen()Returns the current offscreen image.java.awt.RenderingHintsgetRenderingHints()Returns the rendering hints this ImageRenderer is using for its rendering.java.awt.geom.AffineTransformgetTransform()Returns the transform from the current user space (as defined by the top node of the GVT tree) to the device space.GraphicsNodegetTree()Returns the GVT tree associated with this rendererbooleanisDoubleBuffered()Returns true if the Renderer is currently doubleBuffering is rendering requests.protected CachableRedrenderGNR()voidrepaint(java.awt.Shape area)Repaints the associated GVT tree underarea.voidrepaint(RectListManager areas)Repaints the associated GVT tree under the list ofareas.voidsetDoubleBuffered(boolean isDoubleBuffered)Turns on/off double buffering in renderer.voidsetRenderingHints(java.awt.RenderingHints rh)Sets the specified rendering hints to be used for future renderings.voidsetTransform(java.awt.geom.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
-
rootGN
protected GraphicsNode rootGN
Tree this Renderer paints.
-
rootFilter
protected Filter rootFilter
-
rootCR
protected CachableRed rootCR
-
lastCR
protected java.lang.ref.SoftReference lastCR
-
lastCache
protected java.lang.ref.SoftReference lastCache
-
isDoubleBuffered
protected boolean isDoubleBuffered
Flag for double buffering.
-
currentBaseRaster
protected java.awt.image.WritableRaster currentBaseRaster
Offscreen image where the Renderer does its rendering
-
currentRaster
protected java.awt.image.WritableRaster currentRaster
-
currentOffScreen
protected java.awt.image.BufferedImage currentOffScreen
-
workingBaseRaster
protected java.awt.image.WritableRaster workingBaseRaster
-
workingRaster
protected java.awt.image.WritableRaster workingRaster
-
workingOffScreen
protected java.awt.image.BufferedImage workingOffScreen
-
offScreenWidth
protected int offScreenWidth
-
offScreenHeight
protected int offScreenHeight
-
renderingHints
protected java.awt.RenderingHints renderingHints
Passed to the GVT tree to describe the rendering environment
-
usr2dev
protected java.awt.geom.AffineTransform usr2dev
-
defaultRenderingHints
protected static java.awt.RenderingHints defaultRenderingHints
-
-
Method Detail
-
dispose
public void dispose()
Disposes all resources of this renderer.- Specified by:
disposein interfaceImageRenderer- Specified by:
disposein interfaceRenderer
-
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.
-
getTree
public GraphicsNode getTree()
Description copied from interface:RendererReturns the GVT tree associated with this renderer
-
setRenderingHints
public void setRenderingHints(java.awt.RenderingHints rh)
Description copied from interface:ImageRendererSets the specified rendering hints to be used for future renderings. This replaces current set of rendering hints.- Specified by:
setRenderingHintsin interfaceImageRenderer- Parameters:
rh- Set of rendering hints to use for future renderings
-
getRenderingHints
public java.awt.RenderingHints getRenderingHints()
Description copied from interface:ImageRendererReturns the rendering hints this ImageRenderer is using for its rendering.- Specified by:
getRenderingHintsin interfaceImageRenderer- Returns:
- the RenderingHints which the Renderer is using for its rendering
-
setTransform
public void setTransform(java.awt.geom.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.- Specified by:
setTransformin interfaceImageRenderer- Specified by:
setTransformin interfaceRenderer- Parameters:
usr2dev- the new user space to device space transform. If null, the identity transform will be set.
-
getTransform
public java.awt.geom.AffineTransform 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:
getTransformin interfaceImageRenderer- Specified by:
getTransformin 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:
isDoubleBufferedin 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:
setDoubleBufferedin 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:
updateOffScreenin interfaceImageRenderer
-
getOffScreen
public java.awt.image.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.- Specified by:
getOffScreenin 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:
clearOffScreenin interfaceImageRenderer
-
repaint
public void repaint(java.awt.Shape area)
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
public void repaint(RectListManager areas)
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:
flushin interfaceImageRenderer
-
flush
public void flush(java.util.Collection areas)
Flush a list of rectangles of cached image data.- Specified by:
flushin interfaceImageRenderer
-
flush
public void flush(java.awt.Rectangle r)
Flush a rectangle of cached image data.- Specified by:
flushin interfaceImageRenderer
-
setupCache
protected CachableRed setupCache(CachableRed img)
-
renderGNR
protected CachableRed renderGNR()
-
updateWorkingBuffers
protected void updateWorkingBuffers()
Internal method used to synchronize local state in response to various set methods.
-
-