java.awt

Class Graphics2D

Known Direct Subclasses:
AbstractGraphics2D, CairoGraphics2D, Graphics2DImpl, QtGraphics

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

Graphics2D()
The basic constructor.

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 boolean
drawImage(Image image, AffineTransform xform, ImageObserver obs)
abstract void
drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
abstract void
drawRenderableImage(RenderableImage image, AffineTransform xform)
abstract void
drawRenderedImage(RenderedImage image, AffineTransform xform)
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
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
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)
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)

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, drawString, drawString, fill3DRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getColor, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, toString, translate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Graphics2D

protected Graphics2D()
The basic constructor. Object is special, because it has no superclass, so there is no call to super().

Method Details

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.

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

draw3DRect

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

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

drawString

public abstract void drawString(String text,
                                int x,
                                int y)
Draws a string at the specified location, using the current font.
Overrides:
drawString in interface Graphics
Parameters:
text - the string to draw.
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.

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                int x,
                                int y)
Draws an attributed string at the specified location.
Overrides:
drawString in interface Graphics
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).

fill3DRect

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

getBackground

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

getComposite

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

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.

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.

getTransform

public abstract AffineTransform getTransform()
Returns the current transform.
Returns:
The current transform.

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 Graphics.clearRect(int,int,int,int) method).
Parameters:
color - the color.

setComposite

public abstract void setComposite(Composite comp)
Sets the current compositing rule.
Parameters:
comp - the composite.

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(Map)

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

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(double tx,
                               double ty)

translate

public abstract void translate(int x,
                               int y)
Overrides:
translate in interface Graphics

Copyright (C) 2000, 2002, 2004, 2006, Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.