org.apache.batik.gvt.renderer
Class MacRenderer

java.lang.Object
  extended by org.apache.batik.gvt.renderer.MacRenderer
All Implemented Interfaces:
ImageRenderer, Renderer

public class MacRenderer
extends Object
implements ImageRenderer

Simple implementation of the Renderer that supports dynamic updates.


Field Summary
protected  BufferedImage currImg
           
protected  RectListManager damagedAreas
           
protected static RenderingHints defaultRenderingHints
           
static int IMAGE_TYPE
           
protected  boolean isDoubleBuffered
           
protected  int offScreenHeight
           
protected  int offScreenWidth
           
protected  RenderingHints renderingHints
           
protected  GraphicsNode rootGN
           
static Color TRANSPARENT_WHITE
           
protected  AffineTransform usr2dev
           
protected  BufferedImage workImg
           
 
Constructor Summary
MacRenderer()
          Constructs a new dynamic renderer with the specified buffer image.
MacRenderer(RenderingHints rh, AffineTransform at)
           
 
Method Summary
 void clearOffScreen()
          Sets up and clears the current offscreen buffer.
 void dispose()
          release resources associated with this object.
 void flush()
          Flush any cached image data (preliminary interface).
 void flush(Collection areas)
          Flush a list of rectangles of cached image data.
 void flush(Rectangle r)
          Flush a rectangle of cached image data (preliminary interface).
 BufferedImage getOffScreen()
          Returns the current offscreen image.
 RenderingHints getRenderingHints()
          Returns the rendering hints this ImageRenderer is using for its rendering.
 AffineTransform getTransform()
          Returns the transform from the current user space (as defined by the top node of the GVT tree) to the device space.
 GraphicsNode getTree()
          Returns the GVT tree associated with this renderer
 boolean isDoubleBuffered()
          Returns true if the Renderer is currently doubleBuffering is rendering requests.
 void repaint(RectListManager devRLM)
          Repaints the associated GVT tree under the list of areas.
 void repaint(Shape area)
          Repaints the associated GVT tree at least under area.
 void setDoubleBuffered(boolean isDoubleBuffered)
          Turns on/off double buffering in renderer.
 void setRenderingHints(RenderingHints rh)
          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 treeRoot)
          This associates the given GVT Tree with this renderer.
 void updateOffScreen(int width, int height)
          Update the size of the image to be returned by getOffScreen.
protected  void updateWorkingBuffers()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

renderingHints

protected RenderingHints renderingHints

usr2dev

protected AffineTransform usr2dev

rootGN

protected GraphicsNode rootGN

offScreenWidth

protected int offScreenWidth

offScreenHeight

protected int offScreenHeight

isDoubleBuffered

protected boolean isDoubleBuffered

currImg

protected BufferedImage currImg

workImg

protected BufferedImage workImg

damagedAreas

protected RectListManager damagedAreas

IMAGE_TYPE

public static int IMAGE_TYPE

TRANSPARENT_WHITE

public static Color TRANSPARENT_WHITE

defaultRenderingHints

protected static RenderingHints defaultRenderingHints
Constructor Detail

MacRenderer

public MacRenderer()
Constructs a new dynamic renderer with the specified buffer image.


MacRenderer

public MacRenderer(RenderingHints rh,
                   AffineTransform at)
Method Detail

dispose

public void dispose()
Description copied from interface: ImageRenderer
release resources associated with this object.

Specified by:
dispose in interface ImageRenderer
Specified by:
dispose in interface Renderer

setTree

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

Specified by:
setTree in interface Renderer

getTree

public GraphicsNode getTree()
Returns the GVT tree associated with this renderer

Specified by:
getTree in interface Renderer

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.

Specified by:
setTransform in interface ImageRenderer
Specified by:
setTransform in interface Renderer
Parameters:
usr2dev - the new user space to device space transform. If null, the identity transform will be set.

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.

Specified by:
getTransform in interface ImageRenderer
Specified by:
getTransform in interface Renderer

setRenderingHints

public void setRenderingHints(RenderingHints rh)
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 interface ImageRenderer
Parameters:
rh - Set of rendering hints to use for future renderings

getRenderingHints

public RenderingHints getRenderingHints()
Description copied from interface: ImageRenderer
Returns the rendering hints this ImageRenderer is using for its rendering.

Specified by:
getRenderingHints in interface ImageRenderer
Returns:
the RenderingHints which the Renderer is using for its rendering

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 interface Renderer

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 interface Renderer
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 interface ImageRenderer

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.

Specified by:
getOffScreen in interface ImageRenderer

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 interface ImageRenderer

flush

public void flush()
Description copied from interface: ImageRenderer
Flush any cached image data (preliminary interface).

Specified by:
flush in interface ImageRenderer

flush

public void flush(Rectangle r)
Description copied from interface: ImageRenderer
Flush a rectangle of cached image data (preliminary interface).

Specified by:
flush in interface ImageRenderer

flush

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

Specified by:
flush in interface ImageRenderer

updateWorkingBuffers

protected void updateWorkingBuffers()

repaint

public void repaint(Shape area)
Description copied from interface: Renderer
Repaints the associated GVT tree at least under area.

Specified by:
repaint in interface Renderer
Parameters:
area - the region to be repainted, in the current user space coordinate system.

repaint

public void repaint(RectListManager devRLM)
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.

Specified by:
repaint in interface Renderer
Parameters:
devRLM - regions to be repainted, in the current user space coordinate system.


Copyright © 2008 Apache Software Foundation. All Rights Reserved.