jlink.flowchart.graph
Class JLGraph

java.lang.Object
  extended by jlink.flowchart.graph.JLGraph

public class JLGraph
extends java.lang.Object

Implementaion of a graph structure. Used at the core of JLink to represent the data model of any JLFlowchart.

A JLGraph is an ordered pair such that:
JLGraph : (JLVertexSet, JLEdgeSet).

JLVertexSet contains all the vertices associated with this particular graph. JLEdgeSet contains all the edges in this current graph (which are ordered pairs of vertices).

The primary focus of JLink is flow charts. Since flow charts show the flow of a process, the underlying model is essentially a digraph (directed graph). This is why the JLEdge class is an ordered pair of vertices. Note that although this is the default model in JLink, you can set the JLGraph property to be undirected. When this is done, the drawing treats the model as though it was an undirected graph. If you have a digraph that you want some edges to be undirected, you can try setting individual edge properties in JLEdge to display no arrow heads or arrow heads to both head and tail vertices.

JLGraph keeps an eye on its vertices and edges within the JLVertexSet and JLEdgeSet, and provides a model which JLFlowchart can use to display a drawing. This drawing is the corresponding Flow Chart representation of the graph model.

As the JLGraph component contains all the information about the placing of vertices and edges, layout algorithms can use it to intelligently place all the elements inside the container of a JLFlowchart.

Author:
jasonkb
See Also:
JLGraph(), JLGraph(int graphType), JLGraph(JLVertexSet v, JLEdgeSet e), JLGraph(int graphType, JLVertexSet v, JLEdgeSet e), JLFlowchart, JLVertexSet, JLVertex, JLEdgeSet, JLEdge

Field Summary
protected  boolean digraph
          Whether this graph is directed or undirected.
static int DIRECTED_GRAPH
          Integer constant to set JLGraph to be directed.
protected  JLEdgeSet edges
          The complete set of edges for this JLGraph.
static int UNDIRECTED_GRAPH
          Integer constant to set JLGraph to be undirected.
protected  JLVertexSet vertices
          The complete set of vertices for this JLGraph
 
Constructor Summary
JLGraph()
          Creates a new instance of JLGraph with graph type defaulting to digraph (ie.
JLGraph(int graphType)
          Creates a new instance of JLGraph with user defined graph type (either graph or digraph).
JLGraph(int graphType, JLVertexSet v, JLEdgeSet e)
          Fully customisable constructor for JLGraph.
JLGraph(JLVertexSet v, JLEdgeSet e)
          Creates a new instance of JLGraph with user defined vertices and edges.
 
Method Summary
 JLEdge createJLEdge(JLVertex headVertex, JLVertex tailVertex)
           
 JLVertex createJLVertex()
          Creates a JLVertex and registers it with this JLGraph while providing a handle to the calling program for the JLVertex that was created.
 void createJLVertex(JLVertex v)
          While this method can be useful to create a JLVertex and register it inside this JLGraph, it is not the preferred method to do so.
 JLEdgeSet getJLEdgeSet()
          Used to retrieve an edge set (JLEdgeSet) from this JLGraph.
 int getJLGraphType()
          Alternative method to testing whether JLGraph is directed or undirected.
 JLVertexSet getJLVertexSet()
          Used to retrieve a vertex set (JLVertexSet) from this JLGraph.
 boolean isDirected()
          Tests JLGraph to see if it is a directed graph (digraph) or undirected.
 void setDirected(boolean value)
          Sets this JLGraph to be directed or undirected.
 void setJLEdgeSet(JLEdgeSet edgeSet)
          Sets the JLEdgeSet of this JLGraph to the user defined edge set.
 void setJLGraphType(int graphType)
          Sets this JLGraph type to either a directed or undirected graph depending on which integer constant is fed into the arguments.
 void setJLVertexSet(JLVertexSet vertexSet)
          Sets the vertex set of this JLGraph to a user defined JLVertexSet.
 java.lang.String toString()
          Construct a string representation of this JLGraph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vertices

protected JLVertexSet vertices
The complete set of vertices for this JLGraph

See Also:
edges

edges

protected JLEdgeSet edges
The complete set of edges for this JLGraph.

The edges stored in this are ordered pairs of vertices by default.

See Also:
vertices

digraph

protected boolean digraph
Whether this graph is directed or undirected.

See Also:
isDirected(), setDirected(boolean value)

DIRECTED_GRAPH

public static final int DIRECTED_GRAPH
Integer constant to set JLGraph to be directed.

See Also:
JLGraph(int graphType), JLGraph(int graphType, JLVertexSet v, JLEdgeSet e), getJLGraphType(), setJLGraphType(int graphType), UNDIRECTED_GRAPH, Constant Field Values

UNDIRECTED_GRAPH

public static final int UNDIRECTED_GRAPH
Integer constant to set JLGraph to be undirected.

See Also:
JLGraph(int graphType), JLGraph(int graphType, JLVertexSet v, JLEdgeSet e), getJLGraphType(), setJLGraphType(int graphType), DIRECTED_GRAPH, Constant Field Values
Constructor Detail

JLGraph

public JLGraph()
Creates a new instance of JLGraph with graph type defaulting to digraph (ie. Directed Graph)

See Also:
JLGraph(int graphType), JLGraph(JLVertexSet v, JLEdgeSet e), JLGraph(int graphType, JLVertexSet v, JLEdgeSet e)

JLGraph

public JLGraph(int graphType)
Creates a new instance of JLGraph with user defined graph type (either graph or digraph).

Use this if you wish to create an undirected graph using the JLink libraries.

Parameters:
graphType - Either JLGraph.DIRECTED_GRAPH or JLGraph.UNDIRECTED_GRAPH
See Also:
JLGraph(), JLGraph(JLVertexSet v, JLEdgeSet e), JLGraph(int graphType, JLVertexSet v, JLEdgeSet e), DIRECTED_GRAPH, UNDIRECTED_GRAPH

JLGraph

public JLGraph(JLVertexSet v,
               JLEdgeSet e)
Creates a new instance of JLGraph with user defined vertices and edges.

Use this if you wish to create a directed graph using existing vertices and edges.

Parameters:
v - The user defined vertex set to use in this JLGraph
e - The user defined edge set to use in this JLGraph
See Also:
JLGraph(), JLGraph(int graphType, JLVertexSet v, JLEdgeSet e), DIRECTED_GRAPH, UNDIRECTED_GRAPH

JLGraph

public JLGraph(int graphType,
               JLVertexSet v,
               JLEdgeSet e)
Fully customisable constructor for JLGraph. This lets the user specify the vertices, edges and graph type.

Parameters:
graphType - Either JLGraph.DIRECTED_GRAPH or JLGraph.UNDIRECTED_GRAPH
v - The set of vertices to use for this graph (JLGraph).
e - The set of edges (ordered pairs of vertices) to use for this graph (JLGraph).
See Also:
JLGraph(), JLGraph(int graphType), JLVertexSet, JLEdgeSet, DIRECTED_GRAPH, UNDIRECTED_GRAPH
Method Detail

isDirected

public boolean isDirected()
Tests JLGraph to see if it is a directed graph (digraph) or undirected.

Returns:
true if JLGraph is directed, false if undirected.

setDirected

public void setDirected(boolean value)
Sets this JLGraph to be directed or undirected.

An alternative method to the above is the setJLGraphType(int graphType) method which enables the user to set the graph type using integer constants instead.

Parameters:
value - If true this JLGraph is set to being directed, and if false undirected.
See Also:
isDirected(), setJLGraphType(int graphType), digraph, DIRECTED_GRAPH, UNDIRECTED_GRAPH

setJLGraphType

public void setJLGraphType(int graphType)
Sets this JLGraph type to either a directed or undirected graph depending on which integer constant is fed into the arguments.

Parameters:
graphType - Either JLGraph.DIRECTED or JLGraph.UNDIRECTED
See Also:
setDirected(boolean value), DIRECTED_GRAPH, UNDIRECTED_GRAPH

getJLGraphType

public int getJLGraphType()
Alternative method to testing whether JLGraph is directed or undirected.

Returns:
A JLGraph integer constant according to the current status of the graph
See Also:
isDirected(), DIRECTED_GRAPH, UNDIRECTED_GRAPH, setJLGraphType(int graphType), setDirected(boolean value)

setJLEdgeSet

public void setJLEdgeSet(JLEdgeSet edgeSet)
Sets the JLEdgeSet of this JLGraph to the user defined edge set.

Parameters:
edgeSet - The user defined edge set to make as this JLGraph JLEdgeSet
See Also:
getJLEdgeSet(), setJLVertexSet(JLVertexSet vertexSet), JLEdgeSet

getJLEdgeSet

public JLEdgeSet getJLEdgeSet()
Used to retrieve an edge set (JLEdgeSet) from this JLGraph.

Returns:
The current JLEdgeSet of this JLGraph.
See Also:
setJLEdgeSet(JLEdgeSet edgeSet), getJLVertexSet(), JLEdgeSet

setJLVertexSet

public void setJLVertexSet(JLVertexSet vertexSet)
Sets the vertex set of this JLGraph to a user defined JLVertexSet.

Parameters:
vertexSet - The user defined JLVertexSet
See Also:
getJLVertexSet(), setJLEdgeSet(JLEdgeSet edgeSet), JLVertexSet

getJLVertexSet

public JLVertexSet getJLVertexSet()
Used to retrieve a vertex set (JLVertexSet) from this JLGraph.

Returns:
The current vertex set (JLVertexSet)
See Also:
setJLVertexSet(JLVertexSet vertexSet), getJLEdgeSet(), JLVertexSet

createJLVertex

public JLVertex createJLVertex()
Creates a JLVertex and registers it with this JLGraph while providing a handle to the calling program for the JLVertex that was created.

This is the preferred way of using JLink to create vertices.

Returns:
A newly created JLVertex that has been appended to the JLVertexSet.
See Also:
createJLVertex(JLVertex v)

createJLVertex

public void createJLVertex(JLVertex v)
                    throws DuplicateJLVertexException
While this method can be useful to create a JLVertex and register it inside this JLGraph, it is not the preferred method to do so. The main reason for this is to clean your code up by using less exceptions. You are welcome to use it (it is stable) if you don't mind the use of exceptions, but you will have a bit more typing to do so if you use this method.

Parameters:
v - The JLVertex to register with this JLGraph.
Throws:
DuplicateJLVertexException - If a duplicate vertex was found.
See Also:
createJLVertex()

createJLEdge

public JLEdge createJLEdge(JLVertex headVertex,
                           JLVertex tailVertex)
                    throws IncompleteJLEdgeException
Throws:
IncompleteJLEdgeException

toString

public java.lang.String toString()
Construct a string representation of this JLGraph.

Overrides:
toString in class java.lang.Object
Returns:
The string representing some information about this JLGraph.