|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Panel java.applet.Applet javax.swing.JApplet com.rubecula.darwin.visualization.swing.EvolutionaryApplet
public abstract class EvolutionaryApplet
This subclass of JApplet
understands how to interact with an
Evolution
, by virtue of implementing GenerationListener
and
ControlAction
.
It expects that the Evolution object has the property "ui" set to this applet
in the bean configuration file (otherwise, the field evolution
will
not be set when it needs to be).
The init()
method is marked as final (see comments) and thus all
preparatory UI work must be done in the setup()
method
implementations.
This applet has optional censusing capability.
This applet controls a Taxon evolutionary computation system. Essentially,
this applet defines a panel with border layout (N,E,S,W, center). The E/W
panels are unused. The N panel contains a title and the S panel contains a
control panel. The center panel delegates its functionality to an instance of
the VisualizerTabs
class.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JApplet |
---|
javax.swing.JApplet.AccessibleJApplet |
Nested classes/interfaces inherited from class java.applet.Applet |
---|
java.applet.Applet.AccessibleApplet |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected Title |
_title
|
protected static java.lang.String |
APPLET_PARAM_ENABLE_SLIDER
enableSlider |
protected javax.swing.JPanel |
controlPanel
This is the control panel which allows the user to adjust settings. |
protected static java.lang.String |
DEFAULT_PROPERTIES_URL
TODO need to fix this. |
protected Evolution |
evolution
|
protected static java.lang.String |
LBL_VERSION
Version |
protected static org.apache.commons.logging.Log |
LOG
The logger for this class. |
static java.lang.String |
P_TITLE_APPLICATION
TitleApplication |
protected static java.lang.String |
PROPERTIES_URL
|
Fields inherited from class javax.swing.JApplet |
---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface com.rubecula.darwin.domain.helper.GenerationListener |
---|
$1_SECOND |
Fields inherited from interface com.rubecula.darwin.visualization.ControlAction |
---|
NEXT, QUIT, START, STOP, TIME_DELAY |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
protected |
EvolutionaryApplet()
Instantiate the applet, retrieving the title for the applet from the message.properties file (property Applet_Darwinian.0) |
Method Summary | |
---|---|
protected javax.swing.JPanel |
createControlPanel(ControlAction controlAction)
|
protected javax.swing.JLabel |
createEastPanel()
|
protected javax.swing.JPanel |
createNorthPanel(boolean opaque)
|
protected abstract java.util.Map<java.lang.String,java.awt.Component> |
createOptionsComponentMap()
Needs to be overridden by extenders. |
protected javax.swing.JPanel |
createSouthPanel()
|
protected javax.swing.JLabel |
createWestPanel()
|
void |
destroy()
shut down the evolution. |
protected boolean |
getBooleanParameter(java.lang.String parameterName,
boolean defaultValue)
|
protected javax.swing.JPanel |
getControlPanel()
|
protected java.lang.String |
getDefaultBeansFilename()
Subclasses should override this as appropriate. |
Evolution |
getEvolution()
|
java.lang.String |
getParameter(java.lang.String parameterName,
java.lang.String defaultValue)
|
protected Title |
getTitle()
|
void |
init()
Final implementation of init(). |
void |
onGeneration(Evolvable evolvable)
This method is called whenever the Evolvable implementer
completes a new generation or when the Evolution itself is
completely exhausted (has no more evolvables to work with). |
void |
setAppletTitle(java.lang.String title)
|
void |
setControlPanel(ControlPanel_ controlPanel)
|
void |
setEvolution(Evolution evolution)
|
void |
setProperty(java.lang.String name,
java.lang.Object value)
Update the system according to a user-interface property change. |
void |
setState(java.lang.String state)
Method to set a state . |
boolean |
settable(java.lang.String propertyName)
|
protected abstract void |
setup()
Method which is called by invoked by init() , after invoking the
super-method. |
protected void |
setupLayout()
|
void |
start()
Initialize the evolution. |
void |
stop()
Cleanup the evolution |
void |
update(java.awt.Graphics graphics)
This is required for double-buffering to work correctly. |
protected abstract void |
updateModel(java.lang.String name,
java.lang.Object value)
|
Methods inherited from class javax.swing.JApplet |
---|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler |
Methods inherited from class java.applet.Applet |
---|
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus |
Methods inherited from class java.awt.Panel |
---|
addNotify |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String DEFAULT_PROPERTIES_URL
file:../config/pepperedMoth.properties
But to deploy as an
applet you will have to set the parameter PROPERTIES_URL
as an
applet (embed) parameter in the HTML.
protected static final java.lang.String PROPERTIES_URL
protected Evolution evolution
protected javax.swing.JPanel controlPanel
protected final transient Title _title
public static final java.lang.String P_TITLE_APPLICATION
protected static final org.apache.commons.logging.Log LOG
protected static final java.lang.String APPLET_PARAM_ENABLE_SLIDER
protected static final java.lang.String LBL_VERSION
Constructor Detail |
---|
protected EvolutionaryApplet() throws java.awt.HeadlessException
java.awt.HeadlessException
Method Detail |
---|
public void destroy()
destroy
in class java.applet.Applet
Applet.destroy()
public Evolution getEvolution()
getEvolution
in interface Evolutionary
Evolutionary.getEvolution()
public java.lang.String getParameter(java.lang.String parameterName, java.lang.String defaultValue)
parameterName
- defaultValue
-
public final void init()
Final implementation of init(). This is final in order to avoid the
inevitable confusion caused by overriding this method. All of the user
interface work that would normally appear in the init()
method
is actually defined in the setup()
method which is called from
within this method (after the call to the super-method and the beans
configuration).
Here is the sequence:
BeanContainer.setConfiguration(Class, String)
;BeanContainer.imposeBean(String, Object)
;BeanContainer.configure()
;BeanContainer.showBeans()
;setup()
;BeanContainer.runBeans()
.
The beans used by this EvolutionaryApplet are instantiated and configured
here (after the super.init() method is invoked). The reference to this
Applet
is typically dependency-injected into at least some of the
beans. Note that the configuration includes all pre- and
post-configuration processing.
The filename of the beans definition is provided by the "beans" applet
parameter. If the "beans" parameter is unset, then the filename defaults
to getDefaultBeansFilename()
. Assuming that the filename is a
relative name, beans file should reside in the resources directory, under
the package of the concrete class being instantiated (not typically in
the package that this class resides in).
init
in class java.applet.Applet
Applet.init()
public void onGeneration(Evolvable evolvable)
GenerationListener
Evolvable
implementer
completes a new generation or when the Evolution
itself is
completely exhausted (has no more evolvables to work with).
onGeneration
in interface GenerationListener
evolvable
- the implementer of Evolvable
which has completed a
generation or null if the Evolution
itself has
completed.
NOTE: implementers of this method must be prepared to accept
null as the parameter.GenerationListener.onGeneration(com.rubecula.darwin.foundation.Evolvable)
public void setAppletTitle(java.lang.String title)
title
- JLabel.setText(java.lang.String)
public void setControlPanel(ControlPanel_ controlPanel)
controlPanel
- the controlPanel to setpublic void setEvolution(Evolution evolution)
setEvolution
in interface Evolutionary
evolution
- the evolution to setEvolutionary.setEvolution(com.rubecula.darwin.evolution.Evolution)
public void setProperty(java.lang.String name, java.lang.Object value) throws VisualizationException
changeEvolution(String, Object)
. Otherwise, we invoke
updateModel(String, Object)
and then Component.repaint()
.
setProperty
in interface ControlAction
VisualizationException
- XXXControlAction.setProperty(java.lang.String,
java.lang.Object)
public void setState(java.lang.String state) throws VisualizationException
ControlAction
state
.
setState
in interface ControlAction
VisualizationException
- XXXControlAction.setState(java.lang.String)
public boolean settable(java.lang.String propertyName)
settable
in interface ControlAction
ControlAction.settable(java.lang.String)
public void start()
start
in class java.applet.Applet
Applet.start()
public void stop()
stop
in class java.applet.Applet
Applet.stop()
public void update(java.awt.Graphics graphics)
update
in class javax.swing.JApplet
Container.update(java.awt.Graphics)
protected javax.swing.JPanel createControlPanel(ControlAction controlAction)
controlAction
- the object to implement the control actions
ControlPanel_Default
object.
TODO consider using factory class.protected javax.swing.JLabel createEastPanel()
JLabel
protected javax.swing.JPanel createNorthPanel(boolean opaque)
opaque
- true if this panel should be opaque
_title
with opaque property set accordingly.protected abstract java.util.Map<java.lang.String,java.awt.Component> createOptionsComponentMap()
protected javax.swing.JPanel createSouthPanel()
getControlPanel()
.protected javax.swing.JLabel createWestPanel()
JLabel
protected boolean getBooleanParameter(java.lang.String parameterName, boolean defaultValue)
parameterName
- defaultValue
-
getParameter(String, String)
protected javax.swing.JPanel getControlPanel()
protected java.lang.String getDefaultBeansFilename()
FILENAME_BEANS_XML
.protected Title getTitle()
protected abstract void setup()
init()
, after invoking the
super-method.
protected void setupLayout()
protected abstract void updateModel(java.lang.String name, java.lang.Object value) throws VisualizationException
VisualizationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |