scenic.awt
Class ScenicGraphics2D

java.lang.Object
  extended by java.awt.Graphics
      extended by java.awt.Graphics2D
          extended by scenic.awt.AbstractGraphics2D
              extended by scenic.awt.ScenicGraphics2D
All Implemented Interfaces:
java.lang.Cloneable

public class ScenicGraphics2D
extends AbstractGraphics2D

Implementation of the Graphics2D class that uses the Scenic library for rendering. This implementation does not use direct rendering, instead it creates scene trees. After the scene tree is finished it can be rendered on the screen or to an offscreen image.


Constructor Summary
ScenicGraphics2D(SceneContainer scene)
          Constructs a new ScenicGraphics2D using the given scene as the root node.
ScenicGraphics2D(ScenicGraphics2D parent)
          Constructs a SceneGraphics2D that is a copy of the given SceneGraphics2D object.
ScenicGraphics2D(ScenicImage image)
          Constructs a new ScenicGraphics2D using the given image as the rendering target.
 
Method Summary
 void clip(java.awt.Shape s)
          Intersects the current Clip with the interior of the specified Shape and sets the Clip to the resulting intersection.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
           
 java.awt.Graphics create()
           
 void dispose()
           
 void draw(java.awt.Shape s)
           
 boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
          Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface.
 void drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)
           
 void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
           
 void drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
           
 void drawString(java.lang.String str, float x, float y)
           
 void fill(java.awt.Shape s)
           
 java.awt.GraphicsConfiguration getDeviceConfiguration()
           
 java.awt.FontMetrics getFontMetrics(java.awt.Font f)
           
 java.awt.geom.AffineTransform getTransform()
           
 void rotate(double theta)
           
 void rotate(double theta, double x, double y)
           
 void scale(double sx, double sy)
           
 void setClip(java.awt.Shape s)
          Sets the current clipping area to an arbitrary clip shape.
 void setTransform(java.awt.geom.AffineTransform Tx)
           
 void setXORMode(java.awt.Color c1)
           
 void shear(double shx, double shy)
           
 void transform(java.awt.geom.AffineTransform Tx)
           
 void translate(double tx, double ty)
           
 void translate(int tx, int ty)
           
 
Methods inherited from class scenic.awt.AbstractGraphics2D
addRenderingHints, clearRect, clipRect, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getClip, getClipBounds, getColor, getComposite, getFont, getFontRenderContext, getGraphicContext, getPaint, getRenderingHint, getRenderingHints, getStroke, hit, setBackground, setClip, setColor, setComposite, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScenicGraphics2D

public ScenicGraphics2D(SceneContainer scene)
Constructs a new ScenicGraphics2D using the given scene as the root node.

Parameters:
scene - the root node

ScenicGraphics2D

public ScenicGraphics2D(ScenicImage image)
Constructs a new ScenicGraphics2D using the given image as the rendering target. The image is rendered when the dispose method is called.

Parameters:
image - the render target

ScenicGraphics2D

public ScenicGraphics2D(ScenicGraphics2D parent)
Constructs a SceneGraphics2D that is a copy of the given SceneGraphics2D object. Note that the implementation of ScenicGraphics2D is not totally compliant with the normal Graphics2D implementation. To avoid any problems, different SceneGraphics2D objects that share the same parent object should not be in parallel.

Parameters:
parent - the parent object
Method Detail

getTransform

public java.awt.geom.AffineTransform getTransform()
Specified by:
getTransform in class java.awt.Graphics2D

rotate

public void rotate(double theta,
                   double x,
                   double y)
Specified by:
rotate in class java.awt.Graphics2D

rotate

public void rotate(double theta)
Specified by:
rotate in class java.awt.Graphics2D

scale

public void scale(double sx,
                  double sy)
Specified by:
scale in class java.awt.Graphics2D

setTransform

public void setTransform(java.awt.geom.AffineTransform Tx)
Specified by:
setTransform in class java.awt.Graphics2D

shear

public void shear(double shx,
                  double shy)
Specified by:
shear in class java.awt.Graphics2D

transform

public void transform(java.awt.geom.AffineTransform Tx)
Specified by:
transform in class java.awt.Graphics2D

translate

public void translate(double tx,
                      double ty)
Specified by:
translate in class java.awt.Graphics2D

translate

public void translate(int tx,
                      int ty)
Specified by:
translate in class java.awt.Graphics2D

draw

public void draw(java.awt.Shape s)
Specified by:
draw in class java.awt.Graphics2D

fill

public void fill(java.awt.Shape s)
Specified by:
fill in class java.awt.Graphics2D

clip

public void clip(java.awt.Shape s)
Description copied from class: AbstractGraphics2D
Intersects the current Clip with the interior of the specified Shape and sets the Clip to the resulting intersection. The specified Shape is transformed with the current Graphics2D Transform before being intersected with the current Clip. This method is used to make the current Clip smaller. To make the Clip larger, use setClip. The user clip modified by this method is independent of the clipping associated with device bounds and visibility. If no clip has previously been set, or if the clip has been cleared using setClip with a null argument, the specified Shape becomes the new user clip.

Overrides:
clip in class AbstractGraphics2D
Parameters:
s - the Shape to be intersected with the current Clip. If s is null, this method clears the current Clip.

setClip

public void setClip(java.awt.Shape s)
Description copied from class: AbstractGraphics2D
Sets the current clipping area to an arbitrary clip shape. Not all objects that implement the Shape interface can be used to set the clip. The only Shape objects that are guaranteed to be supported are Shape objects that are obtained via the getClip method and via Rectangle objects. This method sets the user clip, which is independent of the clipping associated with device bounds and window visibility.

Overrides:
setClip in class AbstractGraphics2D
Parameters:
s - the Shape to use to set the clip
See Also:
Graphics.getClip(), Graphics.clipRect(int, int, int, int), Graphics.setClip(int, int, int, int)

drawRenderedImage

public void drawRenderedImage(java.awt.image.RenderedImage img,
                              java.awt.geom.AffineTransform xform)
Specified by:
drawRenderedImage in class java.awt.Graphics2D

drawRenderableImage

public void drawRenderableImage(java.awt.image.renderable.RenderableImage img,
                                java.awt.geom.AffineTransform xform)
Specified by:
drawRenderableImage in class java.awt.Graphics2D

drawString

public void drawString(java.lang.String str,
                       float x,
                       float y)
Specified by:
drawString in class java.awt.Graphics2D

drawString

public void drawString(java.text.AttributedCharacterIterator iterator,
                       float x,
                       float y)
Specified by:
drawString in class java.awt.Graphics2D

getDeviceConfiguration

public java.awt.GraphicsConfiguration getDeviceConfiguration()
Specified by:
getDeviceConfiguration in class java.awt.Graphics2D

create

public java.awt.Graphics create()
Specified by:
create in class java.awt.Graphics

setXORMode

public void setXORMode(java.awt.Color c1)
Specified by:
setXORMode in class java.awt.Graphics

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Specified by:
getFontMetrics in class java.awt.Graphics

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Specified by:
copyArea in class java.awt.Graphics

drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class java.awt.Graphics

drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class java.awt.Graphics

drawImage

public boolean drawImage(java.awt.Image img,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         java.awt.image.ImageObserver observer)
Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the image area to be drawn has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached, scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle, and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings.

Specified by:
drawImage in class java.awt.Graphics
Parameters:
img - the specified image to be drawn
dx1 - the x coordinate of the first corner of the destination rectangle.
dy1 - the y coordinate of the first corner of the destination rectangle.
dx2 - the x coordinate of the second corner of the destination rectangle.
dy2 - the y coordinate of the second corner of the destination rectangle.
sx1 - the x coordinate of the first corner of the source rectangle.
sy1 - the y coordinate of the first corner of the source rectangle.
sx2 - the x coordinate of the second corner of the source rectangle.
sy2 - the y coordinate of the second corner of the source rectangle.
observer - object to be notified as more of the image is scaled and converted.
Since:
JDK1.1
See Also:
Image, ImageObserver, ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)

dispose

public void dispose()
Specified by:
dispose in class java.awt.Graphics