com.nootropic.processing.layers
Class AppletLayers

java.lang.Object
  extended by com.nootropic.processing.layers.AppletLayers

public class AppletLayers
extends java.lang.Object

This class is a container for the Layer objects of a Processing sketch. The AppletLayers object manages the rendering of Layers in the correct order, and allows mouse and keyboard events to be propagated to all layers. All created Layer objects must be added to an AppletLayers object in order to be drawn in the sketch.

Author:
Michael Krumpus

Field Summary
 int[] pixels
           
 
Constructor Summary
AppletLayers(processing.core.PApplet parent)
          Create an AppletLayers object for the specified PApplet.
 
Method Summary
 void addLayer(Layer layer)
          Add a layer to this AppletLayers object.
 void draw()
          Draw each Layer managed by this AppletLayers object.
 Layer getLayer(int i)
          Get a layer at a specified index.
 java.util.ListIterator getListIterator()
          Get a list iterator for the list of layers.
 void keyEvent(java.awt.event.KeyEvent event)
          Process key events for the set of Layer objects managed by this AppletLayers object.
 void loadPixels()
          Load the pixels from all layers to the variable pixels.
 void mouseEvent(java.awt.event.MouseEvent event)
          Process mouse events for the set of Layer objects managed by this AppletLayers object.
 int numLayers()
          Get the number of layers in this AppletLayers object.
 void paint(processing.core.PApplet pApplet)
          Paint the set of managed Layers to the screen.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pixels

public int[] pixels
Constructor Detail

AppletLayers

public AppletLayers(processing.core.PApplet parent)
Create an AppletLayers object for the specified PApplet.

Parameters:
parent -
Method Detail

addLayer

public void addLayer(Layer layer)
Add a layer to this AppletLayers object. Layers are added "on top" of the sketch.

Parameters:
layer - the layer to add

numLayers

public int numLayers()
Get the number of layers in this AppletLayers object.

Returns:
the number of layers

getLayer

public Layer getLayer(int i)
Get a layer at a specified index. Index 0 is the bottom-most layer in the sketch. The highest numbered index (one less than the value returned by numLayers()) is the top-most layer in the sketch.

Parameters:
i - the index of the layer to get
Returns:
the layer at index i

getListIterator

public java.util.ListIterator getListIterator()
Get a list iterator for the list of layers.

Returns:
a list iterator for the list of layers.

draw

public void draw()
Draw each Layer managed by this AppletLayers object. This method is invoked automatically by the parent PApplet. Layers are drawn by calling their draw() methods, starting with the bottom-most layer and ending with the top-most layer.


paint

public void paint(processing.core.PApplet pApplet)
Paint the set of managed Layers to the screen. This method MUST be called by the paint(Graphics g) method of your sketch.

Parameters:
pApplet - the parent PApplet

loadPixels

public void loadPixels()
Load the pixels from all layers to the variable pixels.


mouseEvent

public void mouseEvent(java.awt.event.MouseEvent event)
Process mouse events for the set of Layer objects managed by this AppletLayers object. This method will be called automatically by the parent PApplet when a mouse event occurs. The role of the AppletLayers class is to propagate the event to all Layers.

Parameters:
event - the MouseEvent

keyEvent

public void keyEvent(java.awt.event.KeyEvent event)
Process key events for the set of Layer objects managed by this AppletLayers object. This method will be called automatically by the parent PApplet when a key event occurs. The role of the AppletLayers class is to propagate the event to all Layers.

Parameters:
event - the KeyEvent


processing library layers by Michael Krumpus. (c) 2009-2011