Class GenericPop<T,N extends Network,G extends GenericPopGraph<T,N>>

Type Parameters:
T - type of color object: String for 2D and MeshLambertMaterial for 3D
N - type of network
G - type of graph
All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, AbstractGraph.Controller, GenericPopGraph.PopGraphController, TooltipProvider, TooltipProvider.Index, ChangeListener, MilestoneListener, BasicTooltipProvider
Direct Known Subclasses:
Pop2D, Pop3D

public abstract class GenericPop<T,N extends Network,G extends GenericPopGraph<T,N>> extends AbstractView implements GenericPopGraph.PopGraphController, TooltipProvider.Index
The abstract parent class for views that display the configuration of the current state of the model in 2D or 3D. The visual representation depends on the geometry of the model. Lattice structures have a fixed layout but all other strutures are dynamically generated through a process insipired by the physical arrangement of charged spheres that are connected by springs. The spheres represent members of the population and the springs represent their interaction (or competition) neighbourhood. The size of the sphere scales with the size of the individual's neighbourhood. Moreover, the colour of the spheres reflects the state of the individual, for example their trait or fitness.
Author:
Christoph Hauert
  • Field Details

    • graphs

      protected List<G extends GenericPopGraph<T,N>> graphs
      The list of graphs that display the time series data.
      Implementation Notes:
      List<G> 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.
    • hitNode

      protected int hitNode
      The index of the node that was hit by the mouse.
    • tag

      String tag
      The type of data to display.
  • Constructor Details

    • GenericPop

      public GenericPop(EvoLudoGWT engine, Data type)
      Construct a new view to display the configuration of the current state of the EvoLudo model in 2D or 3D.
      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
    • unload

      public void unload()
      Description copied from class: AbstractView
      Unload the view. This is called when changing the module or model that implement this view. This is independent of the activation of the view.
      Overrides:
      unload in class AbstractView
    • modelChanged

      public void modelChanged(ChangeListener.PendingAction action)
      Description copied from interface: ChangeListener
      Called whenever the state of the EvoLudo model changed. Process potentially pending requests.

      Note: the model may process some pending actions directly and without notifying the listeners through modelChanged(PendingAction) first. In particular, this applies to pending actions that fire their own notifications, such as RESET and INIT that in turn trigger modelReset() and modelInit(), respectively.

      Specified by:
      modelChanged in interface ChangeListener
      Overrides:
      modelChanged in class AbstractView
      Parameters:
      action - pending action that needs to be processed.
      See Also:
    • hasLayout

      public boolean hasLayout()
      Description copied from class: AbstractView
      Check if the view has finished layouting its graphs. Currently only GenericPop and its graphs require layouting.
      Overrides:
      hasLayout in class AbstractView
      Returns:
      true if the view has layout
      See Also:
    • layoutComplete

      public void layoutComplete()
      Description copied from interface: AbstractGraph.Controller
      Notifies the controller of the completion of the layouting process.
      Specified by:
      layoutComplete in interface AbstractGraph.Controller
      Overrides:
      layoutComplete in class AbstractView
    • destroyGraphs

      protected void destroyGraphs()
      Description copied from class: AbstractView
      Destroy all graphs in this view and free up resources.
      Overrides:
      destroyGraphs in class AbstractView
    • setGraphGeometry

      void setGraphGeometry(GenericPopGraph<T,N> graph, boolean inter)
      Helper method to assign a geometry to a graph.
      Parameters:
      graph - the graph to assign the geometry
      inter - true for interaction geometry, false for competition geometry
    • 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
    • keyDownHandler

      public boolean keyDownHandler(String key)
      Opportunity for view to implement keyboard shortcut for actions (repeating). If the key remains pressed this event is triggered repeatedly.

      List of additional shortcuts provided by MVPop2D for the following keys:

      s
      Shake and relax dynamically generated network layouts to help achieve a lower 'energy' state.
      Overrides:
      keyDownHandler in class AbstractView
      Parameters:
      key - the code of the pressed key
      Returns:
      true if the key was handled
      See Also:
    • mouseHitNode

      public void mouseHitNode(int id, int node, boolean alt)
      Description copied from interface: GenericPopGraph.PopGraphController
      Notifies the controller that the mouse/tap has hit node with index node on the graph with the tag id. The flag alt indicates whether the alt-modifier was pressed
      Specified by:
      mouseHitNode in interface GenericPopGraph.PopGraphController
      Parameters:
      id - the id of the graph
      node - the index of the node that was hit
      alt - true if the alt-key was pressed
    • getTooltipAt

      public String getTooltipAt(AbstractGraph<?> agraph, int node)
      Description copied from interface: TooltipProvider.Index
      Get the tooltip for the location with index index.
      Specified by:
      getTooltipAt in interface TooltipProvider.Index
      Parameters:
      agraph - the graph requesting the tooltip
      node - the index of the location
      Returns:
      the tooltip for the node
      See Also:
    • getOpponentInteractionGraph

      private G getOpponentInteractionGraph(G graph)
      Get the interaction graph of the opponent of the module associated with the given graph.
      Parameters:
      graph - the graph for which to get the opponent's interaction graph
      Returns:
      the interaction graph of the opponent
    • getOpponentCompetitionGraph

      private G getOpponentCompetitionGraph(G graph)
      Get the competition graph of the opponent of the module associated with the given graph.
      Parameters:
      graph - the graph for which to get the opponent's competition graph
      Returns:
      the competition graph of the opponent
    • formatStrategiesAt

      private String formatStrategiesAt(int node, Geometry geom, G graph)
      Return a formatted string of the strategies of the opponents at the given node. For intra-species interactions and models with identical interaction and competition graphs, graph.getGeometry() == geom holds.
      Parameters:
      node - the index of the node
      geom - the geometry of the graph
      graph - the graph of the opponent
      Returns:
      the formatted string
    • formatStructureAt

      private static String formatStructureAt(int node, Geometry geom)
      Return a formatted string of the neighbourhood structure at the given node.
      Parameters:
      node - the index of the node
      geom - the geometry of the graph
      Returns:
      the formatted string
    • formatOutStructureAt

      private static String formatOutStructureAt(int node, Geometry geom)
      Return a formatted string of the outgoing neighbours on directed graphs at the given node.
      Parameters:
      node - the index of the node
      geom - the geometry of the graph
      Returns:
      the formatted string
    • formatInStructureAt

      private static String formatInStructureAt(int node, Geometry geom)
      Return a formatted string of the incoming neighbours on directed graphs at the given node.
      Parameters:
      node - the index of the node
      geom - the geometry of the graph
      Returns:
      the formatted string
    • formatStructureAt

      private static String formatStructureAt(int[] links, int k, Geometry.Type type)
      Return a formatted string of the neighbourhood structure at the given node.
      Parameters:
      links - the array of indices of the neighbours
      k - the number of links
      type - the type of the geometry
      Returns:
      the formatted string