Class Distribution
- All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, TooltipProvider, TooltipProvider.Index, ChangeListener, LifecycleListener, RunListener, SampleListener, BasicTooltipProvider
View component that renders the distribution of continuous traits for one or
more species in the EvoLudo simulation. This view produces either a 1D
histogram (for a single trait) with temporal history represented as stacked
rows, or a 2D density plot (phase plane) for pairs of traits. The view is
intended to be used with continuous models only and expects the simulation
model to provide trait ranges and histogram data. For more than two traits
the context menu allows to select the traits shown along the horizontal and
vertical axes.
Responsibilities
- Create and manage one PopGraph2D per species module returned by the engine.
- Allocate and maintain a shared bin storage array sized to the current
geometry (
MAX_BINSfor 1D,MAX_BINS * MAX_BINSfor 2D). - Configure graph appearance (axis labels, ranges, ticks, color map) based on the underlying Continuous module trait metadata.
- Request 1D/2D trait histogram data from the CModel implementation and translate those values into the graph data using the graph's color map.
- Provide tooltips for histogram bins and a contextual menu to select which traits to display on the X/Y axes (the latter only for multi-trait modules).
Behavioral notes
MAX_BINS(100) controls the resolution along each trait axis. For single-trait modules a LINEAR geometry of sizeMAX_BINSis used (with history rows), for multi-trait modules a square lattice withMAX_BINS * MAX_BINSbins is used.- The shared
binsarray is reallocated when the geometry size changes. - When initializing or resetting, the view updates axis ranges from the
Continuousmodule's reported trait min/max; changes to those ranges trigger a hard reset of the corresponding PopGraph2D. - The view currently only supports
Data.TRAITtype; calls with otherDatatypes throwUnsupportedOperationException. - The tooltip content formats trait interval(s), frequency, and (for 1D histograms) the associated time slice.
- Trait selection via the context menu is available when the module exposes three or more traits; submenus allow choosing the trait displayed on each axis. Selecting an axis trait triggers a hard reset to rebuild geometries and redraw.
- Export formats supported by this view are SVG and PNG.
Collaborators
EvoLudoGWTengine — provides modules, configuration, and model time/updates.PopGraph2D— per-species graph widget used to render histogram/heatmap data.CModel— queried for 1D/2D trait histogram data.Continuous— module type that exposes trait names and min/max ranges.AbstractGeometry— describes graph layout (LINEAR or SQUARE) and required storage size.
Notes
Histogram data are copied into the shared bins buffer and immediately applied to the graph's data arrays. This avoids repeated allocations but means that graphs cannot retain history independently.- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassCommand to toggle the inclusion of a trait on the phase plane axes.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
FieldsModifier and TypeFieldDescription(package private) double[]The storage to accommodate the trait histograms.protected static final intThe maximum number of bins for the trait histograms.(package private) intThe index of the trait to be shown along the x-axis.private ContextMenuCheckBoxItem[]The context menu for selecting traits to display on the horizontal axis.private ContextMenuThe context menu trigger for selecting traits to display on the horizontal axis.(package private) intThe index of the trait to be shown along the y-axis.private ContextMenuCheckBoxItem[]The context menu for selecting traits to display on the vertical axis.private ContextMenuThe context menu trigger for selecting traits to display on the vertical axis.Fields inherited from class AbstractView
engine, exportSubmenu, exportSubmenuTrigger, gCols, graphs, gRows, isActive, isLoaded, logger, MIN_MSEC_BETWEEN_UPDATES, model, options, restoreMenu, timestamp, type, updatetimeStatus, updatetimeView, 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
ConstructorsConstructorDescriptionDistribution(EvoLudoGWT engine, Data type) Construct a new view to display the distribution of continuous traits of the current EvoLudo model. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanAllocate all graphs managed by this view.private AbstractGeometrycreateGeometry(int nTraits) Create a geometry for the given number of traits.protected AbstractView.ExportType[]Return the list of export types that are acceptable for _all_ graphs in this view.getName()Get the name of this view.getTooltipAt(AbstractGraph<?> graph, int node) Get the tooltip for the location with indexindex.voidCalled after the EvoLudo model got re-initialized.voidpopulateContextMenuAt(ContextMenu menu, int node) Opportunity for the controller to add functionality to the context menu (optional implementation).voidreset(boolean hard) Called when a module has been reset.private voidresetTrait(PopGraph2D graph, boolean hard) Reset the given graph for displaying trait distributions.voidupdate(boolean force) Called when the view needs updating.Methods inherited from class AbstractView
activate, deactivate, destroyGraphs, doUpdateStatus, doUpdateView, export, export, exportDataHeader, exportMeanData, exportPNG, exportStatData, exportSVG, exportTrajData, getGraphAt, getLogger, getMode, getModel, getModelType, getStatus, getStatus, getType, hasLayout, isActive, isRunning, layoutComplete, load, modelChanged, modelDidReset, modelLoaded, modelStopped, modelUnloaded, moduleRestored, moduleUnloaded, mouseHitNode, mouseHitNode, onKeyDown, onKeyUp, onResize, onUnload, parse, populateContextMenu, scheduleUpdate, setBounds, setInitialState, setOptions, shift, unload, update, updateData, 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
moduleLoadedMethods inherited from interface RunListener
modelRelaxed, modelRunning, modelSettingsMethods inherited from interface SampleListener
modelSample
-
Field Details
-
MAX_BINS
protected static final int MAX_BINSThe maximum number of bins for the trait histograms.- See Also:
-
bins
double[] binsThe storage to accommodate the trait histograms. -
traitXIdx
int traitXIdxThe index of the trait to be shown along the x-axis. -
traitYIdx
int traitYIdxThe index of the trait to be shown along the y-axis. -
traitXItems
The context menu for selecting traits to display on the horizontal axis. -
traitYItems
The context menu for selecting traits to display on the vertical axis. -
traitXMenu
The context menu trigger for selecting traits to display on the horizontal axis. -
traitYMenu
The context menu trigger for selecting traits to display on the vertical axis.
-
-
Constructor Details
-
Distribution
Construct a new view to display the distribution of continuous traits 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<PopGraph2D>- 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<PopGraph2D>- Returns:
trueif graphs were (re)allocated- See Also:
-
reset
public void reset(boolean hard) Description copied from class:AbstractViewCalled when a module has been reset. All graphs of the view are reset and updated if needed, unlesshardisfalse.- Overrides:
resetin classAbstractView<PopGraph2D>- Parameters:
hard- the flag to indicate whether to do a hard reset
-
resetTrait
Reset the given graph for displaying trait distributions.- Parameters:
graph- the graph to resethard- the flag to indicate whether to force a hard reset
-
modelDidInit
public void modelDidInit()Description copied from interface:RunListenerCalled after the EvoLudo model got re-initialized.- Specified by:
modelDidInitin interfaceRunListener- Overrides:
modelDidInitin classAbstractView<PopGraph2D>
-
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<PopGraph2D>- Parameters:
force-trueto force the update
-
createGeometry
Create a geometry for the given number of traits. Utility method to generate a linear geometry (with history) for a single trait and a 2D square lattice for multiple traits.- Parameters:
nTraits- the number of traits- Returns:
- the geometry
-
getTooltipAt
Description copied from interface:TooltipProvider.IndexGet the tooltip for the location with indexindex.- Specified by:
getTooltipAtin interfaceTooltipProvider.Index- Parameters:
graph- the graph requesting the tooltipnode- theindexof the location- Returns:
- the tooltip for the node
- See Also:
-
populateContextMenuAt
Description copied from class:AbstractViewOpportunity for the controller to add functionality to the context menu (optional implementation). Additional entries should be added tomenu. If the context menu was opened while the mouse was over a node its index isnode. At this point the menu already contains entries that are relevant for all graphs, e.g. fullscreen and export. Override this method to add further, more specialized entries. Finally, the current pane will be asked whether it wants to add further entries (e.g. autoscale axes) (optional implementation).- Overrides:
populateContextMenuAtin classAbstractView<PopGraph2D>- Parameters:
menu- the context menunode- the index of node- See Also:
-
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
-