public class SpringLayoutAlgorithm extends java.lang.Object implements ILayoutAlgorithm
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_SPRING_GRAVITATION
The default value for the spring layout gravitation-control.
|
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 double |
DEFAULT_SPRING_STRAIN
The default value for the spring layout strain-control.
|
protected static double |
EPSILON
An arbitrarily small value in mathematics.
|
boolean |
fitWithinBounds |
static long |
MAX_SPRING_TIME
the default value for the time algorithm runs.
|
protected static double |
MIN_DISTANCE
Minimum distance considered between nodes
|
Constructor and Description |
---|
SpringLayoutAlgorithm() |
Modifier and Type | Method and Description |
---|---|
void |
applyLayout(boolean clean)
Makes this algorithm perform layout computation and apply it to its
context.
|
protected void |
computeForces()
Computes the force for each node in this SpringLayoutAlgorithm.
|
protected void |
computeOneIteration() |
protected void |
computePositions()
Computes the position for each node in this SpringLayoutAlgorithm.
|
protected int |
getCurrentLayoutStep() |
int |
getIterations()
Returns the number of iterations to be used.
|
ILayoutContext |
getLayoutContext()
Returns the previously set
ILayoutContext . |
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() |
boolean |
isResizing() |
protected boolean |
performAnotherNonContinuousIteration() |
void |
performNIteration(int n) |
void |
performOneIteration() |
void |
placeRandomly()
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(ILayoutContext 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
|
public static final int DEFAULT_SPRING_ITERATIONS
public static final long MAX_SPRING_TIME
public static final boolean DEFAULT_SPRING_RANDOM
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 boolean fitWithinBounds
public void applyLayout(boolean clean)
ILayoutAlgorithm
applyLayout
in interface ILayoutAlgorithm
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.public void setLayoutContext(ILayoutContext context)
ILayoutAlgorithm
setLayoutContext
in interface ILayoutAlgorithm
context
- a new layout context or null if this algorithm should not
perform any layoutpublic ILayoutContext getLayoutContext()
ILayoutAlgorithm
ILayoutContext
.getLayoutContext
in interface ILayoutAlgorithm
ILayoutContext
public void performNIteration(int n)
public void performOneIteration()
public boolean isResizing()
public void setResizing(boolean resizing)
resizing
- true if this algorithm should resize elements (default is
false)public 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)
iterations
- The number of iterations.public int getIterations()
public void setRandom(boolean random)
random
- The random placement value.public boolean getRandom()
protected boolean performAnotherNonContinuousIteration()
protected int getCurrentLayoutStep()
protected int getTotalNumberOfLayoutSteps()
protected void computeOneIteration()
public void placeRandomly()
protected void computeForces()
protected void computePositions()
Copyright (c) 2014 itemis AG and others. All rights reserved.