The Physiologist's Friend Simulation API

ch.unizh.ini.friend.stimulus
Class AbstractStimulus

java.lang.Object
  extended by ch.unizh.ini.friend.stimulus.AbstractStimulus
All Implemented Interfaces:
Updateable, Stimulus
Direct Known Subclasses:
ConcreteStimulus

public abstract class AbstractStimulus
extends Object
implements Stimulus

Provides default implementations for a stimulus, including it's foreground and background brightness, its shapes' container, and the transform applied to the shapes.

Version:
$Revision: 1.16 $
Author:
Christof Marti, Tobi Delbruck

Field Summary
protected  float backgroundExcitationDensity
          The background excitation density.
static float BRIGHTNESS_CHANGE_RATIO
          factor to change brightness of foreground or background by for brightenForeground(), etc.
protected  float foregroundExcitationDensity
          The foreground excitation density.
protected  float newBackgroundExcitationDensity
          The new background excitation density.
protected  float newForegroundExcitationDensity
          The new foreground excitation density.
protected  ShapeList newShape
          the new set of shapes
protected  ShapeList shapes
          the list of original (untransformed) shapes making up the stimulus
 SeparateTransforms transforms
          The transforms of the stimulus.
 
Fields inherited from interface ch.unizh.ini.friend.stimulus.Stimulus
BACKGROUND_BRIGHTNESS, BRIGHTEN_BACKGROUND, BRIGHTEN_FOREGROUND, DARKEN_BACKGROUND, DARKEN_FOREGROUND, FOREGROUND_BRIGHTNESS, RESIZE_RATIO, ROTATE_BY
 
Constructor Summary
AbstractStimulus()
           
 
Method Summary
 void addShape(Transformable shape)
          add a shape to the list of shapes making up the stimulus
 void brightenBackground()
          make background brighter
 void brightenForeground()
          make foreground brighter
 void clearShapes()
          clear the list of shapes
 void compute(float dt)
          Computes the new state of this component of the simulation.
 void darkenBackground()
          make background darker
 void darkenForeground()
          make foreground darker
 void expand()
          expand by ratio Stimulus.RESIZE_RATIO in both dimensions
 void fatten()
          fatten by ratio Stimulus.RESIZE_RATIO
 void flipContrast()
          swap brightness of foreground and background
 float getBackgroundExcitationDensity()
          Returns the background excitation density of the stimulus.
 float getForegroundExcitationDensity()
          Returns the foreground excitation density of the stimulus.
 ShapeList getShapes()
          return list of original (untransformed) shapes making up this stimulus
 ShapeList getTransformedShapes()
          return transformed shapes.
 SeparateTransforms getTransforms()
          return transforms operating on this stimulus
 boolean isVisible()
          is stimulus hidden by its foreground brightness being set to the background?
 void lengthen()
          lengthen by ratio Stimulus.RESIZE_RATIO
 void removeShape(Transformable shape)
          remove a shape from the list of shapes
 void rotate(int n)
          rotate by n*Stimulus.ROTATE_BY
 void rotateCCW()
          rotate CCW by Stimulus.ROTATE_BY
 void rotateCW()
          rotate CW by Stimulus.ROTATE_BY
 void setBackgroundExcitationDensity(float backgroundExcitationDensity)
          Sets the background excitation density of the stimulus.
 void setForegroundExcitationDensity(float foregroundExcitationDensity)
          Sets the foreground excitation density of the stimulus.
 void setShapes(ShapeList list)
          set list of untransformed shapes making up stimulus.
 void setTransforms(SeparateTransforms transforms)
          set the transforms of this stimulus.
 void setVisible(boolean flag)
          set state of stimulus to be hidden or shown.
 void shorten()
          make shorter by ratio Stimulus.RESIZE_RATIO
 void shrink()
          shrink by ratio Stimulus.RESIZE_RATIO in both dimensions
 void thin()
          thin by ratio Stimulus.RESIZE_RATIO
 String toString()
          String representation of stimulus
 void update()
          Updates the actual state to the newly computed - aka double-buffering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

foregroundExcitationDensity

protected float foregroundExcitationDensity
The foreground excitation density.


backgroundExcitationDensity

protected float backgroundExcitationDensity
The background excitation density.


newForegroundExcitationDensity

protected float newForegroundExcitationDensity
The new foreground excitation density.


newBackgroundExcitationDensity

protected float newBackgroundExcitationDensity
The new background excitation density.


BRIGHTNESS_CHANGE_RATIO

public static final float BRIGHTNESS_CHANGE_RATIO
factor to change brightness of foreground or background by for brightenForeground(), etc.


shapes

protected ShapeList shapes
the list of original (untransformed) shapes making up the stimulus


newShape

protected ShapeList newShape
the new set of shapes


transforms

public SeparateTransforms transforms
The transforms of the stimulus.

Constructor Detail

AbstractStimulus

public AbstractStimulus()
Method Detail

getBackgroundExcitationDensity

public float getBackgroundExcitationDensity()
Returns the background excitation density of the stimulus.

Specified by:
getBackgroundExcitationDensity in interface Stimulus
Returns:
The excitation density.

getForegroundExcitationDensity

public float getForegroundExcitationDensity()
Returns the foreground excitation density of the stimulus.

Specified by:
getForegroundExcitationDensity in interface Stimulus
Returns:
The excitation density.

setBackgroundExcitationDensity

public void setBackgroundExcitationDensity(float backgroundExcitationDensity)
Sets the background excitation density of the stimulus.

Specified by:
setBackgroundExcitationDensity in interface Stimulus
Parameters:
backgroundExcitationDensity - The new excitation density.

setForegroundExcitationDensity

public void setForegroundExcitationDensity(float foregroundExcitationDensity)
Sets the foreground excitation density of the stimulus.

Specified by:
setForegroundExcitationDensity in interface Stimulus
Parameters:
foregroundExcitationDensity - The new excitation density.

brightenForeground

public void brightenForeground()
make foreground brighter

Specified by:
brightenForeground in interface Stimulus

darkenForeground

public void darkenForeground()
make foreground darker

Specified by:
darkenForeground in interface Stimulus

brightenBackground

public void brightenBackground()
make background brighter

Specified by:
brightenBackground in interface Stimulus

darkenBackground

public void darkenBackground()
make background darker

Specified by:
darkenBackground in interface Stimulus

flipContrast

public void flipContrast()
swap brightness of foreground and background

Specified by:
flipContrast in interface Stimulus

setVisible

public void setVisible(boolean flag)
set state of stimulus to be hidden or shown. Stimulus is hidden by setting its brightness the same as the background.

Specified by:
setVisible in interface Stimulus

isVisible

public boolean isVisible()
is stimulus hidden by its foreground brightness being set to the background?

Specified by:
isVisible in interface Stimulus

compute

public void compute(float dt)
Computes the new state of this component of the simulation. This does nothing because the new state of the stimulus is determined by the gui which runs independently.

Specified by:
compute in interface Updateable
Parameters:
dt - The time that has passed since the last invocation.

update

public void update()
Updates the actual state to the newly computed - aka double-buffering.

Specified by:
update in interface Updateable

getShapes

public ShapeList getShapes()
return list of original (untransformed) shapes making up this stimulus

Specified by:
getShapes in interface Stimulus

setShapes

public void setShapes(ShapeList list)
set list of untransformed shapes making up stimulus. The ShapeList is wrapped inside a new set of SeparateTransforms, so any existing transformations are lost. Hence this method resets the transform applied to the shapes.

Specified by:
setShapes in interface Stimulus
Parameters:
list - the shapes to use

addShape

public void addShape(Transformable shape)
add a shape to the list of shapes making up the stimulus

Specified by:
addShape in interface Stimulus

removeShape

public void removeShape(Transformable shape)
remove a shape from the list of shapes

Specified by:
removeShape in interface Stimulus

clearShapes

public void clearShapes()
clear the list of shapes

Specified by:
clearShapes in interface Stimulus

getTransforms

public SeparateTransforms getTransforms()
return transforms operating on this stimulus

Specified by:
getTransforms in interface Stimulus

setTransforms

public void setTransforms(SeparateTransforms transforms)
set the transforms of this stimulus. This can be used, e.g., to set the transforms of a new stimulus to the same as the previous one.

Specified by:
setTransforms in interface Stimulus
Parameters:
transforms - the transforms to set for the stimulus

getTransformedShapes

public ShapeList getTransformedShapes()
return transformed shapes. These can be rendered to show the actual stimulus.

Specified by:
getTransformedShapes in interface Stimulus

toString

public String toString()
String representation of stimulus

Overrides:
toString in class Object

lengthen

public void lengthen()
lengthen by ratio Stimulus.RESIZE_RATIO

Specified by:
lengthen in interface Stimulus

shorten

public void shorten()
make shorter by ratio Stimulus.RESIZE_RATIO

Specified by:
shorten in interface Stimulus

fatten

public void fatten()
fatten by ratio Stimulus.RESIZE_RATIO

Specified by:
fatten in interface Stimulus

thin

public void thin()
thin by ratio Stimulus.RESIZE_RATIO

Specified by:
thin in interface Stimulus

expand

public void expand()
expand by ratio Stimulus.RESIZE_RATIO in both dimensions

Specified by:
expand in interface Stimulus

shrink

public void shrink()
shrink by ratio Stimulus.RESIZE_RATIO in both dimensions

Specified by:
shrink in interface Stimulus

rotateCCW

public void rotateCCW()
rotate CCW by Stimulus.ROTATE_BY

Specified by:
rotateCCW in interface Stimulus

rotateCW

public void rotateCW()
rotate CW by Stimulus.ROTATE_BY

Specified by:
rotateCW in interface Stimulus

rotate

public void rotate(int n)
rotate by n*Stimulus.ROTATE_BY

Specified by:
rotate in interface Stimulus
Parameters:
n - number of Stimulus.ROTATE_BY units to rotate

http://www.ini.unizh.ch/~tobi/friend