Package org.evoludo.simulator.views
Class Histogram
Object
UIObject
Widget
Composite
AbstractView
Histogram
- All Implemented Interfaces:
HasAttachHandlers,HasHandlers,EventListener,HasVisibility,IsRenderable,IsWidget,ProvidesResize,RequiresResize,AbstractGraph.Controller,ChangeListener,MilestoneListener
The view to display a histogram of various quantities of the current EvoLudo
model.
- Author:
- Christoph Hauert
-
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) intThe size of the bins in pixels.private ContextMenuItemThe clear context menu.protected booleanThe flag to indicate whether the properties of the gemetric structure have been processed.private booleanThe flag to indicate whether the view is in statistics mode.protected List<HistoGraph> The list of graphs that display the time series data.protected booleanFlag to indicate whether the model entertains multiple species, i.e.(package private) doubleThe scaling factor to map the data onto bins.protected StringThe status of the view.protected doubleThe time of the last update.Fields inherited from class AbstractView
engine, exportSubmenu, exportSubmenuTrigger, gCols, gRows, isActive, isLoaded, logger, MIN_MSEC_BETWEEN_UPDATES, model, restoreMenu, timestamp, type, wrapperFields inherited from class UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionHistogram(EvoLudoGWT engine, Data type) Construct a new view to display the histogram of various quantities. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAllocate all graphs managed by this view.private booleanCheck the mode of the view.private booleandoFixtimeDistr(Module module) Helper method to check whether to show the fixation time distribution or the fixation times for each node.protected voidExport the statistics data.protected AbstractView.ExportType[]Return the list of export types that are acceptable for _all_ graphs in this view.private intgetDegreeBins(Geometry inter, Geometry comp) Determine the number of bins required for the degree distributions of the interaction and competition geometries.private intgetDegreeGraphs(Geometry inter, Geometry comp) Determine the number of histograms required for the degree distributions of the interaction and competition geometries.private voidgetDegreeHistogramData(double[][] data, Geometry geometry, int idx, double ibinwidth) Generate the degree histogram data for the given geometry.private voidgetDegreeHistogramData(double[][] data, Geometry inter, Geometry comp) Generate the degree histogram data for the given interaction and competition geometries.private String[]getDegreeLabels(int nTraits, boolean interUndirected) Get the labels for the degree distributions of the interaction and competition geometries.getMode()Get the mode of this view.getName()Get the name of this view.getStatus(boolean force) Get the status of this view.private static intmaxDegree(int max) Calculate the maximum degree for displaying the degree distribution.voidCalled after the EvoLudo model got re-initialized.voidCalled when the settings of the EvoLudo model changed but no reset was necessary.voidOpportunity for the controller to add functionality to the context menu (optional implementation).voidreset(boolean hard) Called when a module has been reset.voidupdate(boolean force) Called when the view needs updating.Methods inherited from class AbstractView
activate, createWidget, deactivate, destroyGraphs, dispose, export, export, exportDataHeader, exportMeanData, exportPNG, exportSVG, exportTrajData, getGraphAt, getLogger, getModel, getStatus, getType, hasLayout, isRunning, keyDownHandler, keyUpHandler, layoutComplete, load, modelChanged, modelDidReset, modelStopped, modelUnloaded, moduleRestored, moduleUnloaded, onResize, scheduleUpdate, setBounds, setMode, 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, onUnload, 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.Controller
setInitialStateMethods inherited from interface MilestoneListener
modelLoaded, modelRelaxed, modelRunning, moduleLoaded
-
Field Details
-
graphs
The list of graphs that display the time series data.- Implementation Notes:
List<HistoGraph> graphsis deliberately hidingList<AbstractGraph> graphsfrom the superclass because it saves a lot of ugly casting. Note that the two fields point to one and the same object.
-
scale2bins
double scale2binsThe scaling factor to map the data onto bins. -
binSize
int binSizeThe size of the bins in pixels. -
isMultispecies
protected boolean isMultispeciesFlag to indicate whether the model entertains multiple species, i.e.nSpecies>1. Convenience field. Reduces calls toModule. -
degreeProcessed
protected boolean degreeProcessedThe flag to indicate whether the properties of the gemetric structure have been processed. -
doStatistics
private boolean doStatisticsThe flag to indicate whether the view is in statistics mode. -
updatetime
protected double updatetimeThe time of the last update. -
status
The status of the view. -
clearMenu
The clear context menu.
-
-
Constructor Details
-
Histogram
Construct a new view to display the histogram of various quantities.- 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- Returns:
- the name of this view
-
getMode
Description copied from class:AbstractViewGet the mode of this view. The graphical visualizations can request different modes for running the model. The default mode isMode.DYNAMICSto generate a time series of the states of the model. Some views may digest data and, for example, show statistics such as fixation probabilities or times, in which case the modeMode.STATISTICS_SAMPLEorMode.STATISTICS_UPDATEshould be requested.- Overrides:
getModein classAbstractView- Returns:
- the mode of this view
- See Also:
-
allocateGraphs
protected void 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- See Also:
-
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- Parameters:
hard- the flag to indicate whether to do a hard reset
-
modelSettings
public void modelSettings()Description copied from interface:MilestoneListenerCalled when the settings of the EvoLudo model changed but no reset was necessary. -
modelDidInit
public void modelDidInit()Description copied from interface:MilestoneListenerCalled after the EvoLudo model got re-initialized.- Specified by:
modelDidInitin interfaceMilestoneListener- Overrides:
modelDidInitin classAbstractView
-
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- Parameters:
force-trueto force the update
-
checkStatistics
private boolean checkStatistics()Check the mode of the view.- Returns:
trueif the view is in statistics mode
-
doFixtimeDistr
Helper method to check whether to show the fixation time distribution or the fixation times for each node.- Parameters:
module- the module of the graph- Returns:
trueto show the fixation time distribution
-
getStatus
Description copied from class:AbstractViewGet the status of this view. Views that aggregate data may want to provide custom status information. HTML formatting is acceptable. Some status updates may be expensive to compute and views may decide to ignore thegetStatusrequest, except ifforceistrue.- Overrides:
getStatusin classAbstractView- Parameters:
force- whether to force an update of the status- Returns:
- the status of this view
-
maxDegree
private static int maxDegree(int max) Calculate the maximum degree for displaying the degree distribution. This roundsmaxup to10, 20, 50, 100, 200, 500, 1000etc.- Parameters:
max- the maximum degree of the graph- Returns:
- the maximum degree to display
-
getDegreeHistogramData
Generate the degree histogram data for the given interaction and competition geometries.- Parameters:
data- the data array for storing the histogramsinter- the interaction graphcomp- the competition graph
-
getDegreeHistogramData
Generate the degree histogram data for the given geometry.- Parameters:
data- the data array for storing the histogramsgeometry- the interaction graphidx- the index for placing the histogram dataibinwidth- the scaling factor to map degrees to bins
-
getDegreeGraphs
Determine the number of histograms required for the degree distributions of the interaction and competition geometries.- Parameters:
inter- the interaction geometrycomp- the competition geometry- Returns:
- the number of histograms required
-
getDegreeBins
Determine the number of bins required for the degree distributions of the interaction and competition geometries.- Parameters:
inter- the interaction geometrycomp- the competition geometry- Returns:
- the number of histograms required
-
getDegreeLabels
Get the labels for the degree distributions of the interaction and competition geometries.- Parameters:
nTraits- the number of traitsinterUndirected-trueif the interaction graph is undirected- Returns:
- the labels for the degree distributions
-
populateContextMenu
Description copied from interface:AbstractGraph.ControllerOpportunity for the controller to add functionality to the context menu (optional implementation).- Specified by:
populateContextMenuin interfaceAbstractGraph.Controller- Overrides:
populateContextMenuin classAbstractView- Parameters:
menu- the context menu
-
exportTypes
Description copied from class:AbstractViewReturn the list of export types that are acceptable for _all_ graphs in this view.- Overrides:
exportTypesin classAbstractView- Returns:
- the list of viable export types
-
exportStatData
protected void exportStatData()Description copied from class:AbstractViewExport the statistics data.Important: Must be overridden by subclasses that return
AbstractView.ExportType.STAT_DATAamong their export data types.- Overrides:
exportStatDatain classAbstractView- See Also:
-