|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--acm.graphics.GObject | +--acm.graphics.GCompound
public class GCompound extends GObject implements GContainer, GScalable
This class defines a graphical object that consists of a collection of other graphical objects. Once assembled, the internal objects can be manipulated as a unit.
Constructor Summary |
GCompound() |
Method Summary | |
void | add(GObject gobj) |
void | add(GObject gobj,
double x,
double y) |
void | add(GObject gobj,
GPoint pt) |
boolean | contains(double x,
double y) |
GRectangle | getBounds() |
GPoint | getCanvasPoint(double x,
double y) |
GPoint | getCanvasPoint(GPoint localPoint) |
GObject | getElement(int index) |
GObject | getElementAt(double x,
double y) |
GObject | getElementAt(GPoint pt) |
int | getElementCount() |
GPoint | getLocalPoint(double x,
double y) |
GPoint | getLocalPoint(GPoint canvasPoint) |
Iterator | iterator() |
Iterator | iterator(int direction) |
void | markAsComplete() |
void | remove(GObject gobj) |
void | removeAll() |
void | scale(double sf) |
void | scale(double sx,
double sy) |
Inherited Method Summary | |
void | addMouseListener(MouseListener listener) |
void | addMouseMotionListener(MouseMotionListener listener) |
boolean | contains(GPoint pt) |
double | getHeight() |
GPoint | getLocation()GPoint .
|
GDimension | getSize() |
double | getWidth() |
double | getX() |
double | getY() |
boolean | isVisible() |
void | move(double dx, double dy)dx and dy .
|
void | movePolar(double r, double theta) |
void | removeMouseListener(MouseListener listener) |
void | removeMouseMotionListener(MouseMotionListener listener) |
void | sendBackward() |
void | sendForward() |
void | sendToBack() |
void | sendToFront() |
void | setLocation(GPoint pt) |
void | setLocation(double x, double y)GCompound to the point (x , y ).
|
void | setVisible(boolean visible)GCompound .
|
Constructor Detail |
public GCompound()
Usage: | GCompound gcomp = new GCompound(); |
Method Detail |
public void add(GObject gobj)
Usage: | gcomp.add(gobj); | ||
Parameter: |
| ||
Specified by: | add in interface GContainer |
public final void add(GObject gobj,
double x,
double y)
Usage: | gc.add(gobj, x, y); | ||||||
Parameters: |
| ||||||
Specified by: | add in interface GContainer |
public final void add(GObject gobj,
GPoint pt)
Usage: | gc.add(gobj, pt); | ||||
Parameters: |
| ||||
Specified by: | add in interface GContainer |
public boolean contains(double x,
double y)
Usage: | if (gcomp.contains(x, y)) . . . | ||||
Parameters: |
| ||||
Returns: | true if the point (x, y) is inside the compound, and false otherwise |
public GRectangle getBounds()
Usage: | GRectangle bounds = gcomp.getBounds(); |
Returns: | A GRectangle that bounds the components of this object |
public GPoint getCanvasPoint(double x,
double y)
Usage: | canvasPoint = gcomp.getCanvasPoint(x, y); | ||||
Parameters: |
| ||||
Returns: | The coordinates in the space of the enclosing GCanvas |
public final GPoint getCanvasPoint(GPoint localPoint)
Usage: | canvasPoint = gcomp.getCanvasPoint(localPoint); | ||
Parameter: |
| ||
Returns: | The coordinates in the space of the enclosing GCanvas |
public GObject getElement(int index)
Usage: | GObject gobj = gcomp.getElement(index); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified index | ||
Specified by: | getElement in interface GContainer |
public GObject getElementAt(double x,
double y)
Usage: | GObject gobj = gcomp.getElementAt(x, y); | ||||
Parameters: |
| ||||
Returns: | The graphical object at the specified location, or nullif no such object exists | ||||
Specified by: | getElementAt in interface GContainer |
public final GObject getElementAt(GPoint pt)
Usage: | GObject gobj = gc.getElementAt(pt); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified location, or nullif no such object exists | ||
Specified by: | getElementAt in interface GContainer |
public int getElementCount()
Usage: | int n = gcomp.getElementCount(); |
Returns: | The number of graphical objects in this container |
Specified by: | getElementCount in interface GContainer |
public GPoint getLocalPoint(double x,
double y)
Usage: | localPoint = gcomp.getCanvasPoint(x, y); | ||||
Parameters: |
| ||||
Returns: | The coordinates in the space of the compound |
public final GPoint getLocalPoint(GPoint canvasPoint)
Usage: | localPoint = gcomp.getLocalPoint(canvasPoint); | ||
Parameter: |
| ||
Returns: | The coordinates in the space of the compound |
public Iterator iterator()
Applets that want to run in browsers, however, should avoid using this method, because Iterator is not supported on 1.1 browsers. For maximum portability, you should rely instead on the getElementCount and getElement methods, which provide the same functionality in a browser-compatible way.
Usage: | Iterator i = gc.iterator(); |
Returns: | An Iterator ranging over the elements of the container from back to front |
public Iterator iterator(int direction)
for (Iterator i = gc.iterator(direction); i.hasNext(); )
Applets that want to run in browsers, however, should avoid using this method, because Iterator is not supported on 1.1 browsers. For maximum portability, you should rely instead on the getElementCount and getElement methods, which provide the same functionality in a browser-compatible way.
Usage: | Iterator i = gc.iterator(direction); |
Returns: | An Iterator ranging over the elements of the container in the specified direction |
public void markAsComplete()
Usage: | gcomp.markAsComplete(); |
public void remove(GObject gobj)
Usage: | gcomp.remove(gobj); | ||
Parameter: |
| ||
Specified by: | remove in interface GContainer |
public void removeAll()
Usage: | gcomp.removeAll(); |
Specified by: | removeAll in interface GContainer |
public final void scale(double sf)
Usage: | gcomp.scale(sf); | ||
Parameter: |
| ||
Specified by: | scale in interface GScalable |
public void scale(double sx,
double sy)
Usage: | gcomp.scale(sx, sy); | ||||
Parameters: |
| ||||
Specified by: | scale in interface GScalable |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |