acm.graphics
Class G3DRect

java.lang.Object
  extended by acm.graphics.GObject
      extended by acm.graphics.GRect
          extended by acm.graphics.G3DRect

public class G3DRect
extends GRect

The G3DRect class is used to represent a rectangle whose borders are drawn to create a three-dimensional effect. The G3DRect class is a subclass of GRect, and therefore implements all the methods defined for that class. In addition, the G3DRect class supports the following methods:

 
void setRaised(boolean raised)
   Sets the G3DRect to appear raised or lowered as specified by the parameter
boolean isRaised()
   Returns true if this G3DRect is raised.

The appearance of a G3DRect object depends on the system on which it is displayed and is typically more effective if the G3DRect is filled.


Constructor Summary
G3DRect(double width, double height)
Constructs a new 3D rectangle with the specified width and height, positioned at the origin.
G3DRect(double x, double y, double width, double height)
Constructs a new 3D rectangle with the specified bounds.
G3DRect(double x, double y, double width, double height, boolean raised)
Constructs a new 3D rectangle with the specified bounds which is raised if the final parameter is true.
 
Method Summary
 boolean isRaised()
Tests whether this object appears raised.
 void setRaised(boolean raised)
Sets whether this object appears raised.
 
Inherited Method Summary
voidaddMouseListener(MouseListener listener)
Adds a mouse listener to this graphical object.
voidaddMouseMotionListener(MouseMotionListener listener)
Adds a mouse motion listener to this graphical object.
booleancontains(GPoint pt)
Checks to see whether a point is inside the object.
booleancontains(double x, double y)
Checks to see whether a point is inside the object.
GRectanglegetBounds()
Returns the bounding box for this object.
ColorgetColor()
Returns the color used to display this object.
ColorgetFillColor()
Returns the color used to display the filled region of this object.
doublegetHeight()
Returns the height of this object, which is defined to be the height of the bounding box.
GPointgetLocation()
Returns the location of this object as a GPoint.
GDimensiongetSize()
Returns the size of the bounding box for this object.
doublegetWidth()
Returns the width of this object, which is defined to be the width of the bounding box.
doublegetX()
Returns the x-coordinate of the object.
doublegetY()
Returns the y-coordinate of the object.
booleanisFilled()
Returns whether this object is filled.
booleanisVisible()
Checks to see whether this object is visible.
voidmove(double dx, double dy)
Moves the object on the screen using the displacements dx and dy.
voidmovePolar(double r, double theta)
Moves the object using displacements given in polar coordinates.
voidremoveMouseListener(MouseListener listener)
Removes a mouse listener from this graphical object.
voidremoveMouseMotionListener(MouseMotionListener listener)
Removes a mouse motion listener from this graphical object.
voidscale(double sf)
Scales the object on the screen by the scale factor sf, which applies in both dimensions.
voidscale(double sx, double sy)
Scales the object on the screen by the scale factors sx and sy.
voidsendBackward()
Moves this object one step toward the back in the z dimension.
voidsendForward()
Moves this object one step toward the front in the z dimension.
voidsendToBack()
Moves this object to the back of the display in the z dimension.
voidsendToFront()
Moves this object to the front of the display in the z dimension.
voidsetBounds(GDimension size)
Changes the size of this object as specified.
voidsetBounds(GRectangle bounds)
Changes the bounds of this object as specified.
voidsetBounds(double x, double y, double width, double height)
Changes the bounds of this object to the specified parameters.
voidsetColor(Color color)
Sets the color used to display this object.
voidsetFillColor(Color color)
Sets the color used to display the filled region of this object.
voidsetFilled(boolean fill)
Sets whether this object is filled.
voidsetLocation(GPoint pt)
Sets the location of this object to the specified point.
voidsetLocation(double x, double y)
Sets the location of this object to the point (x, y).
voidsetSize(double width, double height)
Changes the size of this object to the specified width and height.
voidsetVisible(boolean visible)
Sets whether this object is visible.
 

Constructor Detail

public G3DRect(double width, double height)

Constructs a new 3D rectangle with the specified width and height, positioned at the origin.

 
Usage: G3DRect grect = new G3DRect(width, height); 
Parameters: 
width  The width of the rectangle in pixels
height  The height of the rectangle in pixels
 


public G3DRect(double x, double y, double width, double height)

Constructs a new 3D rectangle with the specified bounds.

 
Usage: G3DRect grect = new G3DRect(x, y, width, height); 
Parameters: 
 The x-coordinate of the upper left corner
 The y-coordinate of the upper left corner
width  The width of the rectangle in pixels
height  The height of the rectangle in pixels
 


public G3DRect(double x, double y, double width, double height, boolean raised)

Constructs a new 3D rectangle with the specified bounds which is raised if the final parameter is true.

 
Usage: G3DRect grect = new G3DRect(x, y, width, height, raised); 
Parameters: 
 The x-coordinate of the upper left corner
 The y-coordinate of the upper left corner
width  The width of the rectangle in pixels
height  The height of the rectangle in pixels
raised  true if this rectangle should appear raised
 

Method Detail

public boolean isRaised()

Tests whether this object appears raised.

 
Usage: if (grect.isRaised()) . . . 
Returns: true if the object appears raised, false otherwise
 


public void setRaised(boolean raised)

Sets whether this object appears raised.

 
Usage: grect.setRaised(raised); 
Parameter: 
raised  true if the object appears raised, false otherwise