exe
Class GAIGSlegend

java.lang.Object
  extended by exe.GAIGSbase
      extended by exe.GAIGSlegend
All Implemented Interfaces:
GAIGSdatastr

public class GAIGSlegend
extends GAIGSbase

This class provides support for a color legend structure that can be used to show the meanings of the various colors used in GAIGS visualizations. The class is implemented similarly to the GAIGSarray class and uses a two-dimensional array of GAIGSItem objects to store the color and text information for each element in the color key. Each element in the color key is displayed as a box containing the color for that element with the text for that element appearing to the right of the box. Multiple lines are allowed in the text that is displayed, but using too many lines for the labels may force the text to shrink to fit into the available space. Note also that, since the legend structure will likely be displayed in a small portion of the screen, the fontsize will usually have to be increased to keep the labels readable when the structure is localized to its small subset of the screen's area. Each GAIGSItem element in the key is initialized to null so any element that is not set with a value will not be displayed when the key is shown on the screen.

Version:
1.0 (3 July 2006)
Author:
Andrew Jungwirth

Field Summary
 
Fields inherited from interface exe.GAIGSdatastr
DEFAULT_COLOR, DEFAULT_FONT_SIZE, DEFAULT_NAME, DEFAULT_X1, DEFAULT_X2, DEFAULT_Y1, DEFAULT_Y2
 
Constructor Summary
GAIGSlegend(int rows, int columns)
          Constructor that sets only the number of elements in the key and uses default values for all other fields.
GAIGSlegend(int rows, int columns, double fontsize)
          Constructor that sets the number of elements in the key and the key's font size and uses default values for all other fields.
GAIGSlegend(int rows, int columns, double x1, double y1, double x2, double y2)
          Constructor that sets the number of elements in the key and the bounds for the key and uses default values for all other fields.
GAIGSlegend(int rows, int columns, java.lang.String name)
          Constructor that sets the number of elements in the key and the key's name and uses default values for all other fields.
GAIGSlegend(int rows, int columns, java.lang.String name, double fontsize)
          Constructor that sets the number of elements in the key and the key's name and font size and uses default values for the bounds.
GAIGSlegend(int rows, int columns, java.lang.String name, double x1, double y1, double x2, double y2, double fontsize)
          Constructor that explicitly sets all the values for this legend.
 
Method Summary
 void disableBox()
          Disables the drawing of the surroudning box for the legend
 void enableBox()
          Enables the drawing of the surrounding box for the legend
 int getColumns()
          Gives the number of columns in this legend structure.
 double getFontSize()
          Gives the font size for the text labels in this legend.
 GAIGSItem getItem(int row, int column)
          Returns the item from this legend at the index specified.
 java.lang.String getName()
          Returns the name of this legend structure.
 double getNameFontSize()
          Returns the font size for this legend's name (can be sized independently from the text size used for labels within the legend).
 int getRows()
          Gives the number of rows in this legend structure.
 double getX1()
          Returns the left x-bound of this legend.
 double getX2()
          Returns the right x-bound of this legend.
 double getY1()
          Returns the lower y-bound of this legend.
 double getY2()
          Returns the upper y-bound of this legend.
 void setBounds(double x1, double y1, double x2, double y2)
          Sets the bounds for this GAIGSlegend object.
 void setFontSize(double fontsize)
          Sets the font size used for the text labels in this GAIGSlegend.
 void setItem(int row, int column, GAIGSItem item)
          Sets the item in this legend at the index specified.
 void setName(java.lang.String name)
          Sets the name for this legend.
 void setNameFontSize(double name_fontsize)
          Sets the font size used to display this legend's name (can be sized independently from the text size used for labels within the legend).
 java.lang.String toXML()
          Returns the GAIGS XML representation of this GAIGSlegend object as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GAIGSlegend

public GAIGSlegend(int rows,
                   int columns)
Constructor that sets only the number of elements in the key and uses default values for all other fields.

Parameters:
rows - The number of rows in the color key.
columns - The number of columns in the color key.

GAIGSlegend

public GAIGSlegend(int rows,
                   int columns,
                   java.lang.String name)
Constructor that sets the number of elements in the key and the key's name and uses default values for all other fields.

Parameters:
rows - The number of rows in the color key.
columns - The number of columns in the color key.
name - The name of the color key.

GAIGSlegend

public GAIGSlegend(int rows,
                   int columns,
                   double fontsize)
Constructor that sets the number of elements in the key and the key's font size and uses default values for all other fields.

Parameters:
rows - The number of rows in the color key.
columns - The number of columns in the color key.
fontsize - The font size for the text in this legend.

GAIGSlegend

public GAIGSlegend(int rows,
                   int columns,
                   java.lang.String name,
                   double fontsize)
Constructor that sets the number of elements in the key and the key's name and font size and uses default values for the bounds.

Parameters:
rows - The number of rows in the color key.
columns - The number of columns in the color key.
name - The name of the color key.
fontsize - The font size for the text in this legend.

GAIGSlegend

public GAIGSlegend(int rows,
                   int columns,
                   double x1,
                   double y1,
                   double x2,
                   double y2)
Constructor that sets the number of elements in the key and the bounds for the key and uses default values for all other fields.

Parameters:
rows - The number of rows in the color key.
columns - The number of columns in the color key.
x1 - The left boundary of the legend (usually in [0,1]).
y1 - The lower boundary of the legend (usually in [0,1]).
x2 - The right boundary of the legend (usually in [0,1]).
y2 - The upper boundary of the legend (usually in [0,1]).

GAIGSlegend

public GAIGSlegend(int rows,
                   int columns,
                   java.lang.String name,
                   double x1,
                   double y1,
                   double x2,
                   double y2,
                   double fontsize)
Constructor that explicitly sets all the values for this legend.

Parameters:
rows - The number of rows in the color key.
columns - The number of columns in the color key.
name - The name of the color key.
x1 - The left boundary of the legend (usually in [0,1]).
y1 - The lower boundary of the legend (usually in [0,1]).
x2 - The right boundary of the legend (usually in [0,1]).
y2 - The upper boundary of the legend (usually in [0,1]).
fontsize - The font size for the text in this legend.
Method Detail

getItem

public GAIGSItem getItem(int row,
                         int column)
Returns the item from this legend at the index specified.

Parameters:
row - The row index of the GAIGSItem to be returned.
column - The column index of the GAIGSItem to be returned.
Returns:
The GAIGSItem at index [row][column] in the internal array that represents this GAIGSlegend. If this index is out of the bounds given to the array when this GAIGSlegend was created, then null is returned.

getRows

public int getRows()
Gives the number of rows in this legend structure.

Returns:
The number of rows allocated for this legend.

getColumns

public int getColumns()
Gives the number of columns in this legend structure.

Returns:
The number of columns allocated for this legend.

getName

public java.lang.String getName()
Returns the name of this legend structure.

Specified by:
getName in interface GAIGSdatastr
Overrides:
getName in class GAIGSbase
Returns:
The name for this GAIGSlegend object.

getNameFontSize

public double getNameFontSize()
Returns the font size for this legend's name (can be sized independently from the text size used for labels within the legend).

Returns:
The font size used for the name for this GAIGSlegend object.

getX1

public double getX1()
Returns the left x-bound of this legend.

Returns:
The left x-coordinate of the bounds for this GAIGSlegend object.

getY1

public double getY1()
Returns the lower y-bound of this legend.

Returns:
The lower y-coordinate of the bounds for this GAIGSlegend object.

getX2

public double getX2()
Returns the right x-bound of this legend.

Returns:
The right x-coordinate of the bounds for this GAIGSlegend object.

getY2

public double getY2()
Returns the upper y-bound of this legend.

Returns:
The upper y-coordinate of the bounds for this GAIGSlegend object.

getFontSize

public double getFontSize()
Gives the font size for the text labels in this legend.

Returns:
The font size for the labels next to the boxes in this object.

setItem

public void setItem(int row,
                    int column,
                    GAIGSItem item)
Sets the item in this legend at the index specified.

Parameters:
row - The row index of the GAIGSItem to be set.
column - The column index of the GAIGSItem to be set.
item - The GAIGSItem to be stored at the index [row][column] in the internal array that represents this GAIGSlegend. If this index is out of the bounds that were given to this array when this GAIGSlegend was created, then this method returns without doing anything.

setName

public void setName(java.lang.String name)
Sets the name for this legend.

Specified by:
setName in interface GAIGSdatastr
Overrides:
setName in class GAIGSbase
Parameters:
name - The new name String for this GAIGSlegend object.

setNameFontSize

public void setNameFontSize(double name_fontsize)
Sets the font size used to display this legend's name (can be sized independently from the text size used for labels within the legend). The name's font size is initialized to the font size for the labels within the legend by the constructor and can only be changed by calling this method.

Parameters:
name_fontsize - The new font size for the name of this GAIGSlegend object.

setBounds

public void setBounds(double x1,
                      double y1,
                      double x2,
                      double y2)
Sets the bounds for this GAIGSlegend object.

Parameters:
x1 - The new left x-coordinate for the bounds of this legend.
y1 - The new lower y-coordinate for the bounds of this legend.
x2 - The new right x-coordinate for the bounds of this legend.
y2 - The new upper y-coordinate for the bounds of this legend.

setFontSize

public void setFontSize(double fontsize)
Sets the font size used for the text labels in this GAIGSlegend.

Parameters:
fontsize - The new font size for labels in this legend.

enableBox

public void enableBox()
Enables the drawing of the surrounding box for the legend


disableBox

public void disableBox()
Disables the drawing of the surroudning box for the legend


toXML

public java.lang.String toXML()
Returns the GAIGS XML representation of this GAIGSlegend object as a String.

Returns:
A String containing the GAIGS XML representation of this GAIGSlegend object.