java.awt.geom
Class RectangularShape

java.lang.Object
  extended by java.awt.geom.RectangularShape
All Implemented Interfaces:
Shape, Cloneable
Direct Known Subclasses:
Rectangle2D

public abstract class RectangularShape
extends Object
implements Shape, Cloneable

An abstract base class for shapes based on a rectangular frame.

Author:
Lawrie Griffiths

Constructor Summary
RectangularShape()
           
 
Method Summary
 Object clone()
          Create a copy of this object, using a shallow copy.
 boolean contains(Point2D p)
          Test if the shape contains a Point2D
 boolean contains(Rectangle2D r)
          Test if this shape contains a given Rectangle2D
 Rectangle getBounds()
          Get the bounds of this rectangular shape as a Rectangle
 double getCenterX()
          Get the x coordinate of the center of the shape
 double getCenterY()
          Get the y coordinate of the center of the shape
 Rectangle2D getFrame()
          Get the framing rectangle
abstract  double getHeight()
          Get the height as a double
 double getMaxX()
          Get the maximum value of the x coordinate
 double getMaxY()
          Get the maximum value of the y coordinate
 double getMinX()
          Get the minimum value of the x x coordinate
 double getMinY()
          Get the minimum value of the y coordinate
abstract  double getWidth()
          Get the width as a double
abstract  double getX()
          Get the x coordinate as a double
abstract  double getY()
          Get the y coordinate as a double
 boolean intersects(Rectangle2D r)
          Test if this shape intersects a given Rectangle2D
abstract  boolean isEmpty()
          Test if the rectangular shape is empty
abstract  void setFrame(double x, double y, double w, double h)
          Set the frame for the rectangular shape
 void setFrame(Rectangle2D r)
          Set the frame of the rectangular shape
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.Shape
contains, contains, getBounds2D, intersects
 

Constructor Detail

RectangularShape

public RectangularShape()
Method Detail

getX

public abstract double getX()
Get the x coordinate as a double

Returns:
the x coordinate

getY

public abstract double getY()
Get the y coordinate as a double

Returns:
the y coordinate

getWidth

public abstract double getWidth()
Get the width as a double

Returns:
the width

getHeight

public abstract double getHeight()
Get the height as a double

Returns:
the height

getMinX

public double getMinX()
Get the minimum value of the x x coordinate

Returns:
the minimum x coordinate

getMinY

public double getMinY()
Get the minimum value of the y coordinate

Returns:
the minimum y coordinate

getMaxX

public double getMaxX()
Get the maximum value of the x coordinate

Returns:
the maximum y coordinate

getMaxY

public double getMaxY()
Get the maximum value of the y coordinate

Returns:
the maximim y coordinate

getCenterX

public double getCenterX()
Get the x coordinate of the center of the shape

Returns:
the x coordinate of the center

getCenterY

public double getCenterY()
Get the y coordinate of the center of the shape

Returns:
the y coordinate of the center

getFrame

public Rectangle2D getFrame()
Get the framing rectangle

Returns:
the framing rectangle

isEmpty

public abstract boolean isEmpty()
Test if the rectangular shape is empty

Returns:
true iff the shape is empty

setFrame

public abstract void setFrame(double x,
                              double y,
                              double w,
                              double h)
Set the frame for the rectangular shape

Parameters:
x - the x coordinate of the top left corner
y - the y coordinate iof the top left corner
w - the width
h - the height

setFrame

public void setFrame(Rectangle2D r)
Set the frame of the rectangular shape

Parameters:
r - the framing rectangle

contains

public boolean contains(Point2D p)
Test if the shape contains a Point2D

Specified by:
contains in interface Shape
Parameters:
p - the Point2D
Returns:
true iff this shape contains the Point2D

intersects

public boolean intersects(Rectangle2D r)
Test if this shape intersects a given Rectangle2D

Specified by:
intersects in interface Shape
Parameters:
r - the Rectangle2D
Returns:
true iff this shape intersects the given Rectangle2D

contains

public boolean contains(Rectangle2D r)
Test if this shape contains a given Rectangle2D

Specified by:
contains in interface Shape
Parameters:
r - the Rectangle2D
Returns:
true iff this shape contains the given Rectangle2D

getBounds

public Rectangle getBounds()
Get the bounds of this rectangular shape as a Rectangle

Specified by:
getBounds in interface Shape
Returns:
the bounds as a Rectangle

clone

public Object clone()
Description copied from class: Object
Create a copy of this object, using a shallow copy.

Overrides:
clone in class Object
Returns:
The new copy of the Object