wyvern.kernel.maps
Class MapObjectSorter

java.lang.Object
  extended bywyvern.kernel.maps.MapObjectSorter
All Implemented Interfaces:
Visitor

public class MapObjectSorter
extends java.lang.Object
implements Visitor

Used to help draw the contents of a map into a graphical image. The client, the map editor and the Magic Mapping spell all need to be able to take the objects in a region of the map and sort them based on position and drawing layer. You can visit the objects in an arbitrary rectangle of a map, using a MapObjectSorter, and iterate over the sorter to get the objects in the right drawing order.

The class skips Terrain completely, because all the Terrain needs to be drawn first, followed by the terrain borders, and then finally by the objects.

Version:
1.0, Oct 21, 2001
Author:
Steve Yegge

Field Summary
protected  java.util.HashSet cache_
           
protected  java.util.TreeSet objects_
           
 
Constructor Summary
MapObjectSorter()
           
 
Method Summary
 java.util.Iterator iterator()
          Returns an Iterator over the sorted object list.
 void visit(GameObject obj)
          Visits an object, adding it to the sorted list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objects_

protected java.util.TreeSet objects_

cache_

protected java.util.HashSet cache_
Constructor Detail

MapObjectSorter

public MapObjectSorter()
Method Detail

visit

public void visit(GameObject obj)
Visits an object, adding it to the sorted list.

Specified by:
visit in interface Visitor

iterator

public java.util.Iterator iterator()
Returns an Iterator over the sorted object list.