org.gicentre.treemappa
Class MortonList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<E>
              extended by org.gicentre.treemappa.MortonList<E>
Type Parameters:
E - Type of object stored in the Morton ordered collection.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

public class MortonList<E>
extends java.util.Vector<E>

Stores a one-dimensional ordered list of objects that can represent a two-dimensional arrangement using Morton ordering. The order of objects stored in this collection is assumed to be Morton. Ordering can be VERTICAL (mirror 'N' shaped) or HORIZONTAL ('Z' shaped).

Version:
3.0, 24th February, 2011.
Author:
Jo Wood, giCentre.
See Also:
Serialized Form

Field Summary
static int HORIZONTAL
          Indicates that Morton ordering is 'Z' shaped.
static int VERTICAL
          Indicates that Morton ordering is mirror 'N' shaped.
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MortonList()
          Creates the collection assuming a vertical Morton layout.
MortonList(int direction)
          Creates the collection with a Morton layout in the given direction.
 
Method Summary
 E get(int x, int y)
          Returns the object at the given x,y position or null if no object at the given position.
 int getMorton(int x, int y)
          Reports the Morton number representing the given x,y coordinate pair.
 E getNextX(java.lang.Object obj)
          Returns the object that is to the 'right' (x+1) of the first instance of the given reference object or null if no object to the right or if the given reference object not found.
 E getNextY(java.lang.Object obj)
          Returns the object that is 'below' (y+1) the first instance of the given reference object or null if no object below or if the given reference object not found.
 int getX(int mortonNumber)
          Reports the x coordinate of the position represented by the given Morton number.
 int getY(int mortonNumber)
          Reports the y coordinate of the position represented by the given Morton number.
 java.awt.Point positionOf(java.lang.Object obj)
          Returns the x,y position of the first occurrence of the given object in this collection, or null if the collection does not contain the object.
 void resetDirection(int mDirection)
          Clears this collection and sets the given direction for Morton ordering.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

VERTICAL

public static final int VERTICAL
Indicates that Morton ordering is mirror 'N' shaped.

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Indicates that Morton ordering is 'Z' shaped.

See Also:
Constant Field Values
Constructor Detail

MortonList

public MortonList()
Creates the collection assuming a vertical Morton layout.


MortonList

public MortonList(int direction)
Creates the collection with a Morton layout in the given direction.

Parameters:
direction - Direction of layout. Should be one of VERTICAL (mirrored 'N' shaped) or HORIZONTAL ('Z' shaped).
Method Detail

resetDirection

public void resetDirection(int mDirection)
Clears this collection and sets the given direction for Morton ordering.

Parameters:
mDirection - New direction for Morton ordering. Should be one of VERTICAL (mirrored 'N' shaped) or HORIZONTAL ('Z' shaped).

positionOf

public java.awt.Point positionOf(java.lang.Object obj)
Returns the x,y position of the first occurrence of the given object in this collection, or null if the collection does not contain the object.

Parameters:
obj - Object whose position will be reported.
Returns:
2-dimensional position of the object.

get

public E get(int x,
             int y)
Returns the object at the given x,y position or null if no object at the given position. Note that it is not possible to distinguish between a null object at a given position and position that it out of bounds of the current collection.

Parameters:
x - x coordinate of the position from which to retrieve the object.
y - x coordinate of the position from which to retrieve the object.
Returns:
Object at the given position or null if out of bounds or no object.

getNextX

public E getNextX(java.lang.Object obj)
Returns the object that is to the 'right' (x+1) of the first instance of the given reference object or null if no object to the right or if the given reference object not found.

Parameters:
obj - Reference object from which to find its neighbour.
Returns:
Object to the right of the given reference object.

getNextY

public E getNextY(java.lang.Object obj)
Returns the object that is 'below' (y+1) the first instance of the given reference object or null if no object below or if the given reference object not found.

Parameters:
obj - Reference object from which to find its neighbour.
Returns:
Object below the given reference object.

getX

public int getX(int mortonNumber)
Reports the x coordinate of the position represented by the given Morton number.

Parameters:
mortonNumber - Number to process.
Returns:
x coordinate represented by the Morton number.

getY

public int getY(int mortonNumber)
Reports the y coordinate of the position represented by the given Morton number.

Parameters:
mortonNumber - Number to process.
Returns:
y coordinate represented by the Morton number.

getMorton

public int getMorton(int x,
                     int y)
Reports the Morton number representing the given x,y coordinate pair.

Parameters:
x - x coordinate of position to calculate.
y - y coordinate of position to calculate.
Returns:
Morton number representing the given position.


treeMappa V.3.0.1, API documentation generated 4th April, 2011