com.tensegrity.graphics
Class Boundary

java.lang.Object
  extended byjava.awt.Insets
      extended bycom.tensegrity.graphics.Boundary
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Boundary
extends java.awt.Insets

The Boundary class extends the functionalities of class Insets by providing additional functionalities.

However by extending the Insets the Boundary class is restricted to the 2d space.

Version:
$Id: Boundary.java,v 1.29 2006/03/14 14:18:17 MichaelKegel Exp $
Author:
MichaelKegel,
See Also:
Serialized Form

Field Summary
static Boundary DEFAULT_MAX_MIN_BOUNDARY
          constant that defines a Boundary that is initialized to have the upper / left corner in x and y direction at Integer.MAX_VALUE and the lower / right cornder in x and y direction at Integer.MIN_VALUE what makes it an empty Boundary.
static Boundary DEFAULT_MIN_MAX_BOUNDARY
          constant that defines a Boundary that is initialized to have the upper / left corner in x and y direction at Integer.MIN_VALUE and the lower / right cornder in x and y direction at Integer.MAX_VALUE what makes it to the greates Boundary that can be created.
static int INDEX_BOTTOM
          constant that tells about an index in the array of normalized values
static int INDEX_LEFT
          constant that tells about an index in the array of normalized values
static int INDEX_RIGHT
          constant that tells about an index in the array of normalized values
static int INDEX_TOP
          constant that tells about an index in the array of normalized values
 
Fields inherited from class java.awt.Insets
bottom, left, right, top
 
Constructor Summary
Boundary()
          Default constructor that initializes an instance of the Boundary such that it lies at the origin coordinate and is empty.
Boundary(java.awt.Insets insets)
          Constructor with a Insets instance given by insets that initializes an instance of the Boundary class such that it has the same origin coordinate and the same end coordinate as the Insets instance.
Boundary(int left, int top, int right, int bottom)
          Constructor with a coordinate for the origin given by left, top and a coordinate for the end given by right, bottom of the Boundary instance.
 
Method Summary
 boolean contains(Boundary boundary)
          Returns a boolean that indicates whether the Boundary given by boundary lies completely within the Boundary or not.
 boolean contains(int x, int y)
          Returns a boolean that indicates whether the coordinate given by x and y lies within the Boundary or not.
 boolean contains(java.awt.Point pt)
          Returns a boolean that indicates whether the Point given by pt lies within the Boundary or not.
 void deflate(int cxy)
          Deflates the Boundary by the value given by cxy in x direction and in y direction.
 void deflate(int cx, int cy)
          Deflates the Boundary by the value given by cx in x direction and by the value given by cy in y direction.
 void deflate(int cx1, int cy1, int cx2, int cy2)
          Deflates the Boundarys left side by the value given by cx1, the top side by the value given by cy1, the right side by the value given by cx2 and the bottom side by the value given by cy2.
 boolean equalHeight(Boundary boundary)
          Returns a boolean that indicates whether the height of the Boundary given by boundary is equal to the height of this Boundary.
 boolean equalSize(Boundary boundary)
          Returns a boolean that indicates whether the width and the height of the Boundary given by boundary are equal to the width and the height of this Boundary.
 boolean equalWidth(Boundary boundary)
          Returns a boolean that indicates whether the width of the Boundary given by boundary is equal to the width of this Boundary.
 Coordinate getCenter()
          Returns the center coordinate of the Boundary instance as a Coordinate.
 double getCenterDX()
          Returns the current center in x direction of the Boundary instance as a double.
 double getCenterDY()
          Returns the current center in y direction of the Boundary instance as a double.
 int getCenterX()
          Returns the current center in x direction of the Boundary instance as an int.
 int getCenterY()
          Returns the current center in y direction of the Boundary instance as an int.
 int getHeight()
          Returns the current height of the Boundary instance.
 int[] getNormalizedValues()
          Returns an int array with the normalized values for the left, top, right and the bottom side of the Boundary.
 int getWidth()
          Returns the current width of the Boundary instance.
 void inflate(int cxy)
          Inflates the Boundary by the value given by cxy in x direction and in y direction.
 void inflate(int cx, int cy)
          Inflates the Boundary by the value given by cx in x direction and by the value given by cy in y direction.
 void inflate(int cx1, int cy1, int cx2, int cy2)
          Inflates the Boundarys left side by the value given by cx1, the top side by the value given by cy1, the right side by the value given by cx2 and the bottom side by the value given by cy2.
 boolean intersect(java.awt.Insets insets)
          Returns a boolean that indicates whether the Boundary intersects the Insets given by insets or not.
 void intersection(java.awt.Insets insets)
          Creates the intersection of the Insets instance given by insets and the Boundary instance.
 boolean isEmpty()
          Returns a boolean that indicates whether the Boundary is empty or not.
 void normalize()
          Normalizes the Boundary.
 void offset(int cx, int cy)
          Adds the value given by cx to the left side and the right side and the value given by cy to the top and the bottom side of the Boundary.
 void set(java.awt.Insets insets)
          Sets the origin coordinate and the ending coordinate of the Boundary instance to the values of the Insets instance given by insets.
 void set(int left, int top, int right, int bottom)
          Sets the coordinate for the origin of the Boundary instance to the values given by left, top and the coordinate for the ending coordinate to the valus given by right, bottom.
 void setHeight(int height)
          Sets the height of the Boundary instance to the value given by height.
 void setWidth(int width)
          Sets the width of the Boundary instance to the value given by width.
 java.lang.String toString()
          Returns a String that represent the Boundary and all of the attributes of it.
 void union(Boundary boundary)
          Creates the union of the Boundary instance given by boundary and the Boundary instance.
 void union(java.awt.Insets insets)
          Creates the union of the Insets instance given by insets and the Boundary instance.
 
Methods inherited from class java.awt.Insets
clone, equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_MIN_BOUNDARY

public static final Boundary DEFAULT_MAX_MIN_BOUNDARY
constant that defines a Boundary that is initialized to have the upper / left corner in x and y direction at Integer.MAX_VALUE and the lower / right cornder in x and y direction at Integer.MIN_VALUE what makes it an empty Boundary.
This initialization is useful when gather the maximum Boundary over a set of Boundarys.
NOTICE:The instance variables of this Boundary must never be changed. Allways create a new instance of a Boundary.


DEFAULT_MIN_MAX_BOUNDARY

public static final Boundary DEFAULT_MIN_MAX_BOUNDARY
constant that defines a Boundary that is initialized to have the upper / left corner in x and y direction at Integer.MIN_VALUE and the lower / right cornder in x and y direction at Integer.MAX_VALUE what makes it to the greates Boundary that can be created.
This initialization is useful when gather the minimum Boundary over a set of Boundarys.
NOTICE:The instance variables of this Boundary must never be changed. Allways create a new instance of a Boundary.


INDEX_LEFT

public static final int INDEX_LEFT
constant that tells about an index in the array of normalized values

See Also:
Constant Field Values

INDEX_TOP

public static final int INDEX_TOP
constant that tells about an index in the array of normalized values

See Also:
Constant Field Values

INDEX_RIGHT

public static final int INDEX_RIGHT
constant that tells about an index in the array of normalized values

See Also:
Constant Field Values

INDEX_BOTTOM

public static final int INDEX_BOTTOM
constant that tells about an index in the array of normalized values

See Also:
Constant Field Values
Constructor Detail

Boundary

public Boundary()
Default constructor that initializes an instance of the Boundary such that it lies at the origin coordinate and is empty. Empty means in this case that the boundary has no width and no height.


Boundary

public Boundary(int left,
                int top,
                int right,
                int bottom)
Constructor with a coordinate for the origin given by left, top and a coordinate for the end given by right, bottom of the Boundary instance.

Parameters:
left - the new starting x component
top - the new starting y component
right - the new ending x component
bottom - the new ending y component

Boundary

public Boundary(java.awt.Insets insets)
Constructor with a Insets instance given by insets that initializes an instance of the Boundary class such that it has the same origin coordinate and the same end coordinate as the Insets instance.

Parameters:
insets - the Insets instance to take the values from, may not be null.
Method Detail

getWidth

public int getWidth()
Returns the current width of the Boundary instance.

Returns:
int the width of the Boundary

setWidth

public void setWidth(int width)
Sets the width of the Boundary instance to the value given by width.

Parameters:
width - the value to set the width of the Boundary instance to

getHeight

public int getHeight()
Returns the current height of the Boundary instance.

Returns:
int the height of the Boundary

setHeight

public void setHeight(int height)
Sets the height of the Boundary instance to the value given by height.

Parameters:
height - the value to set the height of the Boundary instance to

getCenterX

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

Returns:
int the center of the Boundary in x direction

getCenterY

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

Returns:
int the center of the Boundary in y direction

getCenterDX

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

Returns:
double the center of the Boundary in x direction

getCenterDY

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

Returns:
double the center of the Boundary in x direction

getCenter

public Coordinate getCenter()
Returns the center coordinate of the Boundary instance as a Coordinate.

Returns:
Coordinate the center coordinate of the Boundary

set

public void set(int left,
                int top,
                int right,
                int bottom)
Sets the coordinate for the origin of the Boundary instance to the values given by left, top and the coordinate for the ending coordinate to the valus given by right, bottom.

Parameters:
left - the new starting x component
top - the new starting y component
right - the new ending x component
bottom - the new ending y component

set

public void set(java.awt.Insets insets)
Sets the origin coordinate and the ending coordinate of the Boundary instance to the values of the Insets instance given by insets.

Parameters:
insets - the Insets instance to take the values from

union

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

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

union

public void union(Boundary boundary)
Creates the union of the Boundary instance given by boundary and the Boundary instance. The union means that the origin coordinate and the ending coordinate are adjusted to the smalles rectangle that encapsulates the rectangle of the Boundary instance and the given Boundary instance.

Parameters:
boundary - the Boundary instance to create the union with

intersection

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

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

isEmpty

public boolean isEmpty()
Returns a boolean that indicates whether the Boundary is empty or not. Empty means in this case that the Boundary has a width of zero or a height of zero.

Returns:
boolean flag that indicates whether the Boundary is empty or not

intersect

public boolean intersect(java.awt.Insets insets)
Returns a boolean that indicates whether the Boundary 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 Boundary

inflate

public void inflate(int cxy)
Inflates the Boundary by the value given by cxy in x direction and in y direction.

Parameters:
cxy - the value to inflate all the sides of the Boundary by

inflate

public void inflate(int cx,
                    int cy)
Inflates the Boundary by the value given by cx in x direction and by the value given by cy in y direction.

Parameters:
cx - the value to inflate the Boundary by in x direction
cy - the value to inflate the Boundary by in y direction

inflate

public void inflate(int cx1,
                    int cy1,
                    int cx2,
                    int cy2)
Inflates the Boundarys left side by the value given by cx1, the top side by the value given by cy1, the right side by the value given by cx2 and the bottom side by the value given by cy2.

Parameters:
cx1 - the value to inflate the Boundary by at the left side
cy1 - the value to inflate the Boundary by at the top side
cx2 - the value to inflate the Boundary by at the right side
cy2 - the value to inflate the Boundary by at the bottom side

deflate

public void deflate(int cxy)
Deflates the Boundary by the value given by cxy in x direction and in y direction.

Parameters:
cxy - the value to deflate all the sides of the Boundary by

deflate

public void deflate(int cx,
                    int cy)
Deflates the Boundary by the value given by cx in x direction and by the value given by cy in y direction.

Parameters:
cx - the value to deflate the Boundary by in x direction
cy - the value to deflate the Boundary by in y direction

deflate

public void deflate(int cx1,
                    int cy1,
                    int cx2,
                    int cy2)
Deflates the Boundarys left side by the value given by cx1, the top side by the value given by cy1, the right side by the value given by cx2 and the bottom side by the value given by cy2.

Parameters:
cx1 - the value to deflate the Boundary by at the left side
cy1 - the value to deflate the Boundary by at the top side
cx2 - the value to deflate the Boundary by at the right side
cy2 - the value to deflate the Boundary by at the bottom side

offset

public void offset(int cx,
                   int cy)
Adds the value given by cx to the left side and the right side and the value given by cy to the top and the bottom side of the Boundary.

Parameters:
cx - the value to add to the left and the right side of the Boundary
cy - the valie to add to the top and the bottom side of the Boundary

getNormalizedValues

public int[] getNormalizedValues()
Returns an int array with the normalized values for the left, top, right and the bottom side of the Boundary. Normalized means in this case that the values for the left(top) and the right(bottom) side of the Boundary are swapped if the value for the left is greater than the value for right side.
The indices of the value for the left, top, right and bottom side are defined by constant that are defined in this class.

Returns:
int[] the array with the normalized values for the left, top, right and the bottom side

normalize

public void normalize()
Normalizes the Boundary. Normalizing means in this case that the values for the left(top) and the right(bottom) side of the Boundary are swapped if the value for the left is greater than the value for right side.


contains

public boolean contains(int x,
                        int y)
Returns a boolean that indicates whether the coordinate given by x and y lies within the Boundary or not.

Parameters:
x - the x component of the coordinate to check for
y - the y component of the coordinate to check for
Returns:
boolean flag that indicates whether the given coordinate is contained by the Boundary or not

contains

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

Parameters:
pt - the point to check for
Returns:
boolean flag that indicates whether the given coordinate is contained by the Boundary or not

contains

public boolean contains(Boundary boundary)
Returns a boolean that indicates whether the Boundary given by boundary lies completely within the Boundary or not.

Parameters:
boundary - the Boundary to check for
Returns:
boolean flag that indicates whether the given Boundary is contained by this Boundary or not

equalWidth

public boolean equalWidth(Boundary boundary)
Returns a boolean that indicates whether the width of the Boundary given by boundary is equal to the width of this Boundary.

Parameters:
boundary - the Boundary to check for
Returns:
boolean flag that indicates whether the given Boundary has the same width as this Boundary or not

equalHeight

public boolean equalHeight(Boundary boundary)
Returns a boolean that indicates whether the height of the Boundary given by boundary is equal to the height of this Boundary.

Parameters:
boundary - the Boundary to check for
Returns:
boolean flag that indicates whether the given Boundary has the same height as this Boundary or not

equalSize

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

Parameters:
boundary - the Boundary to check for
Returns:
boolean flag that indicates whether the given Boundary has the same width and height as this Boundary or not

toString

public java.lang.String toString()
Returns a String that represent the Boundary and all of the attributes of it. For instance this representation can be used for tracing purposes and such.

Returns:
String the textual representation of the Boundary


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