java.awt
Class Graphics2D

java.lang.Object
  extended by java.awt.Graphics
      extended by java.awt.Graphics2D

public abstract class Graphics2D
extends Graphics

An abstract class defining a device independent two-dimensional vector graphics API. Concrete subclasses implement this API for output of vector graphics to:

Third party libraries provide support for output to other formats via this API, including encapsulated postscript (EPS), portable document format (PDF), and scalable vector graphics (SVG).


Constructor Summary
protected Graphics2D()
           
 
Method Summary
abstract  void addRenderingHints(Map<?,?> hints)
          Adds/updates the rendering hint.
abstract  void clip(Shape s)
          Sets the clip region to the intersection of the current clipping region and s.
abstract  void draw(Shape shape)
          Draws an outline around a shape using the current stroke and paint.
 void draw3DRect(int x, int y, int width, int height, boolean raised)
           
abstract  void drawGlyphVector(GlyphVector g, float x, float y)
          Draws a glyph vector at the specified location.
abstract  void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
           
abstract  boolean drawImage(Image image, AffineTransform xform, ImageObserver obs)
           
abstract  void drawRenderableImage(RenderableImage image, AffineTransform xform)
           
abstract  void drawRenderedImage(RenderedImage image, AffineTransform xform)
           
abstract  void drawString(AttributedCharacterIterator iterator, float x, float y)
          Draws an attributed string at the specified location.
abstract  void drawString(AttributedCharacterIterator iterator, int x, int y)
          Draws an attributed string at the specified location.
abstract  void drawString(String text, float x, float y)
          Draws a string at the specified location, using the current font.
abstract  void drawString(String text, int x, int y)
          Draws a string at the specified location, using the current font.
abstract  void fill(Shape shape)
          Fills the interior of the specified shape using the current paint.
 void fill3DRect(int x, int y, int width, int height, boolean raised)
          Fills the specified rectangle with a 3D effect
abstract  Color getBackground()
          Returns the color used by the Graphics.clearRect(int, int, int, int) method.
abstract  Composite getComposite()
          Returns the current compositing rule.
abstract  GraphicsConfiguration getDeviceConfiguration()
           
abstract  FontRenderContext getFontRenderContext()
          Returns the font render context.
abstract  Paint getPaint()
          Returns the current paint.
abstract  Object getRenderingHint(RenderingHints.Key hintKey)
          Returns the current value of a rendering hint.
abstract  RenderingHints getRenderingHints()
          Returns the current rendering hints.
abstract  Stroke getStroke()
          Returns the current stroke.
abstract  AffineTransform getTransform()
          Returns the current transform.
abstract  boolean hit(Rectangle rect, Shape text, boolean onStroke)
           
abstract  void rotate(double theta)
           
abstract  void rotate(double theta, double x, double y)
           
abstract  void scale(double scaleX, double scaleY)
           
abstract  void setBackground(Color color)
          Sets the background color (used by the Graphics.clearRect(int, int, int, int) method).
abstract  void setComposite(Composite comp)
          Sets the current compositing rule.
abstract  void setPaint(Paint paint)
          Sets the paint to be used for subsequent drawing operations.
abstract  void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
          Adds or updates a hint in the current rendering hints table.
abstract  void setRenderingHints(Map<?,?> hints)
          Replaces the current rendering hints with the supplied hints.
abstract  void setStroke(Stroke stroke)
          Sets the stroke to be used for subsequent drawing operations.
abstract  void setTransform(AffineTransform transform)
          Sets the current transform.
abstract  void shear(double shearX, double shearY)
           
abstract  void transform(AffineTransform transform)
          Sets the current transform to a concatenation of transform and the existing transform.
abstract  void translate(double tx, double ty)
           
abstract  void translate(int x, int y)
          Translates this context so that its new origin point is the point (x, y).
 
Methods inherited from class java.awt.Graphics
clearRect, clipRect, copyArea, create, create, dispose, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, 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()
Method Detail

draw3DRect

public void draw3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
Overrides:
draw3DRect in class Graphics

fill3DRect

public void fill3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
Description copied from class: Graphics
Fills the specified rectangle with a 3D effect

Overrides:
fill3DRect in class Graphics
Parameters:
x - The X coordinate of the upper left corner of the fill rect.
y - The Y coordinate of the upper left corner of the fill rect.
width - The width of the fill rect.
height - The height of the fill rect.
raised - true if the rectangle appears raised, false if it should appear etched.

draw

public abstract void draw(Shape shape)
Draws an outline around a shape using the current stroke and paint.

Parameters:
shape - the shape (null not permitted).
See Also:
getStroke(), getPaint()

drawImage

public abstract boolean drawImage(Image image,
                                  AffineTransform xform,
                                  ImageObserver obs)

drawImage

public abstract void drawImage(BufferedImage image,
                               BufferedImageOp op,
                               int x,
                               int y)

drawRenderedImage

public abstract void drawRenderedImage(RenderedImage image,
                                       AffineTransform xform)

drawRenderableImage

public abstract void drawRenderableImage(RenderableImage image,
                                         AffineTransform xform)

drawString

public abstract void drawString(String text,
                                int x,
                                int y)
Draws a string at the specified location, using the current font.

Specified by:
drawString in class Graphics
Parameters:
text - the string to draw.
x - the x-coordinate.
y - the y-coordinate.
See Also:
Graphics.setFont(Font)

drawString

public abstract void drawString(String text,
                                float x,
                                float y)
Draws a string at the specified location, using the current font.

Parameters:
text - the string to draw.
x - the x-coordinate.
y - the y-coordinate.
See Also:
Graphics.setFont(Font)

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                int x,
                                int y)
Draws an attributed string at the specified location.

Specified by:
drawString in class Graphics
Parameters:
iterator - the source of the attributed text.
x - the x-coordinate.
y - the y-coordinate.

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                float x,
                                float y)
Draws an attributed string at the specified location.

Parameters:
iterator - the source of the attributed text.
x - the x-coordinate.
y - the y-coordinate.

fill

public abstract void fill(Shape shape)
Fills the interior of the specified shape using the current paint.

Parameters:
shape - the shape to fill (null not permitted).
See Also:
draw(Shape), getPaint()

hit

public abstract boolean hit(Rectangle rect,
                            Shape text,
                            boolean onStroke)

getDeviceConfiguration

public abstract GraphicsConfiguration getDeviceConfiguration()

setComposite

public abstract void setComposite(Composite comp)
Sets the current compositing rule.

Parameters:
comp - the composite.
See Also:
getComposite()

setPaint

public abstract void setPaint(Paint paint)
Sets the paint to be used for subsequent drawing operations.

Parameters:
paint - the paint (null not permitted).
See Also:
getPaint()

setStroke

public abstract void setStroke(Stroke stroke)
Sets the stroke to be used for subsequent drawing operations.

Parameters:
stroke - the stroke (null not permitted).
See Also:
getStroke()

setRenderingHint

public abstract void setRenderingHint(RenderingHints.Key hintKey,
                                      Object hintValue)
Adds or updates a hint in the current rendering hints table.

Parameters:
hintKey - the hint key.
hintValue - the hint value.

getRenderingHint

public abstract Object getRenderingHint(RenderingHints.Key hintKey)
Returns the current value of a rendering hint.

Parameters:
hintKey - the key for the hint.
Returns:
The value for the specified hint.

setRenderingHints

public abstract void setRenderingHints(Map<?,?> hints)
Replaces the current rendering hints with the supplied hints.

Parameters:
hints - the hints.
See Also:
addRenderingHints(Map)

addRenderingHints

public abstract void addRenderingHints(Map<?,?> hints)
Adds/updates the rendering hint.

Parameters:
hints - the hints to add or update.

getRenderingHints

public abstract RenderingHints getRenderingHints()
Returns the current rendering hints.

Returns:
The current rendering hints.

translate

public abstract void translate(int x,
                               int y)
Description copied from class: Graphics
Translates this context so that its new origin point is the point (x, y).

Specified by:
translate in class Graphics
Parameters:
x - The new X coordinate of the origin.
y - The new Y coordinate of the origin.

translate

public abstract void translate(double tx,
                               double ty)

rotate

public abstract void rotate(double theta)

rotate

public abstract void rotate(double theta,
                            double x,
                            double y)

scale

public abstract void scale(double scaleX,
                           double scaleY)

shear

public abstract void shear(double shearX,
                           double shearY)

transform

public abstract void transform(AffineTransform transform)
Sets the current transform to a concatenation of transform and the existing transform.

Parameters:
transform - the transform.

setTransform

public abstract void setTransform(AffineTransform transform)
Sets the current transform. If the caller specifies a null transform, this method should set the current transform to the identity transform.

Parameters:
transform - the transform (null permitted).
See Also:
getTransform()

getTransform

public abstract AffineTransform getTransform()
Returns the current transform.

Returns:
The current transform.
See Also:
setTransform(AffineTransform)

getPaint

public abstract Paint getPaint()
Returns the current paint.

Returns:
The current paint.
See Also:
setPaint(Paint)

getComposite

public abstract Composite getComposite()
Returns the current compositing rule.

Returns:
The current compositing rule.
See Also:
setComposite(Composite)

setBackground

public abstract void setBackground(Color color)
Sets the background color (used by the Graphics.clearRect(int, int, int, int) method).

Parameters:
color - the color.
See Also:
getBackground()

getBackground

public abstract Color getBackground()
Returns the color used by the Graphics.clearRect(int, int, int, int) method.

Returns:
The background color.
See Also:
setBackground(Color)

getStroke

public abstract Stroke getStroke()
Returns the current stroke.

Returns:
The current stroke.
See Also:
setStroke(Stroke)

clip

public abstract void clip(Shape s)
Sets the clip region to the intersection of the current clipping region and s.

Parameters:
s - the shape to intersect with the current clipping region.
See Also:
Graphics.setClip(Shape)

getFontRenderContext

public abstract FontRenderContext getFontRenderContext()
Returns the font render context.

Returns:
The font render context.

drawGlyphVector

public abstract void drawGlyphVector(GlyphVector g,
                                     float x,
                                     float y)
Draws a glyph vector at the specified location.

Parameters:
g - the glyph vector.
x - the x-coordinate.
y - the y-coordinate.