java.awt

Class 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 voidaddRenderingHints(Map<?,?> hints)
Adds/updates the rendering hint.
abstract voidclip(Shape s)
Sets the clip region to the intersection of the current clipping region and s.
abstract voiddraw(Shape shape)
Draws an outline around a shape using the current stroke and paint.
voiddraw3DRect(int x, int y, int width, int height, boolean raised)
abstract voiddrawGlyphVector(GlyphVector g, float x, float y)
Draws a glyph vector at the specified location.
abstract booleandrawImage(Image image, AffineTransform xform, ImageObserver obs)
abstract voiddrawImage(BufferedImage image, BufferedImageOp op, int x, int y)
abstract voiddrawRenderableImage(RenderableImage image, AffineTransform xform)
abstract voiddrawRenderedImage(RenderedImage image, AffineTransform xform)
abstract voiddrawString(String text, int x, int y)
Draws a string at the specified location, using the current font.
abstract voiddrawString(String text, float x, float y)
Draws a string at the specified location, using the current font.
abstract voiddrawString(AttributedCharacterIterator iterator, int x, int y)
Draws an attributed string at the specified location.
abstract voiddrawString(AttributedCharacterIterator iterator, float x, float y)
Draws an attributed string at the specified location.
abstract voidfill(Shape shape)
Fills the interior of the specified shape using the current paint.
voidfill3DRect(int x, int y, int width, int height, boolean raised)
abstract ColorgetBackground()
Returns the color used by the {@link Graphics#clearRect(int, int, int, int)} method.
abstract CompositegetComposite()
Returns the current compositing rule.
abstract GraphicsConfigurationgetDeviceConfiguration()
abstract FontRenderContextgetFontRenderContext()
Returns the font render context.
abstract PaintgetPaint()
Returns the current paint.
abstract ObjectgetRenderingHint(RenderingHints.Key hintKey)
Returns the current value of a rendering hint.
abstract RenderingHintsgetRenderingHints()
Returns the current rendering hints.
abstract StrokegetStroke()
Returns the current stroke.
abstract AffineTransformgetTransform()
Returns the current transform.
abstract booleanhit(Rectangle rect, Shape text, boolean onStroke)
abstract voidrotate(double theta)
abstract voidrotate(double theta, double x, double y)
abstract voidscale(double scaleX, double scaleY)
abstract voidsetBackground(Color color)
Sets the background color (used by the {@link Graphics#clearRect(int, int, int, int)} method).
abstract voidsetComposite(Composite comp)
Sets the current compositing rule.
abstract voidsetPaint(Paint paint)
Sets the paint to be used for subsequent drawing operations.
abstract voidsetRenderingHint(RenderingHints.Key hintKey, Object hintValue)
Adds or updates a hint in the current rendering hints table.
abstract voidsetRenderingHints(Map<?,?> hints)
Replaces the current rendering hints with the supplied hints.
abstract voidsetStroke(Stroke stroke)
Sets the stroke to be used for subsequent drawing operations.
abstract voidsetTransform(AffineTransform transform)
Sets the current transform.
abstract voidshear(double shearX, double shearY)
abstract voidtransform(AffineTransform transform)
Sets the current transform to a concatenation of transform and the existing transform.
abstract voidtranslate(int x, int y)
abstract voidtranslate(double tx, double ty)

Constructor Detail

Graphics2D

protected Graphics2D()

Method Detail

addRenderingHints

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

Parameters: hints the hints to add or update.

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: setClip

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

draw3DRect

public void draw3DRect(int x, int y, int width, int height, boolean raised)

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.

drawImage

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

drawImage

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

drawRenderableImage

public abstract void drawRenderableImage(RenderableImage image, AffineTransform xform)

drawRenderedImage

public abstract void drawRenderedImage(RenderedImage 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.

Parameters: text the string to draw. x the x-coordinate. y the y-coordinate.

See Also: setFont

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: setFont

drawString

public abstract void drawString(AttributedCharacterIterator iterator, int x, int 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.

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 getPaint

fill3DRect

public void fill3DRect(int x, int y, int width, int height, boolean raised)

getBackground

public abstract Color getBackground()
Returns the color used by the {@link Graphics#clearRect(int, int, int, int)} method.

Returns: The background color.

See Also: setBackground

getComposite

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

Returns: The current compositing rule.

See Also: setComposite

getDeviceConfiguration

public abstract GraphicsConfiguration getDeviceConfiguration()

getFontRenderContext

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

Returns: The font render context.

getPaint

public abstract Paint getPaint()
Returns the current paint.

Returns: The current paint.

See Also: setPaint

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.

getRenderingHints

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

Returns: The current rendering hints.

getStroke

public abstract Stroke getStroke()
Returns the current stroke.

Returns: The current stroke.

See Also: setStroke

getTransform

public abstract AffineTransform getTransform()
Returns the current transform.

Returns: The current transform.

See Also: setTransform

hit

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

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)

setBackground

public abstract void setBackground(Color color)
Sets the background color (used by the {@link Graphics#clearRect(int, int, int, int)} method).

Parameters: color the color.

See Also: getBackground

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

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.

setRenderingHints

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

Parameters: hints the hints.

See Also: addRenderingHints

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

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

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.

translate

public abstract void translate(int x, int y)

translate

public abstract void translate(double tx, double ty)