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()
Constructs a new 0x0 rectangle, positioned at the origin.
|
GRect(float width,
float height)
Constructs a new rectangle with the specified width and height,
positioned at the origin.
|
GRect(float x,
float y,
float width,
float height)
Constructs a new rectangle with the specified bounds.
|
| Modifier and Type | Method and Description |
|---|---|
GRectangle |
getBounds()
Returns the bounding box of this object.
|
Paint |
getFillColor()
Returns the color used to display the filled region of this object.
|
float |
getHeight()
Returns the height of this object as a float-precision value, which
is defined to be the height of the bounding box.
|
GDimension |
getSize()
Returns the size of this object as a
GDimension. |
float |
getWidth()
Returns the width of this object as a float-precision value, which
is defined to be the width of the bounding box.
|
boolean |
isFilled()
Returns whether this object is filled.
|
void |
paint(Canvas canvas)
Implements the
paint operation for this graphical object. |
void |
scale(float sf)
Scales the object on the screen by the scale factor
sf, which applies
in both dimensions. |
void |
scale(float sx,
float sy)
Scales the object on the screen by the scale factors
sx and sy. |
void |
setBounds(float x,
float y,
float width,
float 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(Paint 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(float width,
float 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. |
contains, contains, getBottomY, getCenterX, getCenterY, getColor, getGCanvas, getLocation, getPaint, getRightX, getX, getY, intersects, isVisible, moveBy, moveByPolar, moveTo, moveTo, moveToPolar, repaint, sendBackward, sendForward, sendToBack, sendToFront, setBottomY, setCanvas, setColor, setGCanvas, setLocation, setLocation, setPaint, setRightX, setVisible, setX, setY, toString, translatepublic GRect()
public GRect(float width,
float height)
width - The width of the rectangle in pixelsheight - The height of the rectangle in pixelspublic GRect(float x,
float y,
float width,
float 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(Canvas canvas)
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(Paint color)
setFillColor in interface GFillablecolor - The color used to display the filled region of this objectpublic Paint getFillColor()
getFillColor returns the color of the
object.getFillColor in interface GFillablepublic void setSize(float width,
float height)
setSize in interface GResizablewidth - The new width of the objectheight - The new height of the objectpublic final void setSize(GDimension size)
GDimension.setSize in interface GResizablesize - A GDimension object specifying the sizepublic GDimension getSize()
GDimension.public void setBounds(float x,
float y,
float width,
float height)
setBounds in interface GResizablex - 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 GResizablebounds - A GRectangle specifying the new boundspublic GRectangle getBounds()
public float getWidth()
public float getHeight()
public void scale(float sx,
float sy)
sx and sy.