Package org.graphstream.ui.graphicGraph
Class GraphPosLengthUtils
java.lang.Object
org.graphstream.ui.graphicGraph.GraphPosLengthUtils
public class GraphPosLengthUtils extends Object
Lots of small often used measuring algorithms on graphs.
Use this class with a static import.
-
Constructor Summary
Constructors Constructor Description GraphPosLengthUtils() -
Method Summary
Modifier and Type Method Description static doubleedgeLength(Edge edge)LikeedgeLength(Graph,String)but use an existing edge as argument.static doubleedgeLength(Graph graph, String id)Compute the edge length of the given edge according to its two nodes positions.static Point3nodePointPosition(Graph graph, String id)Retrieve a node position from its attributes ("x", "y", "z", or "xy", or "xyz").static Point3nodePointPosition(Node node)LikenodePointPosition(Graph,String)but use an existing node as argument.static double[]nodePosition(Graph graph, String id)Retrieve a node position from its attributes ("x", "y", "z", or "xy", or "xyz").static voidnodePosition(Graph graph, String id, double[] xyz)LikenodePosition(Graph,String), but instead of returning a newly allocated array, fill up the array given as parameter.static Point3nodePosition(Graph graph, String id, Point3 pos)LikenodePointPosition(Graph,String), but instead of returning a newly allocated array, fill up the array given as parameter.static double[]nodePosition(Node node)LikenodePosition(Graph,String)but use an existing node as argument.static voidnodePosition(Node node, double[] xyz)LikenodePosition(Graph,String,double[])but use an existing node as argument.static Point3nodePosition(Node node, Point3 pos)LikenodePosition(Graph,String,Point3)but use an existing node as argument.static voidpositionFromObject(Object o, double[] xyz)Try to convert an object to a position.static Point3positionFromObject(Object o, Point3 pos)Try to convert an object to a position.
-
Constructor Details
-
GraphPosLengthUtils
public GraphPosLengthUtils()
-
-
Method Details
-
nodePosition
Retrieve a node position from its attributes ("x", "y", "z", or "xy", or "xyz").- Parameters:
id- The node identifier.- Returns:
- A newly allocated array of three floats containing the (x,y,z) position of the node, or null if the node is not part of the graph.
-
nodePointPosition
Retrieve a node position from its attributes ("x", "y", "z", or "xy", or "xyz").- Parameters:
id- The node identifier.- Returns:
- A newly allocated point containing the (x,y,z) position of the node, or null if the node is not part of the graph.
-
nodePosition
LikenodePosition(Graph,String)but use an existing node as argument.- Parameters:
node- The node to consider.- Returns:
- A newly allocated array of three floats containing the (x,y,z) position of the node.
-
nodePointPosition
LikenodePointPosition(Graph,String)but use an existing node as argument.- Parameters:
node- The node to consider.- Returns:
- A newly allocated point containing the (x,y,z) position of the node.
-
nodePosition
LikenodePosition(Graph,String), but instead of returning a newly allocated array, fill up the array given as parameter. This array must have at least three cells.- Parameters:
id- The node identifier.xyz- An array of at least three cells.- Throws:
RuntimeException- If the node with the given identifier does not exist.
-
nodePosition
LikenodePointPosition(Graph,String), but instead of returning a newly allocated array, fill up the array given as parameter. This array must have at least three cells.- Parameters:
id- The node identifier.pos- A point that will receive the node position.- Throws:
RuntimeException- If the node with the given identifier does not exist.
-
nodePosition
LikenodePosition(Graph,String,double[])but use an existing node as argument.- Parameters:
node- The node to consider.xyz- An array of at least three cells.
-
nodePosition
LikenodePosition(Graph,String,Point3)but use an existing node as argument.- Parameters:
node- The node to consider.pos- A point that will serve as the default position if node doesn't have position
-
positionFromObject
Try to convert an object to a position. The object can be an array of numbers, an array of base numeric types or their object counterparts.- Parameters:
o- The object to try to convert.xyz- The result.
-
positionFromObject
Try to convert an object to a position. The object can be an array of numbers, an array of base numeric types or their object counterparts.- Parameters:
o- The object to try to convert.pos- The default position if object doesn't have position data.
-
edgeLength
Compute the edge length of the given edge according to its two nodes positions.- Parameters:
id- The identifier of the edge.- Returns:
- The edge length or -1 if the nodes of the edge have no positions.
- Throws:
RuntimeException- If the edge cannot be found.
-
edgeLength
LikeedgeLength(Graph,String)but use an existing edge as argument.- Parameters:
edge-- Returns:
- The edge length or -1 if the nodes of the edge have no positions.
-