org.moyoman.util.closestpoint
Class PointInfo

java.lang.Object
  |
  +--org.moyoman.util.closestpoint.PointInfo
All Implemented Interfaces:
Cloneable, Serializable

public class PointInfo
extends Object
implements Serializable, Cloneable

Each object of this class represents a single point, and the groups closest to it.

See Also:
Serialized Form

Field Summary
private  HashSet closestPointGroups
          Each element is a ClosestPointGroup which is as close to the point as any other group(s).
private  short distance
          The square of the distance to the closest group(s).
private  Point point
          The point being represented.
 
Constructor Summary
protected PointInfo(Point pt)
          Create a new PointInfo object.
 
Method Summary
protected  void addGroup(ClosestPointGroup cpg)
          Add a group to the list of closest groups.
 Object clone()
          Override the Object.clone() method.
private  short computeDistance(Point pt)
          Compute the distance between this point and the parameter point.
protected  boolean contains(ClosestPointGroup cpg)
          Determine if the group is already in the closest groups list.
 boolean equals(Object o)
          Compare this object with another one.
 short getDistance()
          Return the square of the distance to the closest group(s).
protected  int getGroupNumber()
          Get the number of groups which are on the closest groups list.
 ClosestPointGroup[] getGroups()
          Get all of the groups which are the closest to this point.
protected  Point getPoint()
          Get the point that this object represents.
 int hashCode()
          Get a hash code for this object.
protected  short proximity(Point pt)
          Compare the distance of the point with that of the closest groups.
protected  void removeAllGroups()
          Remove all groups from the closest groups list.
protected  void removeGroup(ClosestPointGroup cpg)
          Remove a group from the closest groups list.
protected  void replaceGroup(ClosestPointGroup oldcpg, ClosestPointGroup newcpg)
          Replace one group with another.
protected  void setDistance(Point pt)
          Set the distance between this point and the parameter point.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

point

private Point point
The point being represented.


distance

private short distance
The square of the distance to the closest group(s).


closestPointGroups

private HashSet closestPointGroups
Each element is a ClosestPointGroup which is as close to the point as any other group(s).

Constructor Detail

PointInfo

protected PointInfo(Point pt)
Create a new PointInfo object.

Parameters:
pt - The point which is represented.
Method Detail

setDistance

protected void setDistance(Point pt)
Set the distance between this point and the parameter point.

Parameters:
pt - The point to which the distance is being set.

getDistance

public short getDistance()
Return the square of the distance to the closest group(s).

Returns:
A short which is the square of the distance.

computeDistance

private short computeDistance(Point pt)
Compute the distance between this point and the parameter point.

Parameters:
pt - The point to which the distance is being compared.
Returns:
A short which is the square of the distance between the two points.

addGroup

protected void addGroup(ClosestPointGroup cpg)
Add a group to the list of closest groups.

Parameters:
cpg - A group which to be added to the list.

removeGroup

protected void removeGroup(ClosestPointGroup cpg)
Remove a group from the closest groups list.

Parameters:
cpg - The group to be removed from the list.

replaceGroup

protected void replaceGroup(ClosestPointGroup oldcpg,
                            ClosestPointGroup newcpg)
Replace one group with another. Note that it there are no implications as to whether the old group is actually found, or the new group is already present. The new group is only added if the old group is found.

Parameters:
oldcpg - The old group
newcpg - The new group.

contains

protected boolean contains(ClosestPointGroup cpg)
Determine if the group is already in the closest groups list.

Parameters:
cpg - The group in question.
Returns:
true if the group is in the list, or false.

removeAllGroups

protected void removeAllGroups()
Remove all groups from the closest groups list.


getGroups

public ClosestPointGroup[] getGroups()
Get all of the groups which are the closest to this point.

Returns:
An array of ClosestPointGroup objects.

getGroupNumber

protected int getGroupNumber()
Get the number of groups which are on the closest groups list.

Returns:
The total number of groups.

proximity

protected short proximity(Point pt)
Compare the distance of the point with that of the closest groups.

Parameters:
pt - The point which is being compared.
Returns:
Return one of the following values:
  • -1 if the point is closer than the closest group(s).
  • 0 if the point is the same distance as the closest group(s).
  • 1 if the point is further than the closest group(s).

getPoint

protected Point getPoint()
Get the point that this object represents.

Returns:
A Point object.

equals

public boolean equals(Object o)
Compare this object with another one.

Overrides:
equals in class Object
Parameters:
o - The object being compared with this one.
Returns:
true if the other object is a PointInfo object representing the same point, or false.

hashCode

public int hashCode()
Get a hash code for this object.

Overrides:
hashCode in class Object
Returns:
An int which is the hash code.

clone

public Object clone()
Override the Object.clone() method.

Overrides:
clone in class Object
Returns:
A PointInfo object which is a clone of this one.