Added convenience functions for looking up a location by id and a location

index by id.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@805 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-16 21:22:31 +00:00
parent 5b37850773
commit 5082bb817f
3 changed files with 55 additions and 3 deletions
@@ -1,5 +1,5 @@
//
// $Id: DisplaySpotScene.java,v 1.3 2001/12/05 08:45:05 mdb Exp $
// $Id: DisplaySpotScene.java,v 1.4 2001/12/16 21:22:30 mdb Exp $
package com.threerings.whirled.spot.client;
@@ -28,6 +28,20 @@ public interface DisplaySpotScene extends DisplayScene
*/
public List getLocations ();
/**
* Convenience function for obtaining a location's index in the
* location list given its id.
*
* @return the location's index or -1 if a location with the specified
* id is not in this scene's location list.
*/
public int getLocationIndex (int locationId);
/**
* Convenience funtion for looking up a location by id.
*/
public Location getLocation (int locationId);
/**
* Returns a list of the portals in this scene.
*/
@@ -1,5 +1,5 @@
//
// $Id: DisplaySpotSceneImpl.java,v 1.4 2001/12/05 08:45:05 mdb Exp $
// $Id: DisplaySpotSceneImpl.java,v 1.5 2001/12/16 21:22:30 mdb Exp $
package com.threerings.whirled.spot.client;
@@ -112,6 +112,32 @@ public class DisplaySpotSceneImpl extends DisplaySceneImpl
return _locations;
}
// documentation inherited
public int getLocationIndex (int locationId)
{
int lsize = _locations.size();
for (int i = 0; i < lsize; i++) {
Location loc = (Location)_locations.get(i);
if (loc.locationId == locationId) {
return i;
}
}
return -1;
}
// documentation inherited
public Location getLocation (int locationId)
{
int lsize = _locations.size();
for (int i = 0; i < lsize; i++) {
Location loc = (Location)_locations.get(i);
if (loc.locationId == locationId) {
return loc;
}
}
return null;
}
// documentation inherited
public List getPortals ()
{
@@ -1,5 +1,5 @@
//
// $Id: EditableSpotSceneImpl.java,v 1.9 2001/12/07 02:10:14 mdb Exp $
// $Id: EditableSpotSceneImpl.java,v 1.10 2001/12/16 21:22:31 mdb Exp $
package com.threerings.whirled.tools.spot;
@@ -119,6 +119,18 @@ public class EditableSpotSceneImpl extends EditableSceneImpl
return _delegate.getLocations();
}
// documentation inherited
public int getLocationIndex (int locationId)
{
return _delegate.getLocationIndex(locationId);
}
// documentation inherited
public Location getLocation (int locationId)
{
return _delegate.getLocation(locationId);
}
// documentation inherited
public List getPortals ()
{