Objects and Methods Summary


[Page 246 (continued)]

In this chapter we have talked about several kinds of objects.


[Page 247]

AffineTransform

java.awt.geom

An object that knows how to do transformations, such as rotation, scaling, and shearing.

AlphaComposite

java.awt

An object that knows how to combine overlapping pixels.

BasicStroke

java.awt

An object that knows how to draw the outlines of shapes in different widths, with different kinds of joins between lines, and possibly using dashes.

Ellipse2D.Double

java.awt.geom

An object that represents an ellipse with coordinates that can be of the type double.

Graphics

java.awt

An object that knows how to draw or fill simple shapes.

Graphics2D

java.awt

An object that can handle more complicated drawing.

Line2D.Double

java.awt.geom

An object that represents a line with coordinates that can be of the type double.


Picture Methods

getGraphics()

Returns a Graphics object that can be used to draw on the current picture.

getImage()

Returns an Image object that can be used by drawImage methods in Graphics or Graphics2D.


Graphics Methods


[Page 248]

drawArc(int x1, int y1, int w, int h, int startAngle, int arcAngle)

Draws the outline of an arc which is part of an oval that fits in an enclosing rectangle with an upper-left corner at (x1, y1), a width of w, and a height of h. The arc will start at the given startAngle and end at startAngle + arcAngle.

drawImage(Image image, int x, int y, ImageObserver observer)

Draws the passed image with the top-left corner at (x, y). The observer is the object to be notified as more of the image is drawn.

drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, sy1, sx2, sy2, ImageObserver observer)

Draws the area from the passed image that is inside the rectangle defined by (sx1, sy1) and (sx2, sy2) into the rectangle defined by (dx1, dy1) and (dx2, dy2) in the destination. The observer is the object to be notified as more of the image is drawn.

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

Draws a line from position (x1, y1) to (x2, y2).

drawOval(int x1, int y1, int w, int h)

Draws the outline of an oval that fits in an enclosing rectangle with an upper-left corner at (x1, y1), a width of w, and a height of h.

drawPolygon(int[] xArray, int[] yArray, int numPoints)

Draws the outline of a closed polygon with the points of the polygon given in the x and y arrays.

drawRect(int x1, int y1, int w, int h)

Draws the outline of a rectangle with the upper-left corner at (x1, y1), a width of w, and a height of h.

fillArc(int x1, int y1, int w, int h, int startAngle, int arcAngle)

Draws a filled arc which is part of an oval that fits in an enclosing rectangle with an upper-left corner at (x1, y1), a width of w, and a height of h. The arc will start at the given startAngle and end at startAngle + arcAngle.

fillOval(int x1, int y1, int w, int h)

Draws a filled oval that fits in an enclosing rectangle with an upper-left corner at (x1, y1), a width of w, and a height of h.

fillPolygon(int[] xArray, int[] yArray, int numPoints)

Draws a filled closed polygon with the points of the polygon given in the x and y arrays.

fillRect(int x1, int y1, int w, int h)

Draws a rectangle filled with the current color with an upper-left corner at (x1, y1), a width of w, and a height of h.

setClip(Shape clip)

Sets the shape to use as a stencil to limit what is shown.

setColor(Color colorObj)

Sets the color to draw with.

setFont(Font fontObj)

Sets the font to use for drawing strings.


Graphics2D Methods

draw(Object obj)

Draw the outline of the passed object.

drawImage(Image image, AffineTransform xform, ImageObserver observer)

Draws the passed Image object after applying the passed AffineTransform object to it and notifies the ImageOb-server as more of the rendered image is available.

getFontRenderContext()

Returns a FontRenderContext object that contains rendering hints and device information, such as the dots-per-inch.

gettransform()

Returns the current AffineTransform object that represents all current transformations (rotations, translations, scaling, etc).

fill(Object obj)

Draw the passed object filled with the current paint type.

setComposite(Composite comp)

Set the Composite object that specifies how to handle overlapping pixels.

setPaint(Paint paint)

Sets the color, gradient, or texture to use when painting.

setStroke(Stroke s)

Set the brush (pen) to the one defined by the passed Stroke object.

setTransform(AffineTransform transform)

Sets the current transformation object to the passed AffineTransform object.




Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net