|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.shapepack.Shape
public abstract class Shape
The Shape class is an abstract class which defines the fields, methods and behavior common to all shapes.
Field Summary | |
---|---|
protected java.awt.Color |
color
Fill color for the shape |
static java.awt.Color |
defaultColor
Constant specifying the default fill color for a shape. |
static int |
defaultHeight
Constant specifying the default height of a shape. |
static int |
defaultWidth
Constant specifying the default width of a shape. |
protected int |
height
Height of the bounding box. |
protected int |
width
Width of the bounding box. |
protected int |
x
Horizontal coordinate of the upper left corner of the bounding box. |
protected int |
y
Vertical coordinate of the upper left corner of the bounding box. |
Constructor Summary | |
---|---|
Shape(int x,
int y,
int w,
int h,
java.awt.Color c)
The generic constructor for shape objects. |
Method Summary | |
---|---|
abstract float |
area()
Calculates the area of the shape. |
abstract void |
draw(java.awt.Graphics g)
Draws the shape. |
java.awt.Color |
getColor()
|
int |
getHeight()
|
int |
getWidth()
|
int |
getX()
|
int |
getY()
|
void |
moveTo(int x,
int y)
Moves the shape by setting the upper left corner of the bounding box to the specified coordinates. |
abstract float |
perimeter()
Calculates the perimeter of the shape. |
void |
setColor(java.awt.Color color)
|
void |
setHeight(int h)
|
void |
setWidth(int w)
|
java.lang.String |
toString()
Generates a string describing the parameters of the shape. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int defaultWidth
public static final int defaultHeight
public static final java.awt.Color defaultColor
protected int x
protected int y
protected int width
protected int height
protected java.awt.Color color
Constructor Detail |
---|
public Shape(int x, int y, int w, int h, java.awt.Color c)
x
- horizontal coordinate of the upper left corner of the bounding box.y
- vertical coordinate of the upper left corner of the bounding box.w
- width of the bounding box.h
- height of the bounding box.c
- fill color for the shape.Method Detail |
---|
public void moveTo(int x, int y)
x
- the new horizontal coordinate of the upper left corner of the bounding box.y
- the new vertical coordinate of the upper left corner of the bounding box.public int getX()
public int getY()
public int getWidth()
public void setWidth(int w)
w
- the new width of the bounding box.public int getHeight()
public void setHeight(int h)
h
- the new height of the bounding box.public java.awt.Color getColor()
public void setColor(java.awt.Color color)
color
- the new fill color for the shape.public abstract void draw(java.awt.Graphics g)
g
- the graphics object on which the shape is to be drawn.public abstract float area()
public abstract float perimeter()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |