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.
Method Summary |
void |
add(GObject gobj)
Adds a new graphical object to this GCompound . |
void |
add(GObject gobj,
double x,
double y)
Adds the graphical object to this canvas and sets its location
to the point (x , y ). |
void |
add(GObject gobj,
GPoint pt)
Adds the graphical object to this canvas and sets its location to the specified point. |
boolean |
contains(double x,
double y)
Checks to see whether a point is "inside" the compound, which means that it is
inside one of the components. |
GRectangle |
getBounds()
Returns the bounding rectangle for this compound object, which consists of
the union of the bounding rectangles for each of the components. |
GPoint |
getCanvasPoint(double x,
double y)
Converts the location of the specified point in this compound to
the corresponding point in the enclosing canvas. |
GPoint |
getCanvasPoint(GPoint localPoint)
Converts the location of the specified point in this compound to
the corresponding point in the enclosing canvas. |
GObject |
getElement(int index)
Returns the graphical object at the specified index, numbering from back
to front in the the z dimension. |
GObject |
getElementAt(double x,
double y)
Returns the topmost graphical object that contains the point
(x , y ), or null if no such
object exists. |
GObject |
getElementAt(GPoint pt)
Returns the topmost graphical object that contains the specified point,
or null if no such object exists. |
int |
getElementCount()
Returns the number of graphical objects stored in this container. |
GPoint |
getLocalPoint(double x,
double y)
Converts the specified point on the enclosing canvas to the
corresponding point in the space of this compound. |
GPoint |
getLocalPoint(GPoint canvasPoint)
Converts the location of the specified point on the enclosing canvas
to the corresponding point in the space of this compound. |
Iterator<GObject> |
iterator()
Returns an Iterator that cycles through the elements within
this container in the default direction, which is from back to front. |
Iterator<GObject> |
iterator(int direction)
Returns an Iterator that cycles through the elements
within this container in the specified direction, which must be one
of the constants GContainer.FRONT_TO_BACK
or GContainer.BACK_TO_FRONT . |
void |
markAsComplete()
Calling this method makes it illegal to add or remove elements from the
compound object. |
void |
remove(GObject gobj)
Removes a graphical object from this GCompound . |
void |
removeAll()
Removes all graphical objects from this GCompound . |
void |
scale(double sf)
Scales the object on the screen by the scale factor sf , which applies
in both dimensions. |
void |
scale(double sx,
double sy)
Scales every object contained in this compound by the scale factors
sx and sy . |
Inherited Method Summary |
void | addMouseListener(MouseListener listener)
Adds a mouse listener to this graphical object.
|
void | addMouseMotionListener(MouseMotionListener listener)
Adds a mouse motion listener to this graphical object.
|
boolean | contains(GPoint pt)
Checks to see whether a point is inside the object.
|
double | getHeight()
Returns the height of this object, which is defined to be
the height of the bounding box.
|
GPoint | getLocation()
Returns the location of this object as a GPoint .
|
GDimension | getSize()
Returns the size of the bounding box for this object.
|
double | getWidth()
Returns the width of this object, which is defined to be
the width of the bounding box.
|
double | getX()
Returns the x-coordinate of the object.
|
double | getY()
Returns the y-coordinate of the object.
|
boolean | isVisible()
Checks to see whether the object is visible.
|
void | move(double dx, double dy)
Moves the object on the screen using the displacements dx and dy .
|
void | movePolar(double r, double theta)
Moves the object using displacements given in polar coordinates.
|
void | removeMouseListener(MouseListener listener)
Removes a mouse listener from this graphical object.
|
void | removeMouseMotionListener(MouseMotionListener listener)
Removes a mouse motion listener from this graphical object.
|
void | sendBackward()
Moves this object one step toward the back in the z dimension.
|
void | sendForward()
Moves this object one step toward the front in the z dimension.
|
void | sendToBack()
Moves this object to the back of the display in the z dimension.
|
void | sendToFront()
Moves this object to the front of the display in the z dimension.
|
void | setLocation(GPoint pt)
Sets the location of this object to the specified point.
|
void | setLocation(double x, double y)
Sets the location of the GCompound to the point (x , y ).
|
void | setVisible(boolean visible)
Sets the visibility status of the GCompound .
|