com.speckled.specksim.gui.visualiser
Class SpeckVisualiser

java.lang.Object
  extended by com.ryanm.glvisualiser.GLVisualiser
      extended by com.speckled.specksim.gui.visualiser.SpeckVisualiser
All Implemented Interfaces:
Configurable, StateListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener, javax.media.opengl.GLEventListener

public class SpeckVisualiser
extends GLVisualiser
implements StateListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener

Visualises a field of specks.

Author:
ryanm

Field Summary
 
Fields inherited from class com.ryanm.glvisualiser.GLVisualiser
camera, capture, lighting
 
Constructor Summary
SpeckVisualiser(SpeckSim simulator, StateSink stateSink, SimGUI gui)
          Standard constructor.
 
Method Summary
static void apply(javax.media.opengl.GL gl, SpeckPosition orientation)
          Applies the supplied orientation to the gl context
 void constructObjectTypes(javax.media.opengl.GLAutoDrawable drawable)
          Should be overridden by subclasses.
 StateRenderer getRenderer(java.lang.String className)
          Gets the registered StateRenderer with the specified classname
 int[] getSelectedId()
          Gets the name stack of the object that was last clicked on
 Configurator getSpeckConfigurator()
          Gets the SpeckVisualiser-specific options.
 StateSink getState()
          Gets the state to render
 StatsPlotter getStatsPlotter()
          Gets the statistics plotter
static boolean loadRenderer(java.lang.String className)
          Tries to register a StateRenderer class.
static boolean loadSelectionListener(java.lang.String className)
          Attempts to load the GLSelectionListener with the supplied class name
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void render(javax.media.opengl.GLAutoDrawable drawable)
          This should be overridden to perform your drawing operations.
 void stateRefreshed()
          Called when the associated state is refreshed
 void update()
          Override this method to perform animation and so on
 
Methods inherited from class com.ryanm.glvisualiser.GLVisualiser
addFrameListener, addPostConstructionTask, addPostFrameTask, display, displayChanged, enablePicking, getBackgroundColour, getCamera, getCanvas, getCapture, getConfigurator, getFPS, getGLInfo, getLighting, getLineColour, getLineWidth, getLineWidthRange, getNameStackUnderMouse, getTargetFPS, init, isAxesDrawing, isBoundaryDrawing, isEnabled, isLazyMode, isPicking, refresh, removeFrameListener, reshape, setAxesDrawing, setBackgroundColour, setBoundaryDrawing, setEnabled, setLazyMode, setLineColour, setLineWidth, setTargetFPS, setXaxisText, setYaxisText, setZaxisText, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpeckVisualiser

public SpeckVisualiser(SpeckSim simulator,
                       StateSink stateSink,
                       SimGUI gui)
Standard constructor.

Parameters:
simulator - The simulator to visualise
stateSink - The source of state information
gui - The simulator interface
Method Detail

constructObjectTypes

public void constructObjectTypes(javax.media.opengl.GLAutoDrawable drawable)
Description copied from class: GLVisualiser
Should be overridden by subclasses. This is where you should build your GLObjects, compile display lists and so on.

Specified by:
constructObjectTypes in class GLVisualiser
Parameters:
drawable - The GLAutoDrawable to use

update

public void update()
Description copied from class: GLVisualiser
Override this method to perform animation and so on

Specified by:
update in class GLVisualiser

render

public void render(javax.media.opengl.GLAutoDrawable drawable)
Description copied from class: GLVisualiser
This should be overridden to perform your drawing operations. If you want to do any freelance drawing outside of rendering GLObjects and GLEdges, the OpenGL context is provided. Note that, due to threading isssues, any drawing must be done in this method. Don't try to save a reference to the context for later use.

Specified by:
render in class GLVisualiser
Parameters:
drawable - The OpenGL context, should you want to do any freelance drawing.

getSpeckConfigurator

public Configurator getSpeckConfigurator()
Gets the SpeckVisualiser-specific options. Will include the general GLVisualiser options as a subconfigurator

Returns:
The Configurator

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class GLVisualiser

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class GLVisualiser

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class GLVisualiser

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class GLVisualiser

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class GLVisualiser

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

stateRefreshed

public void stateRefreshed()
Description copied from interface: StateListener
Called when the associated state is refreshed

Specified by:
stateRefreshed in interface StateListener

getSelectedId

public int[] getSelectedId()
Gets the name stack of the object that was last clicked on

Returns:
An int array holding the name stack. The first element lies deepest in the stack

apply

public static void apply(javax.media.opengl.GL gl,
                         SpeckPosition orientation)
Applies the supplied orientation to the gl context

Parameters:
gl - The GL context
orientation - The orientation to apply

loadSelectionListener

public static boolean loadSelectionListener(java.lang.String className)
Attempts to load the GLSelectionListener with the supplied class name

Parameters:
className - The class name of the GLSelectionListener
Returns:
true if loading is succesful, false otherwise

loadRenderer

public static boolean loadRenderer(java.lang.String className)
Tries to register a StateRenderer class. NB: All renderer classes should be registered prior to the construction of the visualiser

Parameters:
className - The name of the renderer class
Returns:
true if the registration was succesful, false otherwise

getRenderer

public StateRenderer getRenderer(java.lang.String className)
Gets the registered StateRenderer with the specified classname

Parameters:
className - The classname of the desired renderer
Returns:
The StateRenderer with the specified classname, or null if there is no such Renderer

getState

public StateSink getState()
Gets the state to render

Returns:
The state object

getStatsPlotter

public StatsPlotter getStatsPlotter()
Gets the statistics plotter

Returns:
the statsplotter