Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Graphics

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


public abstract class Graphics

extends Object

This is the abstract superclass of classes for drawing to graphics devices such as the screen or printers.

Authors:

Constructor Summary

Graphics()

Default constructor for subclasses.

Method Summary

voidclearRect(int x, int y, int width, int height)

Clears the specified rectangle.
voidclipRect(int x, int y, int width, int height)

Sets the clipping region to the intersection of the current clipping region and the rectangle determined by the specified parameters.
voidcopyArea(int x, int y, int width, int height, int dx, int dy)

Copies the specified rectangle to the specified offset location.
java.awt.Graphicscreate()

Returns a copy of this Graphics object.
java.awt.Graphicscreate(int x, int y, int width, int height)

Returns a copy of this Graphics object.
voiddispose()

Free any resources held by this graphics context immediately instead of waiting for the object to be garbage collected and finalized.
voiddraw3DRect(int x, int y, int width, int height, boolean raised)

voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle)

Draws an arc using the specified bounding rectangle and the specified angle parameter.
voiddrawBytes(byte[] data, int offset, int length, int x, int y)

voiddrawChars(char[] data, int offset, int length, int x, int y)

Draws the specified characters starting at the specified point.
voiddrawChars(byte[] data, int offset, int length, int x, int y)

Draws the specified bytes as text starting at the specified point.
booleandrawImage(java.awt.Image image, int x, int y, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns.
booleandrawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns.
booleandrawImage(java.awt.Image image, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns.
booleandrawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns.
booleandrawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)

FIXME: Write Javadocs for this when you understand it.
booleandrawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

FIXME: Write Javadocs for this when you understand it.
voiddrawLine(int x1, int y1, int x2, int y2)

Draws a line between the two specified points.
voiddrawOval(int x, int y, int width, int height)

Draws an oval that just fits within the specified rectangle.
voiddrawPolygon(int[] xPoints, int[] yPoints, int npoints)

Draws a series of interconnected lines determined by the arrays of corresponding x and y coordinates.
voiddrawPolygon(java.awt.Polygon polygon)

Draws the specified polygon.
voiddrawPolyline(int[] xPoints, int[] yPoints, int npoints)

Draws a series of interconnected lines determined by the arrays of corresponding x and y coordinates.
voiddrawRect(int x, int y, int width, int height)

Draws the outline of the specified rectangle.
voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

Draws the outline of the specified rectangle with rounded cornders.
voiddrawRoundRect(int x, int y, int width, int height, boolean raised)

Draws the outline of the specified rectangle with a 3D effect
voiddrawString(java.lang.String string, int x, int y)

Draws the specified string starting at the specified point.
voiddrawString(java.text.AttributedCharacterIterator ci, int x, int y)

voidfill3DRect(int x, int y, int width, int height, boolean raised)

Fills the specified rectangle with a 3D effect
voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)

Fills the arc define by the specified bounding rectangle and the specified angle parameter.
voidfillOval(int x, int y, int width, int height)

Fills an oval that just fits within the specified rectangle.
voidfillPolygon(int[] xPoints, int[] yPoints, int npoints)

Fills the polygon determined by the arrays of corresponding x and y coordinates.
voidfillPolygon(java.awt.Polygon polygon)

Fills the specified polygon
voidfillRect(int x, int y, int width, int height)

Fills the area bounded by the specified rectangle.
voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

Fills the specified rectangle with rounded cornders.
voidfinalize()

Frees the resources held by this graphics context when it is garbage collected.
java.awt.ShapegetClip()

Returns the current clipping region as a Shape object.
java.awt.RectanglegetClipBounds()

Returns the bounding rectangle of the clipping region for this graphics context.
java.awt.RectanglegetClipBounds(java.awt.Rectangle r)

java.awt.RectanglegetClipRect()

Returns the bounding rectangle of the clipping region for this graphics context.
java.awt.ColorgetColor()

Returns the current color for this object.
java.awt.FontgetFont()

Returns the current font for this graphics context.
java.awt.FontMetricsgetFontMetrics()

Returns the font metrics for the current font.
java.awt.FontMetricsgetFontMetrics(java.awt.Font font)

Returns the font metrics for the specified font.
booleanhitClip(int x, int y, int width, int height)

voidsetClip(int x, int y, int width, int height)

Sets the clipping region to the rectangle determined by the specified parameters.
voidsetClip(java.awt.Shape clip)

Sets the clipping region to the specified Shape.
voidsetColor(java.awt.Color color)

Sets the current color for this object.
voidsetFont(java.awt.Font font)

Sets the font for this graphics context to the specified value.
voidsetPaintMode()

Sets this context into "paint" mode, where the target pixels are completely overwritten when drawn on.
voidsetXORMode(java.awt.Color color)

Sets this context info "XOR" mode, where the targe pixles are XOR-ed when drawn on.
java.lang.StringtoString()

Returns a string representation of this object.
voidtranslate(int x, int y)

Translates this context so that its new origin point is the point (x, y).

Constructor Details

Graphics

protected Graphics()

Default constructor for subclasses.


Method Details

clearRect

public void clearRect(int x, int y, int width, int height)

Clears the specified rectangle.

Parameters:


clipRect

public void clipRect(int x, int y, int width, int height)

Sets the clipping region to the intersection of the current clipping region and the rectangle determined by the specified parameters.

Parameters:


copyArea

public void copyArea(int x, int y, int width, int height, int dx, int dy)

Copies the specified rectangle to the specified offset location.

Parameters:


create

public Graphics create()

Returns a copy of this Graphics object.

Returns:


create

public Graphics create(int x, int y, int width, int height)

Returns a copy of this Graphics object. The origin point will be translated to the point (x, y) and the cliping rectangle set to the intersection of the clipping rectangle in this object and the rectangle specified by the parameters to this method.

Parameters:

Returns:


dispose

public void dispose()

Free any resources held by this graphics context immediately instead of waiting for the object to be garbage collected and finalized.


draw3DRect

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

Parameters:


drawArc

public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)

Draws an arc using the specified bounding rectangle and the specified angle parameter. The arc is centered at the center of the rectangle. The arc starts at the arcAngle position and extend for arcAngle degrees. The degree origin is at the 3 o'clock position.

Parameters:


drawBytes

public void drawBytes(byte[] data, int offset, int length, int x, int y)

Parameters:


drawChars

public void drawChars(byte[] data, int offset, int length, int x, int y)

Draws the specified bytes as text starting at the specified point.

Parameters:


drawChars

public void drawChars(char[] data, int offset, int length, int x, int y)

Draws the specified characters starting at the specified point.

Parameters:


drawImage

public boolean drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

FIXME: Write Javadocs for this when you understand it.

Parameters:


drawImage

public boolean drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)

FIXME: Write Javadocs for this when you understand it.

Parameters:


drawImage

public boolean drawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns. The image is scaled to fit in the specified rectangle. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.

Parameters:

Returns:


drawImage

public boolean drawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns. The image is scaled to fit in the specified rectangle. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.

Parameters:

Returns:


drawImage

public boolean drawImage(java.awt.Image image, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.

Parameters:

Returns:


drawImage

public boolean drawImage(java.awt.Image image, int x, int y, java.awt.image.ImageObserver observer)

Draws all of the image that is available and returns. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.

Parameters:

Returns:


drawLine

public void drawLine(int x1, int y1, int x2, int y2)

Draws a line between the two specified points.

Parameters:


drawOval

public void drawOval(int x, int y, int width, int height)

Draws an oval that just fits within the specified rectangle.

Parameters:


drawPolygon

public void drawPolygon(int[] xPoints, int[] yPoints, int npoints)

Draws a series of interconnected lines determined by the arrays of corresponding x and y coordinates. The figure is closed if necessary by connecting the first and last points.

Parameters:


drawPolygon

public void drawPolygon(java.awt.Polygon polygon)

Draws the specified polygon.

Parameters:


drawPolyline

public void drawPolyline(int[] xPoints, int[] yPoints, int npoints)

Draws a series of interconnected lines determined by the arrays of corresponding x and y coordinates.

Parameters:


drawRect

public void drawRect(int x, int y, int width, int height)

Draws the outline of the specified rectangle.

Parameters:


drawRoundRect

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

Draws the outline of the specified rectangle with a 3D effect

Parameters:


drawRoundRect

public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

Draws the outline of the specified rectangle with rounded cornders.

Parameters:


drawString

public void drawString(java.lang.String string, int x, int y)

Draws the specified string starting at the specified point.

Parameters:


drawString

public void drawString(java.text.AttributedCharacterIterator ci, int x, int y)

Parameters:


fill3DRect

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

Fills the specified rectangle with a 3D effect

Parameters:


fillArc

public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)

Fills the arc define by the specified bounding rectangle and the specified angle parameter. The arc is centered at the center of the rectangle. The arc starts at the arcAngle position and extend for arcAngle degrees. The degree origin is at the 3 o'clock position.

Parameters:


fillOval

public void fillOval(int x, int y, int width, int height)

Fills an oval that just fits within the specified rectangle.

Parameters:


fillPolygon

public void fillPolygon(int[] xPoints, int[] yPoints, int npoints)

Fills the polygon determined by the arrays of corresponding x and y coordinates.

Parameters:


fillPolygon

public void fillPolygon(java.awt.Polygon polygon)

Fills the specified polygon

Parameters:


fillRect

public void fillRect(int x, int y, int width, int height)

Fills the area bounded by the specified rectangle.

Parameters:


fillRoundRect

public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

Fills the specified rectangle with rounded cornders.

Parameters:


finalize

public void finalize()

Frees the resources held by this graphics context when it is garbage collected.


getClip

public Shape getClip()

Returns the current clipping region as a Shape object.

Returns:


getClipBounds

public Rectangle getClipBounds()

Returns the bounding rectangle of the clipping region for this graphics context.

Returns:


getClipBounds

public Rectangle getClipBounds(java.awt.Rectangle r)

Parameters:


getClipRect

public Rectangle getClipRect()

Returns the bounding rectangle of the clipping region for this graphics context.

Returns:


getColor

public Color getColor()

Returns the current color for this object.

Returns:


getFont

public Font getFont()

Returns the current font for this graphics context.

Returns:


getFontMetrics

public FontMetrics getFontMetrics()

Returns the font metrics for the current font.

Returns:


getFontMetrics

public FontMetrics getFontMetrics(java.awt.Font font)

Returns the font metrics for the specified font.

Parameters:

Returns:


hitClip

public boolean hitClip(int x, int y, int width, int height)

Parameters:


setClip

public void setClip(int x, int y, int width, int height)

Sets the clipping region to the rectangle determined by the specified parameters.

Parameters:


setClip

public void setClip(java.awt.Shape clip)

Sets the clipping region to the specified Shape.

Parameters:


setColor

public void setColor(java.awt.Color color)

Sets the current color for this object.

Parameters:


setFont

public void setFont(java.awt.Font font)

Sets the font for this graphics context to the specified value.

Parameters:


setPaintMode

public void setPaintMode()

Sets this context into "paint" mode, where the target pixels are completely overwritten when drawn on.


setXORMode

public void setXORMode(java.awt.Color color)

Sets this context info "XOR" mode, where the targe pixles are XOR-ed when drawn on.

Parameters:


toString

public String toString()

Returns a string representation of this object.


translate

public void translate(int x, int y)

Translates this context so that its new origin point is the point (x, y).

Parameters: