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:
@@ -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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
@@ -122,27 +123,21 @@ public class MisoSceneImpl implements EditableMisoScene
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Location[] getLocations ()
|
public List getLocations ()
|
||||||
{
|
{
|
||||||
Location[] locs = new Location[_locations.size()];
|
return _locations;
|
||||||
_locations.toArray(locs);
|
|
||||||
return locs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Cluster[] getClusters ()
|
public List getClusters ()
|
||||||
{
|
{
|
||||||
Cluster[] clusters = new Cluster[_clusters.size()];
|
return _clusters;
|
||||||
_clusters.toArray(clusters);
|
|
||||||
return clusters;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Portal[] getPortals ()
|
public List getPortals ()
|
||||||
{
|
{
|
||||||
Portal[] portals = new Portal[_portals.size()];
|
return _portals;
|
||||||
_portals.toArray(portals);
|
|
||||||
return portals;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// 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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -314,8 +314,8 @@ public class IsoSceneView implements SceneView
|
|||||||
*/
|
*/
|
||||||
protected void paintLocations (Graphics2D gfx)
|
protected void paintLocations (Graphics2D gfx)
|
||||||
{
|
{
|
||||||
Location[] locations = _scene.getLocations();
|
List locations = _scene.getLocations();
|
||||||
int size = locations.length;
|
int size = locations.size();
|
||||||
|
|
||||||
// create the location triangle
|
// create the location triangle
|
||||||
Polygon tri = new Polygon();
|
Polygon tri = new Polygon();
|
||||||
@@ -326,7 +326,7 @@ public class IsoSceneView implements SceneView
|
|||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
|
|
||||||
// retrieve the location
|
// retrieve the location
|
||||||
Location loc = locations[ii];
|
Location loc = (Location)locations.get(ii);
|
||||||
|
|
||||||
// get the cluster index this location is in, if any
|
// get the cluster index this location is in, if any
|
||||||
int clusteridx = MisoSceneUtil.getClusterIndex(_scene, loc);
|
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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.threerings.media.tile.Tile;
|
import com.threerings.media.tile.Tile;
|
||||||
import com.threerings.whirled.data.Scene;
|
import com.threerings.whirled.data.Scene;
|
||||||
|
|
||||||
@@ -36,19 +38,25 @@ public interface MisoScene extends Scene
|
|||||||
public Tile getDefaultTile ();
|
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.
|
* 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;
|
package com.threerings.miso.scene.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
import com.threerings.miso.scene.*;
|
import com.threerings.miso.scene.*;
|
||||||
@@ -22,11 +22,11 @@ public class ClusterUtil
|
|||||||
* @param clusters the cluster list.
|
* @param clusters the cluster list.
|
||||||
* @param loc the location.
|
* @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++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
Cluster cluster = clusters[ii];
|
Cluster cluster = (Cluster)clusters.get(ii);
|
||||||
if (cluster.contains(loc)) {
|
if (cluster.contains(loc)) {
|
||||||
return ii;
|
return ii;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ public class ClusterUtil
|
|||||||
* @param clusters the cluster array.
|
* @param clusters the cluster array.
|
||||||
* @param loc the location.
|
* @param loc the location.
|
||||||
*/
|
*/
|
||||||
public static void remove (ArrayList clusters, Location loc)
|
public static void remove (List clusters, Location loc)
|
||||||
{
|
{
|
||||||
int size = clusters.size();
|
int size = clusters.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
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
|
* @param clusteridx the cluster index, or -1 to remove the location
|
||||||
* from any cluster.
|
* from any cluster.
|
||||||
*/
|
*/
|
||||||
public static void regroup (ArrayList clusters, Location loc,
|
public static void regroup (List clusters, Location loc, int clusteridx)
|
||||||
int clusteridx)
|
|
||||||
{
|
{
|
||||||
// just remove the location if clusteridx is -1
|
// just remove the location if clusteridx is -1
|
||||||
if (clusteridx == -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;
|
package com.threerings.miso.scene.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.threerings.miso.scene.*;
|
import com.threerings.miso.scene.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,10 +27,10 @@ public class MisoSceneUtil
|
|||||||
*/
|
*/
|
||||||
public static Location getLocation (MisoScene scene, int x, int y)
|
public static Location getLocation (MisoScene scene, int x, int y)
|
||||||
{
|
{
|
||||||
Location[] locs = scene.getLocations();
|
List locs = scene.getLocations();
|
||||||
int size = locs.length;
|
int size = locs.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
Location loc = locs[ii];
|
Location loc = (Location)locs.get(ii);
|
||||||
if (loc.x == x && loc.y == y) {
|
if (loc.x == x && loc.y == y) {
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
@@ -47,10 +49,10 @@ public class MisoSceneUtil
|
|||||||
*/
|
*/
|
||||||
public static Portal getPortal (MisoScene scene, String name)
|
public static Portal getPortal (MisoScene scene, String name)
|
||||||
{
|
{
|
||||||
Portal[] portals = scene.getPortals();
|
List portals = scene.getPortals();
|
||||||
int size = portals.length;
|
int size = portals.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
Portal portal = portals[ii];
|
Portal portal = (Portal)portals.get(ii);
|
||||||
if (portal.name.equals(name)) {
|
if (portal.name.equals(name)) {
|
||||||
return portal;
|
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;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -291,12 +291,12 @@ public class XMLSceneGroupParser extends DefaultHandler
|
|||||||
SceneInfo sinfo = (SceneInfo)sceneinfo.get(ii);
|
SceneInfo sinfo = (SceneInfo)sceneinfo.get(ii);
|
||||||
|
|
||||||
// get the portals in the scene
|
// 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
|
// 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++) {
|
for (int jj = 0; jj < size; jj++) {
|
||||||
Portal portal = portals[jj];
|
Portal portal = (Portal)portals.get(jj);
|
||||||
if (!portal.hasDestination()) {
|
if (!portal.hasDestination()) {
|
||||||
Log.warning("Unbound portal [scene=" + sinfo.name +
|
Log.warning("Unbound portal [scene=" + sinfo.name +
|
||||||
", portal=" + portal + "].");
|
", 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;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import com.samskivert.util.ListUtil;
|
import com.samskivert.util.ListUtil;
|
||||||
|
|
||||||
@@ -87,19 +87,19 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
*/
|
*/
|
||||||
protected void writeClusters (MisoScene scene) throws SAXException
|
protected void writeClusters (MisoScene scene) throws SAXException
|
||||||
{
|
{
|
||||||
Cluster[] clusters = scene.getClusters();
|
List clusters = scene.getClusters();
|
||||||
Location[] locs = scene.getLocations();
|
List locs = scene.getLocations();
|
||||||
|
|
||||||
int size = clusters.length;
|
int size = clusters.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
Cluster cluster = clusters[ii];
|
Cluster cluster = (Cluster)clusters.get(ii);
|
||||||
ArrayList clusterlocs = cluster.getLocations();
|
List clusterlocs = cluster.getLocations();
|
||||||
|
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
int clustersize = clusterlocs.size();
|
int clustersize = clusterlocs.size();
|
||||||
for (int jj = 0; jj < clustersize; jj++) {
|
for (int jj = 0; jj < clustersize; jj++) {
|
||||||
Location cloc = (Location)clusterlocs.get(jj);
|
Location cloc = (Location)clusterlocs.get(jj);
|
||||||
buf.append(ListUtil.indexOfEqual(locs, cloc));
|
buf.append(locs.indexOf(cloc));
|
||||||
if (jj < clustersize - 1) {
|
if (jj < clustersize - 1) {
|
||||||
buf.append(",");
|
buf.append(",");
|
||||||
}
|
}
|
||||||
@@ -146,14 +146,14 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
*/
|
*/
|
||||||
protected String getPortalData (MisoScene scene)
|
protected String getPortalData (MisoScene scene)
|
||||||
{
|
{
|
||||||
Location[] locs = scene.getLocations();
|
List locs = scene.getLocations();
|
||||||
Portal[] portals = scene.getPortals();
|
List portals = scene.getPortals();
|
||||||
|
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
int size = portals.length;
|
int size = portals.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
Portal portal = portals[ii];
|
Portal portal = (Portal)portals.get(ii);
|
||||||
buf.append(ListUtil.indexOfEqual(locs, portal)).append(",");
|
buf.append(locs.indexOf(portal)).append(",");
|
||||||
buf.append(portal.name);
|
buf.append(portal.name);
|
||||||
if (ii < size - 1) {
|
if (ii < size - 1) {
|
||||||
buf.append(",");
|
buf.append(",");
|
||||||
@@ -172,12 +172,12 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
*/
|
*/
|
||||||
protected String getLocationData (MisoScene scene)
|
protected String getLocationData (MisoScene scene)
|
||||||
{
|
{
|
||||||
Location[] locs = scene.getLocations();
|
List locs = scene.getLocations();
|
||||||
|
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
int size = locs.length;
|
int size = locs.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
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.x).append(",");
|
||||||
buf.append(loc.y).append(",");
|
buf.append(loc.y).append(",");
|
||||||
buf.append(loc.orient);
|
buf.append(loc.orient);
|
||||||
|
|||||||
Reference in New Issue
Block a user