com.speckled.specksim.state
Class StateFilter

java.lang.Object
  extended by com.speckled.specksim.state.StateFilter
Direct Known Subclasses:
FlavourFilter, LeaderFilter, SpeckIDFilter

public abstract class StateFilter
extends java.lang.Object

Defines an object that will filter elements in the SimulatorState object. For instance, a filter could exclude all speck states except those of a particular flavour, etc. It will be up to the consumers of the SimulatorState object to check which elements are filtered. Note that deactivated filters will always return true to calls of isIncluded()

Author:
ryanm

Field Summary
protected  StateSink stateSink
          Reference to the StateSink object that holds the state to be operated on
 
Constructor Summary
protected StateFilter(java.lang.String name)
          Constructor for a new StateFilter
 
Method Summary
 java.lang.String getName()
          Gets the name of this filter
abstract  boolean included(int index)
          Checks whether or not the entry in the state object with the given index should be included.
 boolean isEnabled()
          Determines if the filter is active or not
protected  void refreshStateListeners()
          Call this when something in the filter has changed to refresh the GUI
 void setEnabled(boolean enabled)
          Turns the filter on and off
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stateSink

protected StateSink stateSink
Reference to the StateSink object that holds the state to be operated on

Constructor Detail

StateFilter

protected StateFilter(java.lang.String name)
Constructor for a new StateFilter

Parameters:
name - The name of the StateFilter
Method Detail

included

public abstract boolean included(int index)
Checks whether or not the entry in the state object with the given index should be included.

Parameters:
index - The index of the element
Returns:
True if the element should be included, false otherwise

setEnabled

public final void setEnabled(boolean enabled)
Turns the filter on and off

Parameters:
enabled - true to trun the filter on, false otherwise

refreshStateListeners

protected final void refreshStateListeners()
Call this when something in the filter has changed to refresh the GUI


isEnabled

public final boolean isEnabled()
Determines if the filter is active or not

Returns:
true if the filter is active, false if not

getName

public final java.lang.String getName()
Gets the name of this filter

Returns:
The name of the filter