com.tensegrity.graphics
Class BoundingBox

java.lang.Object
  extended bycom.tensegrity.graphics.BoundingBox

public class BoundingBox
extends java.lang.Object

The BoundingBox class keeps all datas and methods needed to implement a bounding box functionality.

At the actual state of development the BoundingBox class is restricted to 2d space but it will be enhanced so that it can also be used with 3d space. With this enhancement the documentation will be updated too.

Version:
$Id: BoundingBox.java,v 1.29 2006/03/21 14:23:33 MichaelKegel Exp $
Author:
MichaelKegel

Field Summary
 int[] coordsX
          An Array holding the X-axis (left, right) coordinates of this BoundingBox instance.
 int[] coordsY
          An Array holding the Y-axis (top, bottom) coordinates of this BoundingBox instance.
static int LEFT_TOP
          Constant speciying the left coordinate of array coordsX or the top coordinate of array coordsX.
static int RIGHT_BOTTOM
          Constant speciying the right coordinate of array coordsX or the bottom coordinate of array coordsX.
static int X1
          Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY
static int X2
          Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY
static int Y1
          Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY
static int Y2
          Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY
 
Constructor Summary
BoundingBox()
          Constructor for BoundingBox.
BoundingBox(Boundary boundary)
          Constructor specifying the boundaries.
BoundingBox(BoundingBox bBox)
          Deepcopy constructor speifying the BoundingBox to be copied.
BoundingBox(Coordinate c1, Coordinate c2)
          Constructor specifying the coordinates to be used.
BoundingBox(int left, int top, int right, int bottom)
          Constructor specifying the corner points of this BoundingBox.
 
Method Summary
 boolean contains(BoundingBox bBox)
          Returns a boolean that indicates whether the given BoundingBox lies within this BoundingBox or not.
 boolean contains(int x, int y)
          TODO : comment
 boolean contains(int x1, int y1, int x2, int y2)
          Returns a boolean that indicates whether the bounding box given by x1, y1, x2 and y2 lies completely within this BoundingBox or not.
 boolean contains(java.awt.Point pt)
          Returns a boolean that indicates whether the Point given by pt lies within this BoundingBox or not.
static BoundingBox createMaxMinBBox()
           
static BoundingBox createMinMaxBBox()
           
 boolean equalHeight(BoundingBox bBox)
          Returns a boolean that indicates whether the height of the given BoundingBox is equal to the height of this BoundingBox.
 boolean equals(java.lang.Object o)
           
 boolean equalSize(BoundingBox bBox)
          Returns a boolean that indicates whether the width and the height of the given BoundingBox are equal to the width and the height of this BoundingBox.
 boolean equalWidth(BoundingBox bBox)
          Returns a boolean that indicates whether the width of the given BoundingBox is equal to the width of this BoundingBox.
 java.awt.Point getCenter()
          Returns the center coordinate of the BoundingBox instance as a Point.
 double getCenterDX()
          Returns the current center in x direction of the BoundingBox instance as a double.
 double getCenterDY()
          Returns the current center in y direction of the BoundingBox instance as a double.
 int getCenterX()
          Returns the current center in x direction of the BoundingBox instance as an int.
 int getCenterY()
          Returns the current center in y direction of the BoundingBox instance as an int.
 int getHeight()
          TODO : comment
 Coordinate getLocation()
          TODO : comment
 Size getSize()
          TODO : comment
 int getWidth()
          TODO : comment
 int hashCode()
           
 boolean intersect(BoundingBox bbox)
          Returns a boolean that indicates whether this BoundingBox intersects the BoundingBox given by bbox or not.
 boolean intersect(java.awt.Insets insets)
          Returns a boolean that indicates whether the BoundingBox intersects the Insets given by insets or not.
 BoundingBox intersection_createnew(int left, int top, int right, int bottom)
           
 void intersection(java.awt.Insets insets)
          Creates the intersaction of the Insets instance given by insets and the BoundingBox instance.
 void intersection(int left, int top, int right, int bottom)
           
 boolean isEmpty()
          Returns a boolean that indicates whether the BoundingBox is empty or not.
static boolean isMaxMinBBox(BoundingBox bbox)
           
static boolean isMinMaxBBox(BoundingBox bbox)
           
 void movePosition(int deltaX, int deltaY)
          TODO : comment
 void normalize()
          TODO : comment
 void set(Boundary boundary)
          TODO : comment
 void set(BoundingBox bBox)
          TODO : comment
 void set(Coordinate c1, Coordinate c2)
          TODO : comment
 void setHeight(int height)
          TODO : comment
 void setLeft(int left)
          TODO : comment
 void setLocation(Coordinate coordinate)
          TODO : comment
 void setPosition(int left, int top)
          TODO : comment
 void setSize(Size size)
          TODO : comment
 void setTop(int top)
          TODO : comment
 void setWidth(int width)
          TODO : comment
 Boundary toBoundary()
          TODO : comment
static Boundary toBoundary(BoundingBox box)
          TODO : comment
 java.lang.String toString()
          TODO : comment
 BoundingBox union_createnew(int left, int top, int right, int bottom)
           
 void union(java.awt.Insets insets)
          Creates the union of the Insets instance given by insets and the BoundingBox instance.
 void union(int left, int top, int right, int bottom)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X1

public static final int X1
Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY

See Also:
Constant Field Values

Y1

public static final int Y1
Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY

See Also:
Constant Field Values

X2

public static final int X2
Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY

See Also:
Constant Field Values

Y2

public static final int Y2
Constant specifying a coordinate component in either the coordinate component array coordsX or in the coordinate component array coordsY

See Also:
Constant Field Values

LEFT_TOP

public static final int LEFT_TOP
Constant speciying the left coordinate of array coordsX or the top coordinate of array coordsX.

See Also:
Constant Field Values

RIGHT_BOTTOM

public static final int RIGHT_BOTTOM
Constant speciying the right coordinate of array coordsX or the bottom coordinate of array coordsX.

See Also:
Constant Field Values

coordsX

public int[] coordsX
An Array holding the X-axis (left, right) coordinates of this BoundingBox instance.


coordsY

public int[] coordsY
An Array holding the Y-axis (top, bottom) coordinates of this BoundingBox instance.

Constructor Detail

BoundingBox

public BoundingBox()
Constructor for BoundingBox.


BoundingBox

public BoundingBox(Coordinate c1,
                   Coordinate c2)
Constructor specifying the coordinates to be used.

Parameters:
c1 - the first Coordinate.
c2 - the second Coordinate.

BoundingBox

public BoundingBox(int left,
                   int top,
                   int right,
                   int bottom)
Constructor specifying the corner points of this BoundingBox.

Parameters:
left - the upper left x-coordinate.
top - the left top y-coordinate.
right - the bottom right x-coordinate.
bottom - the right bottom y-coordinate.

BoundingBox

public BoundingBox(BoundingBox bBox)
Deepcopy constructor speifying the BoundingBox to be copied.

Parameters:
bBox - the BoundingBox to be copied.

BoundingBox

public BoundingBox(Boundary boundary)
Constructor specifying the boundaries.

Parameters:
boundary - the Boundary to be set.
Method Detail

setLeft

public void setLeft(int left)
TODO : comment

Parameters:
left -

setTop

public void setTop(int top)
TODO : comment

Parameters:
top -

setPosition

public void setPosition(int left,
                        int top)
TODO : comment


movePosition

public void movePosition(int deltaX,
                         int deltaY)
TODO : comment


getLocation

public Coordinate getLocation()
TODO : comment


setLocation

public void setLocation(Coordinate coordinate)
TODO : comment


set

public void set(Coordinate c1,
                Coordinate c2)
TODO : comment


set

public void set(BoundingBox bBox)
TODO : comment


set

public void set(Boundary boundary)
TODO : comment


getWidth

public int getWidth()
TODO : comment


setWidth

public void setWidth(int width)
TODO : comment


getHeight

public int getHeight()
TODO : comment


setHeight

public void setHeight(int height)
TODO : comment


getSize

public Size getSize()
TODO : comment


setSize

public void setSize(Size size)
TODO : comment


contains

public boolean contains(int x,
                        int y)
TODO : comment


contains

public boolean contains(java.awt.Point pt)
Returns a boolean that indicates whether the Point given by pt lies within this BoundingBox or not.

Parameters:
pt - the point to check.
Returns:
boolean flag that indicates whether the given coordinate is contained by the BoundingBox.

contains

public boolean contains(BoundingBox bBox)
Returns a boolean that indicates whether the given BoundingBox lies within this BoundingBox or not.

Parameters:
bBox - the BoundingBox to check.
Returns:
boolean flag that indicates whether the given BoundingBox is contained by this Boundary.

contains

public boolean contains(int x1,
                        int y1,
                        int x2,
                        int y2)
Returns a boolean that indicates whether the bounding box given by x1, y1, x2 and y2 lies completely within this BoundingBox or not.

Returns:
boolean flag that indicates whether the given Boundary is contained by this Boundary or not

equalWidth

public boolean equalWidth(BoundingBox bBox)
Returns a boolean that indicates whether the width of the given BoundingBox is equal to the width of this BoundingBox.

Parameters:
bBox - the BoundingBox to check; may not be null.
Returns:
boolean flag that indicates whether the given BoundingBox has the same width as this Boundary.

equalHeight

public boolean equalHeight(BoundingBox bBox)
Returns a boolean that indicates whether the height of the given BoundingBox is equal to the height of this BoundingBox.

Parameters:
bBox - the BoundingBox to check; may not be null.
Returns:
boolean flag that indicates whether the given BoundingBox has the same height as this BoundingBox.

equalSize

public boolean equalSize(BoundingBox bBox)
Returns a boolean that indicates whether the width and the height of the given BoundingBox are equal to the width and the height of this BoundingBox.

Parameters:
bBox - the BoundingBox to check; may not be null.
Returns:
boolean flag that indicates whether the given BoundingBox has the same width and height as this BoundingBox.

getCenterX

public int getCenterX()
Returns the current center in x direction of the BoundingBox instance as an int.

Returns:
int the center of the BoundingBox in x direction.

getCenterY

public int getCenterY()
Returns the current center in y direction of the BoundingBox instance as an int.

Returns:
int the center of the BoundingBox in y direction.

getCenterDX

public double getCenterDX()
Returns the current center in x direction of the BoundingBox instance as a double.

Returns:
double the center of the BoundingBox in x direction.

getCenterDY

public double getCenterDY()
Returns the current center in y direction of the BoundingBox instance as a double.

Returns:
double the center of the BoundingBox in x direction.

getCenter

public java.awt.Point getCenter()
Returns the center coordinate of the BoundingBox instance as a Point.

Returns:
Point the center coordinate of the BoundingBox.

union

public void union(int left,
                  int top,
                  int right,
                  int bottom)

union_createnew

public BoundingBox union_createnew(int left,
                                   int top,
                                   int right,
                                   int bottom)

union

public void union(java.awt.Insets insets)
Creates the union of the Insets instance given by insets and the BoundingBox instance. The union means that the origin coordinate and the ending coordinate are adjusted to the smallest rectangle that encapsulates the rectangle of the BoundingBox instance and the given Insets instance.

Parameters:
insets - the Insets instance to create a union with.

intersection

public void intersection(int left,
                         int top,
                         int right,
                         int bottom)

intersection_createnew

public BoundingBox intersection_createnew(int left,
                                          int top,
                                          int right,
                                          int bottom)

intersection

public void intersection(java.awt.Insets insets)
Creates the intersaction of the Insets instance given by insets and the BoundingBox instance. The intersection is the smalles rectangle that is encapsulated by the BoundingBox instance and the given Insets instance. Notice that the intersection rectangle can be empty.

Parameters:
insets - the Insets instance to create an intersection with.

isEmpty

public boolean isEmpty()
Returns a boolean that indicates whether the BoundingBox is empty or not. Empty means, that the BoundingBox has a width of zero or a height of zero.

Returns:
boolean flag that indicates whether the BoundingBox is empty.

intersect

public boolean intersect(java.awt.Insets insets)
Returns a boolean that indicates whether the BoundingBox intersects the Insets given by insets or not.

Parameters:
insets - the Insets to check for intersection.
Returns:
boolean flag that indicates whether the given Insets intersects the BoundingBox.

intersect

public boolean intersect(BoundingBox bbox)
Returns a boolean that indicates whether this BoundingBox intersects the BoundingBox given by bbox or not.

Parameters:
bbox - the BoundingBox to check for intersection.
Returns:
boolean flag that indicates whether the given BoundingBox intersects this BoundingBox.

normalize

public void normalize()
TODO : comment


toBoundary

public Boundary toBoundary()
TODO : comment


toString

public java.lang.String toString()
TODO : comment


toBoundary

public static Boundary toBoundary(BoundingBox box)
TODO : comment


hashCode

public int hashCode()
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object o)
See Also:
Object.equals(java.lang.Object)

createMaxMinBBox

public static final BoundingBox createMaxMinBBox()

isMaxMinBBox

public static final boolean isMaxMinBBox(BoundingBox bbox)

createMinMaxBBox

public static final BoundingBox createMinMaxBBox()

isMinMaxBBox

public static final boolean isMinMaxBBox(BoundingBox bbox)


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.