org.hermit.geometry
Class Region

java.lang.Object
  extended by org.hermit.geometry.Region

public class Region
extends java.lang.Object

An immutable rectangular region in the plane. This immutable class represents a rectangle as two sets of X and Y co-ordinates.


Constructor Summary
Region(double x1, double y1, double x2, double y2)
          Create a Point from individual co-ordinates.
 
Method Summary
 double getHeight()
          Get the height of this region.
 double getWidth()
          Get the width of this region.
 double getX1()
          Get the lower X co-ordinate of this region.
 double getX2()
          Get the upper X co-ordinate of this region.
 double getY1()
          Get the lower Y co-ordinate of this region.
 double getY2()
          Get the upper Y co-ordinate of this region.
 Point randomPoint()
          Get a random point within this region.
 java.lang.String toString()
          Convert this instance to a String suitable for display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Region

public Region(double x1,
              double y1,
              double x2,
              double y2)
Create a Point from individual co-ordinates.

Parameters:
x1 - One X co-ordinate.
y1 - One Y co-ordinate.
x2 - The other X co-ordinate.
y2 - The other Y co-ordinate.
Method Detail

getX1

public double getX1()
Get the lower X co-ordinate of this region.

Returns:
The lower X co-ordinate of this region.

getY1

public double getY1()
Get the lower Y co-ordinate of this region.

Returns:
The lower Y co-ordinate of this region.

getX2

public double getX2()
Get the upper X co-ordinate of this region.

Returns:
The upper X co-ordinate of this region.

getY2

public double getY2()
Get the upper Y co-ordinate of this region.

Returns:
The upper Y co-ordinate of this region.

getWidth

public double getWidth()
Get the width of this region.

Returns:
The width of this region.

getHeight

public double getHeight()
Get the height of this region.

Returns:
The height of this region.

randomPoint

public Point randomPoint()
Get a random point within this region.

Returns:
An evenly-distributed random point within this region.

toString

public java.lang.String toString()
Convert this instance to a String suitable for display.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this instance.