de.unifreiburg.twodeedoo.scene
Class MultiImagePartPuppet

java.lang.Object
  extended by de.unifreiburg.twodeedoo.scene.AbstractPuppet
      extended by de.unifreiburg.twodeedoo.scene.MultiImagePartPuppet
All Implemented Interfaces:
IPhasedPuppet, IPuppet, IPainter

public class MultiImagePartPuppet
extends AbstractPuppet
implements IPhasedPuppet

IPhasedPuppet implementation which paints one of a collection of IBrushes.


Field Summary
 
Fields inherited from interface de.unifreiburg.twodeedoo.scene.IPuppet
NULL_OBJECT
 
Constructor Summary
MultiImagePartPuppet(IBrush imagePart)
          Create new.
 
Method Summary
 int addImagePart(IBrush part)
          Add a IBrush.
 int getNumberOfPhases()
          How many phases.
 void paint(java.awt.Graphics g)
          Delegate painting to brush.
 void setPhase(int phase)
          Change to a different phase.
 java.lang.String toString()
          Nice stringification.
 
Methods inherited from class de.unifreiburg.twodeedoo.scene.AbstractPuppet
getX, getY, moveAbs, removeFromScene, setContainingScene
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.unifreiburg.twodeedoo.scene.IPuppet
getX, getY, moveAbs, removeFromScene, setContainingScene
 

Constructor Detail

MultiImagePartPuppet

public MultiImagePartPuppet(IBrush imagePart)
Create new. Must supply the first IBrush right now so that I never have 0 of them. Inits coordinates 0,0.

Parameters:
imagePart - some IBrush, will become phase 0.
Method Detail

addImagePart

public int addImagePart(IBrush part)
Add a IBrush.

Parameters:
part - some IBrush.
Returns:
the phase of the newly added IBrush.

setPhase

public void setPhase(int phase)
Change to a different phase.

Specified by:
setPhase in interface IPhasedPuppet
Parameters:
phase - a valid index into the brush list.
Throws:
java.lang.IndexOutOfBoundsException - if invalid.

getNumberOfPhases

public int getNumberOfPhases()
How many phases.

Specified by:
getNumberOfPhases in interface IPhasedPuppet
Returns:
number of phases (at least 1)

paint

public void paint(java.awt.Graphics g)
Delegate painting to brush.

Specified by:
paint in interface IPainter
Specified by:
paint in class AbstractPuppet
Parameters:
g - some graphics context.

toString

public java.lang.String toString()
Nice stringification.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()