org.moyoman.debug
Class Legend

java.lang.Object
  |
  +--org.moyoman.debug.Debug
        |
        +--org.moyoman.debug.Legend

public class Legend
extends Debug

This class allows stones or points to be associated with a legend. There is a set of N symbols, and a set of stones or points are associated with the numbers 0 through N - 1. For example, the legend could consist of the three symbols "Forcing Move", "Ko Threat", "Ladder Breaker", and there would be a set of points associated with each. Or there could be the symbols, "Alive", "Dead", "Undetermined", and a set of stones associated with each. Each symbol in the legend may be associated with points or stones, but not both. It is also OK to have a symbol with no points or stones associated with it.


Field Summary
static short NONE
          Value returned by getSymbolType if no points or stones are associated with it.
private  ArrayList points
          Each element is an ArrayList containing Point objects.
static short POINTS
          Value returned by getSymbolType if points are associated with it.
private  ArrayList stones
          Each element is an ArrayList containing Stone objects.
static short STONES
          Value returned by getSymbolType if stones are associated with it.
private  ArrayList symbols
          Each element is a String object.
 
Fields inherited from class org.moyoman.debug.Debug
 
Constructor Summary
Legend(String h)
          Create the Legend object.
 
Method Summary
 void addPoint(Point point, int symbol)
          Associate a point with one of the strings.
 void addPoints(Point[] pt, int symbol)
          Associate points with one of the strings.
 void addStone(Stone stone, int symbol)
          Associate a stone with one of the strings.
 void addStones(Stone[] st, int symbol)
          Associate stones with one of the strings.
 int addSymbol(String symbol)
          Create a new symbol.
 Point[] getPoints(int symbol)
          Get the points associated with a particular symbol.
 Stone[] getStones(int symbol)
          Get the stones associated with a particular symbol.
 String getSymbol(int number)
          Return the string associated with the particular number.
 short getSymbolType(int symbol)
          Determine the type of symbol, either NONE, POINTS, or STONES.
 int getTotalSymbols()
          The total number of symbols in the legend.
 DebugType getType()
          Get the debug type.
 String toString()
          Get a String representation of this object.
 
Methods inherited from class org.moyoman.debug.Debug
getHeaderType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final short NONE
Value returned by getSymbolType if no points or stones are associated with it.

See Also:
Constant Field Values

POINTS

public static final short POINTS
Value returned by getSymbolType if points are associated with it.

See Also:
Constant Field Values

STONES

public static final short STONES
Value returned by getSymbolType if stones are associated with it.

See Also:
Constant Field Values

symbols

private ArrayList symbols
Each element is a String object.


stones

private ArrayList stones
Each element is an ArrayList containing Stone objects.


points

private ArrayList points
Each element is an ArrayList containing Point objects.

Constructor Detail

Legend

public Legend(String h)
Create the Legend object.

Parameters:
h - The header.
Method Detail

addSymbol

public int addSymbol(String symbol)
Create a new symbol.

Parameters:
symbol - The string which is part of the legend.
Returns:
The number of that particular symbol.

getSymbolType

public short getSymbolType(int symbol)
                    throws IndexOutOfBoundsException
Determine the type of symbol, either NONE, POINTS, or STONES.

Parameters:
symbol - - The number of the symbol.
Returns:
A short which is either NONE, POINTS, or STONES.
Throws:
IndexOutOfBoundsException - Thrown if the symbol parameter is invalid.

addStone

public void addStone(Stone stone,
                     int symbol)
              throws IndexOutOfBoundsException,
                     InconsistentStateException
Associate a stone with one of the strings.

Parameters:
stone - The stone to be added.
symbol - The number of the symbol.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.
InconsistentStateException - - Thrown if points have already beena associated with this symbol.

addStones

public void addStones(Stone[] st,
                      int symbol)
               throws IndexOutOfBoundsException,
                      InconsistentStateException
Associate stones with one of the strings.

Parameters:
st - The stones to be added.
symbol - The number of the symbol.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.
InconsistentStateException - - Thrown if points have already beena associated with this symbol.

addPoint

public void addPoint(Point point,
                     int symbol)
              throws IndexOutOfBoundsException,
                     InconsistentStateException
Associate a point with one of the strings.

Parameters:
point - The point to be added.
symbol - The number of the symbol.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.
InconsistentStateException - - Thrown if stones have already beena associated with this symbol.

addPoints

public void addPoints(Point[] pt,
                      int symbol)
               throws IndexOutOfBoundsException,
                      InconsistentStateException
Associate points with one of the strings.

Parameters:
pt - The points to be added.
symbol - The number of the symbol.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.
InconsistentStateException - - Thrown if stones have already beena associated with this symbol.

getSymbol

public String getSymbol(int number)
                 throws IndexOutOfBoundsException
Return the string associated with the particular number.

Parameters:
number - The number of the symbol.
Returns:
The symbol associated with that number. is outside the range of existing symbols.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.

getTotalSymbols

public int getTotalSymbols()
The total number of symbols in the legend.

Returns:
The total number of symbols.

getStones

public Stone[] getStones(int symbol)
                  throws IndexOutOfBoundsException
Get the stones associated with a particular symbol.

Parameters:
symbol - The number of the symbol.
Returns:
An array of stones.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.

getPoints

public Point[] getPoints(int symbol)
                  throws IndexOutOfBoundsException
Get the points associated with a particular symbol.

Parameters:
symbol - The number of the symbol.
Returns:
An array of points.
Throws:
IndexOutOfBoundsException - Thrown if symbol is invalid.

toString

public String toString()
Get a String representation of this object.

Overrides:
toString in class Object
Returns:
A String which represents this object.

getType

public DebugType getType()
Get the debug type.

Specified by:
getType in class Debug
Returns:
DebugType.LEGEND.