com.lizardtech.djvubean
Class SimpleArea

java.lang.Object
  extended by com.lizardtech.djvubean.SimpleArea

public class SimpleArea
extends java.lang.Object

SimpleArea is a wrapper class to java.awt.geom.Area using Java java.lang.reflect to access the class methods at runtime. Should the java.awt.geom.Area class be unavailable, then the methods will use java.awt.Rectangle to simulate the Area class.

Version:
$Revision: 1.2 $
Author:
Bill C. Riemers

Constructor Summary
SimpleArea()
          Creates a new AreaRelection object.
SimpleArea(java.awt.Shape shape)
          Creates a new SimpleArea object.
 
Method Summary
 boolean contains(double x, double y)
          Test if a point is contained within this Area.
 boolean contains(double x, double y, double w, double h)
          Test if the specified rectangle is contained within the Area.
 boolean contains(java.awt.Rectangle r)
          Test if the specified rectangle is contained in the Area.
 java.awt.Rectangle getBounds()
          Get the bounds of the area or rectangle.
 java.awt.Shape getShape()
          Return direct access to the wrapped Area or Rectangle object.
 void intersect(SimpleArea rhs)
          Set this area to the intersection of with the specified area.
 boolean intersects(double x, double y, double w, double h)
          Tests if the specified rectangle intersects the Area.
 boolean intersects(java.awt.Rectangle r)
          Tests if the specified rectangle intersects the Area.
 boolean isEmpty()
          Test if the area or rectangle is empty.
static boolean isFake()
          Method to test if this is really using java.awt.geom.Area.
 void reset()
          Clears this area to a zero volume.
 void setShape(java.awt.Shape area)
          Set the shape of the current area.
 void subtract(SimpleArea rhs)
          Subtract the specified area from this area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleArea

public SimpleArea()
Creates a new AreaRelection object.


SimpleArea

public SimpleArea(java.awt.Shape shape)
Creates a new SimpleArea object.

Parameters:
shape - to construct from.
Method Detail

isFake

public static boolean isFake()
Method to test if this is really using java.awt.geom.Area.

Returns:
false if java.awt.Rectangle is being used instead.

getBounds

public java.awt.Rectangle getBounds()
Get the bounds of the area or rectangle.

Returns:
a bounding rectangle.

isEmpty

public boolean isEmpty()
Test if the area or rectangle is empty.

Returns:
true if no volume is enclosed.

setShape

public void setShape(java.awt.Shape area)
Set the shape of the current area. Only the bounds will be used.

Parameters:
area - to use.

getShape

public java.awt.Shape getShape()
Return direct access to the wrapped Area or Rectangle object.

Returns:
the wrapped object.

contains

public boolean contains(double x,
                        double y)
Test if a point is contained within this Area.

Parameters:
x - coordinate
y - coordinate
Returns:
True if the point is within the Area.

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Test if the specified rectangle is contained within the Area.

Parameters:
x - coordinate of upper left.
y - coordinate of upper left.
w - width of the rectangle.
h - height of the rectangle.
Returns:
true if the rectangle is contained within the Area.

contains

public boolean contains(java.awt.Rectangle r)
Test if the specified rectangle is contained in the Area.

Parameters:
r - the rectangle to test.
Returns:
true if the rectangle is contained in the Area.

intersect

public void intersect(SimpleArea rhs)
Set this area to the intersection of with the specified area.

Parameters:
rhs - Second area to compare with.

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Tests if the specified rectangle intersects the Area.

Parameters:
x - coordinate of upper left.
y - coordinate of upper left.
w - width of the rectangle.
h - height of the rectangle.
Returns:
true if the rectangle intersects the Area.

intersects

public boolean intersects(java.awt.Rectangle r)
Tests if the specified rectangle intersects the Area.

Parameters:
r - the rectangle to test.
Returns:
true if the rectangle intersects the Area.

reset

public void reset()
Clears this area to a zero volume.


subtract

public void subtract(SimpleArea rhs)
Subtract the specified area from this area. If java.awt.Rectangle is being used as the Shape class, then the result will be the rectangle which bounds the resultant Area.

Parameters:
rhs - area to subtract.