exe
Class GAIGSnewQueue

java.lang.Object
  extended by exe.GAIGSbase
      extended by exe.GAIGSlist
          extended by exe.GAIGSnewQueue
All Implemented Interfaces:
GAIGSdatastr

public class GAIGSnewQueue
extends GAIGSlist

GAIGSnewQueue extends the GAIGSlist class, providing the ability to implement a standard queue data structure and also create GAIGS visualizations of its state. Use the various constructors to specify the general parameters for the queue visualization, and use the toXML method to actually generate the queue XML for snapshots.

A method is also provided to set the presentation color of a queue cell. A default queue cell color can be set by using the appropriate constructor. Methods to get a cell color are inherited from GAIGSlist.

Version:
7/7/2010
Author:
Shawn Recker

Nested Class Summary
protected  class GAIGSnewQueue.BoxPair
           
 
Field Summary
protected  java.util.LinkedList<GAIGSnewQueue.BoxPair> deltaArray
          ArrayList for keeping track of width and size requirements
protected  double maxHeight
          Current maximum height
protected  double maxWidth
          Current maximum width
 
Fields inherited from interface exe.GAIGSdatastr
DEFAULT_COLOR, DEFAULT_FONT_SIZE, DEFAULT_NAME, DEFAULT_X1, DEFAULT_X2, DEFAULT_Y1, DEFAULT_Y2
 
Constructor Summary
GAIGSnewQueue()
          Use all default values for instance variables
GAIGSnewQueue(java.lang.String name, java.lang.String color, double x1, double y1, double x2, double y2)
          Explicitly set all instance variables.
 
Method Summary
 java.lang.Object dequeue()
          removes an item from the queue and returns it.
 void enqueue(java.lang.Object v)
          Adds an item to the queue.
 void enqueue(java.lang.Object v, java.lang.String c)
          Adds an item with an associated color to the queue.
 double[] getCornerPoints(int e)
          Get the corner points making up the box around the element
 java.lang.Object peek()
          returns but does not remove an item from the queue.
 java.lang.String toXML()
          Creates and returns GAIGS XML code for the current state of the queue
 
Methods inherited from class exe.GAIGSlist
add, add, add, add, addFirst, addFirst, addLast, addLast, clear, contains, get, getColor, getFirst, getLast, indexOf, isEmpty, lastIndexOf, remove, remove, removeFirst, removeLast, set, set, setColor, size, toXML
 
Methods inherited from class exe.GAIGSbase
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

deltaArray

protected java.util.LinkedList<GAIGSnewQueue.BoxPair> deltaArray
ArrayList for keeping track of width and size requirements


maxWidth

protected double maxWidth
Current maximum width


maxHeight

protected double maxHeight
Current maximum height

Constructor Detail

GAIGSnewQueue

public GAIGSnewQueue()
Use all default values for instance variables


GAIGSnewQueue

public GAIGSnewQueue(java.lang.String name,
                     java.lang.String color,
                     double x1,
                     double y1,
                     double x2,
                     double y2)
Explicitly set all instance variables.

Parameters:
name - Display name of this structure.
color - Color for items unless locally overridden.
x1 - Left display bound.
y1 - Bottom display bound.
x2 - Top display bound.
y2 - Right display bound.
fontSize - Font size for display.
Method Detail

enqueue

public void enqueue(java.lang.Object v)
Adds an item to the queue. Default color will be used for this item.

Parameters:
v - The value to be stored.

enqueue

public void enqueue(java.lang.Object v,
                    java.lang.String c)
Adds an item with an associated color to the queue.

Parameters:
v - The value to be stored.
c - The display color for this item.

dequeue

public java.lang.Object dequeue()
removes an item from the queue and returns it.

Returns:
An Object containing popped value

peek

public java.lang.Object peek()
returns but does not remove an item from the queue.

Returns:
An Object containing the next value to be dequeued.

getCornerPoints

public double[] getCornerPoints(int e)
Get the corner points making up the box around the element

Parameters:
e - the element
Returns:
An array containing the corner points as x,y pairs. First pair is the bottom left, then bottom right, then top right, then top left

toXML

public java.lang.String toXML()
Creates and returns GAIGS XML code for the current state of the queue

Specified by:
toXML in interface GAIGSdatastr
Overrides:
toXML in class GAIGSlist
Returns:
A String containing GAIGS XML code for the queue