Package org.evoludo.simulator.views
Class GenericPop<T,N extends Network,G extends GenericPopGraph<T,N>>
Object
UIObject
Widget
Composite
AbstractView
GenericPop<T,N,G>
- Type Parameters:
T
- type of color object: String for 2D andMeshLambertMaterial
for 3DN
- type of networkG
- type of graph
- All Implemented Interfaces:
HasAttachHandlers
,HasHandlers
,EventListener
,HasVisibility
,IsRenderable
,IsWidget
,ProvidesResize
,RequiresResize
,AbstractGraph.Controller
,GenericPopGraph.PopGraphController
,TooltipProvider
,TooltipProvider.Index
,ChangeListener
,MilestoneListener
,BasicTooltipProvider
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
-
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
Nested classes/interfaces inherited from interface TooltipProvider
TooltipProvider.Index, TooltipProvider.Parametric, TooltipProvider.Simplex
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of graphs that display the time series data.protected int
The index of the node that was hit by the mouse.(package private) String
The type of data to display.Fields inherited from class AbstractView
engine, exportSubmenu, exportSubmenuTrigger, gCols, gRows, isActive, isLoaded, logger, MIN_MSEC_BETWEEN_UPDATES, model, restoreMenu, timestamp, type, updatetime, wrapper
Fields inherited from class UIObject
DEBUG_ID_PREFIX
-
Constructor Summary
ConstructorsConstructorDescriptionGenericPop
(EvoLudoGWT engine, Data type) Construct a new view to display the configuration of the current state of the EvoLudo model in 2D or 3D. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Destroy all graphs in this view and free up resources.private static String
formatInStructureAt
(int node, Geometry geom) Return a formatted string of the incoming neighbours on directed graphs at the given node.private static String
formatOutStructureAt
(int node, Geometry geom) Return a formatted string of the outgoing neighbours on directed graphs at the given node.private String
formatStrategiesAt
(int node, Geometry geom, G graph) Return a formatted string of the strategies of the opponents at the given node.private static String
formatStructureAt
(int[] links, int k, Geometry.Type type) Return a formatted string of the neighbourhood structure at the given node.private static String
formatStructureAt
(int node, Geometry geom) Return a formatted string of the neighbourhood structure at the given node.getName()
Get the name of this view.private G
getOpponentCompetitionGraph
(G graph) Get the competition graph of the opponent of the module associated with the given graph.private G
getOpponentInteractionGraph
(G graph) Get the interaction graph of the opponent of the module associated with the given graph.getTooltipAt
(AbstractGraph<?> agraph, int node) Get the tooltip for the location with indexindex
.boolean
Check if the view has finished layouting its graphs.boolean
keyDownHandler
(String key) Opportunity for view to implement keyboard shortcut for actions (repeating).void
Notifies the controller of the completion of the layouting process.void
Called whenever the state of the EvoLudo model changed.void
Called after the EvoLudo model got re-initialized.void
mouseHitNode
(int id, int node, boolean alt) Notifies the controller that the mouse/tap has hit node with indexnode
on the graph with the tagid
.(package private) void
setGraphGeometry
(GenericPopGraph<T, N> graph, boolean inter) Helper method to assign a geometry to a graph.void
unload()
Unload the view.void
update
(boolean force) Called when the view needs updating.Methods inherited from class AbstractView
activate, allocateGraphs, clear, createWidget, deactivate, dispose, export, export, exportDataHeader, exportMeanData, exportPNG, exportStatData, exportSVG, exportTrajData, exportTypes, getGraphAt, getLogger, getMode, getModel, getStatus, getStatus, getType, isRunning, keyUpHandler, load, modelDidReset, modelStopped, modelUnloaded, moduleRestored, moduleUnloaded, onResize, populateContextMenu, reset, scheduleUpdate, setBounds, setMode, shift, 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
getLogger, getModel, getType, isRunning, populateContextMenu, setInitialState
Methods inherited from interface BasicTooltipProvider
getTooltipAt, getTooltipAt
Methods inherited from interface GenericPopGraph.PopGraphController
mouseHitNode, populateContextMenuAt
Methods inherited from interface MilestoneListener
modelLoaded, modelRelaxed, modelRunning, modelSettings, moduleLoaded
-
Field Details
-
graphs
The list of graphs that display the time series data.- Implementation Notes:
List<G> 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.
-
hitNode
protected int hitNodeThe index of the node that was hit by the mouse. -
tag
String tagThe type of data to display.
-
-
Constructor Details
-
GenericPop
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 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
-
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 classAbstractView
-
modelChanged
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 asRESET
andINIT
that in turn triggermodelReset()
andmodelInit()
, respectively.- Specified by:
modelChanged
in interfaceChangeListener
- Overrides:
modelChanged
in classAbstractView
- 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 onlyGenericPop
and its graphs require layouting.- Overrides:
hasLayout
in classAbstractView
- 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 interfaceAbstractGraph.Controller
- Overrides:
layoutComplete
in classAbstractView
-
destroyGraphs
protected void destroyGraphs()Description copied from class:AbstractView
Destroy all graphs in this view and free up resources.- Overrides:
destroyGraphs
in classAbstractView
-
setGraphGeometry
Helper method to assign a geometry to a graph.- Parameters:
graph
- the graph to assign the geometryinter
-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 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
-
keyDownHandler
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 classAbstractView
- 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 indexnode
on the graph with the tagid
. The flagalt
indicates whether thealt
-modifier was pressed- Specified by:
mouseHitNode
in interfaceGenericPopGraph.PopGraphController
- Parameters:
id
- the id of the graphnode
- the index of the node that was hitalt
-true
if thealt
-key was pressed
-
getTooltipAt
Description copied from interface:TooltipProvider.Index
Get the tooltip for the location with indexindex
.- Specified by:
getTooltipAt
in interfaceTooltipProvider.Index
- Parameters:
agraph
- the graph requesting the tooltipnode
- theindex
of the location- Returns:
- the tooltip for the node
- See Also:
-
getOpponentInteractionGraph
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
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
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 nodegeom
- the geometry of the graphgraph
- the graph of the opponent- Returns:
- the formatted string
-
formatStructureAt
Return a formatted string of the neighbourhood structure at the given node.- Parameters:
node
- the index of the nodegeom
- the geometry of the graph- Returns:
- the formatted string
-
formatOutStructureAt
Return a formatted string of the outgoing neighbours on directed graphs at the given node.- Parameters:
node
- the index of the nodegeom
- the geometry of the graph- Returns:
- the formatted string
-
formatInStructureAt
Return a formatted string of the incoming neighbours on directed graphs at the given node.- Parameters:
node
- the index of the nodegeom
- the geometry of the graph- Returns:
- the formatted string
-
formatStructureAt
Return a formatted string of the neighbourhood structure at the given node.- Parameters:
links
- the array of indices of the neighboursk
- the number of linkstype
- the type of the geometry- Returns:
- the formatted string
-