com.speckled.specksim.gui.imp
Class AbstractStateRenderer

java.lang.Object
  extended by com.speckled.specksim.gui.imp.AbstractStateRenderer
All Implemented Interfaces:
Configurable, StateRenderer, java.lang.Comparable<StateRenderer>
Direct Known Subclasses:
BodyRenderer, BroadcastRenderer, EpidemicRenderer, GravityRenderer, NeighbourhoodRenderer, SpeckRenderer, StatsPlotter, VelocityRenderer, WallRenderer

public abstract class AbstractStateRenderer
extends java.lang.Object
implements StateRenderer

This superclass increases rendering efficiency by compiling any subclasses' rendering into a display list, and then using the display list for as long as possible. It also handles simple enabling/disabling behaviour, along with watching the draw set for changes.

Author:
ryanm

Field Summary
protected  SpeckVisualiser visualiser
          A reference to the parent visualiser
 
Constructor Summary
AbstractStateRenderer()
           
 
Method Summary
 int compareTo(StateRenderer sr)
           
protected abstract  void compileSubLists()
          All display lists used by subclasses should be put into a usable state in this method
 int getRenderPriority()
          Gets a priority indicator for this renderer.
 void init(SpeckVisualiser visualiser)
          Called when the renderers are constructed.
 boolean isEnabled()
          Determnes whether this renderer is enabled or not
 void render(javax.media.opengl.GLAutoDrawable drawable, StateSink state)
          Rendering should be perfromed here
protected abstract  void renderState(javax.media.opengl.GLAutoDrawable drawable, StateSink state)
          Perform your rendering here.
protected  void setDirty()
          Should be called by subclasses to indicate that the display list should be recompiled at the earliest opportunity
 void setEnabled(boolean b)
          Called to enable or disable the renderer.
 void update()
          Any frame-by-frame animation should be done here
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.speckled.specksim.gui.visualiser.StateRenderer
constructGLObjects, getName
 
Methods inherited from interface com.ryanm.config.Configurable
getConfigurator
 

Field Detail

visualiser

protected SpeckVisualiser visualiser
A reference to the parent visualiser

Constructor Detail

AbstractStateRenderer

public AbstractStateRenderer()
Method Detail

init

public void init(SpeckVisualiser visualiser)
Description copied from interface: StateRenderer
Called when the renderers are constructed. Renderers who are interested in knowing the nameStack of what is under the mouse should save a reference to the visualiser and use it to call getNameStackUnderMouse()

Specified by:
init in interface StateRenderer
Parameters:
visualiser - The parent visualiser that this renderer belongs to

setEnabled

public void setEnabled(boolean b)
Description copied from interface: StateRenderer
Called to enable or disable the renderer.

Specified by:
setEnabled in interface StateRenderer

isEnabled

public boolean isEnabled()
Description copied from interface: StateRenderer
Determnes whether this renderer is enabled or not

Specified by:
isEnabled in interface StateRenderer
Returns:
true if enabled, false otherwise

setDirty

protected void setDirty()
Should be called by subclasses to indicate that the display list should be recompiled at the earliest opportunity


render

public void render(javax.media.opengl.GLAutoDrawable drawable,
                   StateSink state)
Description copied from interface: StateRenderer
Rendering should be perfromed here

Specified by:
render in interface StateRenderer
Parameters:
drawable - The context on which to draw
state - The state to draw

update

public final void update()
Description copied from interface: StateRenderer
Any frame-by-frame animation should be done here

Specified by:
update in interface StateRenderer

renderState

protected abstract void renderState(javax.media.opengl.GLAutoDrawable drawable,
                                    StateSink state)
Perform your rendering here. All rendering done in this method will be compiled into a display list.

Parameters:
drawable - The GL context to draw to
state - The state to render

compileSubLists

protected abstract void compileSubLists()
All display lists used by subclasses should be put into a usable state in this method


getRenderPriority

public int getRenderPriority()
Description copied from interface: StateRenderer
Gets a priority indicator for this renderer. Renderers with higher priorities will execute before those with lower priorities

Specified by:
getRenderPriority in interface StateRenderer
Returns:
An int priority indicator

compareTo

public final int compareTo(StateRenderer sr)
Specified by:
compareTo in interface java.lang.Comparable<StateRenderer>