public class GRect extends GObject implements GFillable, GResizable, GScalable
GRect
class is a graphical object whose appearance consists
of a rectangular box.Constructor and Description |
---|
GRect(double width,
double height)
Constructs a new rectangle with the specified width and height, positioned at
the origin.
|
GRect(double x,
double y,
double width,
double height)
Constructs a new rectangle with the specified bounds.
|
Modifier and Type | Method and Description |
---|---|
protected java.awt.Rectangle |
getAWTBounds()
Returns an AWT
Rectangle that specifies the bounds of this
object. |
GRectangle |
getBounds()
Returns the bounding box of this object.
|
java.awt.Color |
getFillColor()
Returns the color used to display the filled region of this object.
|
double |
getHeight()
Returns the height of this object as a double-precision value, which is
defined to be the height of the bounding box.
|
GDimension |
getSize()
Returns the size of this object as a
GDimension . |
double |
getWidth()
Returns the width of this object as a double-precision value, which is
defined to be the width of the bounding box.
|
boolean |
isFilled()
Returns whether this object is filled.
|
void |
paint(java.awt.Graphics g)
Implements the
paint operation for 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 |
setBounds(double x,
double y,
double width,
double height)
Changes the bounds of this object to the specified values.
|
void |
setBounds(GRectangle bounds)
Changes the bounds of this object to the values from the specified
GRectangle . |
void |
setFillColor(java.awt.Color color)
Sets the color used to display the filled region of this object.
|
void |
setFilled(boolean fill)
Sets whether this object is filled.
|
void |
setSize(double width,
double height)
Changes the size of this object to the specified width and height.
|
void |
setSize(GDimension size)
Changes the size of this object to the specified
GDimension . |
addActionListener, addMouseListener, addMouseMotionListener, areMouseListenersEnabled, colorName, contains, contains, fireActionEvent, fireActionEvent, fireMouseListeners, getColor, getComponent, getLocation, getObjectColor, getParent, getX, getY, isVisible, move, movePolar, paintObject, paramString, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, repaint, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, start, start, toString, updateEnabledList
public GRect(double width, double height)
width
- The width of the rectangle in pixelsheight
- The height of the rectangle in pixelspublic GRect(double x, double y, double width, double height)
x
- The x-coordinate of the upper left cornery
- The y-coordinate of the upper left cornerwidth
- The width of the rectangle in pixelsheight
- The height of the rectangle in pixelspublic void paint(java.awt.Graphics g)
paint
operation for this graphical object. This
method is not called directly by clients.public void setFilled(boolean fill)
public boolean isFilled()
public void setFillColor(java.awt.Color color)
setFillColor
in interface GFillable
color
- The color used to display the filled region of this objectpublic java.awt.Color getFillColor()
getFillColor
returns the color of the object.getFillColor
in interface GFillable
public void setSize(double width, double height)
setSize
in interface GResizable
width
- The new width of the objectheight
- The new height of the objectpublic final void setSize(GDimension size)
GDimension
.setSize
in interface GResizable
size
- A GDimension
object specifying the sizepublic GDimension getSize()
GDimension
.public void setBounds(double x, double y, double width, double height)
setBounds
in interface GResizable
x
- The new x-coordinate for the objecty
- The new y-coordinate for the objectwidth
- The new width of the objectheight
- The new height of the objectpublic final void setBounds(GRectangle bounds)
GRectangle
.setBounds
in interface GResizable
bounds
- A GRectangle
specifying the new boundspublic GRectangle getBounds()
public double getWidth()
public double getHeight()
public void scale(double sx, double sy)
sx
and
sy
.public final void scale(double sf)
sf
, which
applies in both dimensions.protected java.awt.Rectangle getAWTBounds()
Rectangle
that specifies the bounds of this
object.Rectangle
that specifies the bounds of this object