Make Location.equals() do fancy stuff to make life easier elsewhere.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@746 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
//
|
//
|
||||||
// $Id: Location.java,v 1.3 2001/12/05 03:38:09 mdb Exp $
|
// $Id: Location.java,v 1.4 2001/12/05 09:06:30 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.whirled.spot.data;
|
package com.threerings.whirled.spot.data;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A location represents a place to stand in a scene. More specifically,
|
* A location represents a place to stand in a scene. More specifically,
|
||||||
* it is a geometric location in a scene with an orientation that would be
|
* it is a geometric location in a scene with an orientation that would be
|
||||||
@@ -30,13 +32,25 @@ public class Location
|
|||||||
public int clusterIndex;
|
public int clusterIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location equality is determined by location id.
|
* Location equality is determined by location id. Locations will
|
||||||
|
* claim to be equal to an <code>Integer</code> object with a value
|
||||||
|
* equal to the location id and will claim to be equal to a
|
||||||
|
* <code>Point</code> object with x and y coordinates equal to the x
|
||||||
|
* and y coordinates of the location.
|
||||||
*/
|
*/
|
||||||
public boolean equals (Object other)
|
public boolean equals (Object other)
|
||||||
{
|
{
|
||||||
if (other instanceof Location) {
|
if (other instanceof Location) {
|
||||||
Location oloc = (Location)other;
|
Location oloc = (Location)other;
|
||||||
return locationId == oloc.locationId;
|
return locationId == oloc.locationId;
|
||||||
|
|
||||||
|
} else if (other instanceof Integer) {
|
||||||
|
return locationId == ((Integer)other).intValue();
|
||||||
|
|
||||||
|
} else if (other instanceof Point) {
|
||||||
|
Point p = (Point)other;
|
||||||
|
return (x == p.x && y == p.y);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user