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.ExportType
Nested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
Nested classes/interfaces inherited from interface ChangeListener
ChangeListener.PendingAction
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
The size of the bins in pixels.private ContextMenuItem
The clear context menu.protected boolean
The flag to indicate whether the properties of the gemetric structure have been processed.private boolean
The flag to indicate whether the view is in statistics mode.protected List
<HistoGraph> The list of graphs that display the time series data.protected boolean
Flag to indicate whether the model entertains multiple species, i.e.(package private) double
The scaling factor to map the data onto bins.protected String
The status of the view.protected double
The 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, wrapper
Fields 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 void
Allocate all graphs managed by this view.private boolean
Check the mode of the view.private boolean
doFixtimeDistr
(Module module) Helper method to check whether to show the fixation time distribution or the fixation times for each node.protected void
Export the statistics data.protected AbstractView.ExportType[]
Return the list of export types that are acceptable for _all_ graphs in this view.private int
getDegreeBins
(Geometry inter, Geometry comp) Determine the number of bins required for the degree distributions of the interaction and competition geometries.private int
getDegreeGraphs
(Geometry inter, Geometry comp) Determine the number of histograms required for the degree distributions of the interaction and competition geometries.private void
getDegreeHistogramData
(double[][] data, Geometry geometry, int idx, double ibinwidth) Generate the degree histogram data for the given geometry.private void
getDegreeHistogramData
(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 int
maxDegree
(int max) Calculate the maximum degree for displaying the degree distribution.void
Called after the EvoLudo model got re-initialized.void
Called when the settings of the EvoLudo model changed but no reset was necessary.void
Opportunity for the controller to add functionality to the context menu (optional implementation).void
reset
(boolean hard) Called when a module has been reset.void
update
(boolean force) Called when the view needs updating.Methods inherited from class AbstractView
activate, clear, 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, zoom
Methods inherited from class Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
Methods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
Methods 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, toString
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface AbstractGraph.Controller
setInitialState
Methods 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> graphs
is deliberately hidingList<AbstractGraph> graphs
from 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:AbstractView
Get the name of this view. This is used to dynamically build the view selector.- Specified by:
getName
in classAbstractView
- Returns:
- the name of this view
-
getMode
Description copied from class:AbstractView
Get the mode of this view. The graphical visualizations can request different modes for running the model. The default mode isMode.DYNAMICS
to 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_SAMPLE
orMode.STATISTICS_UPDATE
should be requested.- Overrides:
getMode
in classAbstractView
- Returns:
- the mode of this view
- See Also:
-
allocateGraphs
protected void allocateGraphs()Description copied from class:AbstractView
Allocate 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:
allocateGraphs
in classAbstractView
- See Also:
-
reset
public void reset(boolean hard) Description copied from class:AbstractView
Called when a module has been reset. All graphs are reset and updated if needed, unlesshard
istrue
.- Overrides:
reset
in classAbstractView
- Parameters:
hard
- the flag to indicate whether to do a hard reset
-
modelSettings
public void modelSettings()Description copied from interface:MilestoneListener
Called when the settings of the EvoLudo model changed but no reset was necessary. -
modelDidInit
public void modelDidInit()Description copied from interface:MilestoneListener
Called after the EvoLudo model got re-initialized.- Specified by:
modelDidInit
in interfaceMilestoneListener
- Overrides:
modelDidInit
in classAbstractView
-
update
public void update(boolean force) Description copied from class:AbstractView
Called 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 unlessforce
istrue
.- Specified by:
update
in classAbstractView
- Parameters:
force
-true
to force the update
-
checkStatistics
private boolean checkStatistics()Check the mode of the view.- Returns:
true
if 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:
true
to show the fixation time distribution
-
getStatus
Description copied from class:AbstractView
Get 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 thegetStatus
request, except ifforce
istrue
.- Overrides:
getStatus
in 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 roundsmax
up to10, 20, 50, 100, 200, 500, 1000
etc.- 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
-true
if the interaction graph is undirected- Returns:
- the labels for the degree distributions
-
populateContextMenu
Description copied from interface:AbstractGraph.Controller
Opportunity for the controller to add functionality to the context menu (optional implementation).- Specified by:
populateContextMenu
in interfaceAbstractGraph.Controller
- Overrides:
populateContextMenu
in classAbstractView
- Parameters:
menu
- the context menu
-
exportTypes
Description copied from class:AbstractView
Return the list of export types that are acceptable for _all_ graphs in this view.- Overrides:
exportTypes
in classAbstractView
- Returns:
- the list of viable export types
-
exportStatData
protected void exportStatData()Description copied from class:AbstractView
Export the statistics data.Important: Must be overridden by subclasses that return
AbstractView.ExportType.STAT_DATA
among their export data types.- Overrides:
exportStatData
in classAbstractView
- See Also:
-