Renamed Spot to Cluster, replaced SpotGroup with ClusterUtil.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@211 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: XMLSceneParser.java,v 1.7 2001/08/10 00:47:34 shaper Exp $
|
||||
// $Id: XMLSceneParser.java,v 1.8 2001/08/10 01:31:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.xml;
|
||||
|
||||
@@ -70,9 +70,9 @@ public class XMLSceneParser extends DefaultHandler
|
||||
int vals[] = StringUtil.parseIntArray(_chars.toString());
|
||||
_scLocations = toLocationsList(vals);
|
||||
|
||||
} else if (qName.equals("spot")) {
|
||||
} else if (qName.equals("cluster")) {
|
||||
int vals[] = StringUtil.parseIntArray(_chars.toString());
|
||||
_scSpots.add(toSpot(_scLocations, vals));
|
||||
_scClusters.add(toCluster(_scLocations, vals));
|
||||
|
||||
} else if (qName.equals("exits")) {
|
||||
String vals[] = StringUtil.parseStringArray(_chars.toString());
|
||||
@@ -88,7 +88,8 @@ public class XMLSceneParser extends DefaultHandler
|
||||
} else if (qName.equals("scene")) {
|
||||
// construct the scene object on tag close
|
||||
_scene = new Scene(
|
||||
_tilemgr, _scName, _scLocations, _scSpots, _scExits, _scTiles);
|
||||
_tilemgr, _scName, _scLocations, _scClusters,
|
||||
_scExits, _scTiles);
|
||||
|
||||
Log.info("Constructed parsed scene [scene=" + _scene + "].");
|
||||
}
|
||||
@@ -168,22 +169,22 @@ public class XMLSceneParser extends DefaultHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of integer values, return a <code>Spot</code>
|
||||
* Given an array of integer values, return a <code>Cluster</code>
|
||||
* object containing the location objects identified by location
|
||||
* index number in the integer array.
|
||||
*
|
||||
* @param locs the locations list.
|
||||
* @param vals the integer values.
|
||||
*
|
||||
* @return the spot object.
|
||||
* @return the cluster object.
|
||||
*/
|
||||
protected Spot toSpot (ArrayList locs, int[] vals)
|
||||
protected Cluster toCluster (ArrayList locs, int[] vals)
|
||||
{
|
||||
Spot spot = new Spot();
|
||||
Cluster cluster = new Cluster();
|
||||
for (int ii = 0; ii < vals.length; ii++) {
|
||||
spot.add((Location)locs.get(vals[ii]));
|
||||
cluster.add((Location)locs.get(vals[ii]));
|
||||
}
|
||||
return spot;
|
||||
return cluster;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +269,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
_scTiles = new Tile[width][height][Scene.NUM_LAYERS];
|
||||
_scLocations = null;
|
||||
_scExits = null;
|
||||
_scSpots = new ArrayList();
|
||||
_scClusters = new ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +321,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
// temporary storage of scene object values and data
|
||||
protected StringBuffer _chars;
|
||||
protected String _scName;
|
||||
protected ArrayList _scLocations, _scExits, _scSpots;
|
||||
protected ArrayList _scLocations, _scExits, _scClusters;
|
||||
protected Tile[][][] _scTiles;
|
||||
protected int _scLnum, _scRownum, _scColstart;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: XMLSceneWriter.java,v 1.5 2001/08/10 00:47:34 shaper Exp $
|
||||
// $Id: XMLSceneWriter.java,v 1.6 2001/08/10 01:31:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.xml;
|
||||
|
||||
@@ -53,9 +53,9 @@ public class XMLSceneWriter extends DataWriter
|
||||
dataElement("version", "" + Scene.VERSION);
|
||||
dataElement("locations", getLocationData(scene));
|
||||
|
||||
startElement("spots");
|
||||
writeSpots(scene);
|
||||
endElement("spots");
|
||||
startElement("clusters");
|
||||
writeClusters(scene);
|
||||
endElement("clusters");
|
||||
|
||||
dataElement("exits", getExitData(scene));
|
||||
|
||||
@@ -76,32 +76,32 @@ public class XMLSceneWriter extends DataWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* Output XML detailing the spot objects. Spots are described by
|
||||
* a list of location object indexes that are contained within the
|
||||
* spot.
|
||||
* Output XML detailing the cluster objects. Clusters are
|
||||
* described by a list of location object indexes that are
|
||||
* contained within the cluster.
|
||||
*
|
||||
* @param scene the scene object.
|
||||
*/
|
||||
protected void writeSpots (Scene scene) throws SAXException
|
||||
protected void writeClusters (Scene scene) throws SAXException
|
||||
{
|
||||
ArrayList spots = scene.getSpotGroup().getSpots();
|
||||
ArrayList clusters = scene.getClusters();
|
||||
ArrayList locs = scene.getLocations();
|
||||
|
||||
int size = spots.size();
|
||||
int size = clusters.size();
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
Spot spot = (Spot)spots.get(ii);
|
||||
ArrayList spotlocs = spot.getLocations();
|
||||
Cluster cluster = (Cluster)clusters.get(ii);
|
||||
ArrayList clusterlocs = cluster.getLocations();
|
||||
|
||||
int spotsize = spotlocs.size();
|
||||
for (int jj = 0; jj < spotsize; jj++) {
|
||||
buf.append(locs.indexOf(spotlocs.get(jj))).append(",");
|
||||
if (jj < spotsize - 1) buf.append(",");
|
||||
int clustersize = clusterlocs.size();
|
||||
for (int jj = 0; jj < clustersize; jj++) {
|
||||
buf.append(locs.indexOf(clusterlocs.get(jj))).append(",");
|
||||
if (jj < clustersize - 1) buf.append(",");
|
||||
}
|
||||
|
||||
dataElement("spot", buf.toString());
|
||||
dataElement("cluster", buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ public class XMLSceneWriter extends DataWriter
|
||||
|
||||
/**
|
||||
* Return a string representation of the locations in the scene.
|
||||
* Each location is specified by a comma-delimited quartet of
|
||||
* (spot id, x, y, orientation) values.
|
||||
* Each location is specified by a comma-delimited triplet of
|
||||
* (x, y, orientation) values.
|
||||
*
|
||||
* @return the locations in String format.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user