From cdaea4bbab90d78da4b31120e037177b8dd3d485 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 28 Sep 2001 01:31:32 +0000 Subject: [PATCH] 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 --- .../miso/client/DisplayMisoSceneImpl.java | 21 +++++------- .../threerings/miso/client/IsoSceneView.java | 8 ++--- .../com/threerings/miso/client/MisoScene.java | 22 +++++++++---- .../miso/client/util/ClusterUtil.java | 15 ++++----- .../miso/client/util/MisoSceneUtil.java | 16 ++++++---- .../miso/tools/xml/XMLSceneGroupParser.java | 8 ++--- .../miso/tools/xml/XMLSceneWriter.java | 32 +++++++++---------- 7 files changed, 63 insertions(+), 59 deletions(-) diff --git a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java index d83d6a9c1..a160e865b 100644 --- a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java +++ b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java @@ -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 diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index ea39fa4ac..4c99b8273 100644 --- a/src/java/com/threerings/miso/client/IsoSceneView.java +++ b/src/java/com/threerings/miso/client/IsoSceneView.java @@ -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); diff --git a/src/java/com/threerings/miso/client/MisoScene.java b/src/java/com/threerings/miso/client/MisoScene.java index 2a5efcc51..23975a63f 100644 --- a/src/java/com/threerings/miso/client/MisoScene.java +++ b/src/java/com/threerings/miso/client/MisoScene.java @@ -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 not 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 not 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 + * not be modified. */ - public Portal[] getPortals (); + public List getPortals (); /** * Return the portal that is the default entrance to this scene. diff --git a/src/java/com/threerings/miso/client/util/ClusterUtil.java b/src/java/com/threerings/miso/client/util/ClusterUtil.java index cdda5b35d..e98b6088c 100644 --- a/src/java/com/threerings/miso/client/util/ClusterUtil.java +++ b/src/java/com/threerings/miso/client/util/ClusterUtil.java @@ -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) { diff --git a/src/java/com/threerings/miso/client/util/MisoSceneUtil.java b/src/java/com/threerings/miso/client/util/MisoSceneUtil.java index 76d6d30d2..6607beb7c 100644 --- a/src/java/com/threerings/miso/client/util/MisoSceneUtil.java +++ b/src/java/com/threerings/miso/client/util/MisoSceneUtil.java @@ -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; } diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneGroupParser.java b/src/java/com/threerings/miso/tools/xml/XMLSceneGroupParser.java index b6cfa5610..81a49ccf0 100644 --- a/src/java/com/threerings/miso/tools/xml/XMLSceneGroupParser.java +++ b/src/java/com/threerings/miso/tools/xml/XMLSceneGroupParser.java @@ -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 + "]."); diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java index 90f6135b2..004534f93 100644 --- a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java +++ b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java @@ -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);