org.jfree.pixie.g2recorder
Class G2Recorder

java.lang.Object
  |
  +--java.awt.Graphics
        |
        +--java.awt.Graphics2D
              |
              +--org.jfree.pixie.AbstractGraphics2D
                    |
                    +--org.jfree.pixie.g2recorder.G2Recorder

public class G2Recorder
extends AbstractGraphics2D


Constructor Summary
G2Recorder()
           
G2Recorder(G2Recorder recorder)
           
 
Method Summary
protected  void addOperation(G2Operation operation)
           
 void addRenderingHints(java.util.Map hints)
          Sets the values of an arbitrary number of preferences for the rendering algorithms.
 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)
          Copies an area of the component by a distance specified by dx and dy.
 java.awt.Graphics create()
          Creates a new Graphics object that is a copy of this Graphics object.
 void dispose()
          Disposes of this graphics context and releases any system resources that it is using.
 void draw(java.awt.Shape s)
          Strokes the outline of a Shape using the settings of the current Graphics2D context.
 boolean drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)
          Renders an image, applying a transform from image space into user space before drawing.
 void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
          Renders a RenderedImage, applying a transform from image space into user space before drawing.
 void drawString(java.lang.String s, float x, float y)
          Renders the text specified by the specified String, using the current Font and Paint attributes in the Graphics2D context.
 void fill(java.awt.Shape s)
          Fills the interior of a Shape using the settings of the Graphics2D context.
 java.awt.Color getBackground()
          Returns the background color used for clearing a region.
 java.awt.Shape getClip()
          Gets the current clipping area.
 java.awt.Composite getComposite()
          Returns the current Composite in the Graphics2D context.
 java.awt.GraphicsConfiguration getDeviceConfiguration()
          Returns the device configuration associated with this Graphics2D.
 java.awt.Font getFont()
          Gets the current font.
 java.awt.FontMetrics getFontMetrics(java.awt.Font f)
          Gets the font metrics for the specified font.
 java.awt.font.FontRenderContext getFontRenderContext()
          Get the rendering context of the Font within this Graphics2D context.
 java.awt.Paint getPaint()
          Returns the current Paint of the Graphics2D context.
 java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
          Returns the value of a single preference for the rendering algorithms.
 java.awt.RenderingHints getRenderingHints()
          Gets the preferences for the rendering algorithms.
 G2OpStore getStore()
           
 java.awt.Stroke getStroke()
          Returns the current Stroke in the Graphics2D context.
 java.awt.geom.AffineTransform getTransform()
          Returns a copy of the current Transform in the Graphics2D context.
 void setBackground(java.awt.Color color)
          Sets the background color for the Graphics2D context.
 void setClip(java.awt.Shape clip)
          Sets the current clipping area to an arbitrary clip shape.
 void setComposite(java.awt.Composite comp)
          Sets the Composite for the Graphics2D context.
 void setFont(java.awt.Font font)
          Sets this graphics context's font to the specified font.
 void setPaint(java.awt.Paint paint)
          Sets the Paint attribute for the Graphics2D context.
 void setPaintMode()
          Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color.
 void setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
          Sets the value of a single preference for the rendering algorithms.
 void setRenderingHints(java.util.Map hints)
          Replaces the values of all preferences for the rendering algorithms with the specified hints.
 void setStroke(java.awt.Stroke s)
          Sets the Stroke for the Graphics2D context.
 void setTransform(java.awt.geom.AffineTransform Tx)
          Sets the Transform in the Graphics2D context.
 void setXORMode(java.awt.Color c1)
          Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color.
 
Methods inherited from class org.jfree.pixie.AbstractGraphics2D
clearRect, clipRect, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRenderableImage, drawRoundRect, drawString, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getClipBounds, getColor, hit, rotate, rotate, scale, setClip, setColor, shear, transform, translate, translate
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

G2Recorder

public G2Recorder()

G2Recorder

public G2Recorder(G2Recorder recorder)
Method Detail

getStore

public G2OpStore getStore()

addOperation

protected void addOperation(G2Operation operation)

draw

public void draw(java.awt.Shape s)
Strokes the outline of a Shape using the settings of the current Graphics2D context. The rendering attributes applied include the Clip, Transform, Paint, Composite and Stroke attributes.

Specified by:
draw in class java.awt.Graphics2D
Parameters:
s - the Shape to be rendered
See Also:
setStroke(java.awt.Stroke), setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), AbstractGraphics2D.transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), clip(java.awt.Shape), setClip(java.awt.Shape), setComposite(java.awt.Composite)

drawImage

public boolean drawImage(java.awt.Image img,
                         java.awt.geom.AffineTransform xform,
                         java.awt.image.ImageObserver obs)
Renders an image, applying a transform from image space into user space before drawing. The transformation from user space into device space is done with the current Transform in the Graphics2D. The specified transformation is applied to the image before the transform attribute in the Graphics2D context is applied. The rendering attributes applied include the Clip, Transform, and Composite attributes. Note that no rendering is done if the specified transform is noninvertible.

Specified by:
drawImage in class java.awt.Graphics2D
Parameters:
img - the Image to be rendered
xform - the transformation from image space into user space
obs - the ImageObserver to be notified as more of the Image is converted
Returns:
true if the Image is fully loaded and completely rendered; false if the Image is still being loaded.
See Also:
AbstractGraphics2D.transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), setClip(java.awt.Shape)

drawRenderedImage

public void drawRenderedImage(java.awt.image.RenderedImage img,
                              java.awt.geom.AffineTransform xform)
Renders a RenderedImage, applying a transform from image space into user space before drawing. The transformation from user space into device space is done with the current Transform in the Graphics2D. The specified transformation is applied to the image before the transform attribute in the Graphics2D context is applied. The rendering attributes applied include the Clip, Transform, and Composite attributes. Note that no rendering is done if the specified transform is noninvertible.

Specified by:
drawRenderedImage in class java.awt.Graphics2D
Parameters:
img - the image to be rendered
xform - the transformation from image space into user space
See Also:
AbstractGraphics2D.transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), setClip(java.awt.Shape)

drawString

public void drawString(java.lang.String s,
                       float x,
                       float y)
Renders the text specified by the specified String, using the current Font and Paint attributes in the Graphics2D context. The baseline of the first character is at position (xy) in the User Space. The rendering attributes applied include the Clip, Transform, Paint, Font and Composite attributes. For characters in script systems such as Hebrew and Arabic, the glyphs can be rendered from right to left, in which case the coordinate supplied is the location of the leftmost character on the baseline.

Specified by:
drawString in class java.awt.Graphics2D
Parameters:
s - the String to be rendered
x - the coordinates where the iterator's text is to be rendered
y - the coordinates where the iterator's text is to be rendered
Throws:
java.lang.NullPointerException - if str is null
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), Graphics.setFont(java.awt.Font), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), setClip(java.awt.Shape)

fill

public void fill(java.awt.Shape s)
Fills the interior of a Shape using the settings of the Graphics2D context. The rendering attributes applied include the Clip, Transform, Paint, and Composite.

Specified by:
fill in class java.awt.Graphics2D
Parameters:
s - the Shape to be filled
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), AbstractGraphics2D.transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), setClip(java.awt.Shape)

getDeviceConfiguration

public java.awt.GraphicsConfiguration getDeviceConfiguration()
Returns the device configuration associated with this Graphics2D.

Specified by:
getDeviceConfiguration in class java.awt.Graphics2D

setComposite

public void setComposite(java.awt.Composite comp)
Sets the Composite for the Graphics2D context. The Composite is used in all drawing methods such as drawImage, drawString, draw, and fill. It specifies how new pixels are to be combined with the existing pixels on the graphics device during the rendering process.

If this Graphics2D context is drawing to a Component on the display screen and the Composite is a custom object rather than an instance of the AlphaComposite class, and if there is a security manager, its checkPermission method is called with an AWTPermission("readDisplayPixels") permission.

Specified by:
setComposite in class java.awt.Graphics2D
Parameters:
comp - the Composite object to be used for rendering
Throws:
java.lang.SecurityException - if a custom Composite object is being used to render to the screen and a security manager is set and its checkPermission method does not allow the operation.
See Also:
Graphics.setXORMode(java.awt.Color), Graphics.setPaintMode(), AlphaComposite, SecurityManager.checkPermission(java.security.Permission), AWTPermission

setPaint

public void setPaint(java.awt.Paint paint)
Sets the Paint attribute for the Graphics2D context. Calling this method with a null Paint object does not have any effect on the current Paint attribute of this Graphics2D.

Specified by:
setPaint in class java.awt.Graphics2D
Parameters:
paint - the Paint object to be used to generate color during the rendering process, or null
See Also:
Graphics.setColor(java.awt.Color), GradientPaint, TexturePaint

setStroke

public void setStroke(java.awt.Stroke s)
Sets the Stroke for the Graphics2D context.

Specified by:
setStroke in class java.awt.Graphics2D
Parameters:
s - the Stroke object to be used to stroke a Shape during the rendering process
See Also:
BasicStroke

setRenderingHint

public void setRenderingHint(java.awt.RenderingHints.Key hintKey,
                             java.lang.Object hintValue)
Sets the value of a single preference for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values.

Specified by:
setRenderingHint in class java.awt.Graphics2D
Parameters:
hintKey - the key of the hint to be set.
hintValue - the value indicating preferences for the specified hint category.
See Also:
RenderingHints

getRenderingHint

public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
Returns the value of a single preference for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values.

Specified by:
getRenderingHint in class java.awt.Graphics2D
Parameters:
hintKey - the key corresponding to the hint to get.
Returns:
an object representing the value for the specified hint key. Some of the keys and their associated values are defined in the RenderingHints class.
See Also:
RenderingHints

setRenderingHints

public void setRenderingHints(java.util.Map hints)
Replaces the values of all preferences for the rendering algorithms with the specified hints. The existing values for all rendering hints are discarded and the new set of known hints and values are initialized from the specified Map object. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values.

Specified by:
setRenderingHints in class java.awt.Graphics2D
Parameters:
hints - the rendering hints to be set
See Also:
RenderingHints

addRenderingHints

public void addRenderingHints(java.util.Map hints)
Sets the values of an arbitrary number of preferences for the rendering algorithms. Only values for the rendering hints that are present in the specified Map object are modified. All other preferences not present in the specified object are left unmodified. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values.

Specified by:
addRenderingHints in class java.awt.Graphics2D
Parameters:
hints - the rendering hints to be set
See Also:
RenderingHints

getRenderingHints

public java.awt.RenderingHints getRenderingHints()
Gets the preferences for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Returns all of the hint key/value pairs that were ever specified in one operation. Refer to the RenderingHints class for definitions of some common keys and values.

Specified by:
getRenderingHints in class java.awt.Graphics2D
Returns:
a reference to an instance of RenderingHints that contains the current preferences.
See Also:
RenderingHints

setTransform

public void setTransform(java.awt.geom.AffineTransform Tx)
Sets the Transform in the Graphics2D context.

Specified by:
setTransform in class java.awt.Graphics2D
Parameters:
Tx - the AffineTransform object to be used in the rendering process
See Also:
AbstractGraphics2D.transform(java.awt.geom.AffineTransform), AffineTransform

getTransform

public java.awt.geom.AffineTransform getTransform()
Returns a copy of the current Transform in the Graphics2D context.

Specified by:
getTransform in class java.awt.Graphics2D
Returns:
the current AffineTransform in the Graphics2D context.
See Also:
AbstractGraphics2D.transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform)

getPaint

public java.awt.Paint getPaint()
Returns the current Paint of the Graphics2D context.

Specified by:
getPaint in class java.awt.Graphics2D
Returns:
the current Graphics2D Paint, which defines a color or pattern.
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color)

getComposite

public java.awt.Composite getComposite()
Returns the current Composite in the Graphics2D context.

Specified by:
getComposite in class java.awt.Graphics2D
Returns:
the current Graphics2D Composite, which defines a compositing style.
See Also:
setComposite(java.awt.Composite)

setBackground

public void setBackground(java.awt.Color color)
Sets the background color for the Graphics2D context. The background color is used for clearing a region. When a Graphics2D is constructed for a Component, the background color is inherited from the Component. Setting the background color in the Graphics2D context only affects the subsequent clearRect calls and not the background color of the Component. To change the background of the Component, use appropriate methods of the Component.

Specified by:
setBackground in class java.awt.Graphics2D
Parameters:
color - the background color that isused in subsequent calls to clearRect
See Also:
getBackground(), Graphics.clearRect(int, int, int, int)

getBackground

public java.awt.Color getBackground()
Returns the background color used for clearing a region.

Specified by:
getBackground in class java.awt.Graphics2D
Returns:
the current Graphics2D Color, which defines the background color.
See Also:
setBackground(java.awt.Color)

getStroke

public java.awt.Stroke getStroke()
Returns the current Stroke in the Graphics2D context.

Specified by:
getStroke in class java.awt.Graphics2D
Returns:
the current Graphics2D Stroke, which defines the line style.
See Also:
setStroke(java.awt.Stroke)

getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()
Get the rendering context of the Font within this Graphics2D context. The FontRenderContext encapsulates application hints such as anti-aliasing and fractional metrics, as well as target device specific information such as dots-per-inch. This information should be provided by the application when using objects that perform typographical formatting, such as Font and TextLayout. This information should also be provided by applications that perform their own layout and need accurate measurements of various characteristics of glyphs such as advance and line height when various rendering hints have been applied to the text rendering.

Specified by:
getFontRenderContext in class java.awt.Graphics2D
Returns:
a reference to an instance of FontRenderContext.
Since:
1.2
See Also:
FontRenderContext, Font.createGlyphVector(java.awt.font.FontRenderContext, java.lang.String), TextLayout

create

public java.awt.Graphics create()
Creates a new Graphics object that is a copy of this Graphics object.

Specified by:
create in class java.awt.Graphics
Returns:
a new graphics context that is a copy of this graphics context.

setPaintMode

public void setPaintMode()
Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color. This sets the logical pixel operation function to the paint or overwrite mode. All subsequent rendering operations will overwrite the destination with the current color.

Specified by:
setPaintMode in class java.awt.Graphics

setXORMode

public void setXORMode(java.awt.Color c1)
Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color. This specifies that logical pixel operations are performed in the XOR mode, which alternates pixels between the current color and a specified XOR color.

When drawing operations are performed, pixels which are the current color are changed to the specified color, and vice versa.

Pixels that are of colors other than those two colors are changed in an unpredictable but reversible manner; if the same figure is drawn twice, then all pixels are restored to their original values.

Specified by:
setXORMode in class java.awt.Graphics
Parameters:
c1 - the XOR alternation color

getFont

public java.awt.Font getFont()
Gets the current font.

Specified by:
getFont in class java.awt.Graphics
Returns:
this graphics context's current font.
See Also:
Font, Graphics.setFont(java.awt.Font)

setFont

public void setFont(java.awt.Font font)
Sets this graphics context's font to the specified font. All subsequent text operations using this graphics context use this font.

Specified by:
setFont in class java.awt.Graphics
Parameters:
font - the font.
See Also:
Graphics.getFont(), Graphics.drawString(String, int, int), Graphics.drawBytes(byte[], int, int, int, int), Graphics.drawChars(char[], int, int, int, int)

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Gets the font metrics for the specified font.

Specified by:
getFontMetrics in class java.awt.Graphics
Parameters:
f - the specified font
Returns:
the font metrics for the specified font.
See Also:
Graphics.getFont(), FontMetrics, Graphics.getFontMetrics()

clip

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

Specified by:
clip in class java.awt.Graphics2D
Parameters:
s - the Shape to be intersected with the current Clip. If s is null, this method clears the current Clip.

getClip

public java.awt.Shape getClip()
Gets the current clipping area. This method returns the user clip, which is independent of the clipping associated with device bounds and window visibility. If no clip has previously been set, or if the clip has been cleared using setClip(null), this method returns null.

Specified by:
getClip in class java.awt.Graphics
Returns:
a Shape object representing the current clipping area, or null if no clip is set.
Since:
JDK1.1
See Also:
Graphics.getClipBounds(), Graphics.clipRect(int, int, int, int), Graphics.setClip(int, int, int, int), Graphics.setClip(Shape)

setClip

public void setClip(java.awt.Shape clip)
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.

Specified by:
setClip in class java.awt.Graphics
Parameters:
clip - the Shape to use to set the clip
Since:
JDK1.1
See Also:
Graphics.getClip(), Graphics.clipRect(int, int, int, int), Graphics.setClip(int, int, int, int)

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Copies an area of the component by a distance specified by dx and dy. From the point specified by x and y, this method copies downwards and to the right. To copy an area of the component to the left or upwards, specify a negative value for dx or dy. If a portion of the source rectangle lies outside the bounds of the component, or is obscured by another window or component, copyArea will be unable to copy the associated pixels. The area that is omitted can be refreshed by calling the component's paint method.

Specified by:
copyArea in class java.awt.Graphics
Parameters:
x - the x coordinate of the source rectangle.
y - the y coordinate of the source rectangle.
width - the width of the source rectangle.
height - the height of the source rectangle.
dx - the horizontal distance to copy the pixels.
dy - the vertical distance to copy the pixels.

dispose

public void dispose()
Disposes of this graphics context and releases any system resources that it is using. A Graphics object cannot be used after disposehas been called.

When a Java program runs, a large number of Graphics objects can be created within a short time frame. Although the finalization process of the garbage collector also disposes of the same system resources, it is preferable to manually free the associated resources by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.

Graphics objects which are provided as arguments to the paint and update methods of components are automatically released by the system when those methods return. For efficiency, programmers should call dispose when finished using a Graphics object only if it was created directly from a component or another Graphics object.

Specified by:
dispose in class java.awt.Graphics
See Also:
Graphics.finalize(), Component.paint(java.awt.Graphics), Component.update(java.awt.Graphics), Component.getGraphics(), Graphics.create()