|
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
GContainer | Defines the functionality of an object that can serve as the parent
of a GObject . |
GFillable | Specifies the characteristics of a graphical object that supports filling. |
GResizable | Specifies the characteristics of a graphical object that supports the
setSize and setBounds methods. |
GScalable | Specifies the characteristics of a graphical object that supports the
scale method. |
Class Summary | |
---|---|
G3DRect | The G3DRect class is used to represent a rectangle whose
borders are drawn to create a three-dimensional effect. |
GArc | The GArc class is a graphical object whose appearance consists
of an arc. |
GCanvas | The GCanvas class is a lightweight component that also
serves as a container for graphical objects. |
GCompound | This class defines a graphical object that consists of a collection of other graphical objects. |
GDimension | This class is a double-precision version of the Dimension class
in java.awt . |
GImage | The GImage class is a graphical object whose appearance is
defined by an image. |
GLabel | The GLabel class is a graphical object whose appearance
consists of a text string. |
GLine | The GLine class is a graphical object whose appearance consists
of a line segment. |
GMath | This class defines a variety of static mathematical methods
that are useful for the acm.graphics package. |
GObject | This class is the common superclass of all graphical objects that can
be displayed on a GCanvas . |
GOval | The GOval class is a graphical object whose appearance consists
of an oval. |
GPen | The GPen class simulates a pen drawing on a canvas. |
GPoint | This class is a double-precision version of the Point class
in java.awt . |
GPolygon | The GPolygon class is a graphical object whose appearance consists
of a polygon. |
GRect | The GRect class is a graphical object whose appearance consists
of a rectangular box. |
GRectangle | This class is a double-precision version of the Rectangle class
in java.awt . |
GRoundRect | The GRoundRect class is a graphical object whose appearance consists
of a rounded rectangle. |
GTurtle | The GTurtle class simulates a turtle moving on a canvas. |
This package provides a set of classes that support the creation of simple,
object-oriented graphical displays. The basic model is that of a felt board
of the sort one might use as a child. The felt board itself is represented by
the GCanvas
class, which is a lightweight
container that supports the addition of graphical objects that correspond to the
shapes attached to the board. These graphical objects come from a variety of
classes that represent geometrical shapes and other graphical entities including
lines, ovals, rectangles, images, and strings.
The standard approach to using the acm.graphics
package consists
of the following steps:
GCanvas
object to serve as the surface to which
subsequent graphical objects are attached.
JFrame
object and then add the GCanvas
at the center of that frame.
add
method in GCanvas
to add new graphical
objects from the GObject
hierarchy.
As an example, the following main program follows this outline to display a red square on the screen:
public static void main(String[] args) {
GCanvas gc = new GCanvas();
JFrame frame = new JFrame();
frame.getContentPane().add(BorderLayout.CENTER, gc);
GRectangle square = new GRectangle(100, 100, 200, 200);
square.setFilled(true);
square.setColor(Color.RED);
gc.add(square);
frame.show();
}
Much of this boilerplate can be eliminated by using the
GraphicsProgram
class
in the acm.program
package.
The public classes in the acm.graphics
package can be diagrammed
as follows:
|
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |