Package org.evoludo.graphics
Class Network2DGWT
- All Implemented Interfaces:
Iterable<Node>
,Collection<Node>
,Iterator<Node>
,List<Node>
,SequencedCollection<Node>
Graphical representation of generic population geometries in 2D. A network
corresponds to a (possibly ephemeral) collection and configuration of nodes.
This implementation includes optimizations for GWT when scheduling
computationally intensive tasks.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested classes/interfaces inherited from class Network
Network.LayoutListener, Network.Status
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Duration
Helper variable to keep track of the time spent layouting the network.protected static final int
The minimum number of links to process in one step.protected static final int
Minimum delay in milliseconds between subsequent updates of the layout in the GUI.protected int
Helper variable to store the index of the node that needs to be processed next.(package private) int
Time when last layout update was processed.Fields inherited from class Network
accuracy, engine, fLinks, geometry, isRunning, layoutTimeout, listener, MAX_LINK_COUNT, nLinks, nNodes, norm, potential, prevAdjust, prevPotential, rng, status, timestamp
Fields inherited from class AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionNetwork2DGWT
(EvoLudo engine, Geometry geometry) Create a new network in 2D for the given engine and geometry with a layouting process optimzed for GWT. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Start the layouting process.protected boolean
Perform a single step in the layouting process by relaxing nodes sequentially.void
reset()
Reset the network (discard any existing layouts).Methods inherited from class Network2D
attraction, finishLayout, get, getLinks, initNodes, linkNodes, relax, relax, repulsion, toArray
Methods inherited from class Network
adjustAccuracy, cancelLayout, clear, contains, doLayoutPrep, getAccuracy, getGeometry, getLayoutTimout, getRadius, getStatus, hasNext, indexOf, isEmpty, isStatus, iterator, lastIndexOf, next, scaleRadiusTo, set, setAccuracy, setLayoutListener, setLayoutTimout, setRadius, setStatus, shake, size
Methods inherited from class AbstractList
add, add, addAll, equals, hashCode, listIterator, listIterator, remove, removeRange, subList
Methods inherited from class AbstractCollection
addAll, containsAll, remove, removeAll, retainAll, toArray, toString
Methods inherited from interface Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface Iterator
forEachRemaining, remove
Methods inherited from interface List
addAll, addFirst, addLast, containsAll, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray
-
Field Details
-
layout
Duration layoutHelper variable to keep track of the time spent layouting the network. -
prevLayout
int prevLayoutTime when last layout update was processed. -
MIN_DELAY_ANIMATE_MSEC
protected static final int MIN_DELAY_ANIMATE_MSECMinimum delay in milliseconds between subsequent updates of the layout in the GUI. This is used to throttle the animated layout process to a default of at most 20 updates per second.- See Also:
-
nextLayoutNode
protected int nextLayoutNodeHelper variable to store the index of the node that needs to be processed next. This is to prevent the GUI from becoming unresponsive and allow the layouting process to resume after relaxing a fixed number of nodes.- See Also:
-
MAX_LINKS_PER_STEP
protected static final int MAX_LINKS_PER_STEPThe minimum number of links to process in one step. AfterMAX_LINKS_PER_STEP
links have been processed the next node to continue is stored innextLayoutNode
and control is returned to the event loop, which prevents the GUI from becoming unresponsive. As a welcome side effect, this parcelling resulted in a dramatic speed increase.- See Also:
-
-
Constructor Details
-
Network2DGWT
Create a new network in 2D for the given engine and geometry with a layouting process optimzed for GWT.- Parameters:
engine
- the pacemaker for running the modelgeometry
- the structure of the population
-
-
Method Details
-
reset
public void reset()Description copied from class:Network
Reset the network (discard any existing layouts). -
doLayout
Description copied from class:Network
Start the layouting process. The layout listener (if any) is informed about the progress of the layouting process. Implementations can take advantage of optimizations available for GWT (scheduling) or JRE (multiple threads). -
doLayoutStep
protected boolean doLayoutStep()Perform a single step in the layouting process by relaxing nodes sequentially. Returnsfalse
once the layouting process has completed, i.e. reached the desired accuracy or the time out.- Returns:
true
if the layouting process should continue
-