Class Pop2D

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, TooltipProvider, TooltipProvider.Index, ChangeListener, LifecycleListener, RunListener, SampleListener, BasicTooltipProvider

public class Pop2D extends GenericPop<String, Network2D, PopGraph2D>
2D population view for the EvoLudo model.

Pop2D renders a two-dimensional population visualization for the EvoLudo simulation. Pop2D is responsible for creating, configuring and maintaining one or more PopGraph2D subviews that display the current state of a Module (species) in either individual‑based spatial (IBS) or PDE modes.

Responsibilities

  • Allocate and arrange one or more PopGraph2D instances according to the model type (IBS vs PDE) and the number of species.
  • Configure graph presentation (axes, ticks, labels, size, border) based on the geometry of the underlying module and the currently selected data type (TRAIT, FITNESS).
  • Construct ColorMap instances used by graphs to map model state values to colors. Supports continuous trait gradients (1D, 2D, ND), discrete indices, PDE-specific mappings and fitness highlighting for IBS.
  • Handle resets and model setting changes by rebuilding/refreshing graphs as needed and deciding when a hard reset (reinitializing reporting or time axes) is required.
  • Provide export capabilities for graph content (SVG, PNG).

Behavior notes

  • For IBS (individual-based spatial) models, Pop2D may create separate graphs for interaction and competition geometries. Graphs are arranged in a grid whose rows correspond to species and whose columns reflect the number of graphs per species (1 or 2).
  • For PDE models Pop2D currently assumes a single (possibly multi-trait) module and creates a single full-size graph. Debugging features for DE-based modules are disabled in this view.
  • When graph geometry is linear, the graph is configured as an x-vs-time scrolling display (nodes on the x axis, time on the y-axis) and changes to the model's reporting frequency will force a hard reset to reinitialize time axis scaling.
  • Color mapping:
    • TRAIT: continuous models use gradient/hue mappings; discrete and PDE trait displays use indexed or 2D gradient schemes appropriate to the number of traits and any dependent variable for PDEs.
    • FITNESS: values are rendered using a 1D gradient; for IBS models monomorphic (homogeneous) trait fitness scores may be highlighted with pale or special colors to indicate mono‑score locations.

Usage and integration

  • Pop2D is constructed with an EvoLudoGWT engine (the simulation controller) and a Data enumeration indicating which quantity to display.
  • The class delegates per-module visualization logic to PopGraph2D and relies on Module, AbstractGeometry and ColorMap helper classes to query model state and construct visual representations.
  • Reset and update cycles should be invoked from the UI/event thread that drives the GWT view lifecycle; Pop2D is not safe for concurrent updates from arbitrary threads.

Implementation details

  • Extends GenericPop<String, Network2D, PopGraph2D> and follows that contract for activation, deactivation and lifecycle management.
  • Graph style is encapsulated in GraphStyle objects and adjusted by configureGraph(...). Changes to reporting frequency (time step) result in a request for a hard reset so that time axes and sampling align with the new frequency.
  • ColorMap construction uses a small palette of CSS-based gradient and index implementations (e.g. ColorMapCSS classes) and adapts to the engine's chosen ColorModelType.

Limitations and assumptions

  • PDE mode is currently restricted to single-species.
  • Assumes modules provide geometry information via AbstractGeometry instances and that Module implementations expose trait counts, colors, and PDE-dependent indices where applicable.
Author:
Christoph Hauert
See Also:
  • Constructor Details

    • Pop2D

      public Pop2D(EvoLudoGWT engine, Data type)
      Construct a new view to display the configuration of the current state of the EvoLudo model in 2D.
      Parameters:
      engine - the pacemaker for running the model
      type - the type of data to display
  • Method Details

    • allocateGraphs

      protected boolean 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<PopGraph2D>
      Returns:
      true if graphs were (re)allocated
      See Also:
    • allocateIBSGraphs

      private boolean allocateIBSGraphs()
      Allocate graphs for individual-based spatial models. This method creates separate graphs for interaction and competition geometries.
      Returns:
      true if graphs were reallocated
    • allocatePDEGraph

      private boolean allocatePDEGraph()
      Allocate graph for PDE models. Currently restricted to single species.
      Returns:
      true if graphs were reallocated
    • modelSettings

      public void modelSettings()
      Description copied from interface: RunListener
      Called when the settings of the EvoLudo model changed but no reset was necessary.
    • 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<PopGraph2D>
      Parameters:
      hard - the flag to indicate whether to do a hard reset
    • configureGraph

      private boolean configureGraph(PopGraph2D graph)
      Configure the graph's style according to its geometry.
      Parameters:
      graph - the graph to configure
      Returns:
      true if a hard reset is required
    • createColorMap

      private ColorMap<String> createColorMap(Module<?> module)
      Create the ColorMap for a given module/graph based on the current data type and model settings.
      Parameters:
      module - module whose data will be visualized
      Returns:
      configured color map
    • createTraitColorMapContinuous

      private ColorMap<String> createTraitColorMapContinuous(Module<?> module)
      Helper for continuous trait color maps.
      Parameters:
      module - module providing trait metadata
      Returns:
      configured color map
    • createTraitColorMapDiscreteOrPDE

      private ColorMap<String> createTraitColorMapDiscreteOrPDE(Module<?> module)
      Helper for discrete and PDE trait color maps.
      Parameters:
      module - module providing trait metadata
      Returns:
      configured color map
    • createFitnessColorMap

      private ColorMap<String> createFitnessColorMap(Module<?> module)
      Helper to create color map for fitness data. Marks monomorphic scores for IBS.
      Parameters:
      module - module providing trait metadata
      Returns:
      configured color map
    • 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<PopGraph2D>
      Returns:
      the list of viable export types