ewe.util
Class Grid

java.lang.Object
  extended byewe.data.DataObject
      extended byewe.util.Vector
          extended byewe.util.Grid
All Implemented Interfaces:
Comparable, Copyable, DataUnit

public class Grid
extends Vector

A Grid is a way of storing a 2-D collection of objects. Objects are either added left to right and top to bottom OR an explicit row and column can be set.

When adding sequentially call the add(Object what,boolean lastInRow) method to add an object to the end of the current row. End a row either by calling endRow() or by setting "lastInRow" true when adding the last object to the row.


Field Summary
 int columns
          This holds the number of columns in the Grid.
 int rows
          This holds the number of rows in the Grid.
 
Constructor Summary
Grid()
           
 
Method Summary
 Object add(Object what, boolean lastInRow)
          Add the object to the current row.
 void addAll(Vector what)
          Add all elements of the Vector parameter to the current row.
protected  Object addToRow(Vector row, Object what)
           
 void clear()
          Clear the entire grid.
 void endRow()
          End the current row - all future add() calls will add objects to a new row.
 Vector getMostCurrentRow()
          Return the Vector which represents the row which is currently being added to (you are hardly likely to use this method).
 Object objectAt(int index)
          Return the Object stored at the index.
 Object objectAt(int row, int column)
          Return the Object stored at the specified row and column.
 void set(int row, int column, Object what)
          Set the Object at a particluar row and column.
 
Methods inherited from class ewe.util.Vector
add, add, add, addAll, addAll, addCopiesFrom, addElement, compare, contains, copyCopiesFrom, copyFrom, copyInto, copyInto, del, elementAt, elements, find, find, get, getCount, getFullCopy, insert, insertElementAt, isEmpty, iterator, iterator, pop, push, remove, removeAllElements, removeElementAt, set, setElementAt, setSize, size, sort, sort, toArray, toArray, toObjectArray, toString, zero
 
Methods inherited from class ewe.data.DataObject
_getSetField, appendAllFields, compareTo, copied, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode
 

Field Detail

columns

public int columns
This holds the number of columns in the Grid. Only read this value, do not set it.


rows

public int rows
This holds the number of rows in the Grid. Only read this value, do not set it.

Constructor Detail

Grid

public Grid()
Method Detail

addToRow

protected Object addToRow(Vector row,
                          Object what)

endRow

public void endRow()
End the current row - all future add() calls will add objects to a new row.


add

public Object add(Object what,
                  boolean lastInRow)
Add the object to the current row. If lastInRow is true, the current row will be ended after the object is added.


addAll

public void addAll(Vector what)
Add all elements of the Vector parameter to the current row.

Overrides:
addAll in class Vector

clear

public void clear()
Clear the entire grid.

Overrides:
clear in class Vector

objectAt

public Object objectAt(int index)
Return the Object stored at the index. The row for the index will be index/columns and the column will be index%columns.


objectAt

public Object objectAt(int row,
                       int column)
Return the Object stored at the specified row and column.


getMostCurrentRow

public Vector getMostCurrentRow()
Return the Vector which represents the row which is currently being added to (you are hardly likely to use this method).


set

public void set(int row,
                int column,
                Object what)
Set the Object at a particluar row and column.