Package mgui.interfaces.graphs.util
Class GraphFunctions
java.lang.Object
mgui.interfaces.Utility
mgui.interfaces.graphs.util.GraphFunctions
public class GraphFunctions extends Utility
Provides utility functions for Graphs.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GraphFunctions.ArrowVisibility
static class
GraphFunctions.EdgeFactory
Factory to create graph edges.static class
GraphFunctions.EdgeVisibility
static class
GraphFunctions.GraphEdgeLabelRenderer
Allows labels to be turned off.static class
GraphFunctions.GraphNodeLabelRenderer
Allows labels to be turned off.static class
GraphFunctions.NodeFactory
Factory to create graph nodes.static class
GraphFunctions.NodeVisibility
-
Constructor Summary
Constructors Constructor Description GraphFunctions()
-
Method Summary
Modifier and Type Method Description static NodeShape
createNodeShape(java.lang.String line)
Creates aShape
instance, used to render graph nodes, by parsing a line of text, with the format:static GraphFunctions.ArrowVisibility
getArrowVisibilityPredicate(boolean initial)
Returns a predicate object to control the visibility of edge arrows in a graph.static InterfaceAbstractGraph
getDistanceWeightedGraphForMesh(Mesh3D mesh)
Convertsmesh
to a weighted graph.static org.apache.commons.collections15.Factory<AbstractGraphEdge>
getEdgeFactory()
static <T extends AbstractGraphEdge>
org.apache.commons.collections15.Factory<AbstractGraphEdge>getEdgeFactory(java.lang.Class<T> edge_class)
static org.apache.commons.collections15.Transformer<AbstractGraphEdge,java.lang.String>
getEdgeLabeller()
Returns aTransformer
object which produces a label for an edge.static GraphFunctions.GraphEdgeLabelRenderer
getEdgeLabelRenderer()
Returns an edge label renderer which can be turned off.static GraphFunctions.EdgeVisibility
getEdgeVisibilityPredicate(boolean initial)
Returns a predicate object to control the visibility of edges in a graph.static edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position
getLabelPosition(java.lang.String pos)
Returns the label position associated with the Stringpos
.static java.util.ArrayList<java.lang.String>
getLabelPositions()
Get a list of possible node label positions, as Strings.static java.util.HashMap<java.lang.String,java.lang.Class<?>>
getLayout3DTypes()
Returns list of available 3D graph layouts.static java.util.HashMap<java.lang.String,java.lang.Class>
getLayout3DTypes2()
Returns list of available 3D graph layouts.static java.util.HashMap<java.lang.String,java.lang.Class<?>>
getLayoutTypes()
Returns list of available graph layouts.static java.util.HashMap<java.lang.String,java.lang.Class>
getLayoutTypes2()
Returns list of available graph layouts.static org.apache.commons.collections15.Factory<AbstractGraphNode>
getNodeFactory()
static <T extends AbstractGraphNode>
org.apache.commons.collections15.Factory<AbstractGraphNode>getNodeFactory(java.lang.Class<T> node_class, java.lang.String prefix, boolean add_ids, boolean has_locations)
static GraphFunctions.GraphNodeLabelRenderer
getNodeLabelRenderer(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position position)
Returns a node label renderer which can be turned off.static GraphFunctions.NodeVisibility
getNodeVisibilityPredicate(boolean initial)
Returns a predicate object to control the visibility of nodes in a graph.static Jama.Matrix
getShortestPaths(InterfaceAbstractGraph graph)
Returns an N x N matrix with the shortest paths lengths between each pair of vertices i and j, ingraph
.static Jama.Matrix
getShortestPaths(InterfaceAbstractGraph graph, java.util.ArrayList<java.lang.Integer> vertices)
Returns an N x N matrix with the shortest paths lengths between each pair of vertices i and j, invertices
.static org.apache.commons.collections15.Transformer<AbstractGraphNode,java.lang.String>
getVertexLabeller()
Returns aTransformer
object which produces a label for a vertex.protected static NodeShape
loadNodeShapeFromSvg(java.lang.String filename)
Loads a node shape from an svg filestatic boolean
scaleToGraphExtents(InterfaceGraphDisplay display)
Determines the current extents of this display's graph and scales/translates to itMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
GraphFunctions
public GraphFunctions()
-
-
Method Details
-
getNodeFactory
-
getNodeFactory
public static <T extends AbstractGraphNode> org.apache.commons.collections15.Factory<AbstractGraphNode> getNodeFactory(java.lang.Class<T> node_class, java.lang.String prefix, boolean add_ids, boolean has_locations) -
getEdgeFactory
-
getEdgeFactory
public static <T extends AbstractGraphEdge> org.apache.commons.collections15.Factory<AbstractGraphEdge> getEdgeFactory(java.lang.Class<T> edge_class) -
getLayoutTypes
public static java.util.HashMap<java.lang.String,java.lang.Class<?>> getLayoutTypes()Returns list of available graph layouts.TODO: load these into a GraphEnvironment.
- Returns:
- a HashMap of available layout types, and their corresponding classes
-
getLayoutTypes2
public static java.util.HashMap<java.lang.String,java.lang.Class> getLayoutTypes2()Returns list of available graph layouts. Unparameterized, because generics can be a pain in the ass sometimes...TODO: load these into a GraphEnvironment.
- Returns:
- a HashMap of available layout types, and their corresponding classes
-
getLayout3DTypes2
public static java.util.HashMap<java.lang.String,java.lang.Class> getLayout3DTypes2()Returns list of available 3D graph layouts. Revised because generics can be a bitch.TODO: load these into a GraphEnvironment.
- Returns:
- a HashMap of available layout types, and their corresponding classes
-
getLayout3DTypes
public static java.util.HashMap<java.lang.String,java.lang.Class<?>> getLayout3DTypes()Returns list of available 3D graph layouts.TODO: load these into a GraphEnvironment.
- Returns:
- a HashMap of available layout types, and their corresponding classes
-
getVertexLabeller
public static org.apache.commons.collections15.Transformer<AbstractGraphNode,java.lang.String> getVertexLabeller()Returns aTransformer
object which produces a label for a vertex.- Returns:
-
getEdgeLabeller
public static org.apache.commons.collections15.Transformer<AbstractGraphEdge,java.lang.String> getEdgeLabeller()Returns aTransformer
object which produces a label for an edge.- Returns:
-
createNodeShape
Creates aShape
instance, used to render graph nodes, by parsing a line of text, with the format:[name] [is-fillable] [qualified-class-name] [space delimited parameter list]
Or, to load an path:
[name] [is-fillable] java.awt.Path2D$[Float|Double] [SVG-like M (move) and L (line) commands; e.g., M 1,5 L 10,5 M 5,1 L 5,10 ]
- Parameters:
line
-- Returns:
- the shape, or
null
if none was created
-
loadNodeShapeFromSvg
Loads a node shape from an svg file- Parameters:
filename
-
-
scaleToGraphExtents
Determines the current extents of this display's graph and scales/translates to it- Parameters:
display
-- Returns:
-
getLabelPositions
public static java.util.ArrayList<java.lang.String> getLabelPositions()Get a list of possible node label positions, as Strings.- Returns:
-
getLabelPosition
public static edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position getLabelPosition(java.lang.String pos)Returns the label position associated with the Stringpos
.- Returns:
-
getEdgeVisibilityPredicate
Returns a predicate object to control the visibility of edges in a graph.- Parameters:
initial
-- Returns:
-
getNodeVisibilityPredicate
Returns a predicate object to control the visibility of nodes in a graph.- Parameters:
initial
-- Returns:
-
getArrowVisibilityPredicate
Returns a predicate object to control the visibility of edge arrows in a graph.- Parameters:
initial
-- Returns:
-
getNodeLabelRenderer
public static GraphFunctions.GraphNodeLabelRenderer getNodeLabelRenderer(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position position)Returns a node label renderer which can be turned off.- Parameters:
position
-- Returns:
-
getEdgeLabelRenderer
Returns an edge label renderer which can be turned off.- Parameters:
position
-- Returns:
-
getShortestPaths
Returns an N x N matrix with the shortest paths lengths between each pair of vertices i and j, ingraph
.- Parameters:
graph
-- Returns:
-
getShortestPaths
public static Jama.Matrix getShortestPaths(InterfaceAbstractGraph graph, java.util.ArrayList<java.lang.Integer> vertices)Returns an N x N matrix with the shortest paths lengths between each pair of vertices i and j, invertices
.- Parameters:
graph
-vertices
- The list of vertices for which to obtain distances- Returns:
-
getDistanceWeightedGraphForMesh
Convertsmesh
to a weighted graph.- Parameters:
mesh
-- Returns:
-