algoanim.primitives
Class ConceptualStack<T>

java.lang.Object
  extended by algoanim.primitives.Primitive
      extended by algoanim.primitives.VisualStack<T>
          extended by algoanim.primitives.ConceptualStack<T>

public class ConceptualStack<T>
extends VisualStack<T>

Represents a stack which has an usual LIFO-functionality and will be visualized as a conceptual stack.
The stored objects are of the generic data type T, so it is generally possible to use ConceptualStack with any objects.

Author:
Dima Vronskyi

Field Summary
 
Fields inherited from class algoanim.primitives.Primitive
gen
 
Constructor Summary
ConceptualStack(ConceptualStackGenerator<T> csg, Node upperLeftCorner, java.util.List<T> content, java.lang.String name, DisplayOptions display, StackProperties sp)
          Instantiates the ConceptualStack and calls the create() method of the associated ConceptualStackGenerator.
 
Method Summary
 void highlightTopCell(Timing delay, Timing duration)
          Highlights the cell which contains the top element of the stack.
 void highlightTopElem(Timing delay, Timing duration)
          Highlights the top element of the stack.
 boolean isEmpty(Timing delay, Timing duration)
          Tests if the stack is empty.
This is the delayed version as specified by delay.
 T pop(Timing delay, Timing duration)
          Removes and returns the element at the top of the stack.
This is the delayed version as specified by delay.
 void push(T elem, Timing delay, Timing duration)
          Pushes the element elem onto the top of the stack.
 T top(Timing delay, Timing duration)
          Retrieves (without removing) the element at the top of the stack.
This is the delayed version as specified by delay.
 void unhighlightTopCell(Timing delay, Timing duration)
          Unhighlights the cell which contains the top element of the stack.
 void unhighlightTopElem(Timing delay, Timing duration)
          Unhighlights the top element of the stack.
 
Methods inherited from class algoanim.primitives.VisualStack
getInitContent, getProperties, getStack, getUpperLeft, isEmpty, pop, push, setName, top
 
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
 

Constructor Detail

ConceptualStack

public ConceptualStack(ConceptualStackGenerator<T> csg,
                       Node upperLeftCorner,
                       java.util.List<T> content,
                       java.lang.String name,
                       DisplayOptions display,
                       StackProperties sp)
Instantiates the ConceptualStack and calls the create() method of the associated ConceptualStackGenerator.

Parameters:
csg - the appropriate code Generator.
upperLeftCorner - the upper left corner of this ConceptualStack.
content - the initial content of the ConceptualStack, consisting of the elements of the generic type T.
name - the name of this ConceptualStack.
display - [optional] the DisplayOptions of this ConceptualStack.
sp - [optional] the properties of this ConceptualStack.
Method Detail

push

public void push(T elem,
                 Timing delay,
                 Timing duration)
Pushes the element elem onto the top of the stack. Unlike the push-method of java.util.Stack it doesn't return the element to be pushed.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
elem - the element to be pushed onto the stack.
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

pop

public T pop(Timing delay,
             Timing duration)
Removes and returns the element at the top of the stack.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.
Returns:
The element at the top of the stack.
Throws:
java.util.EmptyStackException - - if the stack is empty.

top

public T top(Timing delay,
             Timing duration)
Retrieves (without removing) the element at the top of the stack.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.
Returns:
The element at the top of the stack.
Throws:
java.util.EmptyStackException - - if the stack is empty.

isEmpty

public boolean isEmpty(Timing delay,
                       Timing duration)
Tests if the stack is empty.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.
Returns:
true if and only if the stack contains no elements; false otherwise.

highlightTopElem

public void highlightTopElem(Timing delay,
                             Timing duration)
Highlights the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

unhighlightTopElem

public void unhighlightTopElem(Timing delay,
                               Timing duration)
Unhighlights the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

highlightTopCell

public void highlightTopCell(Timing delay,
                             Timing duration)
Highlights the cell which contains the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

unhighlightTopCell

public void unhighlightTopCell(Timing delay,
                               Timing duration)
Unhighlights the cell which contains the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.