jwo.landserf.structure
Class Footprint

java.lang.Object
  extended by jwo.landserf.structure.Footprint
All Implemented Interfaces:
Serializable

public class Footprint
extends Object
implements Serializable

Class for defining the spatial footprint of an object. Using this class to wrap all public communication of locations and boundaries ensures maximum flexibility. Current model assumes 2d Cartesian referencing, but can be adapted in future.

Version:
2.3, 13th March, 2004.
Author:
Jo Wood
See Also:
Serialized Form

Constructor Summary
Footprint(float x, float y)
          Creates a point footprint with given x,y location.
Footprint(float x, float y, float width, float height)
          Creates a 2d areal footprint with given origin, width and height.
Footprint(Footprint oldFootprint)
          Creates a footprint based on a copy of the given one.
 
Method Summary
 boolean equals(Object obj)
          Reports whether this object is equal to the given one.
 float getMERHeight()
          Reports the height of the footprint's Minimum Enclosing Rectangle.
 float getMERWidth()
          Reports the width of the footprint's Minimum Enclosing Rectangle.
 int getType()
          Reports the type of spatial footprint.
 float getXOrigin()
          Reports the x origin of the footprint.
 float getYOrigin()
          Reports the y origin of the footprint.
 int hashCode()
          Reports the hashcode associated with this object.
 void setMERHeight(float height)
          Sets the height of the footprint's Minimum Enclosing Rectangle.
 void setMERWidth(float width)
          Sets the width of the footprint's Minimum Enclosing Rectangle.
 void setType(int type)
          Sets the type of spatial footprint.
 void setXOrigin(float xOrigin)
          Sets the x origin of the footprint.
 void setYOrigin(float yOrigin)
          Sets the y origin of the footprint.
 String toString()
          Reports the details of this footprint.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Footprint

public Footprint(float x,
                 float y)
Creates a point footprint with given x,y location.

Parameters:
x - X coordinate of footprint's location.
y - Y coordinate of footprint's location.

Footprint

public Footprint(float x,
                 float y,
                 float width,
                 float height)
Creates a 2d areal footprint with given origin, width and height.

Parameters:
x - X coordinate of footprint's origin.
y - Y coordinate of footprint's origin.
width - Width of object (in x direction).
height - Height of object (in y direction).

Footprint

public Footprint(Footprint oldFootprint)
Creates a footprint based on a copy of the given one.

Parameters:
oldFootprint - Footprint to copy.
Method Detail

getXOrigin

public float getXOrigin()
Reports the x origin of the footprint.

Returns:
xOrigin Cartesian x coordinate of footprint.

setXOrigin

public void setXOrigin(float xOrigin)
Sets the x origin of the footprint.

Parameters:
xOrigin - New x origin of the footprint.

getYOrigin

public float getYOrigin()
Reports the y origin of the footprint.

Returns:
yOrigin Cartesian y coordinate of footprint.

setYOrigin

public void setYOrigin(float yOrigin)
Sets the y origin of the footprint.

Parameters:
yOrigin - New y origin of the footprint.

getMERWidth

public float getMERWidth()
Reports the width of the footprint's Minimum Enclosing Rectangle.

Returns:
width MER's width (in the x direction).

setMERWidth

public void setMERWidth(float width)
Sets the width of the footprint's Minimum Enclosing Rectangle.

Parameters:
width - New width of the MER (in the x direction).

getMERHeight

public float getMERHeight()
Reports the height of the footprint's Minimum Enclosing Rectangle.

Returns:
height MER's height (in the y direction).

setMERHeight

public void setMERHeight(float height)
Sets the height of the footprint's Minimum Enclosing Rectangle.

Parameters:
height - New height of the MER (in the y direction).

getType

public int getType()
Reports the type of spatial footprint.

Returns:
Type of spatial footprint.

setType

public void setType(int type)
Sets the type of spatial footprint.

Parameters:
type - Type of spatial footprint.

toString

public String toString()
Reports the details of this footprint.

Overrides:
toString in class Object
Returns:
Summary of this footprint.

equals

public boolean equals(Object obj)
Reports whether this object is equal to the given one. This will be true if the other object is also a Footprint and has the same origin and dimensions.

Overrides:
equals in class Object
Parameters:
obj - Object to compare with this one.
Returns:
True if other object is a Footprint with the same origin and dimensions.

hashCode

public int hashCode()
Reports the hashcode associated with this object. Note that for computational efficiency this hashcode is a unique function of the footprint's origin only. This also means that it will change if the origin of the footprint changes. This therefore could 'strand' objects in a hashtable if their content changes while stored. One alternative would be to give each footprint the same hashcode, but this would slow down hash searches. Another alternative would be to give each footprint a unique hashcode, but this would violate the equals() contract that requires equal footprints to share the same hashcode.

Overrides:
hashCode in class Object
Returns:
Hashcode unique to any given origin of the footprint.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009