Class AbstractShape

java.lang.Object
  extended by AbstractShape
Direct Known Subclasses:
RectangleShape

public abstract class AbstractShape
extends Object

Class AbstractShape: abstract class for shapes that can be represented with 2 points Copyright Georgia Institute of Technology 2007

Author:
Barb Ericson ericson@cc.gatech.edu

Field Summary
protected  Color color
          the color of this shape
static String OVAL
           
protected  Point p1
          the first point in the shape
protected  Point p2
          the second point in the shape
static String RECTANGLE
           
 
Constructor Summary
AbstractShape()
          Constructor that takes no arguments
AbstractShape(int x1, int y1, int x2, int y2)
          Constructor that takes x1,y1,x2,y2
AbstractShape(Point firstPoint, Point secondPoint)
          Constructor that takes the first and second point
 
Method Summary
abstract  void draw(Graphics g)
          Abstract method to draw the shape given the graphics context
 int getHeight()
          Method to get the height of the bounding rectangle
 int getMinX()
          Method to get minimum x value of the bounding rectangle
 int getMinY()
          Method to get the minimum y value of the bounding rectangle
 int getWidth()
          Method to get the width of the bounding rectangle
 void setPoint1Values(int newX, int newY)
          Method to set the point values for point1 that defines the shape
 void setPoint2Values(int newX, int newY)
          Method to set the point values for point2 that defines the shape
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECTANGLE

public static final String RECTANGLE
See Also:
Constant Field Values

OVAL

public static final String OVAL
See Also:
Constant Field Values

color

protected Color color
the color of this shape


p1

protected Point p1
the first point in the shape


p2

protected Point p2
the second point in the shape

Constructor Detail

AbstractShape

public AbstractShape()
Constructor that takes no arguments


AbstractShape

public AbstractShape(Point firstPoint,
                     Point secondPoint)
Constructor that takes the first and second point

Parameters:
firstPoint - the first point that defines the shape
secondPoint - the second point that defines the shape

AbstractShape

public AbstractShape(int x1,
                     int y1,
                     int x2,
                     int y2)
Constructor that takes x1,y1,x2,y2

Parameters:
x1 - x value of the first point that defines the shape
y1 - y value of the first point that defines the shape
x2 - x value of the second point that defines the shape
y2 - y value of the second point that defines the shape
Method Detail

getMinX

public int getMinX()
Method to get minimum x value of the bounding rectangle

Returns:
the minimum x value of the two points that define the shape

getMinY

public int getMinY()
Method to get the minimum y value of the bounding rectangle

Returns:
the minimum y value of the two points that define the shape

getWidth

public int getWidth()
Method to get the width of the bounding rectangle

Returns:
the width of the bounding rectangle

getHeight

public int getHeight()
Method to get the height of the bounding rectangle

Returns:
the height of the bounding rectangle

setPoint1Values

public void setPoint1Values(int newX,
                            int newY)
Method to set the point values for point1 that defines the shape

Parameters:
newX - the new x value for point 1
newY - the new y value for point 1

setPoint2Values

public void setPoint2Values(int newX,
                            int newY)
Method to set the point values for point2 that defines the shape

Parameters:
newX - the new x value for point 2
newY - the new y value for point 2

draw

public abstract void draw(Graphics g)
Abstract method to draw the shape given the graphics context

Parameters:
g - the graphics context to draw the shape on