ls
Class ChanceBlock

java.lang.Object
  |
  +--ls.Block
        |
        +--ls.ChanceBlock

public class ChanceBlock
extends Block

This class inherits all of the functionality of the Block class. It is then specalized to be a probability node, and thus it holds the names and values associated with different probabilities.


Constructor Summary
ChanceBlock()
          An empty constructor.
ChanceBlock(java.lang.String name, int x, int y, boolean isnew)
          Constructs a new Chance block with a given name and location.
 
Method Summary
 void add()
          Adds a new state to the current node.
 void add(java.lang.String name)
          Adds a new state to the node.
 void delete(int loc)
          Deletes the state at the corresponding location in the LinkedList.
 java.util.LinkedList getAttributeNames()
          Returns a LinkedList of the state names
 java.util.LinkedList getAttributeValues()
          Returns a LinkedList of the state values
 int getColumns()
          Gets the number of columns that the array of probabilities is currently using.
 int getRows()
          Gets the number of rows that the array of probabilities is using, this does the same thing as numAttributes.
 int getTotalColumns()
          Returns the total number of columns in the array that this particular ChanceBlock has access to.
 double getValue(int irow, int icolumn)
          Gets the corresponding value in the probability table
 int numAttributes()
          Returns the number of states this node has, it does the same thing that getRows does
 void setAttributeName(java.lang.String name, int loc)
          Sets the name of a state at a specific location in the LinkedList of names.
 void setAttributeValue(java.lang.Double value, int loc)
          Sets the value of a state at a specific location in the LinkedList of values.
 void setColumns(int numcolumns)
          Changes how many columns in the probability table.
 void setValue(double item, int irow, int icolumn)
          Sets the corresponding value in the probability table to the value that is being passed in.
 void setValues(double[][] values, int columns)
          Stores all of the probabilites of the corresponding linked list
 void shrinkTable(int numattributes, int offset)
          This function allows the tables to shrink when a node has been deleted.
 
Methods inherited from class ls.Block
getBlockName, getType, getx, gety, setBlockName, setCoordinates, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChanceBlock

public ChanceBlock()
An empty constructor.

ChanceBlock

public ChanceBlock(java.lang.String name,
                   int x,
                   int y,
                   boolean isnew)
Constructs a new Chance block with a given name and location.
Parameters:
name - the name of this chance block
x - the inital x location of this block
y - the inital y location of this block
innew - a boolean that tells if this is a node that is being loaded from a file or if it is one the user has created
Method Detail

numAttributes

public int numAttributes()
Returns the number of states this node has, it does the same thing that getRows does
Returns:
num - the number states this block is associated with
See Also:

getAttributeNames

public java.util.LinkedList getAttributeNames()
Returns a LinkedList of the state names
Returns:
varnames - a LinkedList that contains the state names

getAttributeValues

public java.util.LinkedList getAttributeValues()
Returns a LinkedList of the state values
Returns:
varvalues - a LinkeList that contains the state values

setAttributeName

public void setAttributeName(java.lang.String name,
                             int loc)
Sets the name of a state at a specific location in the LinkedList of names.
Parameters:
name - the name to be set
loc - the location in the LinkedList to set the name to

setAttributeValue

public void setAttributeValue(java.lang.Double value,
                              int loc)
Sets the value of a state at a specific location in the LinkedList of values.
Parameters:
value - the value to be set
loc - the location in the LinkedList to set the value to

add

public void add()
Adds a new state to the current node.
See Also:
add

add

public void add(java.lang.String name)
Adds a new state to the node. This method is only called directly when a file is being loaded into the editor.
Parameters:
name - the name of the state that is being added
See Also:
add

delete

public void delete(int loc)
Deletes the state at the corresponding location in the LinkedList.
Parameters:
loc - the location of the state to delete

setValues

public void setValues(double[][] values,
                      int columns)
Stores all of the probabilites of the corresponding linked list
Parameters:
values - a two dimensinal array in which the rows represent the number of attributes that this particular node has, the columns represent the number of possible combinations that these can be recongized in
across - the number of rows across in the array

getRows

public int getRows()
Gets the number of rows that the array of probabilities is using, this does the same thing as numAttributes.
Returns:
num - the number of attributes this node has
See Also:

getColumns

public int getColumns()
Gets the number of columns that the array of probabilities is currently using.
Returns:
numcolumns - the number of columns that are filled in

getTotalColumns

public int getTotalColumns()
Returns the total number of columns in the array that this particular ChanceBlock has access to.
Returns:
columns - the number of columns in the array

setColumns

public void setColumns(int numcolumns)
Changes how many columns in the probability table.
Parameters:
columns - the number that are currently being used

getValue

public double getValue(int irow,
                       int icolumn)
Gets the corresponding value in the probability table
Parameters:
irow - the row the value is in
icolumn - the column the value is in
Returns:
values[irow][icolumn] - the value at this location

setValue

public void setValue(double item,
                     int irow,
                     int icolumn)
Sets the corresponding value in the probability table to the value that is being passed in. This function is called when the Edit Panes recongizes that something has been updated.
Parameters:
item - the new value of the table
irow - the row that corresponds to the new value
icolumn - the column that corresponds to the new value

shrinkTable

public void shrinkTable(int numattributes,
                        int offset)
This function allows the tables to shrink when a node has been deleted.
Parameters:
numattributes - the number of attributes that need to be collapsed into one
offset - the number that is inbetween these attributes that need to be shrank