Waffle waffle. Changed MisoScene back to returning lists rather than

arrays for locations, portals and clusters.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@355 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-09-28 01:31:32 +00:00
parent b567223419
commit cdaea4bbab
7 changed files with 63 additions and 59 deletions
@@ -1,11 +1,12 @@
//
// $Id: DisplayMisoSceneImpl.java,v 1.35 2001/09/21 02:30:35 mdb Exp $
// $Id: DisplayMisoSceneImpl.java,v 1.36 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene;
import java.awt.Point;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import com.samskivert.util.StringUtil;
@@ -122,27 +123,21 @@ public class MisoSceneImpl implements EditableMisoScene
}
// documentation inherited
public Location[] getLocations ()
public List getLocations ()
{
Location[] locs = new Location[_locations.size()];
_locations.toArray(locs);
return locs;
return _locations;
}
// documentation inherited
public Cluster[] getClusters ()
public List getClusters ()
{
Cluster[] clusters = new Cluster[_clusters.size()];
_clusters.toArray(clusters);
return clusters;
return _clusters;
}
// documentation inherited
public Portal[] getPortals ()
public List getPortals ()
{
Portal[] portals = new Portal[_portals.size()];
_portals.toArray(portals);
return portals;
return _portals;
}
// documentation inherited
@@ -1,5 +1,5 @@
//
// $Id: IsoSceneView.java,v 1.55 2001/09/21 02:30:35 mdb Exp $
// $Id: IsoSceneView.java,v 1.56 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene;
@@ -314,8 +314,8 @@ public class IsoSceneView implements SceneView
*/
protected void paintLocations (Graphics2D gfx)
{
Location[] locations = _scene.getLocations();
int size = locations.length;
List locations = _scene.getLocations();
int size = locations.size();
// create the location triangle
Polygon tri = new Polygon();
@@ -326,7 +326,7 @@ public class IsoSceneView implements SceneView
for (int ii = 0; ii < size; ii++) {
// retrieve the location
Location loc = locations[ii];
Location loc = (Location)locations.get(ii);
// get the cluster index this location is in, if any
int clusteridx = MisoSceneUtil.getClusterIndex(_scene, loc);
@@ -1,8 +1,10 @@
//
// $Id: MisoScene.java,v 1.1 2001/09/21 02:30:35 mdb Exp $
// $Id: MisoScene.java,v 1.2 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene;
import java.util.List;
import com.threerings.media.tile.Tile;
import com.threerings.whirled.data.Scene;
@@ -36,19 +38,25 @@ public interface MisoScene extends Scene
public Tile getDefaultTile ();
/**
* Return the locations in this scene.
* Return the locations in this scene. The locations list should
* contain all locations and portals in the scene. The list returned
* by this method should <em>not</em> be modified.
*/
public Location[] getLocations ();
public List getLocations ();
/**
* Return the clusters in this scene.
* Return the clusters in this scene. The clusters will reference all
* of the locations that are clustered. The list returned by this
* method should <em>not</em> be modified.
*/
public Cluster[] getClusters ();
public List getClusters ();
/**
* Return the portals associated with this scene.
* Return the portals associated with this scene. Portals should never
* be part of a cluster. The list returned by this method should
* <em>not</em> be modified.
*/
public Portal[] getPortals ();
public List getPortals ();
/**
* Return the portal that is the default entrance to this scene.
@@ -1,9 +1,9 @@
//
// $Id: ClusterUtil.java,v 1.2 2001/09/21 02:30:35 mdb Exp $
// $Id: ClusterUtil.java,v 1.3 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene.util;
import java.util.ArrayList;
import java.util.List;
import com.threerings.miso.Log;
import com.threerings.miso.scene.*;
@@ -22,11 +22,11 @@ public class ClusterUtil
* @param clusters the cluster list.
* @param loc the location.
*/
public static int getClusterIndex (Cluster[] clusters, Location loc)
public static int getClusterIndex (List clusters, Location loc)
{
int size = clusters.length;
int size = clusters.size();
for (int ii = 0; ii < size; ii++) {
Cluster cluster = clusters[ii];
Cluster cluster = (Cluster)clusters.get(ii);
if (cluster.contains(loc)) {
return ii;
}
@@ -40,7 +40,7 @@ public class ClusterUtil
* @param clusters the cluster array.
* @param loc the location.
*/
public static void remove (ArrayList clusters, Location loc)
public static void remove (List clusters, Location loc)
{
int size = clusters.size();
for (int ii = 0; ii < size; ii++) {
@@ -78,8 +78,7 @@ public class ClusterUtil
* @param clusteridx the cluster index, or -1 to remove the location
* from any cluster.
*/
public static void regroup (ArrayList clusters, Location loc,
int clusteridx)
public static void regroup (List clusters, Location loc, int clusteridx)
{
// just remove the location if clusteridx is -1
if (clusteridx == -1) {
@@ -1,8 +1,10 @@
//
// $Id: MisoSceneUtil.java,v 1.1 2001/09/21 02:30:35 mdb Exp $
// $Id: MisoSceneUtil.java,v 1.2 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene.util;
import java.util.List;
import com.threerings.miso.scene.*;
/**
@@ -25,10 +27,10 @@ public class MisoSceneUtil
*/
public static Location getLocation (MisoScene scene, int x, int y)
{
Location[] locs = scene.getLocations();
int size = locs.length;
List locs = scene.getLocations();
int size = locs.size();
for (int ii = 0; ii < size; ii++) {
Location loc = locs[ii];
Location loc = (Location)locs.get(ii);
if (loc.x == x && loc.y == y) {
return loc;
}
@@ -47,10 +49,10 @@ public class MisoSceneUtil
*/
public static Portal getPortal (MisoScene scene, String name)
{
Portal[] portals = scene.getPortals();
int size = portals.length;
List portals = scene.getPortals();
int size = portals.size();
for (int ii = 0; ii < size; ii++) {
Portal portal = portals[ii];
Portal portal = (Portal)portals.get(ii);
if (portal.name.equals(name)) {
return portal;
}
@@ -1,5 +1,5 @@
//
// $Id: XMLSceneGroupParser.java,v 1.4 2001/09/21 02:30:35 mdb Exp $
// $Id: XMLSceneGroupParser.java,v 1.5 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene.xml;
@@ -291,12 +291,12 @@ public class XMLSceneGroupParser extends DefaultHandler
SceneInfo sinfo = (SceneInfo)sceneinfo.get(ii);
// get the portals in the scene
Portal[] portals = sinfo.scene.getPortals();
List portals = sinfo.scene.getPortals();
// check each portal to make sure it has a valid destination
int psize = portals.length;
int psize = portals.size();
for (int jj = 0; jj < size; jj++) {
Portal portal = portals[jj];
Portal portal = (Portal)portals.get(jj);
if (!portal.hasDestination()) {
Log.warning("Unbound portal [scene=" + sinfo.name +
", portal=" + portal + "].");
@@ -1,11 +1,11 @@
//
// $Id: XMLSceneWriter.java,v 1.13 2001/09/21 02:30:35 mdb Exp $
// $Id: XMLSceneWriter.java,v 1.14 2001/09/28 01:31:32 mdb Exp $
package com.threerings.miso.scene.xml;
import java.awt.Point;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import com.samskivert.util.ListUtil;
@@ -87,19 +87,19 @@ public class XMLSceneWriter extends DataWriter
*/
protected void writeClusters (MisoScene scene) throws SAXException
{
Cluster[] clusters = scene.getClusters();
Location[] locs = scene.getLocations();
List clusters = scene.getClusters();
List locs = scene.getLocations();
int size = clusters.length;
int size = clusters.size();
for (int ii = 0; ii < size; ii++) {
Cluster cluster = clusters[ii];
ArrayList clusterlocs = cluster.getLocations();
Cluster cluster = (Cluster)clusters.get(ii);
List clusterlocs = cluster.getLocations();
StringBuffer buf = new StringBuffer();
int clustersize = clusterlocs.size();
for (int jj = 0; jj < clustersize; jj++) {
Location cloc = (Location)clusterlocs.get(jj);
buf.append(ListUtil.indexOfEqual(locs, cloc));
buf.append(locs.indexOf(cloc));
if (jj < clustersize - 1) {
buf.append(",");
}
@@ -146,14 +146,14 @@ public class XMLSceneWriter extends DataWriter
*/
protected String getPortalData (MisoScene scene)
{
Location[] locs = scene.getLocations();
Portal[] portals = scene.getPortals();
List locs = scene.getLocations();
List portals = scene.getPortals();
StringBuffer buf = new StringBuffer();
int size = portals.length;
int size = portals.size();
for (int ii = 0; ii < size; ii++) {
Portal portal = portals[ii];
buf.append(ListUtil.indexOfEqual(locs, portal)).append(",");
Portal portal = (Portal)portals.get(ii);
buf.append(locs.indexOf(portal)).append(",");
buf.append(portal.name);
if (ii < size - 1) {
buf.append(",");
@@ -172,12 +172,12 @@ public class XMLSceneWriter extends DataWriter
*/
protected String getLocationData (MisoScene scene)
{
Location[] locs = scene.getLocations();
List locs = scene.getLocations();
StringBuffer buf = new StringBuffer();
int size = locs.length;
int size = locs.size();
for (int ii = 0; ii < size; ii++) {
Location loc = locs[ii];
Location loc = (Location)locs.get(ii);
buf.append(loc.x).append(",");
buf.append(loc.y).append(",");
buf.append(loc.orient);