public class SpringLayoutAlgorithm extends ContinuousLayoutAlgorithm
Instructions for using SpringLayoutAlgorithm:
1. Instantiate a SpringLayout object;
2. Populate the data repository using add(...);
3. Populate the relation repository using
addRelation(...);
4. Execute compute();
5. Execute fitWithinBounds(...);
6. Query the computed results(node size and node position).
| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_SPRING_GRAVITATION
The default value for the spring layout gravitation-control.
|
static boolean |
DEFAULT_SPRING_IGNORE_UNCON
The default value for ignoring unconnected nodes.
|
static int |
DEFAULT_SPRING_ITERATIONS
The default value for the spring layout number of interations.
|
static double |
DEFAULT_SPRING_LENGTH
The default value for the spring layout length-control.
|
static double |
DEFAULT_SPRING_MOVE
The default value for the spring layout move-control.
|
static boolean |
DEFAULT_SPRING_RANDOM
The default value for positioning nodes randomly.
|
static boolean |
DEFAULT_SPRING_SEPARATE_COMPONENTS
The default value for separating connected components.
|
static double |
DEFAULT_SPRING_STRAIN
The default value for the spring layout strain-control.
|
protected static double |
EPSILON
An arbitrarily small value in mathematics.
|
static long |
MAX_SPRING_TIME
the default value for the time algorithm runs.
|
protected static double |
MIN_DISTANCE
Minimum distance considered between nodes
|
comparator, filter, internalAsynchronous, internalContinuous, layout_styles, layoutStopped, MIN_ENTITY_SIZE, resizeEntitiesAfterLayout| Constructor and Description |
|---|
SpringLayoutAlgorithm()
Creates a sprint layout algoirthm with no style
|
SpringLayoutAlgorithm(int styles)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
computeForces(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
Computes the force for each node in this SpringLayoutAlgorithm.
|
protected void |
computeOneIteration(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height)
Computes a single iteration of the layout algorithm
|
protected void |
computePositions(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
Computes the position for each node in this SpringLayoutAlgorithm.
|
protected void |
convertNodePositionsBack(int i,
org.eclipse.zest.layouts.dataStructures.InternalNode entityToConvert,
double px,
double py,
double screenWidth,
double screenHeight,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle layoutBounds) |
protected void |
convertToUnitCoordinates(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
Converts the position for each node in this SpringLayoutAlgorithm
to unit coordinates in double precision.
|
protected int |
getCurrentLayoutStep()
Gets the current layout step
|
int |
getIterations()
Returns the number of iterations to be used.
|
protected org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle |
getLayoutBoundsTemp(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
boolean includeNodeSize) |
boolean |
getRandom()
Returns whether or not this SpringLayoutAlgorithm will layout the
nodes randomly before beginning iterations.
|
double |
getSpringGravitation()
Returns the gravitation-control value of this SpringLayoutAlgorithm
in double presion.
|
double |
getSpringLength()
Returns the length-control value of this SpringLayoutAlgorithm in
double presion.
|
double |
getSpringMove()
Returns the move-control value of this SpringLayoutAlgorithm in
double presion.
|
double |
getSpringStrain()
Returns the strain-control value of this SpringLayoutAlgorithm in
double presion.
|
long |
getSpringTimeout()
Gets the max time this algorithm will run for
|
protected int |
getTotalNumberOfLayoutSteps()
Gets the total number of steps in this layout
|
double |
getWeight(java.lang.String relType) |
protected boolean |
isValidConfiguration(boolean asynchronous,
boolean continueous)
Determines if the configuration is valid for this layout
|
protected boolean |
performAnotherNonContinuousIteration()
The logic to determine if a layout should continue running or not
|
void |
placeRandomly(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
Puts vertices in random places, all between (0,0) and (1,1).
|
protected void |
postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
Code called after the layout algorithm ends
|
protected void |
preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height)
Code called before the layout algorithm starts
|
void |
setDefaultConditions()
Sets the default conditions.
|
void |
setIterations(int iterations)
Sets the number of iterations to be used.
|
void |
setLayoutArea(double x,
double y,
double width,
double height) |
void |
setRandom(boolean random)
Sets whether or not this SpringLayoutAlgorithm will layout the
nodes randomly before beginning iterations.
|
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
|
void |
setWeight(java.lang.String relType,
double weight) |
applyLayoutInternal, getBounds, setBoundsaddEntity, addProgressListener, addRelationship, applyLayout, defaultFitWithinBounds, defaultFitWithinBounds, fireProgressEnded, fireProgressEvent, fireProgressStarted, getEntityAspectRatio, getLayoutBounds, getLocalLocation, getNumberOfProgressListeners, getStyle, isRunning, removeEntity, removeProgressListener, removeRelationship, removeRelationships, removeRelationships, setComparator, setEntityAspectRatio, setFilter, setStyle, stop, updateBendPoints, updateEntities, updateLayoutLocations, updateRelationships, verifyInputpublic static final int DEFAULT_SPRING_ITERATIONS
public static final long MAX_SPRING_TIME
public static final boolean DEFAULT_SPRING_RANDOM
public static final boolean DEFAULT_SPRING_IGNORE_UNCON
public static final boolean DEFAULT_SPRING_SEPARATE_COMPONENTS
public static final double DEFAULT_SPRING_MOVE
public static final double DEFAULT_SPRING_STRAIN
public static final double DEFAULT_SPRING_LENGTH
public static final double DEFAULT_SPRING_GRAVITATION
protected static final double MIN_DISTANCE
protected static final double EPSILON
public SpringLayoutAlgorithm(int styles)
public SpringLayoutAlgorithm()
public void setLayoutArea(double x,
double y,
double width,
double height)
setLayoutArea in class ContinuousLayoutAlgorithmpublic void setSpringMove(double move)
move - The move-control value.public double getSpringMove()
public void setSpringStrain(double strain)
strain - The strain-control value.public double getSpringStrain()
public void setSpringLength(double length)
length - The length-control value.public long getSpringTimeout()
public void setSpringTimeout(long timeout)
timeout - public double getSpringLength()
public void setSpringGravitation(double gravitation)
gravitation - The gravitation-control value.public double getSpringGravitation()
public void setIterations(int iterations)
gravitation - The number of iterations.public int getIterations()
public void setRandom(boolean random)
random - The random placement value.public boolean getRandom()
public void setWeight(java.lang.String relType,
double weight)
public double getWeight(java.lang.String relType)
public void setDefaultConditions()
protected void preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height)
AbstractLayoutAlgorithmpreLayoutAlgorithm in class AbstractLayoutAlgorithmprotected void postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
AbstractLayoutAlgorithmpostLayoutAlgorithm in class AbstractLayoutAlgorithmprotected org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle getLayoutBoundsTemp(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
boolean includeNodeSize)
protected void convertNodePositionsBack(int i,
org.eclipse.zest.layouts.dataStructures.InternalNode entityToConvert,
double px,
double py,
double screenWidth,
double screenHeight,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle layoutBounds)
protected boolean performAnotherNonContinuousIteration()
ContinuousLayoutAlgorithmperformAnotherNonContinuousIteration in class ContinuousLayoutAlgorithmprotected int getCurrentLayoutStep()
AbstractLayoutAlgorithmgetCurrentLayoutStep in class AbstractLayoutAlgorithmprotected int getTotalNumberOfLayoutSteps()
AbstractLayoutAlgorithmgetTotalNumberOfLayoutSteps in class AbstractLayoutAlgorithmprotected void computeOneIteration(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height)
ContinuousLayoutAlgorithmcomputeOneIteration in class ContinuousLayoutAlgorithmpublic void placeRandomly(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
protected void computeForces(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
protected void computePositions(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
protected void convertToUnitCoordinates(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout)
protected boolean isValidConfiguration(boolean asynchronous,
boolean continueous)
AbstractLayoutAlgorithmisValidConfiguration in class AbstractLayoutAlgorithmCopyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.