edu.unh.sdb.lattice
Class GBounds

java.lang.Object
  extended by edu.unh.sdb.common.Bounds
      extended by edu.unh.sdb.lattice.GBounds
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
GBoundsIterator

public class GBounds
extends Bounds
implements java.lang.Cloneable

The GBounds class is meant to represent n-d hypercubes in the data space of a lattice.


Field Summary
protected  float[] lower
           
protected  float[] upper
           
 
Constructor Summary
  GBounds(float[] dimensions)
          This constructor takes a single float array that defines the dimensions of a hypercube with lower coordinates at the origin.
  GBounds(GBounds bounds)
          Construct a copy of the argument bounds.
protected GBounds(int dimensionality)
          This constructor just allocates space for the lower and upper arrays.
  GBounds(Point dimensions)
          This constructor takes a single Point that defines the dimensions of a hypercube with lower coordinates at the origin.
  GBounds(Point corner1, Point corner2)
          This constructor takes two corner points (SpaceIDs) that define a hypercube of arbitrary dimensionality.
 
Method Summary
 void boundingVolume(GBounds db)
          Updates this GBounds object to be the bounding volume of this GBounds and the parameter GBounds.
 java.lang.Object clone()
          Return a copy of this GBounds object
 boolean contains(float[] coords)
          Returns true if this Bounds contains the coordinates contained in the integer array.
 boolean contains(GBounds b2)
          Returns true if this Bounds completely contains the argument bounds.
 boolean contains(Point id)
          Returns true if this Bounds contains the argument Point.
 GBounds copy()
          Return a copy of this GBounds object
static GBounds copyAndMoveToOrigin(GBounds bounds)
          Returns a new GBounds of the same shape as the argument bounds, but moved to the origin.
 GBounds copyBounds()
          Return a copy of this GBounds object.
 int dim()
          Return dimensionality of Bounds.
 boolean equals(GBounds b)
          Return true if parameter is equal to this object, false otherwise.
 float getDimension(int axis)
          Return the extent of this GBounds along the specified axis.
 Point getDimensions()
          Return a Point with axis values denoting the size of each corresponding dimension of the GBounds.
 float[] getDimensions(float[] coords)
          Fill the argument array with coordinate values denoting the size of each corresponding dimension of the GBounds.
 Point getLower()
          Return an Point representing the upper bounds.
 float[] getLowerArray(float[] arr)
          Copy the lower bound coordinates into the array argument.
 Point getUpper()
          Return an Point representing the lower bounds.
 float[] getUpperArray(float[] arr)
          Copy the upper bound coordinates into the array argument.
 boolean intersects(GBounds b2)
          Updates this object to be the intersecton of itself with the GBounds argument.
static void main(java.lang.String[] args)
          For debugging.
 void move(float[] distance)
          Translate the GBounds object in space by the coordinates in the integer array argument.
 void move(Point distance)
          Translate the GBounds object in space by the value of the parameter Point.
 void moveTo(float[] location)
          Translate the GBounds object in space so that the lower left corner is moved to the coordinates specified int the integer array argument.
 void moveTo(Point location)
          Translate the GBounds object in space so that the lower left corner is moved to the location specified by the parameter Point.
 void moveToOrigin()
          Translate this GBounds in space so that the lower point is now at the origin.
 void setLower(float[] lower)
          Set the lower bounds to the coordinates represented by the integer array argument.
 void setLower(Point lower)
          Set the lower bounds to the coordinates represented by the Point argument.
 void setUpper(float[] upper)
          Set the upper bounds to the coordinates represented by the integer array argument.
 void setUpper(Point upper)
          Set the upper bounds to the coordinates represented by the Point argument.
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
          Return a String representing the object indented by the argument string.
 float volume()
          Return the total volume of the GBounds as an integer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lower

protected float[] lower

upper

protected float[] upper
Constructor Detail

GBounds

public GBounds(Point corner1,
               Point corner2)
This constructor takes two corner points (SpaceIDs) that define a hypercube of arbitrary dimensionality. Notice that the getLower() and getUpper() methods may or may not return the same Point values given in this constructor.


GBounds

public GBounds(Point dimensions)
This constructor takes a single Point that defines the dimensions of a hypercube with lower coordinates at the origin. This constructor takes the absolute value of all coordinates in the argument.


GBounds

public GBounds(float[] dimensions)
This constructor takes a single float array that defines the dimensions of a hypercube with lower coordinates at the origin. This constructor takes the absolute value of all coordinates in the argument.


GBounds

public GBounds(GBounds bounds)
Construct a copy of the argument bounds.


GBounds

protected GBounds(int dimensionality)
This constructor just allocates space for the lower and upper arrays.

Method Detail

copy

public final GBounds copy()
Return a copy of this GBounds object


copyBounds

public GBounds copyBounds()
Return a copy of this GBounds object. Here, this method is the same as copy, but child classes use this method to allow the copying of just the bounds information.


clone

public java.lang.Object clone()
Return a copy of this GBounds object

Specified by:
clone in class Bounds

setLower

public final void setLower(Point lower)
Set the lower bounds to the coordinates represented by the Point argument.


setUpper

public final void setUpper(Point upper)
Set the upper bounds to the coordinates represented by the Point argument.


setLower

public final void setLower(float[] lower)
Set the lower bounds to the coordinates represented by the integer array argument.


setUpper

public final void setUpper(float[] upper)
Set the upper bounds to the coordinates represented by the integer array argument.


getLower

public final Point getLower()
Return an Point representing the upper bounds.


getUpper

public final Point getUpper()
Return an Point representing the lower bounds.


getLowerArray

public final float[] getLowerArray(float[] arr)
Copy the lower bound coordinates into the array argument. A reference to the argument is returned.


getUpperArray

public final float[] getUpperArray(float[] arr)
Copy the upper bound coordinates into the array argument. A reference to the argument is returned.


dim

public final int dim()
Return dimensionality of Bounds.

Specified by:
dim in class Bounds

equals

public boolean equals(GBounds b)
Return true if parameter is equal to this object, false otherwise.


volume

public final float volume()
Return the total volume of the GBounds as an integer. "Volume" is defined to be the total number of elements within the dataspace enclosed by the GBounds.


getDimensions

public final Point getDimensions()
Return a Point with axis values denoting the size of each corresponding dimension of the GBounds.


getDimensions

public final float[] getDimensions(float[] coords)
Fill the argument array with coordinate values denoting the size of each corresponding dimension of the GBounds. A reference to the argument array is returned as a convenience. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


getDimension

public final float getDimension(int axis)
Return the extent of this GBounds along the specified axis.


move

public final void move(Point distance)
Translate the GBounds object in space by the value of the parameter Point. Each coordinate of the Point is added to the coordinates of the upper and lower bounds of this GBounds. This is a *relative* move.


move

public final void move(float[] distance)
Translate the GBounds object in space by the coordinates in the integer array argument. Each coordinate is added to the coordinates of the upper and lower bounds of this GBounds. This is a *relative* move. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


moveTo

public void moveTo(Point location)
Translate the GBounds object in space so that the lower left corner is moved to the location specified by the parameter Point. This is an *absolute* move. The Point should have the same dimensionality as the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


moveTo

public void moveTo(float[] location)
Translate the GBounds object in space so that the lower left corner is moved to the coordinates specified int the integer array argument. This is an *absolute* move. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will be created.


moveToOrigin

public void moveToOrigin()
Translate this GBounds in space so that the lower point is now at the origin.


copyAndMoveToOrigin

public static GBounds copyAndMoveToOrigin(GBounds bounds)
Returns a new GBounds of the same shape as the argument bounds, but moved to the origin.


boundingVolume

public void boundingVolume(GBounds db)
Updates this GBounds object to be the bounding volume of this GBounds and the parameter GBounds. If the dimensionality of the parameter GBounds does not match the dimensionality of this GBounds, then a DimensionalityException is thrown.


intersects

public boolean intersects(GBounds b2)
Updates this object to be the intersecton of itself with the GBounds argument. If the intersection exists the method returns true, and false otherwise. This object is unchanged.


contains

public boolean contains(GBounds b2)
Returns true if this Bounds completely contains the argument bounds.


contains

public boolean contains(Point id)
Returns true if this Bounds contains the argument Point.


contains

public boolean contains(float[] coords)
Returns true if this Bounds contains the coordinates contained in the integer array. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


toString

public java.lang.String toString()
Return a String representing the object.

Specified by:
toString in class Bounds

toString

public java.lang.String toString(java.lang.String indent)
Return a String representing the object indented by the argument string.


main

public static void main(java.lang.String[] args)
For debugging. Runs basic tests on the GBounds class.