Class Histogram

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, AbstractGraph.Controller, ChangeListener, MilestoneListener

public class Histogram extends AbstractView
The view to display a histogram of various quantities of the current EvoLudo model.
Author:
Christoph Hauert
  • Field Details

    • graphs

      protected List<HistoGraph> graphs
      The list of graphs that display the time series data.
      Implementation Notes:
      List<HistoGraph> graphs is deliberately hiding List<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 scale2bins
      The scaling factor to map the data onto bins.
    • binSize

      int binSize
      The size of the bins in pixels.
    • isMultispecies

      protected boolean isMultispecies
      Flag to indicate whether the model entertains multiple species, i.e. nSpecies&gt;1. Convenience field. Reduces calls to Module.
    • degreeProcessed

      protected boolean degreeProcessed
      The flag to indicate whether the properties of the gemetric structure have been processed.
    • doStatistics

      private boolean doStatistics
      The flag to indicate whether the view is in statistics mode.
    • updatetime

      protected double updatetime
      The time of the last update.
    • status

      protected String status
      The status of the view.
    • clearMenu

      private ContextMenuItem clearMenu
      The clear context menu.
  • Constructor Details

    • Histogram

      public Histogram(EvoLudoGWT engine, Data type)
      Construct a new view to display the histogram of various quantities.
      Parameters:
      engine - the pacemaker for running the model
      type - the type of data to display
  • Method Details

    • getName

      public String 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 class AbstractView
      Returns:
      the name of this view
    • getMode

      public Mode 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 is Mode.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 mode Mode.STATISTICS_SAMPLE or Mode.STATISTICS_UPDATE should be requested.
      Overrides:
      getMode in class AbstractView
      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's calcBounds(int, int) is triggered through setBounds(int, int) to properly calculate the layout.
      Specified by:
      allocateGraphs in class AbstractView
      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, unless hard is true.
      Overrides:
      reset in class AbstractView
      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 interface MilestoneListener
      Overrides:
      modelDidInit in class AbstractView
    • 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 unless force is true.
      Specified by:
      update in class AbstractView
      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

      private boolean doFixtimeDistr(Module module)
      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

      public String getStatus(boolean force)
      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 the getStatus request, except if force is true.
      Overrides:
      getStatus in class AbstractView
      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 rounds max up to 10, 20, 50, 100, 200, 500, 1000 etc.
      Parameters:
      max - the maximum degree of the graph
      Returns:
      the maximum degree to display
    • getDegreeHistogramData

      private void getDegreeHistogramData(double[][] data, Geometry inter, Geometry comp)
      Generate the degree histogram data for the given interaction and competition geometries.
      Parameters:
      data - the data array for storing the histograms
      inter - the interaction graph
      comp - the competition graph
    • getDegreeHistogramData

      private void getDegreeHistogramData(double[][] data, Geometry geometry, int idx, double ibinwidth)
      Generate the degree histogram data for the given geometry.
      Parameters:
      data - the data array for storing the histograms
      geometry - the interaction graph
      idx - the index for placing the histogram data
      ibinwidth - the scaling factor to map degrees to bins
    • getDegreeGraphs

      private int getDegreeGraphs(Geometry inter, Geometry comp)
      Determine the number of histograms required for the degree distributions of the interaction and competition geometries.
      Parameters:
      inter - the interaction geometry
      comp - the competition geometry
      Returns:
      the number of histograms required
    • getDegreeBins

      private int getDegreeBins(Geometry inter, Geometry comp)
      Determine the number of bins required for the degree distributions of the interaction and competition geometries.
      Parameters:
      inter - the interaction geometry
      comp - the competition geometry
      Returns:
      the number of histograms required
    • getDegreeLabels

      private String[] getDegreeLabels(int nTraits, boolean interUndirected)
      Get the labels for the degree distributions of the interaction and competition geometries.
      Parameters:
      nTraits - the number of traits
      interUndirected - true if the interaction graph is undirected
      Returns:
      the labels for the degree distributions
    • populateContextMenu

      public void populateContextMenu(ContextMenu menu)
      Description copied from interface: AbstractGraph.Controller
      Opportunity for the controller to add functionality to the context menu (optional implementation).
      Specified by:
      populateContextMenu in interface AbstractGraph.Controller
      Overrides:
      populateContextMenu in class AbstractView
      Parameters:
      menu - the context menu
    • exportTypes

      protected AbstractView.ExportType[] exportTypes()
      Description copied from class: AbstractView
      Return the list of export types that are acceptable for _all_ graphs in this view.
      Overrides:
      exportTypes in class AbstractView
      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 class AbstractView
      See Also: