Java Platform 1.2
Beta 4

Class java.awt.Graphics2D

java.lang.Object
  |
  +--java.awt.Graphics
        |
        +--java.awt.Graphics2D

public abstract class Graphics2D
extends Graphics
This is the fundamental class for 2D rendering in Java. This class extends the original java.awt.Graphics class to provide more sophisticated control over geometry, coordinate transformation, color management, and text layout.

Coordinate Spaces

All coordinates that are given to a Graphics2D object are treated as being in a virtual coordinate system which is called the User Coordinate Space, or User Space. The Graphics2D object contains an AffineTransform object as part of its rendering state that defines how to convert coordinates from this user space to coordinates in the Device Coordinate Space, or Device Space.

Coordinates in device space usually refer to individual device pixels and are aligned in the infinitely thin gaps between these pixels. Some Graphics2D objects may be used to capture rendering operations for storage into a graphics metafile for playback on a concrete device of unknown physical resolution at a later time. Since the resolution may not be known when the rendering operations are captured, the Transform will be set up to transform user coordinates to a virtual device space that typically approximates the expected resolution of the target device, though further transformation may need to be applied at playback time if the estimate is incorrect.

Some of the operations performed by the rendering attribute objects may operate in the device space, but all methods that are defined on the Graphics2D object work with user space coordinates.

The default transform when a Graphics2D object is created will be specified by the GraphicsConfiguration for the target of the Graphics2D (a Component or Image). This default transform will map the user space coordinate system to screen and printer device coordinates such that the origin maps to the upper left hand corner of the target region of the device with increasing X coordinates extending to the right and increasing Y coordinates extending downward. The scaling of the default transform for screen devices will be set to identity for screen devices. The scaling of the default transform for printers and other high resolution devices will be set to approximate 72 user space coordinates per device inch. For image buffers, the default transform will be the Identity transform.

Rendering Outline

Rendering in the Java 2D API can be described by a 4-step conceptual process controlled by the various rendering attributes in the Graphics2D object. The renderer may optimize many of these steps, either by caching the results for future calls, by collapsing multiple virtual steps into a single operation, or by recognizing various attributes as common simple cases that can be eliminated by modifying other parts of the operation.

As a behavioral reference, the steps can be described in the following way:

  1. Determine where to render. This step can be further broken down according to the type of rendering operation as follows:
    Shape operations
    1. If the operation is a draw(Shape) operation, then the shape is converted into a shape to fill using the Stroke.createStrokedShape(java.awt.Shape) method on the current Stroke.
    2. The shape is transformed from user space to device space using the current AffineTransform.
    3. The outline of the Shape is extracted using a PathIterator using the Shape.getPathIterator(java.awt.geom.AffineTransform) method.
    4. If the Graphics2D object is not able to handle the curved segments that a PathIterator object can return, then it may call the alternat getPathIterator() method which flattens the shape.
    Text operations
    1. The set of glyphs required to render the indicated string are determined as follows:
      • If the argument is a String, then the current Font is asked to convert the Unicode characters in the String into a a set of glyphs for presentation with whatever basic layout and shaping algorithms the font implements.
      • If the argument is an AttributedCharacterIterator, the iterator is asked to convert itself to a TextLayout using its embedded font attributes. The TextLayout may implement more sophisticated glyph layout algorithms that perform Unicode bi-directional layout adjustments automatically for multiple fonts of differing writing directions.
      • If the argument is a GlyphVector, then the GlyphVector object already contains the appropriate font-specific glyph codes with explicit coordinates for the position of each glyph.
    2. The current Font is queried to obtain outlines for the indicated glyphs. These outlines are treated as shapes in user space relative to the position of each glyph that was determined in step 1.
    3. The outline of the characters are filled as indicated above under Graphics2D#rendershape
    Image operations
    1. The bounding box of the source image defines the region of interest in a coordinate system local to the Image object, called Image Space.
    2. If an optional transform is supplied to the drawImage(java.awt.Image, java.awt.geom.AffineTransform, java.awt.image.ImageObserver) method call, then this transform is used to transform the bounding box from image space to user space, otherwise the bounding box is treated as if it already was in user space.
    3. The bounding box of the source image is then transformed from user space into device space using the current transform of the Graphics2D. Note that the result of transforming the bounding box will not necessarily result in a rectangular region in device space and for some custom transforms may not even result in a quadrilateral region.
  2. Constrain the rendering operation to the current Clip. The clip was originally specified by a shape in user space and was converted into device space by the Transform in effect at the time it was modified.
  3. Determine what colors to render as the renderer scan converts the associated shape in device space.
  4. Apply the colors to the destination drawing surface using the current Composite object.

Default values

The default values for the various rendering attributes are:
Color
The color of the Component.
Font
The font of the Component.
Stroke
A square pen with a linewidth of 1, no dashing, miter segment joins and non-projecting end caps.
Transform
The GraphicsConfiguration.getDefaultTransform() for the GraphicsConfiguration of the Component.
Composite
The Porter-Duff rule.
Clip
No rendering clip, output is clipped to the Component

Rendering compatibility issue

The rendering model presented by the pre-Java 2D API Graphics class was based on a pixelization model that specified that coordinates were infinitely thin, lying between the pixels, and that drawing operations were performed by dragging a one-pixel square Pen along the path hanging down and to the right of the anchor point on the path.

The behavior of these operations given the model presented here is unclear if the current Stroke specifies a wide pen, or if there is a non-identity Transform being applied.

That rendering model was consistent with the capabilities of most of the existing class of platform renderers that needed to resolve integer coordinates to a discrete pen that must fall completely on a given number of pixels. Since the Java 2D API is capable of driving an antialiasing renderer it no longer makes sense to choose a bias direction for a wide pen since sub-pixel positioning of the pen can be made visible to the user via the blending that occurs along the edges of the traversal of the pen. It is thus, no longer true that a 1-pixel wide pen must choose to fall on pixel N as opposed to pixel N+1; it can now fall partially on both pixels.

When antialiasing is turned off with the ANTIALIAS_OFF hint, the underlying renderer may still need to apply a bias in order to resolve the conflict of which pixel to modify when the pen is exactly straddling a pixel boundary (such as when it is drawn along an integer coordinate in device space). But when antialiasing is enabled, no biasing of the pen needs to occur and so no bias should be explicitly specified by the rendering model.

Thus, there remains the problem of how to define the operation of the legacy rendering operations inherited from the Graphics class to be compatible with existing rendering behavior and to be predictable and unsurprising under all possible settings of the latest rendering attributes.

To provide predictability we will define operations for all of the legacy methods that map onto the more general draw(Shape) and fill(Shape) methods. Such a specification will thus be clear how it extends based on various settings of Stroke and Transform attributes, and rendering hints.

To provide compatibility with previous rendering behavior it is important to specify a definition that performs identically under the default attribute settings. In particular, the default Stroke is a BasicStroke with a width of 1 and no dashing, and the default Transform for screen drawing is an Identity transform. Unfortunately, the default antialiasing rendering hint is ANTIALIAS_DEFAULT which may be enabled on some implementations and not on others. This means that the definition of these operations needs to be invariant under antialiasing.

We now define the following generalizations of the various legacy methods which can be shown to be identical to the previously specified behavior under the default attributes:

The existing Graphics class defined only the single setColor method to control the color to be painted. Since the Java 2D API extends the Color object to implement the new Paint interface, the existing setColor method is now a convenience method for setting the current Paint to a Color object. setColor(c) is thus equivalent to setPaint(c).

The existing Graphics class defined two methods for controlling how colors were applied to the destination. The setPaintMode() method will now be implemented as a convenience method to set the default Composite, equivalent to setComposite(new AlphaComposite(SRC_OVER)). The setXORMode(Color xorcolor) method will now be implemented as a convenience method to set a special Composite object which ignores the Alpha components of source colors and sets the destination color to the value:

 dstpixel = (PixelOf(srccolor) ^ PixelOf(xorcolor) ^ dstpixel);
 


Constructor Summary
Graphics2D()
          Constructs a new Graphics2D object.
 
Method Summary
abstract  void clip(Shape s)
          Intersects the current clip with the interior of the specified Shape and sets the current clip to the resulting intersection.
abstract  void draw(Shape s)
          Strokes the outline of a Shape using the settings of the current graphics state.
abstract  void drawGlyphVector(GlyphVector g, float x, float y)
          Draws the text specified by the given GlyphVector using this graphics context's rendering attributes.
abstract  void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
          Draws a BufferedImage that is filtered with a BufferedImageOp.
abstract  boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
          Draws an image, applying a transform from image space into user space before drawing.
abstract  void drawRenderableImage(RenderableImage img, AffineTransform xform)
          Draws an RenderableImage, applying a transform from image space into user space before drawing.
abstract  void drawRenderedImage(RenderedImage img, AffineTransform xform)
          Draws an RenderedImage, applying a transform from image space into user space before drawing.
abstract  void drawString(AttributedCharacterIterator iterator, float x, float y)
          Draws the text given by the specified iterator, using this graphics context's current color.
abstract  void drawString(AttributedCharacterIterator iterator, int x, int y)
          Draws the text given by the specified iterator, using this graphics context's current color.
abstract  void drawString(String s, float x, float y)
          Draws the text given by the specified string, using this graphics context's current font and color.
abstract  void drawString(String str, int x, int y)
          Draws the text given by the specified string, using this graphics context's current font and color.
abstract  void fill(Shape s)
          Fills the interior of a Shape using the settings of the current graphics state.
abstract  Color getBackground()
          Returns the background color used for clearing a region.
abstract  Composite getComposite()
          Returns the current Composite in the Graphics2D state.
abstract  GraphicsConfiguration getDeviceConfiguration()
          Returns the device configuration associated with this Graphics2D.
abstract  FontRenderContext getFontRenderContext()
          Get the rendering context of the font within this Graphics2D context.
abstract  Paint getPaint()
          Returns the current Paint in the Graphics2D state.
abstract  Object getRenderingHint(String hintKey)
          Returns the preferences for the rendering algorithms.
abstract  RenderingHints getRenderingHints()
          Gets the preferences for the rendering algorithms.
abstract  Stroke getStroke()
          Returns the current Stroke in the Graphics2D state.
abstract  AffineTransform getTransform()
          Returns the current transform in the Graphics2D state.
abstract  boolean hit(Rectangle rect, Shape s, boolean onStroke)
          Checks to see if the outline of a Shape intersects the specified Rectangle in device space.
abstract  void rotate(double theta, double x, double y)
          Concatenates the current transform of this Graphics2D with a translated rotation transformation.
abstract  void rotate(double theta)
          Concatenates the current transform of this Graphics2D with a rotation transformation.
abstract  void scale(double sx, double sy)
          Concatenates the current transform of this Graphics2D with a scaling transformation.
abstract  void setBackground(Color color)
          Sets the background color in this context used for clearing a region.
abstract  void setComposite(Composite comp)
          Sets the Composite in the current graphics state.
abstract  void setPaint(Paint paint)
          Sets the Paint in the current graphics state.
abstract  void setRenderingHint(String hintKey, Object hintValue)
          Sets the preferences for the rendering algorithms.
abstract  void setRenderingHints(RenderingHints hints)
          Sets the preferences for the rendering algorithms.
abstract  void setStroke(Stroke s)
          Sets the Stroke in the current graphics state.
abstract  void setTransform(AffineTransform Tx)
          Sets the transform in the current graphics state.
abstract  void shear(double shx, double shy)
          Concatenates the current transform of this Graphics2D with a shearing transformation.
abstract  void transform(AffineTransform Tx)
          Composes an AffineTransform object with the transform in this Graphics2D according to the rule last-specified-first-applied.
abstract  void translate(double tx, double ty)
          Concatenates the current transform of this Graphics2D with a translation transformation.
abstract  void translate(int x, int y)
          Translates the origin of the graphics context to the point (xy) in the current coordinate system.
 
Methods inherited from class java.awt.Graphics
clearRect , clipRect , copyArea , create , create , dispose , draw3DRect , drawArc , drawBytes , drawChars , drawImage , drawImage , drawImage , drawImage , drawImage , drawImage , drawLine , drawOval , drawPolygon , drawPolygon , drawPolyline , drawRect , drawRoundRect , fill3DRect , fillArc , fillOval , fillPolygon , fillPolygon , fillRect , fillRoundRect , finalize , getClip , getClipBounds , getClipBounds , getClipRect , getColor , getFont , getFontMetrics , getFontMetrics , hitClip , setClip , setClip , setColor , setFont , setPaintMode , setXORMode , toString
 
Methods inherited from class java.lang.Object
clone , equals , getClass , hashCode , notify , notifyAll , wait , wait , wait
 

Constructor Detail

Graphics2D

protected Graphics2D()
Constructs a new Graphics2D object. Since Graphics2D is an abstract class, and since it must be customized by subclasses for different output devices, Graphics2D objects cannot be created directly. Instead, Graphics2D objects must be obtained from another Graphics2D object or created by a Component.
See Also:
Component.getGraphics(), Graphics.create()
Method Detail

draw

public abstract void draw(Shape s)
Strokes the outline of a Shape using the settings of the current graphics state. The rendering attributes applied include the clip, transform, paint or color, composite and stroke attributes.
Parameters:
s - The shape to be drawn.
See Also:
setStroke(java.awt.Stroke), setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), clip(java.awt.Shape), Graphics.setClip(int, int, int, int), setComposite(java.awt.Composite)

drawImage

public abstract boolean drawImage(Image img,
                                  AffineTransform xform,
                                  ImageObserver obs)
Draws 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 given transformation is applied to the image before the transform attribute in the Graphics2D state is applied. The rendering attributes applied include the clip, transform, and composite attributes. Note that the result is undefined, if the given transform is noninvertible.
Parameters:
img - The image to be drawn.
xform - The transformation from image space into user space.
obs - The image observer to be notified as more of the image is converted.
See Also:
transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), Graphics.setClip(int, int, int, int)

drawImage

public abstract void drawImage(BufferedImage img,
                               BufferedImageOp op,
                               int x,
                               int y)
Draws a BufferedImage that is filtered with a BufferedImageOp. The rendering attributes applied include the clip, transform and composite attributes. This is equivalent to:
 img1 = op.filter(img, null);
 drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
 
Parameters:
op - The filter to be applied to the image before drawing.
img - The BufferedImage to be drawn.
x,y - The location in user space where the image should be drawn.
See Also:
transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), Graphics.setClip(int, int, int, int)

drawRenderedImage

public abstract void drawRenderedImage(RenderedImage img,
                                       AffineTransform xform)
Draws an 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 given transformation is applied to the image before the transform attribute in the Graphics2D state is applied. The rendering attributes applied include the clip, transform, and composite attributes. Note that the result is undefined, if the given transform is noninvertible.
Parameters:
img - The image to be drawn.
xform - The transformation from image space into user space.
See Also:
transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), Graphics.setClip(int, int, int, int)

drawRenderableImage

public abstract void drawRenderableImage(RenderableImage img,
                                         AffineTransform xform)
Draws an RenderableImage, 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 given transformation is applied to the image before the transform attribute in the Graphics2D state is applied. The rendering attributes applied include the clip, transform, and composite attributes. Note that the result is undefined, if the given transform is noninvertible.

Any rendering hints set on the this Graphics2D object may be used in drawing the RenderableImage. If explicit control is required over specific hints recognized by a specific RenderableImage or if knowledge of which hints are used is required, then a RenderedImage should be obtained directly from the RenderableImage and then drawn using drawRenderedImage.

Parameters:
img - The image to be drawn.
xform - The transformation from image space into user space.
See Also:
transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), Graphics.setClip(int, int, int, int), drawRenderedImage(java.awt.image.RenderedImage, java.awt.geom.AffineTransform)

drawString

public abstract void drawString(String str,
                                int x,
                                int y)
Draws the text given by the specified string, using this graphics context's current font and color. The baseline of the first character is at position (xy) in this graphics context's coordinate system. The rendering attributes applied include the clip, transform, paint or color, font and composite attributes. For characters in script systems such as Hebrew and Arabic, the glyphs may be draw from right to left, in which case the coordinate supplied is the the location of the leftmost character on the baseline.
Parameters:
str - the string to be drawn.
x - the x coordinate.
y - the y coordinate.
Overrides:
drawString in class Graphics
Since:
JDK1.0
See Also:
Graphics.drawBytes(byte[], int, int, int, int), Graphics.drawChars(char[], int, int, int, int)

drawString

public abstract void drawString(String s,
                                float x,
                                float y)
Draws the text given by the specified string, using this graphics context's current font and color. The baseline of the first character is at position (xy) in this graphics context's coordinate system. The rendering attributes applied include the clip, transform, paint or color, font and composite attributes. For characters in script systems such as Hebrew and Arabic, the glyphs may be draw from right to left, in which case the coordinate supplied is the the location of the leftmost character on the baseline.
Parameters:
s - The string to be drawn.
x,y - The coordinates where the string should be drawn.
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), Graphics.setClip(int, int, int, int)

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                int x,
                                int y)
Draws the text given by the specified iterator, using this graphics context's current color. The iterator has to specify a font for each character. The baseline of the first character is at position (xy) in this graphics context's coordinate system. The rendering attributes applied include the clip, transform, paint or color, and composite attributes. For characters in script systems such as Hebrew and Arabic, the glyphs may be draw from right to left, in which case the coordinate supplied is the the location of the leftmost character on the baseline.
Parameters:
iterator - the iterator whose text is to be drawn
x,y - the coordinates where the iterator's text should be drawn.
Overrides:
drawString in class Graphics
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), Graphics.setClip(int, int, int, int)

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                float x,
                                float y)
Draws the text given by the specified iterator, using this graphics context's current color. The iterator has to specify a font for each character. The baseline of the first character is at position (xy) in this graphics context's coordinate system. The rendering attributes applied include the clip, transform, paint or color, and composite attributes. For characters in script systems such as Hebrew and Arabic, the glyphs may be draw from right to left, in which case the coordinate supplied is the the location of the leftmost character on the baseline.
Parameters:
iterator - the iterator whose text is to be drawn
x,y - the coordinates where the iterator's text should be drawn.
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), Graphics.setClip(int, int, int, int)

drawGlyphVector

public abstract void drawGlyphVector(GlyphVector g,
                                     float x,
                                     float y)
Draws the text specified by the given GlyphVector using this graphics context's rendering attributes. The rendering attributes applied include the clip, transform, paint or color, and composite attributes. The glyphVector specifies individual glyphs from a Font, and optionally their positions. This is the fastest method of getting a visual representation of a set of characters to the screen.
Parameters:
g - The GlyphVector to be drawn.
x,y - The coordinates where the glyphs should be drawn.
See Also:
Font.createGlyphVector(java.awt.font.FontRenderContext, java.lang.String), GlyphVector, setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), Graphics.setClip(int, int, int, int)

fill

public abstract void fill(Shape s)
Fills the interior of a Shape using the settings of the current graphics state. The rendering attributes applied include the clip, transform, paint or color, and composite.
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color), transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), setComposite(java.awt.Composite), clip(java.awt.Shape), Graphics.setClip(int, int, int, int)

hit

public abstract boolean hit(Rectangle rect,
                            Shape s,
                            boolean onStroke)
Checks to see if the outline of a Shape intersects the specified Rectangle in device space. The rendering attributes taken into account include the clip, transform, and stroke attributes.
Parameters:
rect - The area in device space to check for a hit.
s - The shape to check for a hit.
onStroke - Flag to choose between testing the stroked or the filled shape.
Returns:
True if there is a hit, false otherwise.
See Also:
setStroke(java.awt.Stroke), fill(java.awt.Shape), draw(java.awt.Shape), transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform), clip(java.awt.Shape), Graphics.setClip(int, int, int, int)

getDeviceConfiguration

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

setComposite

public abstract void setComposite(Composite comp)
Sets the Composite in the current graphics state. 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 in the rendering process.
Parameters:
comp - The Composite object to be used for drawing.
See Also:
Graphics.setXORMode(java.awt.Color), Graphics.setPaintMode(), AlphaComposite

setPaint

public abstract void setPaint(Paint paint)
Sets the Paint in the current graphics state.
Parameters:
paint - The Paint object to be used to generate color in the rendering process.
See Also:
Graphics.setColor(java.awt.Color), GradientPaint, TexturePaint

setStroke

public abstract void setStroke(Stroke s)
Sets the Stroke in the current graphics state.
Parameters:
s - The Stroke object to be used to stroke a Shape in the rendering process.
See Also:
BasicStroke

setRenderingHint

public abstract void setRenderingHint(String hintKey,
                                      Object hintValue)
Sets the preferences for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process.
Parameters:
hintKey - The key of hint to be set. The strings are defined in the RenderingHints class.
hintValue - The value indicating preferences for the specified hint category. These objects are defined in the RenderingHints class.
See Also:
RenderingHints

getRenderingHint

public abstract Object getRenderingHint(String hintKey)
Returns the preferences for the rendering algorithms.
Parameters:
hintCategory - The category of hint to be set. The strings are defined in the RenderingHints class.
Returns:
The preferences for rendering algorithms. The objects are defined in the RenderingHints class.
See Also:
RenderingHints

setRenderingHints

public abstract void setRenderingHints(RenderingHints hints)
Sets the preferences for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process.
Parameters:
hints - The rendering hints to be set
See Also:
RenderingHints

getRenderingHints

public abstract 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.
See Also:
RenderingHints

translate

public abstract void translate(int x,
                               int y)
Translates the origin of the graphics context to the point (xy) in the current coordinate system. Modifies this graphics context so that its new origin corresponds to the point (xy) in this graphics context's original coordinate system. All coordinates used in subsequent rendering operations on this graphics context will be relative to this new origin.
Parameters:
x - the x coordinate.
y - the y coordinate.
Overrides:
translate in class Graphics
Since:
JDK1.0

translate

public abstract void translate(double tx,
                               double ty)
Concatenates the current transform of this Graphics2D with a translation transformation. This is equivalent to calling transform(T), where T is an AffineTransform represented by the following matrix:
		[   1    0    tx  ]
		[   0    1    ty  ]
		[   0    0    1   ]
 

rotate

public abstract void rotate(double theta)
Concatenates the current transform of this Graphics2D with a rotation transformation. This is equivalent to calling transform(R), where R is an AffineTransform represented by the following matrix:
		[   cos(theta)    -sin(theta)    0   ]
		[   sin(theta)     cos(theta)    0   ]
		[       0              0         1   ]
 
Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis.
Parameters:
theta - The angle of rotation in radians.

rotate

public abstract void rotate(double theta,
                            double x,
                            double y)
Concatenates the current transform of this Graphics2D with a translated rotation transformation. This is equivalent to the following sequence of calls:
		translate(x, y);
		rotate(theta);
		translate(-x, -y);
 
Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis.
Parameters:
theta - The angle of rotation in radians.
x - The x coordinate of the origin of the rotation
y - The x coordinate of the origin of the rotation

scale

public abstract void scale(double sx,
                           double sy)
Concatenates the current transform of this Graphics2D with a scaling transformation. This is equivalent to calling transform(S), where S is an AffineTransform represented by the following matrix:
		[   sx   0    0   ]
		[   0    sy   0   ]
		[   0    0    1   ]
 

shear

public abstract void shear(double shx,
                           double shy)
Concatenates the current transform of this Graphics2D with a shearing transformation. This is equivalent to calling transform(SH), where SH is an AffineTransform represented by the following matrix:
		[   1   shx   0   ]
		[  shy   1    0   ]
		[   0    0    1   ]
 
Parameters:
shx - The factor by which coordinates are shifted towards the positive X axis direction according to their Y coordinate
shy - The factor by which coordinates are shifted towards the positive Y axis direction according to their X coordinate

transform

public abstract void transform(AffineTransform Tx)
Composes an AffineTransform object with the transform in this Graphics2D according to the rule last-specified-first-applied. If the currrent transform is Cx, the result of composition with Tx is a new transform Cx'. Cx' becomes the current transform for this Graphics2D. Transforming a point p by the updated transform Cx' is equivalent to first transforming p by Tx and then transforming the result by the original transform Cx. In other words, Cx'(p) = Cx(Tx(p)). A copy of the Tx is made, if necessary, so further modifications to Tx do not affect rendering.
Parameters:
Tx - The AffineTransform object to be composed with the current transform.
See Also:
setTransform(java.awt.geom.AffineTransform), TransformChain, AffineTransform

setTransform

public abstract void setTransform(AffineTransform Tx)
Sets the transform in the current graphics state.
Parameters:
Tx - The AffineTransform object to be used in the rendering process.
See Also:
transform(java.awt.geom.AffineTransform), TransformChain, AffineTransform

getTransform

public abstract AffineTransform getTransform()
Returns the current transform in the Graphics2D state.
See Also:
transform(java.awt.geom.AffineTransform), setTransform(java.awt.geom.AffineTransform)

getPaint

public abstract Paint getPaint()
Returns the current Paint in the Graphics2D state.
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color)

getComposite

public abstract Composite getComposite()
Returns the current Composite in the Graphics2D state.
See Also:
setComposite(java.awt.Composite)

setBackground

public abstract void setBackground(Color color)
Sets the background color in this context used for clearing a region. When Graphics2D is constructed for a component, the backgroung 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.
Parameters:
color - The background color that should be used in subsequent calls to clearRect().
See Also:
getBackground, Graphics.clearRect()

getBackground

public abstract Color getBackground()
Returns the background color used for clearing a region.
See Also:
setBackground

getStroke

public abstract Stroke getStroke()
Returns the current Stroke in the Graphics2D state.
See Also:
setStroke

clip

public abstract void clip(Shape s)
Intersects the current clip with the interior of the specified Shape and sets the current clip to the resulting intersection. The indicated shape is transformed with the current transform in the Graphics2D state before being intersected with the current clip. This method is used to make the current clip smaller. To make the clip larger, use any setClip method.
Parameters:
s - The Shape to be intersected with the current clip.

getFontRenderContext

public abstract FontRenderContext getFontRenderContext()
Get the rendering context of the font within this Graphics2D context. The rendering context encapsulates application hints such as anti-aliasing and fractional metrics, as well as target device specific information such as the dots-per-inch. This information should be provided by the application during the usage of objects which perform typographical formatting, such as Font and TextLayout. This information should also be provided by applications which 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.
Returns:
a reference to an instance of FontRenderContext.
Since:
JDK1.2
See Also:
FontRenderContext, Font.createGlyphVector(java.awt.font.FontRenderContext, java.lang.String), TextLayout

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.