algoanim.primitives
Class IntArray

java.lang.Object
  extended by algoanim.primitives.Primitive
      extended by algoanim.primitives.ArrayPrimitive
          extended by algoanim.primitives.IntArray

public class IntArray
extends ArrayPrimitive

IntArray manages an internal array. Operations on objects of IntArray are almost performed like on a simple array.

Author:
jens

Field Summary
protected  IntArrayGenerator generator
          The related IntArrayGenerator, which is responsible for generating the appropriate scriptcode for operations performed on this object.
 
Fields inherited from class algoanim.primitives.ArrayPrimitive
length
 
Fields inherited from class algoanim.primitives.Primitive
gen
 
Constructor Summary
IntArray(IntArrayGenerator iag, Node upperLeftCorner, int[] arrayData, java.lang.String name, ArrayDisplayOptions display, ArrayProperties iap)
          Instantiates the IntArray and calls the create() method of the associated IntArrayGenerator.
 
Method Summary
 int[] getData()
          Returns the internal int array.
 int getData(int i)
          Returns the data at the given position of the internal array.
 ArrayProperties getProperties()
          Returns the properties of this array.
 Node getUpperLeft()
          Returns the upper left corner of this array.
 void highlightCell(int from, int to, Timing offset, Timing duration)
          Highlights a range of array cells.
 void highlightCell(int position, Timing offset, Timing duration)
          Highlights the array cell at a given position after a distinct offset.
 void highlightElem(int from, int to, Timing offset, Timing duration)
          Highlights a range of array elements.
 void highlightElem(int position, Timing offset, Timing duration)
          Highlights the array element at a given position after a distinct offset.
 void put(int where, int what, Timing t, Timing d)
          Puts the value what at position where.
 void setName(java.lang.String newName)
          Sets the name of this Primitive.
 void swap(int what, int with, Timing t, Timing d)
          Swaps the elements at index what and with.
 void unhighlightCell(int from, int to, Timing offset, Timing duration)
          Unhighlights a range of array cells.
 void unhighlightCell(int position, Timing offset, Timing duration)
          Unhighlights the array cell at a given position after a distinct offset.
 void unhighlightElem(int from, int to, Timing offset, Timing duration)
          Unhighlights a range of array elements.
 void unhighlightElem(int position, Timing offset, Timing duration)
          Unhighlights the array element at a given position after a distinct offset.
 
Methods inherited from class algoanim.primitives.ArrayPrimitive
getLength
 
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 IntArrayGenerator generator
The related IntArrayGenerator, which is responsible for generating the appropriate scriptcode for operations performed on this object.

Constructor Detail

IntArray

public IntArray(IntArrayGenerator iag,
                Node upperLeftCorner,
                int[] arrayData,
                java.lang.String name,
                ArrayDisplayOptions display,
                ArrayProperties iap)
Instantiates the IntArray and calls the create() method of the associated IntArrayGenerator.

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

put

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

Parameters:
where - the index 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 what,
                 int with,
                 Timing t,
                 Timing d)
          throws java.lang.IndexOutOfBoundsException
Swaps the elements at index what and with. This is the delayed version. The duration of this operation may also be specified.

Specified by:
swap in class ArrayPrimitive
Parameters:
what - first element to swap.
with - 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 int[] getData()
Returns the internal int array.

Returns:
the internal int array.

getData

public int getData(int i)
            throws java.lang.IndexOutOfBoundsException
Returns the data at the given position of the internal array.

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

getUpperLeft

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

Returns:
the upper left corner of this array.

getProperties

public ArrayProperties getProperties()
Returns the properties of this array.

Returns:
the properties of this array.

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 position,
                          Timing offset,
                          Timing duration)
Highlights the array cell at a given position after a distinct offset.

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

highlightCell

public void highlightCell(int from,
                          int to,
                          Timing offset,
                          Timing duration)
Highlights a range of array cells.

Parameters:
from - the start of the interval to highlight.
to - the end 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 position,
                            Timing offset,
                            Timing duration)
Unhighlights the array cell at a given position after a distinct offset.

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

unhighlightCell

public void unhighlightCell(int from,
                            int to,
                            Timing offset,
                            Timing duration)
Unhighlights a range of array cells.

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

highlightElem

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

Parameters:
position - the position of the element 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 from,
                          int to,
                          Timing offset,
                          Timing duration)
Highlights a range of array elements.

Parameters:
from - the start of the interval to highlight.
to - the end of the 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 position,
                            Timing offset,
                            Timing duration)
Unhighlights the array element at a given position after a distinct offset.

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

unhighlightElem

public void unhighlightElem(int from,
                            int to,
                            Timing offset,
                            Timing duration)
Unhighlights a range of array elements.

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