Package org.zkoss.chart.plotOptions
Class NetworkGraphLayoutAlgorithm
- java.lang.Object
-
- org.zkoss.chart.Optionable
-
- org.zkoss.chart.plotOptions.NetworkGraphLayoutAlgorithm
-
- All Implemented Interfaces:
Serializable,OptionDataListener,org.zkoss.json.JSONAware
public class NetworkGraphLayoutAlgorithm extends Optionable
A option for layout algorithm.- Since:
- 7.2.1.0
- Author:
- rudyhuang
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.zkoss.chart.Optionable
NOT_NULL_VALUE, options
-
-
Constructor Summary
Constructors Constructor Description NetworkGraphLayoutAlgorithm()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetApproximation()Returns the approximation used to calculate repulsive forces affecting nodes.org.zkoss.json.JavaScriptValuegetAttractiveForce()Returns the attraction force applied on a node which is connected to another node by a link.NumbergetFriction()Returns the friction applied on forces to prevent nodes rushing to fast to the desired positions.NumbergetGravitationalConstant()Returns the gravitational const used in the barycenter force of the algorithm.NumbergetInitialPositionRadius()When initialPositions are set to 'circle', initialPositionRadius is a distance from the center of circle, in which nodes are created.ObjectgetInitialPositions()Returns the initial layout algorithm for positioning nodes.StringgetIntegration()Returns the integration type.NumbergetLinkLength()Returns the ideal length (px) of the link between two nodes.NumbergetMaxIterations()Returns the max number of iterations before algorithm will stop.NumbergetMaxSpeed()Verlet integration only.org.zkoss.json.JavaScriptValuegetRepulsiveForce()Returns the repulsive force applied on a node.NumbergetTheta()Barnes-Hut approximation only.StringgetType()Returns the type of the algorithm used when positioning nodes.booleanisEnableSimulation()Experimental.voidsetApproximation(String approximation)Sets the approximation used to calculate repulsive forces affecting nodes.voidsetAttractiveForce(org.zkoss.json.JavaScriptValue attractiveForce)Sets the attraction force applied on a node which is connected to another node by a link.voidsetEnableSimulation(boolean enableSimulation)Experimental.voidsetFriction(Number friction)Sets the friction applied on forces to prevent nodes rushing to fast to the desired positions.voidsetGravitationalConstant(Number gravitationalConstant)Sets the gravitational const used in the barycenter force of the algorithm.voidsetInitialPositionRadius(Number initialPositionRadius)When initialPositions are set to 'circle', initialPositionRadius is a distance from the center of circle, in which nodes are created.voidsetInitialPositions(String initialPositions)Sets the initial layout algorithm for positioning nodes.voidsetInitialPositions(org.zkoss.json.JavaScriptValue initialPositions)Sets the initial layout algorithm for positioning nodes.voidsetIntegration(String integration)Sets the integration type.voidsetLinkLength(Number linkLength)Sets the ideal length (px) of the link between two nodes.voidsetMaxIterations(Number maxIterations)Sets the max number of iterations before algorithm will stop.voidsetMaxSpeed(Number maxSpeed)Verlet integration only.voidsetRepulsiveForce(org.zkoss.json.JavaScriptValue repulsiveForce)Sets the repulsive force applied on a node.voidsetTheta(Number theta)Barnes-Hut approximation only.voidsetType(String type)Sets the type of the algorithm used when positioning nodes.-
Methods inherited from class org.zkoss.chart.Optionable
addExtraAttr, addOptionDataListener, clearOptonDataListener, clone, containsKey, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, getAttr, getAttr, getClientState, getExtraAttr, merge, onChange, removeExtraAttr, removeKey, removeOptionDataListener, setAttr, setAttr, setAttr, setAttr, toJSONString, toString
-
-
-
-
Method Detail
-
getApproximation
public String getApproximation()
Returns the approximation used to calculate repulsive forces affecting nodes. By default, when calculating net force, nodes are compared against each other, which gives O(N^2) complexity. Using Barnes-Hut approximation, we decrease this to O(N log N), but the resulting graph will have different layout. Barnes-Hut approximation divides space into rectangles via quad tree, where forces exerted on nodes are calculated directly for nearby cells, and for all others, cells are treated as a separate node with center of mass.Default: "none"
-
setApproximation
public void setApproximation(String approximation)
Sets the approximation used to calculate repulsive forces affecting nodes. By default, when calculating net force, nodes are compared against each other, which gives O(N^2) complexity. Using Barnes-Hut approximation, we decrease this to O(N log N), but the resulting graph will have different layout. Barnes-Hut approximation divides space into rectangles via quad tree, where forces exerted on nodes are calculated directly for nearby cells, and for all others, cells are treated as a separate node with center of mass.
-
getAttractiveForce
public org.zkoss.json.JavaScriptValue getAttractiveForce()
Returns the attraction force applied on a node which is connected to another node by a link. Passed are two arguments:- d - which is current distance between two nodes
- k - which is desired distance between two nodes
In
verletintegration, defaults to:function (d, k) { return (k - d) / d; }. Defaults tofunction (d, k) { return k * k / d; }.
-
setAttractiveForce
public void setAttractiveForce(org.zkoss.json.JavaScriptValue attractiveForce)
Sets the attraction force applied on a node which is connected to another node by a link. Passed are two arguments:- d - which is current distance between two nodes
- k - which is desired distance between two nodes
-
isEnableSimulation
public boolean isEnableSimulation()
Experimental. Returns whether to enable live simulation of the algorithm implementation. All nodes are animated as the forces applies on them.Default: false.
-
setEnableSimulation
public void setEnableSimulation(boolean enableSimulation)
Experimental. Sets whether to enable live simulation of the algorithm implementation. All nodes are animated as the forces applies on them.
-
getFriction
public Number getFriction()
Returns the friction applied on forces to prevent nodes rushing to fast to the desired positions.Default: -0.981
-
setFriction
public void setFriction(Number friction)
Sets the friction applied on forces to prevent nodes rushing to fast to the desired positions.
-
getGravitationalConstant
public Number getGravitationalConstant()
Returns the gravitational const used in the barycenter force of the algorithm.Default: 0.0625
-
setGravitationalConstant
public void setGravitationalConstant(Number gravitationalConstant)
Sets the gravitational const used in the barycenter force of the algorithm.
-
getInitialPositionRadius
public Number getInitialPositionRadius()
When initialPositions are set to 'circle', initialPositionRadius is a distance from the center of circle, in which nodes are created.Default: 1
-
setInitialPositionRadius
public void setInitialPositionRadius(Number initialPositionRadius)
When initialPositions are set to 'circle', initialPositionRadius is a distance from the center of circle, in which nodes are created.
-
getInitialPositions
public Object getInitialPositions()
Returns the initial layout algorithm for positioning nodes. Can be one of built-in options ("circle", "random") or a function where positions should be set on each node (this.nodes) asnode.plotXandnode.plotY.Default: "circle"
-
setInitialPositions
public void setInitialPositions(String initialPositions)
Sets the initial layout algorithm for positioning nodes. Can be one of built-in options ("circle", "random").
-
setInitialPositions
public void setInitialPositions(org.zkoss.json.JavaScriptValue initialPositions)
Sets the initial layout algorithm for positioning nodes. Can be a function where positions should be set on each node (this.nodes) asnode.plotXandnode.plotY.
-
getIntegration
public String getIntegration()
Returns the integration type. Available options are 'euler' and 'verlet'. Integration determines how forces are applied on particles. In Euler integration, force is applied direct as newPosition += velocity;. In Verlet integration, new position is based on a previous position without velocity: newPosition += previousPosition - newPosition. Note that different integrations give different results as forces are different.Default: "euler"
-
setIntegration
public void setIntegration(String integration)
Sets the integration type. Available options are 'euler' and 'verlet'. Integration determines how forces are applied on particles. In Euler integration, force is applied direct as newPosition += velocity;. In Verlet integration, new position is based on a previous position without velocity: newPosition += previousPosition - newPosition. Note that different integrations give different results as forces are different.
-
getLinkLength
public Number getLinkLength()
Returns the ideal length (px) of the link between two nodes. When not defined, length is calculated as:Math.pow(availableWidth * availableHeight / nodesLength, 0.4);Note: Because of the algorithm specification, length of each link might be not exactly as specified.Default: null
-
setLinkLength
public void setLinkLength(Number linkLength)
Sets the ideal length (px) of the link between two nodes. When not defined, length is calculated as:Math.pow(availableWidth * availableHeight / nodesLength, 0.4);Note: Because of the algorithm specification, length of each link might be not exactly as specified.
-
getMaxIterations
public Number getMaxIterations()
Returns the max number of iterations before algorithm will stop. In general, algorithm should find positions sooner, but when rendering huge number of nodes, it is recommended to increase this value as finding perfect graph positions can require more time.Default: 1000
-
setMaxIterations
public void setMaxIterations(Number maxIterations)
Sets the max number of iterations before algorithm will stop. In general, algorithm should find positions sooner, but when rendering huge number of nodes, it is recommended to increase this value as finding perfect graph positions can require more time.
-
getMaxSpeed
public Number getMaxSpeed()
Verlet integration only. Returns the max speed that node can get in one iteration. In terms of simulation, it's a maximum translation (in pixels) that node can move (in both, x and y, dimensions). While friction is applied on all nodes, max speed is applied only for nodes that move very fast, for example small or disconnected ones.Default: 10
-
setMaxSpeed
public void setMaxSpeed(Number maxSpeed)
Verlet integration only. Sets the max speed that node can get in one iteration. In terms of simulation, it's a maximum translation (in pixels) that node can move (in both, x and y, dimensions). While friction is applied on all nodes, max speed is applied only for nodes that move very fast, for example small or disconnected ones.
-
getRepulsiveForce
public org.zkoss.json.JavaScriptValue getRepulsiveForce()
Returns the repulsive force applied on a node. Passed are two arguments:- d - which is current distance between two nodes
- k - which is desired distance between two nodes
In
verletintegration, defaults to:function (d, k) { return (k - d) / d * (k > d ? 1 : 0) }. Defaults tofunction (d, k) { return k * k / d; }.
-
setRepulsiveForce
public void setRepulsiveForce(org.zkoss.json.JavaScriptValue repulsiveForce)
Sets the repulsive force applied on a node. Passed are two arguments:- d - which is current distance between two nodes
- k - which is desired distance between two nodes
-
getTheta
public Number getTheta()
Barnes-Hut approximation only. Determines when distance between cell and node is small enough to calculate forces. Value of theta is compared directly with quotients / d, wheresis the size of the cell, anddis distance between center of cell's mass and currently compared node.Default: 0.5
-
setTheta
public void setTheta(Number theta)
Barnes-Hut approximation only. Determines when distance between cell and node is small enough to calculate forces. Value of theta is compared directly with quotients / d, wheresis the size of the cell, anddis distance between center of cell's mass and currently compared node.
-
getType
public String getType()
Returns the type of the algorithm used when positioning nodes.Default: "reingold-fruchterman"
-
setType
public void setType(String type)
Sets the type of the algorithm used when positioning nodes.
-
-