This class is the common superclass of all graphical objects that can
be displayed on a GCanvas
.
Because it is an abstract class, you are not allowed to construct an
object whose class is GObject
directly. What you do
instead is construct one of the concrete subclasses like
GRect
or
GLine
.
The purpose of this class definition is to define methods that apply
to all graphical objects regardless of their specific class.
Method Summary |
void |
addActionListener(ActionListener listener)
Adds an action listener to this graphical object. |
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(double x,
double y)
Checks to see whether a point is inside the object. |
boolean |
contains(GPoint pt)
Checks to see whether a point is inside the object. |
void |
fireActionEvent(ActionEvent e)
Triggers an action event for this graphical object. |
void |
fireActionEvent(String actionCommand)
Triggers an action event for this graphical object with the specified
action command. |
GRectangle |
getBounds()
Returns the bounding box of this object, which is defined to be the
smallest rectangle that covers everything drawn by the figure. |
Color |
getColor()
Returns the color used to display this 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 . |
GContainer |
getParent()
Returns the parent of this object, which is the canvas or compound object in
which it is enclosed. |
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 this 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 |
paint(Graphics g)
All subclasses of GObject must define a paint
method which allows the object to draw itself on the Graphics
context passed in as the parameter g . |
void |
pause(double milliseconds)
Delays the calling thread for the specified time, which is expressed in
milliseconds. |
void |
removeActionListener(ActionListener listener)
Removes an action listener from this graphical object. |
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 |
setColor(Color color)
Sets the color used to display this object. |
void |
setLocation(double x,
double y)
Sets the location of this object to the point (x , y ). |
void |
setVisible(boolean visible)
Sets whether this object is visible. |