com.rubecula.darwin.evolution
Class Evolver_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.evolution.Evolver_
All Implemented Interfaces:
com.rubecula.beanpot.Configurable, Evolver, Clocked, net.sf.tostring0.IToString
Direct Known Subclasses:
Evolution_

public abstract class Evolver_
extends net.sf.tostring0.AToString
implements Evolver, com.rubecula.beanpot.Configurable

This is the base abstract class for the Evolver interface.

Author:
Robin Hillyard

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Fields inherited from interface net.sf.tostring0.IToString
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE
 
Constructor Summary
protected Evolver_()
           
 
Method Summary
 void addEvolvable(Evolvable listener)
          TEST
 void addEvolvable(Evolvable evolvable, int ticks)
          Add an evolvable object which undergoes a new generation once every ticks ticks of the clock.
 boolean addListener(GenerationListener listener)
          Add a listener to the evolution process.
 boolean addVisualizableListener(VisualizableListener listener)
          This is invoked by reflection during configuration.
 void cleanup()
          TEST
 long getClock()
           
 ClockWatcher getClockWatcher()
           
 java.util.Set<Evolvable> getEvolvableKeys()
           
protected  java.util.Map<Evolvable,java.lang.Integer> getEvolvables()
           
protected  java.util.Collection<GenerationListener> getListeners()
           
protected  java.util.Collection<VisualizableListener> getVisualizableListeners()
           
 void init()
          This method initializes the Evolution so that it is ready to start the first generation.
 boolean next()
          Create a new EvolutionTask and run it.
 void postConfigure(java.lang.Object data)
          Do nothing - override if you need something doing
 void preConfigure(java.lang.Object data)
          Do nothing - override if you need something doing
 java.lang.Integer putEvolvable(Evolvable evolvable, java.lang.Integer ticks)
          This is invoked by reflection during configuration.
 void removeEvolvable(Evolvable evolvable)
           
 void seedEvolvables()
          Seed the currently registered evolvables by calling Theological.seedMembers() on each one.
 void setClockWatcher(ClockWatcher clockWatcher)
           
 void setEvolvables(java.util.Map<? extends Evolvable,? extends java.lang.Integer> map)
          Bean-type method to define the evolvables.
 void setListeners(java.util.Collection<? extends GenerationListener> listeners)
          This is invoked by reflection during configuration.
 void setVisualizableListeners(java.util.Collection<VisualizableListener> visualizableListeners)
          Method to clear and reset the visualizable listeners.
static java.lang.String showTime(java.util.Calendar time)
           
static void showTime(java.util.Calendar time, java.io.PrintWriter writer)
           
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
The logger for this class.

Constructor Detail

Evolver_

protected Evolver_()
Method Detail

showTime

public static java.lang.String showTime(java.util.Calendar time)
Parameters:
time -
Returns:
a usable String to represent the time

showTime

public static void showTime(java.util.Calendar time,
                            java.io.PrintWriter writer)
Parameters:
time -
writer - the writer to show the time on

addEvolvable

public void addEvolvable(Evolvable listener)
TEST

Specified by:
addEvolvable in interface Evolver
Parameters:
listener -
See Also:
Evolver.addEvolvable(com.rubecula.darwin.foundation.Evolvable, int)

addEvolvable

public void addEvolvable(Evolvable evolvable,
                         int ticks)
Description copied from interface: Evolver
Add an evolvable object which undergoes a new generation once every ticks ticks of the clock.

Specified by:
addEvolvable in interface Evolver
Parameters:
evolvable - an Evolvable object, typically a Taxon.
ticks - the number of ticks of the clock per generation.
See Also:
Evolver.addEvolvable(com.rubecula.darwin.foundation.Evolvable, int)

addListener

public boolean addListener(GenerationListener listener)
Description copied from interface: Evolver
Add a listener to the evolution process.

Specified by:
addListener in interface Evolver
Returns:
true if the listener was added
See Also:
Evolver.addListener(com.rubecula.darwin.domain.helper.GenerationListener)

addVisualizableListener

public boolean addVisualizableListener(VisualizableListener listener)
This is invoked by reflection during configuration.

Parameters:
listener -
Returns:
true if the addition was successful
See Also:
Collection.add(java.lang.Object)

cleanup

public void cleanup()
TEST

Specified by:
cleanup in interface Evolver
See Also:
Evolver.cleanup()

getClock

public long getClock()
Specified by:
getClock in interface Clocked
Returns:
the number of ticks since this Generator was started, or null if this evolution has not been started.

getClockWatcher

public ClockWatcher getClockWatcher()
Specified by:
getClockWatcher in interface Evolver
Returns:
the clockWatcher

getEvolvableKeys

public java.util.Set<Evolvable> getEvolvableKeys()
Specified by:
getEvolvableKeys in interface Evolver
Returns:
the set of Evolvable objects.
See Also:
Evolver.getEvolvableKeys()

init

public void init()
This method initializes the Evolution so that it is ready to start the first generation. Work done here is performed after any user interface initialization has been done, for example it is called by Applet.start(). The complementary method is #cleanup().

Specified by:
init in interface Evolver
See Also:
Evolver.init()

next

public boolean next()
             throws EvolutionException
Create a new EvolutionTask and run it. This method has works quite differently in the two different modes (manual versus auto). When this Evolution is in auto mode, we is intended for manual stepping of the evolutionary process.

Specified by:
next in interface Evolver
Returns:
true if there are evolvables still to evolve.
Throws:
EvolutionException
See Also:
Evolver.next()

postConfigure

public void postConfigure(java.lang.Object data)
Do nothing - override if you need something doing

Specified by:
postConfigure in interface com.rubecula.beanpot.Configurable
See Also:
Configurable.postConfigure(java.lang.Object)

preConfigure

public void preConfigure(java.lang.Object data)
Do nothing - override if you need something doing

Specified by:
preConfigure in interface com.rubecula.beanpot.Configurable
See Also:
Configurable.preConfigure(java.lang.Object)

putEvolvable

public java.lang.Integer putEvolvable(Evolvable evolvable,
                                      java.lang.Integer ticks)
This is invoked by reflection during configuration.

Parameters:
evolvable -
ticks -
Returns:
the value previously associated with evolvable.

removeEvolvable

public void removeEvolvable(Evolvable evolvable)
Specified by:
removeEvolvable in interface Evolver
See Also:
Evolver.removeEvolvable(com.rubecula.darwin.foundation.Evolvable)

seedEvolvables

public void seedEvolvables()
Description copied from interface: Evolver
Seed the currently registered evolvables by calling Theological.seedMembers() on each one.

Specified by:
seedEvolvables in interface Evolver

setClockWatcher

public void setClockWatcher(ClockWatcher clockWatcher)
Specified by:
setClockWatcher in interface Evolver
Parameters:
clockWatcher - the clockWatcher to set

setEvolvables

public void setEvolvables(java.util.Map<? extends Evolvable,? extends java.lang.Integer> map)
Bean-type method to define the evolvables. This is invoked by reflection during configuration.

Parameters:
map - A map of Evolvable objects, each with the number of ticks between generations. The evolutionary process proceeds one tick at a time, but not every evolvable will undergo a new generation for every tick. For instance, the 13-year and 17-year cicadas would have tick values of 13 and 17 assuming that the Evolution proceeded one tick per year.

setListeners

public void setListeners(java.util.Collection<? extends GenerationListener> listeners)
This is invoked by reflection during configuration.

Parameters:
listeners -

setVisualizableListeners

public void setVisualizableListeners(java.util.Collection<VisualizableListener> visualizableListeners)
Method to clear and reset the visualizable listeners. This is invoked by reflection during configuration.

Parameters:
visualizableListeners -

getEvolvables

protected java.util.Map<Evolvable,java.lang.Integer> getEvolvables()
Returns:
the map of the evolvables.

getListeners

protected java.util.Collection<GenerationListener> getListeners()
Returns:
the list of listeners

getVisualizableListeners

protected java.util.Collection<VisualizableListener> getVisualizableListeners()
Returns:
the visualizableListeners


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.