exe
Class GAIGSnewArray

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

public class GAIGSnewArray
extends GAIGSbase

GAIGSnewArray provides the ability to implement a one or two dimensional array and also create GAIGS visualizations of its state. Use the various constructors to specify the general parameters for the array visualization, and use the toXML method to actually generate the array XML for snapshots. The display mode can be as an array or as a bar graph. In the case of a bar graph the stored items must be integers (or bad things will happen!).

Unlike standard Java, where all arrays are really one dimensional arrays, a GAIGSnewArray is a two dimensional array, whether treated like one or not. If a 1-d array is constructed, a 2-d array is allocated with just one column. The getter and setter methods take one or two parameters, allowing the array to be treated as 1-d or 2-d. Row and column labels are also supported.

Methods are also provided to set and get the presentation color of an array cell. A default array cell color can be set by using the appropriate constructor.

Version:
6/6/2010
Author:
Shawn Recker

Nested Class Summary
protected  class GAIGSnewArray.BoxPair
           
 
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
GAIGSnewArray(int rows)
          Create a "1-d" array of length rows, using default parameters for all other instance variables.
GAIGSnewArray(int rows, int cols)
          Create a "2-d" array of dimensions rows x cols, using default parameters for all other instance variables.
GAIGSnewArray(int rows, int cols, java.lang.String name, java.lang.String color, double x1, double y1, double x2, double y2)
          Create a "2-d" array of dimensions rows x cols, setting all the instance variables.
GAIGSnewArray(int rows, java.lang.String name, java.lang.String color, double x1, double y1, double x2, double y2, double fontSize)
          Create a "1-d" array of length rows using default parameters for all other instance variables..
 
Method Summary
 java.lang.Object get(int r)
          Return the value at location r.
 java.lang.Object get(int r, int c)
          Return the value at location r,c.
 java.lang.String getColLabel(java.lang.String label, int c)
          Get the label of column c.
 java.lang.String getColor(int r)
          Return the color at location r.
 java.lang.String getColor(int r, int c)
          Return the color at location r,c.
 double[] getCornerPoints(int re, int ce)
          Get the corner points making up the box around the element
 java.lang.String getRowLabel(int r)
          Get the label of row r.
 void set(java.lang.Object item, int r)
          Set location r to value item.
 void set(java.lang.Object item, int r, int c)
          Set location r,c to value item.
 void set(java.lang.Object item, int r, int c, java.lang.String cl)
          Set location r,c to value itemusing color cl.
 void set(java.lang.Object item, int r, java.lang.String cl)
          Set location r to value item using color cl.
 void setColLabel(java.lang.String label, int c)
          Set the label of column c.
 void setColor(int r, int c, java.lang.String co)
          Set the color of location r,c.
 void setColor(int r, java.lang.String co)
          Set the color of location r.
 void setRowLabel(java.lang.String label, int r)
          Set the label of row r.
 java.lang.String toXML()
          Creates and returns GAIGS XML code for the current state of the array.
 
Methods inherited from class exe.GAIGSbase
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GAIGSnewArray

public GAIGSnewArray(int rows)
Create a "1-d" array of length rows, using default parameters for all other instance variables.

Parameters:
rows - The length of this array.

GAIGSnewArray

public GAIGSnewArray(int rows,
                     java.lang.String name,
                     java.lang.String color,
                     double x1,
                     double y1,
                     double x2,
                     double y2,
                     double fontSize)
Create a "1-d" array of length rows using default parameters for all other instance variables..

Parameters:
rows - The length of this array.
name - Display name of this structure.
color - Color for items unless locally overridden.
x1 - Left display bound.
y1 - Bottom display bound.
x2 - Top display bound.
y2 - Right display bound.
fontSize - Font size for display.

GAIGSnewArray

public GAIGSnewArray(int rows,
                     int cols)
Create a "2-d" array of dimensions rows x cols, using default parameters for all other instance variables.

Parameters:
rows - The number of rows in this array.
cols - The number of columns in this array.

GAIGSnewArray

public GAIGSnewArray(int rows,
                     int cols,
                     java.lang.String name,
                     java.lang.String color,
                     double x1,
                     double y1,
                     double x2,
                     double y2)
Create a "2-d" array of dimensions rows x cols, setting all the instance variables.

Parameters:
rows - The length of this array.
cols - The number of columns in this array.
name - Display name of this structure.
color - Color for items unless locally overridden.
x1 - Left display bound.
y1 - Bottom display bound.
x2 - Top display bound.
y2 - Right display bound.
fontSize - Font size for display.
Method Detail

get

public java.lang.Object get(int r)
Return the value at location r. A "1-d" method.

Parameters:
r - The location to be accessed.
Returns:
The object at that location

get

public java.lang.Object get(int r,
                            int c)
Return the value at location r,c. A "2-d" method.

Parameters:
r - The row to be accessed.
c - The col to be accessed.
Returns:
The object at that location

set

public void set(java.lang.Object item,
                int r)
Set location r to value item. Default color will be used for this item. A "1-d" method.

Parameters:
item - The value to be stored.
r - The location to be set.

set

public void set(java.lang.Object item,
                int r,
                java.lang.String cl)
Set location r to value item using color cl. A "1-d" method.

Parameters:
item - The value to be stored.
r - The location to be set.
cl - The color for the value.

set

public void set(java.lang.Object item,
                int r,
                int c)
Set location r,c to value item. Default color will be used for this item. A "2-d" method.

Parameters:
item - The value to be stored.
r - The row location to be set.
c - The col location to be set.

set

public void set(java.lang.Object item,
                int r,
                int c,
                java.lang.String cl)
Set location r,c to value itemusing color cl. A "2-d" method.

Parameters:
item - The value to be stored.
r - The row location to be set.
c - The col location to be set.
cl - The color for the value.

getColor

public java.lang.String getColor(int r)
Return the color at location r. A "1-d" method.

Parameters:
r - The location to be accessed.
Returns:
The color at the location

getColor

public java.lang.String getColor(int r,
                                 int c)
Return the color at location r,c. A "2-d" method.

Parameters:
r - The row to be accessed.
c - The col to be accessed.
Returns:
The color at the location

setColor

public void setColor(int r,
                     java.lang.String co)
Set the color of location r. A "1-d" method.

Parameters:
r - The location to be set.
co - The color to be stored.

setColor

public void setColor(int r,
                     int c,
                     java.lang.String co)
Set the color of location r,c. A "2-d" method.

Parameters:
r - The row location to be set.
c - The col location to be set.
co - The color for the value.

getRowLabel

public java.lang.String getRowLabel(int r)
Get the label of row r. The row labels are also used as the labels for the bars in the bargraph representation of a one-dimensional array.

Parameters:
r - The row.
Returns:
The label of the row

getColLabel

public java.lang.String getColLabel(java.lang.String label,
                                    int c)
Get the label of column c.

Parameters:
c - The column.
Returns:
The label of the column

setRowLabel

public void setRowLabel(java.lang.String label,
                        int r)
Set the label of row r. This method is also used to set the labels for each bar in the bargraph representation of a one-dimensional array.

Parameters:
label - The label.
r - The row.

setColLabel

public void setColLabel(java.lang.String label,
                        int c)
Set the label of column c.

Parameters:
label - The label.
c - The column.

getCornerPoints

public double[] getCornerPoints(int re,
                                int ce)
Get the corner points making up the box around the element

Parameters:
re - The row element.
ce - The column element.
Returns:
An array containing the corner points as x,y pairs. First pair is the bottom left, then bottom right, then top right, then top left

toXML

public java.lang.String toXML()
Creates and returns GAIGS XML code for the current state of the array.

Returns:
A String containing GAIGS XML code for the array