Class Pop2D
- All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, TooltipProvider, TooltipProvider.Index, ChangeListener, LifecycleListener, RunListener, SampleListener, BasicTooltipProvider
2D population view for the EvoLudo model.
Pop2D renders a two-dimensional population visualization for
the
EvoLudo simulation. Pop2D is responsible for creating, configuring and
maintaining one or more PopGraph2D subviews that display the current state of
a Module (species) in either individual‑based spatial (IBS) or PDE modes.
Responsibilities
- Allocate and arrange one or more PopGraph2D instances according to the model type (IBS vs PDE) and the number of species.
- Configure graph presentation (axes, ticks, labels, size, border) based
on the geometry of the underlying module and the currently selected
data type (
TRAIT,FITNESS). - Construct ColorMap instances used by graphs to map model state values to colors. Supports continuous trait gradients (1D, 2D, ND), discrete indices, PDE-specific mappings and fitness highlighting for IBS.
- Handle resets and model setting changes by rebuilding/refreshing graphs as needed and deciding when a hard reset (reinitializing reporting or time axes) is required.
- Provide export capabilities for graph content (SVG, PNG).
Behavior notes
- For IBS (individual-based spatial) models,
Pop2Dmay create separate graphs for interaction and competition geometries. Graphs are arranged in a grid whose rows correspond to species and whose columns reflect the number of graphs per species (1 or 2). - For PDE models
Pop2Dcurrently assumes a single (possibly multi-trait) module and creates a single full-size graph. Debugging features for DE-based modules are disabled in this view. - When graph geometry is linear, the graph is configured as an x-vs-time scrolling display (nodes on the x axis, time on the y-axis) and changes to the model's reporting frequency will force a hard reset to reinitialize time axis scaling.
- Color mapping:
TRAIT: continuous models use gradient/hue mappings; discrete and PDE trait displays use indexed or 2D gradient schemes appropriate to the number of traits and any dependent variable for PDEs.FITNESS: values are rendered using a 1D gradient; for IBS models monomorphic (homogeneous) trait fitness scores may be highlighted with pale or special colors to indicate mono‑score locations.
Usage and integration
- Pop2D is constructed with an
EvoLudoGWTengine (the simulation controller) and a Data enumeration indicating which quantity to display. - The class delegates per-module visualization logic to PopGraph2D and
relies on Module,
AbstractGeometryandColorMaphelper classes to query model state and construct visual representations. - Reset and update cycles should be invoked from the UI/event thread that
drives the GWT view lifecycle;
Pop2Dis not safe for concurrent updates from arbitrary threads.
Implementation details
- Extends
GenericPop<String, Network2D, PopGraph2D>and follows that contract for activation, deactivation and lifecycle management. - Graph style is encapsulated in
GraphStyleobjects and adjusted byconfigureGraph(...). Changes to reporting frequency (time step) result in a request for a hard reset so that time axes and sampling align with the new frequency. - ColorMap construction uses a small palette of CSS-based gradient and
index implementations (e.g.
ColorMapCSSclasses) and adapts to the engine's chosenColorModelType.
Limitations and assumptions
- PDE mode is currently restricted to single-species.
- Assumes modules provide geometry information via
AbstractGeometryinstances and thatModuleimplementations expose trait counts, colors, and PDE-dependent indices where applicable.
- 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.PendingActionNested classes/interfaces inherited from interface TooltipProvider
TooltipProvider.Index, TooltipProvider.Parametric, TooltipProvider.Simplex -
Field Summary
Fields inherited from class GenericPop
hitNodeFields 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_PREFIXFields inherited from interface BasicTooltipProvider
TABLE_CELL_BULLET, TABLE_CELL_NEXT, TABLE_CELL_NEXT_COLOR, TABLE_END, TABLE_ROW_END, TABLE_ROW_START, TABLE_ROW_START_COLOR, TABLE_ROW_START_RIGHT, TABLE_SEPARATOR, TABLE_STYLE -
Constructor Summary
ConstructorsConstructorDescriptionPop2D(EvoLudoGWT engine, Data type) Construct a new view to display the configuration of the current state of the EvoLudo model in 2D. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanAllocate all graphs managed by this view.private booleanAllocate graphs for individual-based spatial models.private booleanAllocate graph for PDE models.private booleanconfigureGraph(PopGraph2D graph) Configure the graph's style according to its geometry.createColorMap(Module<?> module) Create the ColorMap for a given module/graph based on the current data type and model settings.createFitnessColorMap(Module<?> module) Helper to create color map for fitness data.createTraitColorMapContinuous(Module<?> module) Helper for continuous trait color maps.createTraitColorMapDiscreteOrPDE(Module<?> module) Helper for discrete and PDE trait color maps.protected AbstractView.ExportType[]Return the list of export types that are acceptable for _all_ graphs in this view.voidCalled when the settings of the EvoLudo model changed but no reset was necessary.voidreset(boolean hard) Called when a module has been reset.Methods inherited from class GenericPop
destroyGraphs, getName, getTooltipAt, hasLayout, layoutComplete, modelChanged, modelDidInit, mouseHitNode, onKeyDown, setGraphGeometry, unload, updateMethods inherited from class AbstractView
activate, deactivate, export, export, exportDataHeader, exportMeanData, exportPNG, exportStatData, exportSVG, exportTrajData, getGraphAt, getLogger, getMode, getModel, getStatus, getStatus, getType, isActive, isRunning, load, modelDidReset, modelStopped, modelUnloaded, moduleRestored, moduleUnloaded, mouseHitNode, onKeyUp, onResize, onUnload, parse, populateContextMenu, populateContextMenuAt, scheduleUpdate, setBounds, setInitialState, setOptions, shift, 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 BasicTooltipProvider
getTooltipAt, getTooltipAtMethods inherited from interface LifecycleListener
modelLoaded, moduleLoadedMethods inherited from interface RunListener
modelRelaxed, modelRunningMethods inherited from interface SampleListener
modelSample
-
Constructor Details
-
Pop2D
Construct a new view to display the configuration of the current state of the EvoLudo model in 2D.- Parameters:
engine- the pacemaker for running the modeltype- the type of data to display
-
-
Method Details
-
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<PopGraph2D>- Returns:
trueif graphs were (re)allocated- See Also:
-
allocateIBSGraphs
private boolean allocateIBSGraphs()Allocate graphs for individual-based spatial models. This method creates separate graphs for interaction and competition geometries.- Returns:
trueif graphs were reallocated
-
allocatePDEGraph
private boolean allocatePDEGraph()Allocate graph for PDE models. Currently restricted to single species.- Returns:
trueif graphs were reallocated
-
modelSettings
public void modelSettings()Description copied from interface:RunListenerCalled when the settings of the EvoLudo model changed but no reset was necessary. -
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<PopGraph2D>- Parameters:
hard- the flag to indicate whether to do a hard reset
-
configureGraph
Configure the graph's style according to its geometry.- Parameters:
graph- the graph to configure- Returns:
trueif a hard reset is required
-
createColorMap
-
createTraitColorMapContinuous
-
createTraitColorMapDiscreteOrPDE
-
createFitnessColorMap
-
exportTypes
Description copied from class:AbstractViewReturn the list of export types that are acceptable for _all_ graphs in this view.- Overrides:
exportTypesin classAbstractView<PopGraph2D>- Returns:
- the list of viable export types
-