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 (
nBinsfor 1D,nBins * nBinsfor 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
- The number of bins per axis is configurable from the context menu
(100/200/500), with
DEFAULT_BINS(100) as the initial value. For single-trait modules a LINEAR geometry of sizenBinsis used (with history rows), for multi-trait modules a square lattice withnBins * nBinsbins 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 TypeFieldDescriptionprivate static final int[]Available bin counts per axis.(package private) double[]The storage to accommodate the trait histograms.protected static final intDefault number of bins per trait axis for histograms.private static final doubleSentinel for unavailable frequency values.private double[]Per-module maxima for the histogram color legend.private intActive number of bins per axis.(package private) intThe index of the trait to be shown along the x-axis.(package private) intThe index of the trait to be shown along the y-axis.Fields inherited from class AbstractView
engine, gCols, graphs, gRows, isActive, isLoaded, logger, MIN_MSEC_BETWEEN_UPDATES, model, options, timestamp, type, updatetimeStatus, updatetimeView, wrapperFields inherited from class UIObject
DEBUG_ID_PREFIXFields inherited from interface BasicTooltipProvider
SPAN_COLOR, 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 TypeMethodDescriptionprivate voidaddBinsMenu(ContextMenu menu) Add binning controls to the context menu.protected voidHook for resize work that needs to happen after the graphs are resized but before the view is repainted.protected booleanAllocate all graphs managed by this view.private voidapplyBinsPerAxis(int newBins) Apply a new number of bins per axis and preserve existing rendered data.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.int[]Return capacities offered in the synchronized buffer-size menu.doublegetLegendMax(int moduleId) Get the maximum histogram frequency for the legend of the module with indexmoduleId.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.voidOpportunity 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.protected voidupdateData(boolean force) Update view-specific data even when GUI rendering is throttled.Methods inherited from class AbstractView
activate, addAxesMenu, addBufferSizeMenu, applyBufferCapacity, beforeResize, bufferCapacityChanged, deactivate, destroyGraphs, doUpdateStatus, doUpdateView, export, export, exportDataHeader, exportMeanData, exportPNG, exportStatData, exportSVG, exportTrajData, formatBufferCapacity, getBufferCapacity, 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, populateAxesMenu, populateContextMenuAt, scheduleUpdate, setBounds, setBufferCapacity, setInitialState, setOptions, setRightYAxis, 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
-
DEFAULT_BINS
protected static final int DEFAULT_BINSDefault number of bins per trait axis for histograms.- See Also:
-
BIN_OPTIONS
private static final int[] BIN_OPTIONSAvailable bin counts per axis. -
INVALID_FREQUENCY
private static final double INVALID_FREQUENCYSentinel for unavailable frequency values.- See Also:
-
nBins
private int nBinsActive number of bins per axis. -
bins
double[] binsThe storage to accommodate the trait histograms. -
legendMax
private double[] legendMaxPer-module maxima for the histogram color legend. -
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.
-
-
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
-
getBufferMenuCapacities
public int[] getBufferMenuCapacities()Description copied from class:AbstractViewReturn capacities offered in the synchronized buffer-size menu.- Overrides:
getBufferMenuCapacitiesin classAbstractView<PopGraph2D>- Returns:
- capacities in entries
-
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>
-
updateData
protected void updateData(boolean force) Description copied from class:AbstractViewUpdate view-specific data even when GUI rendering is throttled.- Overrides:
updateDatain classAbstractView<PopGraph2D>- Parameters:
force- whether the update was explicitly forced
-
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
-
afterResize
protected void afterResize()Description copied from class:AbstractViewHook for resize work that needs to happen after the graphs are resized but before the view is repainted.- Overrides:
afterResizein classAbstractView<PopGraph2D>
-
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:
-
populateContextMenu
Description copied from class:AbstractViewOpportunity for the controller to add functionality to the context menu (optional implementation).- Overrides:
populateContextMenuin classAbstractView<PopGraph2D>- Parameters:
menu- the context menu
-
getLegendMax
public double getLegendMax(int moduleId) Get the maximum histogram frequency for the legend of the module with indexmoduleId.- Parameters:
moduleId- the module identifier- Returns:
- the current histogram maximum or
0.0
-
addBinsMenu
Add binning controls to the context menu.- Parameters:
menu- the context menu to populate
-
applyBinsPerAxis
private void applyBinsPerAxis(int newBins) Apply a new number of bins per axis and preserve existing rendered data.- Parameters:
newBins- the new number of bins per axis
-
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
-