Class GenericPop<T, N extends Network<?>, G extends GenericPopGraph<T,N>>
Object
UIObject
Widget
Composite
AbstractView<G>
GenericPop<T,N,G>
- Type Parameters:
T- the element type used by the color map / trait representationN- the concreteNetworktype used by graphsG- the concreteGenericPopGraphtype managed by this view
- All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ProvidesResize, RequiresResize, TooltipProvider, TooltipProvider.Index, ChangeListener, LifecycleListener, RunListener, SampleListener, BasicTooltipProvider
public abstract class GenericPop<T, N extends Network<?>, G extends GenericPopGraph<T,N>>
extends AbstractView<G>
implements TooltipProvider.Index
Abstract base view for rendering population-related data (traits or fitness)
for EvoLudo models that expose spatial/graph structure (IBS and PDE models).
GenericPop manages one or more GenericPopGraph instances, coordinates
layout and painting, reads data from the model (traits or fitness) and
assembles HTML tooltips describing nodes, their neighbourhoods and
metrics. The view supports both 2D and 3D variants (through subclasses such
as Pop2D or Pop3D to determine the concrete geometry string
used in the name).
Responsibilities:
- Manage lifecycle of graphs (initialisation, invalidation, destruction).
- Query networks for layout readiness and notify the engine when layout completes.
- Pull trait or fitness data from the underlying model and forward it to graphs for updating and painting.
- Assign geometries to graphs based on model/module configuration (interaction vs competition geometry).
- Provide rich HTML tooltips for nodes that include trait names, colors, payoffs/fitness, neighbour lists, tags, and interaction counts.
- Forward mouse node-hit events to IBS models and handle a small set of view-level keyboard shortcuts (e.g. 's' for shaking network layouts).
- Author:
- Christoph Hauert Type parameters:
- See Also:
-
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 TypeFieldDescriptionprivate final StringThe type of data to display.protected intThe index of the node that was hit by the mouse.Fields inherited from class AbstractView
engine, exportSubmenu, exportSubmenuTrigger, gCols, graphs, gRows, isActive, isLoaded, logger, MIN_MSEC_BETWEEN_UPDATES, model, options, restoreMenu, timestamp, type, updatetime, wrapperFields inherited from class UIObject
DEBUG_ID_PREFIXFields inherited from interface BasicTooltipProvider
TABLE_CELL_BULLET, TABLE_CELL_NEXT, TABLE_CELL_NEXT_COLOR, TABLE_END, TABLE_ROW_END, TABLE_ROW_START, TABLE_ROW_START_COLOR, TABLE_ROW_START_RIGHT, TABLE_SEPARATOR, TABLE_STYLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGenericPop(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 TypeMethodDescriptionprivate static StringBuilderappendCompNeighborsAt(int node, AbstractGeometry geom, StringBuilder tip) Append competition neighbours at the given node.private voidappendFitnessTip(int node, Module<?> module, StringBuilder tip) Append fitness (and payoffs if the module is using payoff-to-fitness mappings) as well as interaction count for modules implementing thePayoffsinterface.private voidappendFormattedValues(StringBuilder tip, double[] values, int vac, Map2Fitness map, boolean useInvMap) Append a comma separated list of values (or '-' for vacant index).private static StringBuilderappendInterNeighborsAt(int node, AbstractGeometry geom, StringBuilder tip) Append interaction neighbours at the given node.private voidappendLinearTip(int node, int nNodes, StringBuilder tip) Append tooltip information for linear geometry / time slices.private static StringBuilderappendNeighbors(String label, int[] links, int k, StringBuilder tip) Return a formatted string of the neighbourhood structure at the given node.private voidappendNodeTraitTip(int node, int id, G graph, StringBuilder tip) Append node and trait information (with color when appropriate).private StringBuilderappendOppTraitsAt(int node, AbstractGeometry geom, G graph, StringBuilder tip) Append opponent traits at the given node.private voidappendPDEFitnessTip(int node, Module<?> module, G graph, StringBuilder tip) Append fitness and payoff information for PDE models.private voidappendPDETraitTip(int node, Module<?> module, G graph, StringBuilder tip) Append trait and density information for PDE models.protected voidDestroy all graphs in this view and free up resources.getName()Get the name of this view.private GgetOppCompGraph(G graph) Get the competition graph of the opponent of the module associated with the given graph.private GgetOppInterGraph(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.voidNotification 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.booleanOpportunity for view to implement keyboard shortcut for actions (repeating).(package private) voidsetGraphGeometry(GenericPopGraph<T, N> graph, boolean inter) Helper method to assign a geometry to a graph.private StringtooltipForIBS(int node, int nNodes, Module<?> module, G graph, StringBuilder tip) Assemble tooltip for IBS models.private StringtooltipForPDE(int node, int nNodes, AbstractGeometry geometry, Module<?> module, G graph, StringBuilder tip) Assemble tooltip for PDE models.voidunload()Unload the view.voidupdate(boolean force) Called when the view needs updating.Methods inherited from class AbstractView
activate, allocateGraphs, deactivate, export, export, exportDataHeader, exportMeanData, exportPNG, exportStatData, exportSVG, exportTrajData, exportTypes, getGraphAt, getLogger, getMode, getModel, getStatus, getStatus, getType, isActive, isRunning, load, modelDidReset, modelStopped, modelUnloaded, moduleRestored, moduleUnloaded, mouseHitNode, onKeyUp, onResize, onUnload, parse, populateContextMenu, populateContextMenuAt, reset, scheduleUpdate, setBounds, setInitialState, setOptions, 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, 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 BasicTooltipProvider
getTooltipAt, getTooltipAtMethods inherited from interface LifecycleListener
modelLoaded, moduleLoadedMethods inherited from interface RunListener
modelRelaxed, modelRunning, modelSettingsMethods inherited from interface SampleListener
modelSample
-
Field Details
-
hitNode
protected int hitNodeThe index of the node that was hit by the mouse. -
dim
The 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<G extends GenericPopGraph<T,N>> - 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<G extends GenericPopGraph<T,N>>
-
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<G extends GenericPopGraph<T,N>> - 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<G extends GenericPopGraph<T,N>> - Returns:
trueif the view has layout- See Also:
-
layoutComplete
public void layoutComplete()Description copied from class:AbstractViewNotification of the completion of the layouting process.- Overrides:
layoutCompletein classAbstractView<G extends GenericPopGraph<T,N>>
-
destroyGraphs
protected void destroyGraphs()Description copied from class:AbstractViewDestroy all graphs in this view and free up resources.- Overrides:
destroyGraphsin classAbstractView<G extends GenericPopGraph<T,N>>
-
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:RunListenerCalled after the EvoLudo model got re-initialized.- Specified by:
modelDidInitin interfaceRunListener- Overrides:
modelDidInitin classAbstractView<G extends GenericPopGraph<T,N>>
-
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<G extends GenericPopGraph<T,N>> - Parameters:
force-trueto force the update
-
onKeyDown
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:
onKeyDownin classAbstractView<G extends GenericPopGraph<T,N>> - 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 class:AbstractViewNotifies the controller that the mouse/tap has hit node with indexnodeon the graph with the tagid. The flagaltindicates whether thealt-modifier was pressed (optional implementation).- Overrides:
mouseHitNodein classAbstractView<G extends GenericPopGraph<T,N>> - 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:
-
tooltipForIBS
Assemble tooltip for IBS models.- Parameters:
node- node indexnNodes- total number of geometry nodesmodule- module owning the graphgraph- graph providing geometry and color mappingtip- builder used to accumulate HTML- Returns:
- tooltip HTML string
-
appendLinearTip
Append tooltip information for linear geometry / time slices.- Parameters:
node- the node indexnNodes- the number of nodes per time slicetip- the StringBuilder to append to
-
appendNodeTraitTip
Append node and trait information (with color when appropriate).- Parameters:
node- the node indexid- the module IDgraph- the graphtip- the StringBuilder to append to
-
appendPDETraitTip
Append trait and density information for PDE models.- Parameters:
node- the node indexmodule- the modulegraph- the graphtip- the StringBuilder to append to
-
appendFitnessTip
Append fitness (and payoffs if the module is using payoff-to-fitness mappings) as well as interaction count for modules implementing thePayoffsinterface.- Parameters:
node- the node indexmodule- the moduletip- the StringBuilder to append to
-
appendPDEFitnessTip
Append fitness and payoff information for PDE models.- Parameters:
node- the node indexmodule- the modulegraph- the graphtip- the StringBuilder to append to
-
appendFormattedValues
private void appendFormattedValues(StringBuilder tip, double[] values, int vac, Map2Fitness map, boolean useInvMap) Append a comma separated list of values (or '-' for vacant index). If useInvMap is true, values are converted via map.invmap(...).- Parameters:
tip- the StringBuilder to append tovalues- the array of valuesvac- the vacant indexmap- the Map2FitnessuseInvMap- whether to convert values via map.invmap(...)
-
tooltipForPDE
private String tooltipForPDE(int node, int nNodes, AbstractGeometry geometry, Module<?> module, G graph, StringBuilder tip) Assemble tooltip for PDE models.- Parameters:
node- the node indexnNodes- the total number of nodesgeometry- the geometry of the graphmodule- the modulegraph- the graphtip- the StringBuilder to append to- Returns:
- tooltip HTML string
-
getOppInterGraph
-
getOppCompGraph
-
appendOppTraitsAt
private StringBuilder appendOppTraitsAt(int node, AbstractGeometry geom, G graph, StringBuilder tip) Append opponent traits at the given node.- Parameters:
node- the node indexgeom- the geometrygraph- the opponent's graphtip- the StringBuilder to append to- Returns:
- the updated StringBuilder
-
appendInterNeighborsAt
private static StringBuilder appendInterNeighborsAt(int node, AbstractGeometry geom, StringBuilder tip) Append interaction neighbours at the given node.- Parameters:
node- the node indexgeom- the geometrytip- the StringBuilder to append to- Returns:
- the updated StringBuilder
-
appendCompNeighborsAt
private static StringBuilder appendCompNeighborsAt(int node, AbstractGeometry geom, StringBuilder tip) Append competition neighbours at the given node.- Parameters:
node- the node indexgeom- the geometrytip- the StringBuilder to append to- Returns:
- the updated StringBuilder
-
appendNeighbors
Return a formatted string of the neighbourhood structure at the given node.- Parameters:
label- label describing the neighbour setlinks- array of neighbour indicesk- number of linkstip- builder to append to- Returns:
- the updated builder
-