edu.umd.cs.jazz.util
Class ZRenderContext

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZRenderContext
All Implemented Interfaces:
java.io.Serializable

public class ZRenderContext
extends java.lang.Object
implements java.io.Serializable

ZRenderContext stores information relevant to the current render as it occurs. The render context is available to objects when they are rendered, and the objects can use this information to change the way they render themselves.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Benjamin B. Bederson
See Also:
ZCamera, Serialized Form

Constructor Summary
ZRenderContext(java.awt.Graphics2D aG2, ZBounds visibleBounds, ZDrawingSurface aSurface, int qualityRequested)
          Constructs a new ZRenderContext.
ZRenderContext(ZCamera camera)
          Constructs a simple ZRenderContext.
 
Method Summary
 boolean getAccurateSpacing()
          Determine if strings should be rendered with accurate (but slower) character spacing.
 double getCameraMagnification()
          Returns the magnification of the current camera being rendered within.
 java.awt.geom.AffineTransform getCameraTransform()
          Get the transform the current camera was given before it started rendering itself.
 double getCompositeMagnification()
          Returns the total current magnification that is currently being used for rendering.
 ZDrawingSurface getDrawingSurface()
          Get the drawing surface being rendered onto.
 java.awt.Graphics2D getGraphics2D()
          Get the graphics used for this render.
 boolean getGreekText()
          Determine if text should be rendered "greeked"
 ZCamera getRenderingCamera()
          Get the current camera being rendered within.
 ZBounds getVisibleBounds()
          Get the visible bounds of the current render in the local coordinate system.
 void popCamera()
          Remove a rendering camera
 void popVisibleBounds()
          Remove a visible bounds from the render context.
 void pushCamera(ZCamera camera)
          Add a rendering camera
 void pushVisibleBounds(ZBounds bounds)
          Add a visible bounds to the render context.
 void setAccurateSpacing(boolean b)
          Specify if strings should be rendered one character at a time with slower, but more accurate spacing.
 void setGreekText(boolean b)
          Specify if strings should be rendered as "greek" blobs rather than actual text.
protected  void setRenderingHints(java.awt.Graphics2D g2, int quality)
          Sets the rendering hints of the specified graphics to either or high or low.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZRenderContext

public ZRenderContext(ZCamera camera)
Constructs a simple ZRenderContext. This is intended to be used only by context-sensitive objects to compute bounds. This constructor should not be used for render contexts to be used for an actual render.
Parameters:
camera - The camera

ZRenderContext

public ZRenderContext(java.awt.Graphics2D aG2,
                      ZBounds visibleBounds,
                      ZDrawingSurface aSurface,
                      int qualityRequested)
Constructs a new ZRenderContext.
Parameters:
aG2 - The graphics for this render
visibleBounds - The bounds being rendered in screen coordinates
aSurface - The surface being rendered onto
qualityRequested - The quality to render with
Method Detail

getGraphics2D

public java.awt.Graphics2D getGraphics2D()
Get the graphics used for this render.
Returns:
the graphics

pushVisibleBounds

public void pushVisibleBounds(ZBounds bounds)
Add a visible bounds to the render context.
Parameters:
bounds - the new bounds.

popVisibleBounds

public void popVisibleBounds()
Remove a visible bounds from the render context.

getVisibleBounds

public ZBounds getVisibleBounds()
Get the visible bounds of the current render in the local coordinate system.
Returns:
the bounds

getDrawingSurface

public ZDrawingSurface getDrawingSurface()
Get the drawing surface being rendered onto.
Returns:
the surface

setAccurateSpacing

public void setAccurateSpacing(boolean b)
Specify if strings should be rendered one character at a time with slower, but more accurate spacing.
Parameters:
b - True turns on accurate spacing, false turns it off.

getAccurateSpacing

public boolean getAccurateSpacing()
Determine if strings should be rendered with accurate (but slower) character spacing.
Returns:
true if accurate spacing is on

setGreekText

public void setGreekText(boolean b)
Specify if strings should be rendered as "greek" blobs rather than actual text. Typically only very small text should be rendered "greeked" and only when the system is animating.
Parameters:
b - True turns on greek text.

getGreekText

public boolean getGreekText()
Determine if text should be rendered "greeked"
Returns:
true if text is "greeked"

setRenderingHints

protected void setRenderingHints(java.awt.Graphics2D g2,
                                 int quality)
Sets the rendering hints of the specified graphics to either or high or low. This gets called whenever the surface is painted, and specifies how high and low quality are defined.

getRenderingCamera

public ZCamera getRenderingCamera()
Get the current camera being rendered within.
Returns:
the camera

getCameraTransform

public java.awt.geom.AffineTransform getCameraTransform()
Get the transform the current camera was given before it started rendering itself. This could be useful for an advanced object type that needs to know what the transform was before the current camera changed it to apply its view.
Returns:
the transform

pushCamera

public void pushCamera(ZCamera camera)
Add a rendering camera
Parameters:
camera - The camera

popCamera

public void popCamera()
Remove a rendering camera

getCameraMagnification

public double getCameraMagnification()
Returns the magnification of the current camera being rendered within. If currently being rendered within nested cameras, then this returns only the magnification of the current camera. Note that this does not include the transformations of the current or any other object being rendered.
See Also:
getCompositeMagnification()

getCompositeMagnification

public double getCompositeMagnification()
Returns the total current magnification that is currently being used for rendering. This includes the magnifcation of the current cameras as well as the scale of the current any parent objects.
See Also:
getCameraMagnification()


Copyright © 2001 by University of Maryland, College Park, MD 20742, USA All rights reserved.