diff --git a/src/java/com/threerings/miso/client/Cluster.java b/src/java/com/threerings/miso/client/Cluster.java
index 075db7b1c..a4813096b 100644
--- a/src/java/com/threerings/miso/client/Cluster.java
+++ b/src/java/com/threerings/miso/client/Cluster.java
@@ -1,10 +1,12 @@
//
-// $Id: Cluster.java,v 1.1 2001/08/10 01:31:25 shaper Exp $
+// $Id: Cluster.java,v 1.2 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.scene;
import java.util.ArrayList;
+import com.samskivert.util.StringUtil;
+
/**
* A Cluster is a gathering of Location objects
* that represent a logical grouping for the purposes of display and
@@ -72,6 +74,14 @@ public class Cluster
return _locations;
}
+ /**
+ * Return a string representation of this object.
+ */
+ public String toString ()
+ {
+ return StringUtil.toString(_locations);
+ }
+
/** The list of locations in this cluster. */
protected ArrayList _locations;
}
diff --git a/src/java/com/threerings/miso/client/ClusterUtil.java b/src/java/com/threerings/miso/client/ClusterUtil.java
index 06d73474a..aff68222e 100644
--- a/src/java/com/threerings/miso/client/ClusterUtil.java
+++ b/src/java/com/threerings/miso/client/ClusterUtil.java
@@ -1,5 +1,5 @@
//
-// $Id: ClusterUtil.java,v 1.1 2001/08/10 01:31:25 shaper Exp $
+// $Id: ClusterUtil.java,v 1.2 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.scene;
@@ -14,9 +14,27 @@ import com.threerings.miso.Log;
*/
public class ClusterUtil
{
+ /**
+ * Return the cluster index number the given location is in, or -1
+ * if the location is not in any cluster.
+ *
+ * @param clusters the cluster list.
+ * @param loc the location.
+ */
+ public static int getClusterIndex (ArrayList clusters, Location loc)
+ {
+ int size = clusters.size();
+ for (int ii = 0; ii < size; ii++) {
+ Cluster cluster = (Cluster)clusters.get(ii);
+ if (cluster.contains(loc)) return ii;
+ }
+ return -1;
+ }
+
/**
* Remove the given location from its cluster, if any.
*
+ * @param clusters the cluster list.
* @param loc the location.
*/
public static void remove (ArrayList clusters, Location loc)
@@ -52,7 +70,7 @@ public class ClusterUtil
* in the group, in which case a new cluster object will be created
* that initially contains only the given location.
*
- * @param clusters the list of clusters.
+ * @param clusters the cluster list.
* @param loc the location.
* @param clusteridx the cluster index, or -1 to remove the location
* from any cluster.
diff --git a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java
index 143f4765f..dd9b5ef52 100644
--- a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java
+++ b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java
@@ -1,5 +1,5 @@
//
-// $Id: DisplayMisoSceneImpl.java,v 1.21 2001/08/10 01:31:25 shaper Exp $
+// $Id: DisplayMisoSceneImpl.java,v 1.22 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.scene;
@@ -104,11 +104,19 @@ public class Scene
this.tiles = tiles;
}
+ /**
+ * Return the cluster index number the given location is in, or -1
+ * if the location is not in any cluster.
+ *
+ * @param loc the location.
+ */
+ public int getClusterIndex (Location loc)
+ {
+ return ClusterUtil.getClusterIndex(_clusters, loc);
+ }
+
public void updateLocation (int x, int y, int orient, int clusteridx)
{
- Log.info("updateLocation [x=" + x + ", y=" + y +
- ", orient=" + orient + ", clusteridx=" + clusteridx + "].");
-
// look the location up in our existing location list
int size = _locations.size();
Location loc = null;
diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java
index 16e58d5ce..148caff64 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.37 2001/08/10 01:31:25 shaper Exp $
+// $Id: IsoSceneView.java,v 1.38 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.scene;
@@ -64,8 +64,8 @@ public class IsoSceneView implements EditableSceneView
// clip the drawing region to our desired bounds since we
// currently draw tiles willy-nilly in undesirable areas.
- Shape oldclip = gfx.getClip();
- gfx.setClip(0, 0, _model.bounds.width, _model.bounds.height);
+ Shape oldclip = gfx.getClip();
+ gfx.setClip(0, 0, _model.bounds.width, _model.bounds.height);
if (_numDirty == 0) {
// render the full scene
@@ -82,11 +82,13 @@ public class IsoSceneView implements EditableSceneView
clearDirtyRegions();
}
- // draw an outline around the highlighted tile
- paintHighlightedTile(gfx, _htile.x, _htile.y);
+ // draw marks at each location
+ if (_model.showLocs) {
+ paintLocations(gfx);
+ }
- // draw an outline around the highlighted full coordinate
- paintHighlightedFull(gfx, _hfull.x, _hfull.y);
+ // draw highlighted tiles and full coordinates
+ paintHighlights(gfx);
// restore the original clipping region
gfx.setClip(oldclip);
@@ -161,6 +163,11 @@ public class IsoSceneView implements EditableSceneView
// draw all sprites residing in the current tile
_spritemgr.renderSprites(gfx, poly);
+ // paint the tile coordinate if desired
+ if (_model.showCoords) {
+ paintCoords(gfx, xx, yy, poly.xpoints[0], poly.ypoints[0]);
+ }
+
// bail early if we know we've drawn all dirty tiles
if (++numDrawn == _numDirty) break;
}
@@ -262,44 +269,86 @@ public class IsoSceneView implements EditableSceneView
}
/**
- * Paint a highlight around the specified tile.
+ * Paint highlights around any highlighted tiles and fine coordinates.
*
* @param gfx the graphics context.
- * @param x the tile x-position coordinate.
- * @param y the tile y-position coordinate.
*/
- protected void paintHighlightedTile (Graphics2D gfx, int x, int y)
+ protected void paintHighlights (Graphics2D gfx)
{
- if (x == -1 || y == -1) return;
+ // paint the highlighted tile
+ if (_htile.x != -1 && _htile.y != -1) {
+ // set the desired stroke and color
+ Stroke ostroke = gfx.getStroke();
+ gfx.setStroke(_hstroke);
+ gfx.setColor(Color.green);
- // set the desired stroke and color
- Stroke ostroke = gfx.getStroke();
- gfx.setStroke(HLT_STROKE);
- gfx.setColor(HLT_COLOR);
+ // draw the tile outline
+ gfx.draw(IsoUtil.getTilePolygon(_model, _htile.x, _htile.y));
- // draw the tile outline
- gfx.draw(IsoUtil.getTilePolygon(_model, x, y));
+ // restore the original stroke
+ gfx.setStroke(ostroke);
+ }
- // restore the original stroke
- gfx.setStroke(ostroke);
+ // paint the highlighted full coordinate
+ if (_hfull.x != -1 && _hfull.y != -1) {
+ Point spos = new Point();
+ IsoUtil.fullToScreen(_model, _hfull.x, _hfull.y, spos);
+
+ // set the desired stroke and color
+ Stroke ostroke = gfx.getStroke();
+ gfx.setStroke(_hstroke);
+
+ // draw a red circle at the coordinate
+ gfx.setColor(Color.red);
+ gfx.draw(new Ellipse2D.Float(spos.x - 1, spos.y - 1, 3, 3));
+
+ // restore the original stroke
+ gfx.setStroke(ostroke);
+ }
}
/**
- * Paint a highlight around the specified full coordinate.
+ * Paint rectangular demarcations at all locations in the scene,
+ * with each location's cluster index, if any, along the right
+ * side of its rectangle.
*
* @param gfx the graphics context.
- * @param x the full x-position coordinate.
- * @param y the full y-position coordinate.
*/
- protected void paintHighlightedFull (Graphics2D gfx, int x, int y)
+ protected void paintLocations (Graphics2D gfx)
{
- if (x == -1 || y == -1) return;
+ ArrayList locations = _scene.getLocations();
+ int size = locations.size();
+ for (int ii = 0; ii < size; ii++) {
- Point spos = new Point();
- IsoUtil.fullToScreen(_model, x, y, spos);
+ // retrieve the location
+ Location loc = (Location)locations.get(ii);
- gfx.setColor(Color.red);
- gfx.draw(new Ellipse2D.Float(spos.x, spos.y, 3, 3));
+ // get the cluster index this location is in, if any
+ int clusteridx = _scene.getClusterIndex(loc);
+
+ Point spos = new Point();
+ IsoUtil.fullToScreen(_model, loc.x, loc.y, spos);
+
+ int cx = spos.x, cy = spos.y;
+
+ // outline the location in multiple colors to make sure
+ // it's visible atop the unknown smorgasbord of potential tiles
+ gfx.setColor(Color.yellow);
+ gfx.fillRect(cx - 1, cy - 1, 3, 3);
+
+ gfx.setColor(Color.red);
+ gfx.drawRect(cx - 2, cy - 2, 4, 4);
+
+ gfx.setColor(Color.green);
+ gfx.drawRect(cx - 3, cy - 3, 6, 6);
+
+ if (clusteridx != -1) {
+ // draw the cluster index number on the right side
+ gfx.setFont(_font);
+ gfx.setColor(Color.white);
+ gfx.drawString("" + clusteridx, cx + 5, cy + 3);
+ }
+ }
}
public void setHighlightedTile (int sx, int sy)
@@ -447,16 +496,6 @@ public class IsoSceneView implements EditableSceneView
_scene = scene;
}
- public boolean getShowCoordinates ()
- {
- return _model.showCoords;
- }
-
- public void setShowCoordinates (boolean show)
- {
- _model.showCoords = show;
- }
-
public void setTile (int x, int y, int lnum, Tile tile)
{
Point tpos = new Point();
@@ -511,11 +550,8 @@ public class IsoSceneView implements EditableSceneView
return (_scene == null) ? 0 : _scene.getNumClusters();
}
- /** The color to draw the highlighted tile. */
- protected static final Color HLT_COLOR = Color.green;
-
- /** The stroke object used to draw the highlighted tile. */
- protected static final Stroke HLT_STROKE = new BasicStroke(3);
+ /** The stroke object used to draw highlighted tiles and coordinates. */
+ protected BasicStroke _hstroke = new BasicStroke(3);
/** The currently highlighted tile. */
protected Point _htile;
diff --git a/src/java/com/threerings/miso/client/IsoSceneViewModel.java b/src/java/com/threerings/miso/client/IsoSceneViewModel.java
index 92f035cda..7dfacc6fe 100644
--- a/src/java/com/threerings/miso/client/IsoSceneViewModel.java
+++ b/src/java/com/threerings/miso/client/IsoSceneViewModel.java
@@ -1,5 +1,5 @@
//
-// $Id: IsoSceneViewModel.java,v 1.5 2001/08/08 22:29:39 shaper Exp $
+// $Id: IsoSceneViewModel.java,v 1.6 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.scene;
@@ -62,6 +62,9 @@ public class IsoSceneModel
/** Whether tile coordinates should be drawn. */
public boolean showCoords;
+ /** Whether locations in the scene should be drawn. */
+ public boolean showLocs;
+
/**
* Construct an IsoSceneModel with reasonable default values.
*/
@@ -72,6 +75,7 @@ public class IsoSceneModel
setBounds(600, 600);
setOrigin(bounds.width / 2, -(9 * tilehei));
showCoords = false;
+ showLocs = false;
}
/**
@@ -86,6 +90,42 @@ public class IsoSceneModel
finegran = gran;
}
+ /**
+ * Return whether locations in the scene are currently drawn.
+ */
+ public boolean getShowLocations ()
+ {
+ return showLocs;
+ }
+
+ /**
+ * Set whether locations in the scene should be drawn.
+ *
+ * @param show whether to show locations.
+ */
+ public void setShowLocations (boolean show)
+ {
+ showLocs = show;
+ }
+
+ /**
+ * Return whether coordinates are currently drawn for each tile.
+ */
+ public boolean getShowCoordinates ()
+ {
+ return showCoords;
+ }
+
+ /**
+ * Set whether coordinates should be drawn for each tile.
+ *
+ * @param show whether to show coordinates.
+ */
+ public void setShowCoordinates (boolean show)
+ {
+ showCoords = show;
+ }
+
/**
* Set the dimensions of the tiles that comprise the base layer of
* the isometric view and therefore drive the view geometry as a
diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java
index 26fb1c0be..d22c0241f 100644
--- a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java
+++ b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java
@@ -1,5 +1,5 @@
//
-// $Id: XMLSceneWriter.java,v 1.6 2001/08/10 01:31:25 shaper Exp $
+// $Id: XMLSceneWriter.java,v 1.7 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.scene.xml;
@@ -97,7 +97,7 @@ public class XMLSceneWriter extends DataWriter
int clustersize = clusterlocs.size();
for (int jj = 0; jj < clustersize; jj++) {
- buf.append(locs.indexOf(clusterlocs.get(jj))).append(",");
+ buf.append(locs.indexOf(clusterlocs.get(jj)));
if (jj < clustersize - 1) buf.append(",");
}
diff --git a/tests/rsrc/scenes/default.xml b/tests/rsrc/scenes/default.xml
index 6b7824a98..2f7d00ece 100644
--- a/tests/rsrc/scenes/default.xml
+++ b/tests/rsrc/scenes/default.xml
@@ -4,7 +4,7 @@
Untitled Scene
1
-
+
diff --git a/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java b/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java
index 64af044bc..ed09ab33b 100644
--- a/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java
+++ b/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java
@@ -1,5 +1,5 @@
//
-// $Id: ViewerSceneViewPanel.java,v 1.5 2001/08/08 22:29:39 shaper Exp $
+// $Id: ViewerSceneViewPanel.java,v 1.6 2001/08/10 21:17:07 shaper Exp $
package com.threerings.miso.viewer;
@@ -40,8 +40,6 @@ public class ViewerSceneViewPanel extends SceneViewPanel
// load up the initial scene
prepareStartingScene();
- //((EditableSceneView)_view).setShowCoordinates(true);
-
PerformanceMonitor.register(this, "paint", 1000);
}