Class SpringLayoutAlgorithm
java.lang.Object
org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm
- All Implemented Interfaces:
LayoutAlgorithm
The SpringLayoutAlgorithm has its own data repository and relation
repository. A user can populate the repository, specify the layout
conditions, do the computation and query the computed results.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Deprecated, for removal: This API element is subject to removal in a future version. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
The default value for the spring layout gravitation-control.static final int
The default value for the spring layout number of interations.static final double
The default value for the spring layout length-control.static final double
The default value for the spring layout move-control.static final boolean
The default value for positioning nodes randomly.static final double
The default value for the spring layout strain-control.protected static final double
An arbitrarily small value in mathematics.boolean
static final long
the default value for the time algorithm runs.protected static final double
Minimum distance considered between nodesFields inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
context
-
Constructor Summary
ConstructorsConstructorDescriptionSpringLayoutAlgorithm
(int style) Deprecated.Since Zest 2.0, useSpringLayoutAlgorithm()
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyLayout
(boolean clean) Makes this algorithm perform layout computation and apply it to its context.protected void
Computes the force for each node in this SpringLayoutAlgorithm.protected void
protected void
Computes the position for each node in this SpringLayoutAlgorithm.protected int
int
Returns the number of iterations to be used.boolean
Returns whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.double
Returns the gravitation-control value of this SpringLayoutAlgorithm in double presion.double
Returns the length-control value of this SpringLayoutAlgorithm in double presion.double
Returns the move-control value of this SpringLayoutAlgorithm in double presion.double
Returns the strain-control value of this SpringLayoutAlgorithm in double presion.long
Gets the max time this algorithm will run forprotected int
boolean
protected boolean
void
performNIteration
(int n) void
void
Puts vertices in random places, all between (0,0) and (1,1).void
setIterations
(int iterations) Sets the number of iterations to be used.void
setLayoutContext
(LayoutContext context) Sets the layout context for this algorithm.void
setRandom
(boolean random) Sets whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.void
setResizing
(boolean resizing) void
setSpringGravitation
(double gravitation) Sets the spring layout gravitation-control.void
setSpringLength
(double length) Sets the spring layout length-control.void
setSpringMove
(double move) Sets the spring layout move-control.void
setSpringStrain
(double strain) Sets the spring layout strain-control.void
setSpringTimeout
(long timeout) Sets the spring timeout
-
Field Details
-
DEFAULT_SPRING_ITERATIONS
public static final int DEFAULT_SPRING_ITERATIONSThe default value for the spring layout number of interations.- See Also:
-
MAX_SPRING_TIME
public static final long MAX_SPRING_TIMEthe default value for the time algorithm runs.- See Also:
-
DEFAULT_SPRING_RANDOM
public static final boolean DEFAULT_SPRING_RANDOMThe default value for positioning nodes randomly.- See Also:
-
DEFAULT_SPRING_MOVE
public static final double DEFAULT_SPRING_MOVEThe default value for the spring layout move-control.- See Also:
-
DEFAULT_SPRING_STRAIN
public static final double DEFAULT_SPRING_STRAINThe default value for the spring layout strain-control.- See Also:
-
DEFAULT_SPRING_LENGTH
public static final double DEFAULT_SPRING_LENGTHThe default value for the spring layout length-control.- See Also:
-
DEFAULT_SPRING_GRAVITATION
public static final double DEFAULT_SPRING_GRAVITATIONThe default value for the spring layout gravitation-control.- See Also:
-
MIN_DISTANCE
protected static final double MIN_DISTANCEMinimum distance considered between nodes- See Also:
-
EPSILON
protected static final double EPSILONAn arbitrarily small value in mathematics.- See Also:
-
fitWithinBounds
public boolean fitWithinBounds- Since:
- 2.0
-
-
Constructor Details
-
SpringLayoutAlgorithm
Deprecated.Since Zest 2.0, useSpringLayoutAlgorithm()
. -
SpringLayoutAlgorithm
public SpringLayoutAlgorithm()
-
-
Method Details
-
applyLayout
public void applyLayout(boolean clean) Description copied from interface:LayoutAlgorithm
Makes this algorithm perform layout computation and apply it to its context.- Parameters:
clean
- if true the receiver should assume that the layout context has changed significantly and recompute the whole layout even if it keeps track of changes with listeners. False can be used after dynamic layout in a context is turned back on so that layout algorithm working in background can apply accumulated changes. Static layout algorithm can ignore this call entirely if clean is false.
-
setLayoutContext
Description copied from interface:LayoutAlgorithm
Sets the layout context for this algorithm. The receiver will unregister from its previous layout context and register to the new one (registration means for example adding listeners). After a call to this method, the receiving algorithm can compute and cache internal data related to given context and perform an initial layout.- Specified by:
setLayoutContext
in interfaceLayoutAlgorithm
- Overrides:
setLayoutContext
in classAbstractLayoutAlgorithm
- Parameters:
context
- a new layout context or null if this algorithm should not perform any layout
-
performNIteration
public void performNIteration(int n) - Since:
- 2.0
-
performOneIteration
public void performOneIteration()- Since:
- 2.0
-
isResizing
public boolean isResizing()- Returns:
- true if this algorithm is set to resize elements
- Since:
- 2.0
-
setResizing
public void setResizing(boolean resizing) - Parameters:
resizing
- true if this algorithm should resize elements (default is false)- Since:
- 2.0
-
setSpringMove
public void setSpringMove(double move) Sets the spring layout move-control.- Parameters:
move
- The move-control value.
-
getSpringMove
public double getSpringMove()Returns the move-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The move-control value.
-
setSpringStrain
public void setSpringStrain(double strain) Sets the spring layout strain-control.- Parameters:
strain
- The strain-control value.
-
getSpringStrain
public double getSpringStrain()Returns the strain-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The strain-control value.
-
setSpringLength
public void setSpringLength(double length) Sets the spring layout length-control.- Parameters:
length
- The length-control value.
-
getSpringTimeout
public long getSpringTimeout()Gets the max time this algorithm will run for -
setSpringTimeout
public void setSpringTimeout(long timeout) Sets the spring timeout- Parameters:
timeout
-
-
getSpringLength
public double getSpringLength()Returns the length-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The length-control value.
-
setSpringGravitation
public void setSpringGravitation(double gravitation) Sets the spring layout gravitation-control.- Parameters:
gravitation
- The gravitation-control value.
-
getSpringGravitation
public double getSpringGravitation()Returns the gravitation-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The gravitation-control value.
-
setIterations
public void setIterations(int iterations) Sets the number of iterations to be used.- Parameters:
iterations
- The number of iterations.
-
getIterations
public int getIterations()Returns the number of iterations to be used.- Returns:
- The number of iterations.
-
setRandom
public void setRandom(boolean random) Sets whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.- Parameters:
random
- The random placement value.
-
getRandom
public boolean getRandom()Returns whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations. -
performAnotherNonContinuousIteration
protected boolean performAnotherNonContinuousIteration() -
getCurrentLayoutStep
protected int getCurrentLayoutStep() -
getTotalNumberOfLayoutSteps
protected int getTotalNumberOfLayoutSteps() -
computeOneIteration
protected void computeOneIteration()- Since:
- 2.0
-
placeRandomly
public void placeRandomly()Puts vertices in random places, all between (0,0) and (1,1).- Since:
- 2.0
-
computeForces
protected void computeForces()Computes the force for each node in this SpringLayoutAlgorithm. The computed force will be stored in the data repository- Since:
- 2.0
-
computePositions
protected void computePositions()Computes the position for each node in this SpringLayoutAlgorithm. The computed position will be stored in the data repository. position = position + sprMove * force- Since:
- 2.0
-
SpringLayoutAlgorithm
instead.