com.partnersoft.v3x.graphics
Class DoubleRectangle

java.lang.Object
  extended by com.partnersoft.v3x.graphics.DoubleRectangle
All Implemented Interfaces:
java.io.Serializable

public class DoubleRectangle
extends java.lang.Object
implements java.io.Serializable

A rectangle in whole-number space. Because whole numbers are part of this nutritious breakfast.

See Also:
Serialized Form

Field Summary
 double east
           
static double EPSILON
           
 double north
           
 double south
           
 double west
           
 
Constructor Summary
DoubleRectangle()
          Create a new DoubleRectangle.
DoubleRectangle(double west, double south, double east, double north)
          Create a new DoubleRectangle with given west, south, east and north.
 
Method Summary
 java.lang.Object clone()
           
 boolean contains(double x, double y)
          Returns true if this rectangle contains the given point.
 boolean covers(DoubleRectangle nother)
          Returns true if this rectangle covers the given one.
static DoubleRectangle createStartingRectangleForExtents()
          Gives a rectangle with reversed infinite extents, useful in conjunction with stretchToInclude() when generating extents boxes.
 double getArea()
          Area (width * height)
 Coord3D getCenter()
          Returns the center of the given rectangle
 double getEast()
          Maximum x coordinate (east edge)
 double getHeight()
          Height
 double getNorth()
          Maximum y coordinate (north edge)
 double getSouth()
          Minimum y coordinate (southern edge)
 double getWest()
          Minimum x coordinate (western edge)
 double getWidth()
          Width
 double getX()
          Minimum x (same as west)
 double getY()
          Minimum y (same as south)
 DoubleRectangle intersection(DoubleRectangle nother)
          Returns the intersection of the given rectangle with this (returns null if there is none)
 boolean intersects(DoubleRectangle nother)
          Returns true if the given rectangle intersects this one.
 boolean isDegenerate()
          True if rectangle is degenerate (has either no height or no width)
 void setEast(double newEast)
          Maximum x coordinate (east edge)
 void setNorth(double newNorth)
          Maximum y coordinate (north edge)
 void setSouth(double newSouth)
          Minimum y coordinate (southern edge)
 void setWest(double newWest)
          Minimum x coordinate (western edge)
 void stretchToInclude(Coord2D coord)
          Stretches the rectangle to include the given point.
 void stretchToInclude(double x, double y)
          Stretches the rectangle to include the given point.
 java.lang.String toString()
           
 java.util.ArrayList trimmings(DoubleRectangle nother)
          Returns a list of rectangles formed when the given rectangle is cropped by this one.
 DoubleRectangle union(DoubleRectangle nother)
          Returns the union of the given rectangle with this.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EPSILON

public static final double EPSILON
See Also:
Constant Field Values

west

public double west

south

public double south

east

public double east

north

public double north
Constructor Detail

DoubleRectangle

public DoubleRectangle()
Create a new DoubleRectangle.


DoubleRectangle

public DoubleRectangle(double west,
                       double south,
                       double east,
                       double north)
Create a new DoubleRectangle with given west, south, east and north.

Method Detail

createStartingRectangleForExtents

public static DoubleRectangle createStartingRectangleForExtents()
Gives a rectangle with reversed infinite extents, useful in conjunction with stretchToInclude() when generating extents boxes.


contains

public boolean contains(double x,
                        double y)
Returns true if this rectangle contains the given point.


intersects

public boolean intersects(DoubleRectangle nother)
Returns true if the given rectangle intersects this one.


covers

public boolean covers(DoubleRectangle nother)
Returns true if this rectangle covers the given one.


union

public DoubleRectangle union(DoubleRectangle nother)
Returns the union of the given rectangle with this. The result is a smallest rectangle that contains both.


stretchToInclude

public void stretchToInclude(Coord2D coord)
Stretches the rectangle to include the given point.


stretchToInclude

public void stretchToInclude(double x,
                             double y)
Stretches the rectangle to include the given point.


intersection

public DoubleRectangle intersection(DoubleRectangle nother)
Returns the intersection of the given rectangle with this (returns null if there is none)


trimmings

public java.util.ArrayList trimmings(DoubleRectangle nother)
Returns a list of rectangles formed when the given rectangle is cropped by this one. It's possible the list could be empty (the given rectangle is contained by this one). Opposite case is when the given rectangle contains this one, in which case you get 4 trimmings. Another case is no intersection, in which case you get a copy of the rectangle given. More usual is two.


clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getWest

public double getWest()
Minimum x coordinate (western edge)


setWest

public void setWest(double newWest)
Minimum x coordinate (western edge)


getSouth

public double getSouth()
Minimum y coordinate (southern edge)


setSouth

public void setSouth(double newSouth)
Minimum y coordinate (southern edge)


getEast

public double getEast()
Maximum x coordinate (east edge)


setEast

public void setEast(double newEast)
Maximum x coordinate (east edge)


getNorth

public double getNorth()
Maximum y coordinate (north edge)


setNorth

public void setNorth(double newNorth)
Maximum y coordinate (north edge)


getArea

public double getArea()
Area (width * height)


getX

public double getX()
Minimum x (same as west)


getY

public double getY()
Minimum y (same as south)


getWidth

public double getWidth()
Width


getHeight

public double getHeight()
Height


getCenter

public Coord3D getCenter()
Returns the center of the given rectangle


isDegenerate

public boolean isDegenerate()
True if rectangle is degenerate (has either no height or no width)