Class LayeredSceneElement

java.lang.Object
  extended by LayeredSceneElement

public class LayeredSceneElement
extends Object

Class that uses a linked list to indicate the layer a picture is in

Author:
Mark Guzdial, Barb Ericson

Constructor Summary
LayeredSceneElement(Picture heldPic, int xPos, int yPos)
          Make a new element with a picture as input, and next as null, to be drawn at given x,y
 
Method Summary
 void add(LayeredSceneElement node)
          Add the input node after the last node in this list.
 void drawFromMeOn(Picture bg)
          Method to draw from this node on in the list, using blueScreen.
 LayeredSceneElement getNext()
          Method to get the next element
 Picture getPicture()
          Returns the picture in the node.
 void insertAfter(LayeredSceneElement node)
          Insert the input node after this node.
 LayeredSceneElement last()
          Return the last element in the list
 void remove(LayeredSceneElement node)
          Method to remove node from list, fixing links appropriately.
 LayeredSceneElement reverse()
          Reverse the list starting at this, and return the last element of the list.
 LayeredSceneElement reverse2()
          Reverse2: Push all the elements on the stack, then pop all the elements off the stack.
 void setNext(LayeredSceneElement nextOne)
          Method to set the next element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayeredSceneElement

public LayeredSceneElement(Picture heldPic,
                           int xPos,
                           int yPos)
Make a new element with a picture as input, and next as null, to be drawn at given x,y

Parameters:
heldPic - Picture for element to hold
xPos - x position desired for element
yPos - y position desired for element
Method Detail

setNext

public void setNext(LayeredSceneElement nextOne)
Method to set the next element

Parameters:
nextOne - next element in list

getNext

public LayeredSceneElement getNext()
Method to get the next element

Returns:
the next element

getPicture

public Picture getPicture()
Returns the picture in the node.

Returns:
the picture in the node

drawFromMeOn

public void drawFromMeOn(Picture bg)
Method to draw from this node on in the list, using blueScreen. Each new element has it's lower-left corner at the lower-right of the previous node. Starts drawing from left-bottom

Parameters:
bg - Picture to draw drawing on

remove

public void remove(LayeredSceneElement node)
Method to remove node from list, fixing links appropriately.

Parameters:
node - element to remove from list.

last

public LayeredSceneElement last()
Return the last element in the list


reverse

public LayeredSceneElement reverse()
Reverse the list starting at this, and return the last element of the list. The last element becomes the FIRST element of the list, and THIS points to null.


reverse2

public LayeredSceneElement reverse2()
Reverse2: Push all the elements on the stack, then pop all the elements off the stack.


add

public void add(LayeredSceneElement node)
Add the input node after the last node in this list.

Parameters:
node - element to insert after this.

insertAfter

public void insertAfter(LayeredSceneElement node)
Insert the input node after this node.

Parameters:
node - element to insert after this.