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 |
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(Point pt)
Checks to see whether a point is inside the object, where the point is
specified as a Point, as defined in java.awt. |
|
Rectangle |
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. |
|
Component |
getComponent()
Returns the component in which this object is installed, or null
if none exists. |
|
Color |
getFillColor()
Returns the color used to display the filled region of this object. |
|
double |
getHeight()
Returns the height of this object. |
|
Point |
getLocation()
Returns the nearest Point corresponding to the location of this object. |
|
GContainer |
getParent()
Returns the parent of this object, which is the canvas or compound object in
which it is enclosed. |
|
Dimension |
getSize()
Returns the size of this object as a Dimension. |
|
double |
getWidth()
Returns the width of this object. |
|
double |
getX()
Returns the x-coordinate of the object. |
|
double |
getY()
Returns the y-coordinate of the object. |
|
boolean |
isFilled()
Returns whether this object is filled. |
|
boolean |
isVisible()
Checks to see whether this object is visible. |
|
void |
moveToBack()
Moves this object to the back of the display in stacking order. |
|
void |
moveToFront()
Moves this object to the front of the display in stacking order. |
|
abstract 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 |
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 |
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 the object on the screen by the scale factors sx and sy. |
|
void |
setColor(Color c)
Sets the color used to display this object. |
|
void |
setFillColor(Color c)
Sets the color used to display the filled region of this object. |
|
void |
setFilled(boolean fill)
Sets whether this object is filled. |
|
void |
setLocation(double x,
double y)
Sets the location of this object to the point (x, y). |
|
void |
setLocation(Point pt)
Sets the location of this object to the specified point, specified using
the standard Point class from java.awt. |
|
void |
setSize(Dimension size)
Changes the size of this object to the specified Dimension
object as defined in java.awt. |
|
void |
setSize(double width,
double height)
Changes the size of this object to the specified width and height. |
|
void |
setVisible(boolean visible)
Sets whether this object is visible. |
|
void |
translate(double dx,
double dy)
Moves the object on the screen using the displacements dx and dy. |