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 andMeshLambertMaterialfor 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.ExportTypeNested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface ChangeListener
ChangeListener.PendingActionNested 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 intThe index of the node that was hit by the mouse.(package private) StringThe 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, wrapperFields 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 voidDestroy all graphs in this view and free up resources.private static StringformatInStructureAt(int node, Geometry geom) Return a formatted string of the incoming neighbours on directed graphs at the given node.private static StringformatOutStructureAt(int node, Geometry geom) Return a formatted string of the outgoing neighbours on directed graphs at the given node.private static StringformatStructureAt(int[] links, int k, Geometry.Type type) Return a formatted string of the neighbourhood structure at the given node.private static StringformatStructureAt(int node, Geometry geom) Return a formatted string of the neighbourhood structure at the given node.private StringformatTraitsAt(int node, Geometry geom, G graph) Return a formatted string of the traits of the opponents at the given node.getName()Get the name of this view.private GgetOpponentCompetitionGraph(G graph) Get the competition graph of the opponent of the module associated with the given graph.private GgetOpponentInteractionGraph(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.booleanCheck if the view has finished layouting its graphs.booleankeyDownHandler(String key) Opportunity for view to implement keyboard shortcut for actions (repeating).voidNotifies the controller of the completion of the layouting process.voidCalled whenever the state of the EvoLudo model changed.voidCalled after the EvoLudo model got re-initialized.voidmouseHitNode(int id, int node, boolean alt) Notifies the controller that the mouse/tap has hit node with indexnodeon the graph with the tagid.(package private) voidsetGraphGeometry(GenericPopGraph<T, N> graph, boolean inter) Helper method to assign a geometry to a graph.voidunload()Unload the view.voidupdate(boolean force) Called when the view needs updating.Methods inherited from class AbstractView
activate, allocateGraphs, 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, zoomMethods inherited from class Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidgetMethods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods 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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbstractGraph.Controller
getLogger, getModel, getType, isRunning, populateContextMenu, setInitialStateMethods inherited from interface BasicTooltipProvider
getTooltipAt, getTooltipAtMethods inherited from interface GenericPopGraph.PopGraphController
mouseHitNode, populateContextMenuAtMethods 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> graphsis deliberately hidingList<AbstractGraph> graphsfrom 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:AbstractViewGet the name of this view. This is used to dynamically build the view selector.- Specified by:
getNamein classAbstractView- Returns:
- the name of this view
-
unload
public void unload()Description copied from class:AbstractViewUnload 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:
unloadin classAbstractView
-
modelChanged
Description copied from interface:ChangeListenerCalled 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 asRESETandINITthat in turn triggermodelReset()andmodelInit(), respectively.- Specified by:
modelChangedin interfaceChangeListener- Overrides:
modelChangedin classAbstractView- Parameters:
action- pending action that needs to be processed.- See Also:
-
hasLayout
public boolean hasLayout()Description copied from class:AbstractViewCheck if the view has finished layouting its graphs. Currently onlyGenericPopand its graphs require layouting.- Overrides:
hasLayoutin classAbstractView- Returns:
trueif the view has layout- See Also:
-
layoutComplete
public void layoutComplete()Description copied from interface:AbstractGraph.ControllerNotifies the controller of the completion of the layouting process.- Specified by:
layoutCompletein interfaceAbstractGraph.Controller- Overrides:
layoutCompletein classAbstractView
-
destroyGraphs
protected void destroyGraphs()Description copied from class:AbstractViewDestroy all graphs in this view and free up resources.- Overrides:
destroyGraphsin classAbstractView
-
setGraphGeometry
Helper method to assign a geometry to a graph.- Parameters:
graph- the graph to assign the geometryinter-truefor interaction geometry,falsefor competition geometry
-
modelDidInit
public void modelDidInit()Description copied from interface:MilestoneListenerCalled after the EvoLudo model got re-initialized.- Specified by:
modelDidInitin interfaceMilestoneListener- Overrides:
modelDidInitin classAbstractView
-
update
public void update(boolean force) Description copied from class:AbstractViewCalled 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 unlessforceistrue.- Specified by:
updatein classAbstractView- Parameters:
force-trueto 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
MVPop2Dfor the following keys:s- Shake and relax dynamically generated network layouts to help achieve a lower 'energy' state.
- Overrides:
keyDownHandlerin classAbstractView- Parameters:
key- the code of the pressed key- Returns:
trueif the key was handled- See Also:
-
mouseHitNode
public void mouseHitNode(int id, int node, boolean alt) Description copied from interface:GenericPopGraph.PopGraphControllerNotifies the controller that the mouse/tap has hit node with indexnodeon the graph with the tagid. The flagaltindicates whether thealt-modifier was pressed- Specified by:
mouseHitNodein interfaceGenericPopGraph.PopGraphController- Parameters:
id- the id of the graphnode- the index of the node that was hitalt-trueif thealt-key was pressed
-
getTooltipAt
Description copied from interface:TooltipProvider.IndexGet the tooltip for the location with indexindex.- Specified by:
getTooltipAtin interfaceTooltipProvider.Index- Parameters:
agraph- the graph requesting the tooltipnode- theindexof 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
-
formatTraitsAt
Return a formatted string of the traits of the opponents at the given node. For intra-species interactions and models with identical interaction and competition graphs,graph.getGeometry() == geomholds.- 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
-