algoanim.primitives
Class DoubleMatrix

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

public class DoubleMatrix
extends MatrixPrimitive

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

Author:
jens

Field Summary
protected  DoubleMatrixGenerator generator
          The related DoubleMatrixGenerator, 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
DoubleMatrix(DoubleMatrixGenerator iag, Node upperLeftCorner, double[][] matrixData, java.lang.String name, DisplayOptions display, MatrixProperties iap)
          Instantiates the DoubleMatrix and calls the create() method of the associated DoubleMatrixGenerator.
 
Method Summary
 double[][] getData()
          Returns the internal double matrix.
 double getElement(int row, int col)
           
 MatrixProperties getProperties()
          Returns the properties of this matrix.
 double[] 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 DoubleMatrix.
 void highlightCellRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Highlights a range of array cells of an DoubleMatrix.
 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 DoubleMatrix.
 void put(int row, int col, double 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 DoubleMatrix 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 DoubleMatrix.
 void unhighlightCellRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Unhighlights a range of array cells of an DoubleMatrix.
 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 DoubleMatrix.
 void unhighlightElemRowRange(int startRow, int endRow, int col, Timing offset, Timing duration)
          Unhighlights a range of array elements of an DoubleMatrix.
 
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 DoubleMatrixGenerator generator
The related DoubleMatrixGenerator, which is responsible for generating the appropriate scriptcode for operations performed on this object.

Constructor Detail

DoubleMatrix

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

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

getElement

public double getElement(int row,
                         int col)

put

public void put(int row,
                int col,
                double 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 double[][] getData()
Returns the internal double matrix.

Returns:
the internal double matrix.

getRow

public double[] 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 double 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 DoubleMatrix.

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 DoubleMatrix.

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 DoubleMatrix 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 DoubleMatrix.

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 DoubleMatrix.

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 DoubleMatrix.

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 DoubleMatrix.

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 DoubleMatrix.

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.