Class Mean
- All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, AbstractGraph.Shifter, AbstractGraph.Zoomer, ChangeListener, LifecycleListener, RunListener, SampleListener
public class Mean
extends AbstractView<LineGraph>
implements AbstractGraph.Shifter, AbstractGraph.Zoomer
A view that displays time-series plots of mean trait values or mean fitness
for the current EvoLudo model using one or more LineGraph panels.
Responsibilities
- Create and manage the set of
LineGraphpanels appropriate for the current model configuration (one panel per discrete species, or one panel per continuous trait when the model is continuous). - Configure visual style for each graph (labels, y-range, colors, markers) depending on whether the data represents TRAIT or FITNESS and whether the underlying model is continuous or discrete.
- Collect mean values from the model and push them to the graphs on updates; supports both mean +/- standard deviation (continuous) and per-trait frequencies/mean payoffs (discrete).
- Manage zooming and shifting of displayed window of time series data.
- Handle layout, sizing and resetting of graphs when model settings change.
Exports
Supports exporting graphs as SVG and PNG as well as exporting the mean time series data as CSV).- Author:
- Christoph Hauert
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractView
AbstractView.ExportCommand, AbstractView.ExportTypeNested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface ChangeListener
ChangeListener.PendingAction -
Field Summary
FieldsModifier and TypeFieldDescription(package private) double[]The state of the model at the current time.Fields inherited from class AbstractView
engine, exportSubmenu, exportSubmenuTrigger, gCols, graphs, gRows, isActive, isLoaded, logger, MIN_MSEC_BETWEEN_UPDATES, model, options, restoreMenu, timestamp, type, updatetime, wrapperFields inherited from class UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionMean(EvoLudoGWT engine, Data type) Construct a new view to display the time series data of the current EvoLudo model. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddLineGraph(Module<?> module) Create and register the LineGraph(s) for a single module: one graph for the module, and additional graphs for extra traits when the model is continuous.protected booleanAllocate all graphs managed by this view.protected AbstractView.ExportType[]Return the list of export types that are acceptable for _all_ graphs in this view.private voidfinishGraphSetup(LineGraph graph, boolean hard) Finalize the setup of a graph (x-label, x-range, module label).getName()Get the name of this view.voidCalled after the EvoLudo model got re-initialized.voidCalled when the settings of the EvoLudo model changed but no reset was necessary.voidreset(boolean hard) Called when a module has been reset.private booleansetFitRange(LineGraph graph) Set the y-range for fitness graphs; returns true if the range changed.private voidsetupCFitGraph(LineGraph graph) Configure a graph style and colors for fitness in continuous models.private voidsetupCTraitGraph(LineGraph graph, int idx) Configure a graph style and colors for a single continuous trait.private voidsetupDFitGraph(LineGraph graph) Configure a graph style and colors for fitness in discrete models.private voidsetupDTraitGraph(LineGraph graph) Configure a graph style and colors for a discrete module (multiple traits).voidupdate(boolean force) Called when the view needs updating.private double[]Build the data array for continuous fitness graphs (mean +/- stddev).private double[]updateCTraitGraph(int nState, int idx) Build the data array for a continuous-trait graph (mean +/- stddev).private double[]updateDFitGraph(int nState) Build the data array for discrete fitness graphs.private double[]updateDTraitGraph(int nState) Build the data array for a discrete-trait graph.private intupdateGraph(LineGraph graph, Module<?> module, int idx, double newtime) Pull updated mean data for the supplied graph and append it to the data buffer.Methods inherited from class AbstractView
activate, deactivate, destroyGraphs, export, export, exportDataHeader, exportMeanData, exportPNG, exportStatData, exportSVG, exportTrajData, getGraphAt, getLogger, getMode, getModel, getStatus, getStatus, getType, hasLayout, isActive, isRunning, layoutComplete, load, modelChanged, modelDidReset, modelStopped, modelUnloaded, moduleRestored, moduleUnloaded, mouseHitNode, mouseHitNode, onKeyDown, onKeyUp, onResize, onUnload, parse, populateContextMenu, populateContextMenuAt, scheduleUpdate, setBounds, setInitialState, setOptions, shift, unload, update, zoomMethods inherited from class Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidgetMethods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods inherited from class UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbstractGraph.Shifter
shiftMethods inherited from interface AbstractGraph.Zoomer
zoomMethods inherited from interface LifecycleListener
modelLoaded, moduleLoadedMethods inherited from interface RunListener
modelRelaxed, modelRunningMethods inherited from interface SampleListener
modelSample
-
Field Details
-
state
double[] stateThe state of the model at the current time.
-
-
Constructor Details
-
Mean
Construct a new view to display the time series data of the current EvoLudo model.- Parameters:
engine- the pacemaker for running the modeltype- the type of data to display
-
-
Method Details
-
getName
Description copied from class:AbstractViewGet the name of this view. This is used to dynamically build the view selector.- Specified by:
getNamein classAbstractView<LineGraph>- Returns:
- the name of this view
-
allocateGraphs
protected boolean allocateGraphs()Description copied from class:AbstractViewAllocate all graphs managed by this view. This is called when loading the view. Once all views are attached to the browser DOM a call to the graph'scalcBounds(int, int)is triggered throughsetBounds(int, int)to properly calculate the layout.- Specified by:
allocateGraphsin classAbstractView<LineGraph>- Returns:
trueif graphs were (re)allocated- See Also:
-
addLineGraph
Create and register the LineGraph(s) for a single module: one graph for the module, and additional graphs for extra traits when the model is continuous.- Parameters:
module- module for which graphs should be created
-
reset
public void reset(boolean hard) Description copied from class:AbstractViewCalled when a module has been reset. All graphs are reset and updated if needed, unlesshardistrue.- Overrides:
resetin classAbstractView<LineGraph>- Parameters:
hard- the flag to indicate whether to do a hard reset
-
setupDTraitGraph
Configure a graph style and colors for a discrete module (multiple traits).- Parameters:
graph- the graph to configure
-
setupCTraitGraph
Configure a graph style and colors for a single continuous trait.- Parameters:
graph- the graph to configureidx- the index of the trait
-
setFitRange
Set the y-range for fitness graphs; returns true if the range changed.- Parameters:
graph- the graph to configure- Returns:
trueif the y-range changed
-
setupDFitGraph
Configure a graph style and colors for fitness in discrete models.- Parameters:
graph- the graph to configure
-
setupCFitGraph
Configure a graph style and colors for fitness in continuous models.- Parameters:
graph- the graph to configure
-
finishGraphSetup
Finalize the setup of a graph (x-label, x-range, module label).- Parameters:
graph- the graph to configurehard- if true, forces a hard reset of the graph
-
modelSettings
public void modelSettings()Description copied from interface:RunListenerCalled when the settings of the EvoLudo model changed but no reset was necessary.- Specified by:
modelSettingsin interfaceRunListener
-
modelDidInit
public void modelDidInit()Description copied from interface:RunListenerCalled after the EvoLudo model got re-initialized.- Specified by:
modelDidInitin interfaceRunListener- Overrides:
modelDidInitin classAbstractView<LineGraph>
-
update
public void update(boolean force) Description copied from class:AbstractViewCalled when the view needs updating. This gets called when the selected view changed or new data is available from the model. Views may ignore updating requests unlessforceistrue.- Specified by:
updatein classAbstractView<LineGraph>- Parameters:
force-trueto force the update
-
updateGraph
Pull updated mean data for the supplied graph and append it to the data buffer.- Parameters:
graph- graph to updatemodule- module currently being processedidx- index offset used when processing multiple traitsnewtime- latest simulation time- Returns:
- updated index offset for subsequent graphs
-
updateDTraitGraph
private double[] updateDTraitGraph(int nState) Build the data array for a discrete-trait graph.- Parameters:
nState- number of traits- Returns:
- data array (time slot left unassigned)
-
updateCTraitGraph
private double[] updateCTraitGraph(int nState, int idx) Build the data array for a continuous-trait graph (mean +/- stddev).- Parameters:
nState- number of traitsidx- state offset of the current trait- Returns:
- data array (time slot left unassigned)
-
updateDFitGraph
private double[] updateDFitGraph(int nState) Build the data array for discrete fitness graphs.- Parameters:
nState- number of traits- Returns:
- data array (time slot left unassigned)
-
updateCFitGraph
private double[] updateCFitGraph()Build the data array for continuous fitness graphs (mean +/- stddev).- Returns:
- data array (time slot left unassigned)
-
exportTypes
Description copied from class:AbstractViewReturn the list of export types that are acceptable for _all_ graphs in this view.- Overrides:
exportTypesin classAbstractView<LineGraph>- Returns:
- the list of viable export types
-