JHotDraw 6.0b1

org.jhotdraw.util
Class Bounds

java.lang.Object
  extended by org.jhotdraw.util.Bounds
All Implemented Interfaces:
java.io.Serializable

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

This class is a rectangle with floating point dimensions and location. This class provides many convenient geometrical methods related to rectangles. Basically, this class is like java.awt.geom.Rectangle2D with some extra functionality.

See Also:
Serialized Form

Field Summary
protected  double _dX1
           
protected  double _dX2
           
protected  double _dY1
           
protected  double _dY2
           
 
Constructor Summary
protected Bounds()
           
  Bounds(Bounds aBounds)
           
  Bounds(java.awt.Dimension aDimension)
           
  Bounds(double x, double y)
           
  Bounds(double x1, double y1, double x2, double y2)
           
  Bounds(java.awt.geom.Point2D aPoint2D)
           
  Bounds(java.awt.geom.Point2D centerPoint2D, double dWidth, double dHeight)
           
  Bounds(java.awt.geom.Point2D firstPoint2D, java.awt.geom.Point2D secondPoint2D)
           
  Bounds(java.awt.geom.Rectangle2D aRectangle2D)
           
 
Method Summary
 java.awt.geom.Rectangle2D asRectangle2D()
           
 boolean completelyContainsLine(double x1, double y1, double x2, double y2)
           
 java.awt.geom.Point2D[] cropLine(double x1, double y1, double x2, double y2)
           
 boolean equals(java.lang.Object anObject)
           
 void expandToRatio(double dRatio)
          This will cause the bounds to grow until the given ratio is satisfied.
 java.awt.geom.Point2D getCenter()
           
 double getEast()
           
 double getGreaterX()
           
 double getGreaterY()
           
 double getHeight()
           
 double getLesserX()
           
 double getLesserY()
           
 double getNorth()
           
 double getSouth()
           
 double getWest()
           
 double getWidth()
           
 int hashCode()
           
 void includeBounds(Bounds aBounds)
           
 void includeLine(double x1, double y1, double x2, double y2)
           
 void includeLine(java.awt.geom.Point2D onePoint2D, java.awt.geom.Point2D twoPoint2D)
           
 void includePoint(double x, double y)
           
 void includePoint(java.awt.geom.Point2D aPoint2D)
           
 void includeRectangle2D(java.awt.geom.Rectangle2D aRectangle2D)
           
 void includeXCoordinate(double x)
           
 void includeYCoordinate(double y)
           
 void intersect(Bounds aBounds)
           
 boolean intersectsBounds(Bounds aBounds)
           
 boolean intersectsLine(double x1, double y1, double x2, double y2)
           
 boolean intersectsLine(java.awt.geom.Point2D onePoint2D, java.awt.geom.Point2D twoPoint2D)
           
 boolean intersectsPoint(double x, double y)
           
 boolean intersectsPoint(java.awt.geom.Point2D aPoint2D)
           
 boolean isCompletelyInside(Bounds aBounds)
           
 void offset(double dDeltaX, double dDeltaY)
           
 void setCenter(java.awt.geom.Point2D centerPoint2D)
           
 void shiftBy(int nXPercentage, int nYPercentage)
           
 java.lang.String toString()
           
 void zoomBy(double dRatio)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_dX1

protected double _dX1

_dY1

protected double _dY1

_dX2

protected double _dX2

_dY2

protected double _dY2
Constructor Detail

Bounds

public Bounds(double x,
              double y)

Bounds

public Bounds(double x1,
              double y1,
              double x2,
              double y2)

Bounds

public Bounds(java.awt.geom.Point2D aPoint2D)

Bounds

public Bounds(java.awt.geom.Point2D firstPoint2D,
              java.awt.geom.Point2D secondPoint2D)

Bounds

public Bounds(Bounds aBounds)

Bounds

public Bounds(java.awt.geom.Rectangle2D aRectangle2D)

Bounds

public Bounds(java.awt.geom.Point2D centerPoint2D,
              double dWidth,
              double dHeight)

Bounds

public Bounds(java.awt.Dimension aDimension)

Bounds

protected Bounds()
Method Detail

getLesserX

public double getLesserX()

getGreaterX

public double getGreaterX()

getLesserY

public double getLesserY()

getGreaterY

public double getGreaterY()

getWest

public double getWest()

getEast

public double getEast()

getSouth

public double getSouth()

getNorth

public double getNorth()

getWidth

public double getWidth()

getHeight

public double getHeight()

asRectangle2D

public java.awt.geom.Rectangle2D asRectangle2D()

setCenter

public void setCenter(java.awt.geom.Point2D centerPoint2D)

getCenter

public java.awt.geom.Point2D getCenter()

zoomBy

public void zoomBy(double dRatio)

shiftBy

public void shiftBy(int nXPercentage,
                    int nYPercentage)

offset

public void offset(double dDeltaX,
                   double dDeltaY)

expandToRatio

public void expandToRatio(double dRatio)
This will cause the bounds to grow until the given ratio is satisfied. The Ration is calculated by getWidth() / getHeight()


includeXCoordinate

public void includeXCoordinate(double x)

includeYCoordinate

public void includeYCoordinate(double y)

includePoint

public void includePoint(double x,
                         double y)

includePoint

public void includePoint(java.awt.geom.Point2D aPoint2D)

includeLine

public void includeLine(double x1,
                        double y1,
                        double x2,
                        double y2)

includeLine

public void includeLine(java.awt.geom.Point2D onePoint2D,
                        java.awt.geom.Point2D twoPoint2D)

includeBounds

public void includeBounds(Bounds aBounds)

includeRectangle2D

public void includeRectangle2D(java.awt.geom.Rectangle2D aRectangle2D)

intersect

public void intersect(Bounds aBounds)

intersectsPoint

public boolean intersectsPoint(double x,
                               double y)

intersectsPoint

public boolean intersectsPoint(java.awt.geom.Point2D aPoint2D)

intersectsLine

public boolean intersectsLine(double x1,
                              double y1,
                              double x2,
                              double y2)

intersectsLine

public boolean intersectsLine(java.awt.geom.Point2D onePoint2D,
                              java.awt.geom.Point2D twoPoint2D)

intersectsBounds

public boolean intersectsBounds(Bounds aBounds)

completelyContainsLine

public boolean completelyContainsLine(double x1,
                                      double y1,
                                      double x2,
                                      double y2)

isCompletelyInside

public boolean isCompletelyInside(Bounds aBounds)

cropLine

public java.awt.geom.Point2D[] cropLine(double x1,
                                        double y1,
                                        double x2,
                                        double y2)

equals

public boolean equals(java.lang.Object anObject)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

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

JHotDraw 6.0b1