Package soot.util.dot
Class DotGraph
- java.lang.Object
-
- soot.util.dot.AbstractDotGraphElement
-
- soot.util.dot.DotGraph
-
- All Implemented Interfaces:
Renderable
public class DotGraph extends AbstractDotGraphElement implements Renderable
Allow a serialized drawing, following steps:- new DotGraph
- draw(Directed/Undirected)Edge, attachAttributes, addNode
- plot
-
-
Field Summary
Fields Modifier and Type Field Description static StringDOT_EXTENSIONThe extension added to output files, exported so that clients can search for the filenames.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsNode(String name)Checks if the graph already contains the node with the specified name.booleancontainsNode(DotGraphNode node)Checks if the graph already contains the givenDotGraphNode.DotGraphcreateSubGraph(String label)creates a sub graph.DotGraphEdgedrawEdge(String from, String to)Draws a directed edge (including the source and end nodes, if they have not already been drawn).DotGraphNodedrawNode(String name)Draws a node.DotGraphEdgedrawUndirectedEdge(String node1, String node2)Draws a undirected edge (including the nodes, if they have not already been drawn).DotGraphNodegetNode(String name)Gets the graph node by name.voidplot(String filename)Generates the drawing on canvas to the dot file.voidquoteNodeNames(boolean value)NOTE: default is truevoidrender(OutputStream out, int indent)voidsetGraphAttribute(String id, String value)sets any general attributes NOTE: Alias forAbstractDotGraphElement.setAttribute(java.lang.String, java.lang.String).voidsetGraphAttribute(DotGraphAttribute attr)sets any general attributes NOTE: Alias forAbstractDotGraphElement.setAttribute(soot.util.dot.DotGraphAttribute).voidsetGraphLabel(String label)NOTE: Alias forAbstractDotGraphElement.setLabel(java.lang.String).voidsetGraphName(String name)sets the graph namevoidsetGraphSize(double width, double height)sets the size of drawing area, in inchesvoidsetNodeShape(String shape)Sets all node shapes, see the list of node shapes in DotGraphConstants.voidsetNodeStyle(String style)Sets all node stylesvoidsetOrientation(String orientation)sets the graph rotation anglesvoidsetPageSize(double width, double height)sets the pages size, once this is set, the generated graph will be broken into several pages.-
Methods inherited from class soot.util.dot.AbstractDotGraphElement
getAttribute, getAttributes, getAttributeValue, getLabel, removeAllAttributes, removeAttribute, removeAttribute, setAttribute, setAttribute, setLabel
-
-
-
-
Field Detail
-
DOT_EXTENSION
public static final String DOT_EXTENSION
The extension added to output files, exported so that clients can search for the filenames.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DotGraph
public DotGraph(String graphname)
Creates a new graph for drawing.- Parameters:
graphname- , the name used to identify the graph in the dot source.
-
-
Method Detail
-
plot
public void plot(String filename)
Generates the drawing on canvas to the dot file.- Parameters:
filename- the name for the output file. By convention, it should end with DOT_EXTENSION, but this is not enforced.
-
drawEdge
public DotGraphEdge drawEdge(String from, String to)
Draws a directed edge (including the source and end nodes, if they have not already been drawn).- Parameters:
from- , the source nodeto- , the end node- Returns:
- a directed graph edge connecting
fromwithto
-
drawUndirectedEdge
public DotGraphEdge drawUndirectedEdge(String node1, String node2)
Draws a undirected edge (including the nodes, if they have not already been drawn).- Parameters:
node1-node2-- Returns:
- an undirected graph edge connecting
node1withnode2
-
drawNode
public DotGraphNode drawNode(String name)
Draws a node.- Parameters:
name- , the node to draw.- Returns:
- the
DotGraphNodecorresponding to the specified name.
-
getNode
public DotGraphNode getNode(String name)
Gets the graph node by name.- Parameters:
name- , unique name of the node.- Returns:
- the node with the specified name, adding a new node to the graph if there is no such node.
-
containsNode
public boolean containsNode(String name)
Checks if the graph already contains the node with the specified name.- Parameters:
name- , unique name of the node.- Returns:
- true if the node with the specified name is already in the graph, false otherwise
-
containsNode
public boolean containsNode(DotGraphNode node)
Checks if the graph already contains the givenDotGraphNode.- Parameters:
node-- Returns:
- true if the node is already in the graph, false otherwise
-
quoteNodeNames
public void quoteNodeNames(boolean value)
NOTE: default is true- Parameters:
value-
-
setNodeShape
public void setNodeShape(String shape)
Sets all node shapes, see the list of node shapes in DotGraphConstants.- Parameters:
shape- , the node shape
-
setNodeStyle
public void setNodeStyle(String style)
Sets all node styles- Parameters:
style- , the node style
-
setGraphSize
public void setGraphSize(double width, double height)sets the size of drawing area, in inches
-
setPageSize
public void setPageSize(double width, double height)sets the pages size, once this is set, the generated graph will be broken into several pages.
-
setOrientation
public void setOrientation(String orientation)
sets the graph rotation angles
-
setGraphName
public void setGraphName(String name)
sets the graph name
-
setGraphLabel
public void setGraphLabel(String label)
NOTE: Alias forAbstractDotGraphElement.setLabel(java.lang.String).
-
setGraphAttribute
public void setGraphAttribute(String id, String value)
sets any general attributes NOTE: Alias forAbstractDotGraphElement.setAttribute(java.lang.String, java.lang.String).- Parameters:
id- is the attribute name.value- is the attribute value.
-
setGraphAttribute
public void setGraphAttribute(DotGraphAttribute attr)
sets any general attributes NOTE: Alias forAbstractDotGraphElement.setAttribute(soot.util.dot.DotGraphAttribute).- Parameters:
attr- aDotGraphAttributespecifying the attribute name and value.
-
createSubGraph
public DotGraph createSubGraph(String label)
creates a sub graph. NOTE: Some renderers require subgraph labels to start with "cluster".- Returns:
- the newly created sub graph.
-
render
public void render(OutputStream out, int indent) throws IOException
- Specified by:
renderin interfaceRenderable- Throws:
IOException
-
-