algoanim.primitives
Class StringMatrix

java.lang.Object
  extended by algoanim.primitives.Primitive
      extended by algoanim.primitives.MatrixPrimitive
          extended by algoanim.primitives.StringMatrix

public class StringMatrix
extends MatrixPrimitive

StringMatrix manages an internal matrix. Operations on objects of StringMatrix are almost performed like on a simple matrix.

Author:
jens

Field Summary
protected  StringMatrixGenerator generator
          The related StringMatrixGenerator, which is responsible for generating the appropriate scriptcode for operations performed on this object.
 
Fields inherited from class algoanim.primitives.MatrixPrimitive
nrCols, nrRows
 
Fields inherited from class algoanim.primitives.Primitive
gen
 
Constructor Summary
StringMatrix(StringMatrixGenerator iag, Node upperLeftCorner, java.lang.String[][] matrixData, java.lang.String name, DisplayOptions display, MatrixProperties iap)
          Instantiates the StringMatrix and calls the create() method of the associated StringMatrixGenerator.
 
Method Summary
 java.lang.String[][] getData()
          Returns the internal int matrix.
 java.lang.String getElement(int row, int col)
          retrieves the element at position (row, col) if this is legal, else ""
 MatrixProperties getProperties()
          Returns the properties of this matrix.
 java.lang.String[] getRow(int row)
          Returns the data at the given position of the internal matrix.
 Node getUpperLeft()
          Returns the upper left corner of this matrix.
 void highlightCell(int row, int col, Timing offset, Timing duration)
          Highlights the matrix cell at a given position after a distinct offset.
 void highlightCellColumnRange(int row, int startCol, int endCol, Timing offset, Timing duration)
          Highlights a range of array cells of an StringMatrix.
 void highlightCellRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Highlights a range of array cells of an StringMatrix.
 void highlightElem(int row, int col, Timing offset, Timing duration)
          Highlights the matrix element at a given position after a distinct offset.
 void highlightElemColumnRange(int row, int startCol, int endCol, Timing offset, Timing duration)
          Highlights a range of matrix elements.
 void highlightElemRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Highlights a range of array elements of an StringMatrix.
 void put(int row, int col, java.lang.String what, Timing t, Timing d)
          Puts the value what at position [row][col].
 void setName(java.lang.String newName)
          Sets the name of this Primitive.
 void swap(int sourceRow, int sourceCol, int targetRow, int targetCol, Timing t, Timing d)
          Swaps the elements at index [sourceRow][sourceCol] and [targetRow][targetCol].
 void unhighlightCell(int row, int col, Timing offset, Timing duration)
          Unhighlights the array cell of an StringMatrix at a given position after a distinct offset.
 void unhighlightCellColumnRange(int row, int startCol, int endCol, Timing offset, Timing duration)
          Unhighlights a range of array cells of an StringMatrix.
 void unhighlightCellRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Unhighlights a range of array cells of an StringMatrix.
 void unhighlightElem(int row, int col, Timing offset, Timing duration)
          Unhighlights the matrix element at a given position after a distinct offset.
 void unhighlightElemColumnRange(int row, int startCol, int endCol, Timing offset, Timing duration)
          Unhighlights a range of array elements of an StringMatrix.
 void unhighlightElemRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Unhighlights a range of array elements of an StringMatrix.
 
Methods inherited from class algoanim.primitives.MatrixPrimitive
getNrCols, getNrRows
 
Methods inherited from class algoanim.primitives.Primitive
changeColor, exchange, getDisplayOptions, getName, hide, hide, moveBy, moveTo, moveVia, rotate, rotate, show, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generator

protected StringMatrixGenerator generator
The related StringMatrixGenerator, which is responsible for generating the appropriate scriptcode for operations performed on this object.

Constructor Detail

StringMatrix

public StringMatrix(StringMatrixGenerator iag,
                    Node upperLeftCorner,
                    java.lang.String[][] matrixData,
                    java.lang.String name,
                    DisplayOptions display,
                    MatrixProperties iap)
Instantiates the StringMatrix and calls the create() method of the associated StringMatrixGenerator.

Parameters:
iag - the appropriate code Generator.
upperLeftCorner - the upper left corner of this StringMatrix.
matrixData - the data of this StringMatrix.
name - the name of this StringMatrix.
display - [optional] the DisplayOptions of this StringMatrix.
iap - [optional] the properties of this StringMatrix.
Method Detail

getElement

public java.lang.String getElement(int row,
                                   int col)
retrieves the element at position (row, col) if this is legal, else ""

Parameters:
row - the row of the element to be retrieved
col - the column of the element to be retrieved
Returns:
"" if the position is invalid, else the element at that position

put

public void put(int row,
                int col,
                java.lang.String what,
                Timing t,
                Timing d)
         throws java.lang.IndexOutOfBoundsException
Puts the value what at position [row][col]. This is the delayed version as specified by t. The duration of this operation may also be specified.

Parameters:
row - the row position of the element to write.
col - the column position of the element to write.
what - the new value.
t - [optional] the delay which shall be applied to the operation.
d - [optional] the duration this action needs.
Throws:
java.lang.IndexOutOfBoundsException

swap

public void swap(int sourceRow,
                 int sourceCol,
                 int targetRow,
                 int targetCol,
                 Timing t,
                 Timing d)
          throws java.lang.IndexOutOfBoundsException
Swaps the elements at index [sourceRow][sourceCol] and [targetRow][targetCol]. This is the delayed version. The duration of this operation may also be specified.

Parameters:
sourceRow - the row position of the first element to swap.
sourceCol - the column position of the first element to swap.
targetRow - the row position of the second element to swap.
targetCol - the column position of the second element to swap.
t - [optional] the delay which shall be applied to the operation.
d - [optional] the duration this action needs.
Throws:
java.lang.IndexOutOfBoundsException

getData

public java.lang.String[][] getData()
Returns the internal int matrix.

Returns:
the internal int matrix.

getRow

public java.lang.String[] getRow(int row)
                          throws java.lang.IndexOutOfBoundsException
Returns the data at the given position of the internal matrix.

Parameters:
row - the position where to look for the data.
Returns:
the data at position i in the internal int matrix.
Throws:
java.lang.IndexOutOfBoundsException

getUpperLeft

public Node getUpperLeft()
Returns the upper left corner of this matrix.

Returns:
the upper left corner of this matrix.

getProperties

public MatrixProperties getProperties()
Returns the properties of this matrix.

Returns:
the properties of this matrix.

setName

public void setName(java.lang.String newName)
Description copied from class: Primitive
Sets the name of this Primitive.

Overrides:
setName in class Primitive
Parameters:
newName - the new name for this Primitive.
See Also:
Primitive.setName(java.lang.String)

highlightCell

public void highlightCell(int row,
                          int col,
                          Timing offset,
                          Timing duration)
Highlights the matrix cell at a given position after a distinct offset.

Parameters:
row - the row of the cell to highlight.
col - the column of the cell to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

highlightCellColumnRange

public void highlightCellColumnRange(int row,
                                     int startCol,
                                     int endCol,
                                     Timing offset,
                                     Timing duration)
Highlights a range of array cells of an StringMatrix.

Parameters:
row - the row of the interval to highlight.
startCol - the start column of the interval to highlight.
endCol - the end column of the interval to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

highlightCellRowRange

public void highlightCellRowRange(int startRow,
                                  int endRow,
                                  int col,
                                  Timing offset,
                                  Timing duration)
Highlights a range of array cells of an StringMatrix.

Parameters:
startRow - the start row of the interval to highlight.
endRow - the end row of the interval to highlight.
col - the column of the interval to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

unhighlightCell

public void unhighlightCell(int row,
                            int col,
                            Timing offset,
                            Timing duration)
Unhighlights the array cell of an StringMatrix at a given position after a distinct offset.

Parameters:
row - the row position of the cell to unhighlight.
col - the column position of the cell to unhighlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

unhighlightCellColumnRange

public void unhighlightCellColumnRange(int row,
                                       int startCol,
                                       int endCol,
                                       Timing offset,
                                       Timing duration)
Unhighlights a range of array cells of an StringMatrix.

Parameters:
row - the row of the interval to highlight.
startCol - the start column of the interval to highlight.
endCol - the end column of the interval to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

unhighlightCellRowRange

public void unhighlightCellRowRange(int startRow,
                                    int endRow,
                                    int col,
                                    Timing offset,
                                    Timing duration)
Unhighlights a range of array cells of an StringMatrix.

Parameters:
startRow - the start row of the interval to highlight.
endRow - the end row of the interval to highlight.
col - the column of the interval to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

highlightElem

public void highlightElem(int row,
                          int col,
                          Timing offset,
                          Timing duration)
Highlights the matrix element at a given position after a distinct offset.

Parameters:
row - the row of the element to highlight.
col - the column of the element to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

highlightElemColumnRange

public void highlightElemColumnRange(int row,
                                     int startCol,
                                     int endCol,
                                     Timing offset,
                                     Timing duration)
Highlights a range of matrix elements.

Parameters:
row - the row of the interval to highlight.
startCol - the start of the column interval to highlight.
endCol - the end of the column interval to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

highlightElemRowRange

public void highlightElemRowRange(int startRow,
                                  int endRow,
                                  int col,
                                  Timing offset,
                                  Timing duration)
Highlights a range of array elements of an StringMatrix.

Parameters:
startRow - the start of the row interval to highlight.
endRow - the end of the row interval to highlight.
col - the column interval to highlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

unhighlightElem

public void unhighlightElem(int row,
                            int col,
                            Timing offset,
                            Timing duration)
Unhighlights the matrix element at a given position after a distinct offset.

Parameters:
row - the row of the element to unhighlight.
col - the column of the element to unhighlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

unhighlightElemColumnRange

public void unhighlightElemColumnRange(int row,
                                       int startCol,
                                       int endCol,
                                       Timing offset,
                                       Timing duration)
Unhighlights a range of array elements of an StringMatrix.

Parameters:
row - the row of the interval to unhighlight.
startCol - the start of the column interval to unhighlight.
endCol - the end of the column interval to unhighlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.

unhighlightElemRowRange

public void unhighlightElemRowRange(int startRow,
                                    int endRow,
                                    int col,
                                    Timing offset,
                                    Timing duration)
Unhighlights a range of array elements of an StringMatrix.

Parameters:
startRow - the start row of the interval to unhighlight.
endRow - the end row of the interval to unhighlight.
col - the column interval to unhighlight.
offset - [optional] the offset after which the operation shall be started.
duration - [optional] the duration this operation lasts.