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 SummaryNested ClassesModifier and TypeClassDescriptionstatic classDeprecated, for removal: This API element is subject to removal in a future version.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final doubleThe default value for the spring layout gravitation-control.static final intThe default value for the spring layout number of interations.static final doubleThe default value for the spring layout length-control.static final doubleThe default value for the spring layout move-control.static final booleanThe default value for positioning nodes randomly.static final doubleThe default value for the spring layout strain-control.protected static final doubleAn arbitrarily small value in mathematics.booleanstatic final longthe default value for the time algorithm runs.protected static final doubleMinimum distance considered between nodesFields inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithmcontext
- 
Constructor SummaryConstructorsConstructorDescriptionSpringLayoutAlgorithm(int style) Deprecated.Since Zest 2.0, useSpringLayoutAlgorithm().
- 
Method SummaryModifier and TypeMethodDescriptionvoidapplyLayout(boolean clean) Makes this algorithm perform layout computation and apply it to its context.protected voidComputes the force for each node in this SpringLayoutAlgorithm.protected voidprotected voidComputes the position for each node in this SpringLayoutAlgorithm.protected intintReturns the number of iterations to be used.booleanReturns whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.doubleReturns the gravitation-control value of this SpringLayoutAlgorithm in double presion.doubleReturns the length-control value of this SpringLayoutAlgorithm in double presion.doubleReturns the move-control value of this SpringLayoutAlgorithm in double presion.doubleReturns the strain-control value of this SpringLayoutAlgorithm in double presion.longGets the max time this algorithm will run forprotected intbooleanprotected booleanvoidperformNIteration(int n) voidvoidPuts vertices in random places, all between (0,0) and (1,1).voidsetIterations(int iterations) Sets the number of iterations to be used.voidsetLayoutContext(LayoutContext context) Sets the layout context for this algorithm.voidsetRandom(boolean random) Sets whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.voidsetResizing(boolean resizing) voidsetSpringGravitation(double gravitation) Sets the spring layout gravitation-control.voidsetSpringLength(double length) Sets the spring layout length-control.voidsetSpringMove(double move) Sets the spring layout move-control.voidsetSpringStrain(double strain) Sets the spring layout strain-control.voidsetSpringTimeout(long timeout) Sets the spring timeout
- 
Field Details- 
DEFAULT_SPRING_ITERATIONSpublic static final int DEFAULT_SPRING_ITERATIONSThe default value for the spring layout number of interations.- See Also:
 
- 
MAX_SPRING_TIMEpublic static final long MAX_SPRING_TIMEthe default value for the time algorithm runs.- See Also:
 
- 
DEFAULT_SPRING_RANDOMpublic static final boolean DEFAULT_SPRING_RANDOMThe default value for positioning nodes randomly.- See Also:
 
- 
DEFAULT_SPRING_MOVEpublic static final double DEFAULT_SPRING_MOVEThe default value for the spring layout move-control.- See Also:
 
- 
DEFAULT_SPRING_STRAINpublic static final double DEFAULT_SPRING_STRAINThe default value for the spring layout strain-control.- See Also:
 
- 
DEFAULT_SPRING_LENGTHpublic static final double DEFAULT_SPRING_LENGTHThe default value for the spring layout length-control.- See Also:
 
- 
DEFAULT_SPRING_GRAVITATIONpublic static final double DEFAULT_SPRING_GRAVITATIONThe default value for the spring layout gravitation-control.- See Also:
 
- 
MIN_DISTANCEprotected static final double MIN_DISTANCEMinimum distance considered between nodes- See Also:
 
- 
EPSILONprotected static final double EPSILONAn arbitrarily small value in mathematics.- See Also:
 
- 
fitWithinBoundspublic boolean fitWithinBounds- Since:
- 2.0
 
 
- 
- 
Constructor Details- 
SpringLayoutAlgorithmDeprecated.Since Zest 2.0, useSpringLayoutAlgorithm().
- 
SpringLayoutAlgorithmpublic SpringLayoutAlgorithm()
 
- 
- 
Method Details- 
applyLayoutpublic void applyLayout(boolean clean) Description copied from interface:LayoutAlgorithmMakes 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.
 
- 
setLayoutContextDescription copied from interface:LayoutAlgorithmSets 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:
- setLayoutContextin interface- LayoutAlgorithm
- Overrides:
- setLayoutContextin class- AbstractLayoutAlgorithm
- Parameters:
- context- a new layout context or null if this algorithm should not perform any layout
 
- 
performNIterationpublic void performNIteration(int n) - Since:
- 2.0
 
- 
performOneIterationpublic void performOneIteration()- Since:
- 2.0
 
- 
isResizingpublic boolean isResizing()- Returns:
- true if this algorithm is set to resize elements
- Since:
- 2.0
 
- 
setResizingpublic void setResizing(boolean resizing) - Parameters:
- resizing- true if this algorithm should resize elements (default is false)
- Since:
- 2.0
 
- 
setSpringMovepublic void setSpringMove(double move) Sets the spring layout move-control.- Parameters:
- move- The move-control value.
 
- 
getSpringMovepublic double getSpringMove()Returns the move-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The move-control value.
 
- 
setSpringStrainpublic void setSpringStrain(double strain) Sets the spring layout strain-control.- Parameters:
- strain- The strain-control value.
 
- 
getSpringStrainpublic double getSpringStrain()Returns the strain-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The strain-control value.
 
- 
setSpringLengthpublic void setSpringLength(double length) Sets the spring layout length-control.- Parameters:
- length- The length-control value.
 
- 
getSpringTimeoutpublic long getSpringTimeout()Gets the max time this algorithm will run for
- 
setSpringTimeoutpublic void setSpringTimeout(long timeout) Sets the spring timeout- Parameters:
- timeout-
 
- 
getSpringLengthpublic double getSpringLength()Returns the length-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The length-control value.
 
- 
setSpringGravitationpublic void setSpringGravitation(double gravitation) Sets the spring layout gravitation-control.- Parameters:
- gravitation- The gravitation-control value.
 
- 
getSpringGravitationpublic double getSpringGravitation()Returns the gravitation-control value of this SpringLayoutAlgorithm in double presion.- Returns:
- The gravitation-control value.
 
- 
setIterationspublic void setIterations(int iterations) Sets the number of iterations to be used.- Parameters:
- iterations- The number of iterations.
 
- 
getIterationspublic int getIterations()Returns the number of iterations to be used.- Returns:
- The number of iterations.
 
- 
setRandompublic void setRandom(boolean random) Sets whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.- Parameters:
- random- The random placement value.
 
- 
getRandompublic boolean getRandom()Returns whether or not this SpringLayoutAlgorithm will layout the nodes randomly before beginning iterations.
- 
performAnotherNonContinuousIterationprotected boolean performAnotherNonContinuousIteration()
- 
getCurrentLayoutStepprotected int getCurrentLayoutStep()
- 
getTotalNumberOfLayoutStepsprotected int getTotalNumberOfLayoutSteps()
- 
computeOneIterationprotected void computeOneIteration()- Since:
- 2.0
 
- 
placeRandomlypublic void placeRandomly()Puts vertices in random places, all between (0,0) and (1,1).- Since:
- 2.0
 
- 
computeForcesprotected void computeForces()Computes the force for each node in this SpringLayoutAlgorithm. The computed force will be stored in the data repository- Since:
- 2.0
 
- 
computePositionsprotected 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
 
 
- 
SpringLayoutAlgorithminstead.