TUM CCSM Commons

edu.tum.cs.commons.graph
Class GraphvizGenerator

java.lang.Object
  extended by edu.tum.cs.commons.graph.GraphvizGenerator

public class GraphvizGenerator
extends java.lang.Object

Java interface to the Graphviz graph drawing toolkit.

Version:
$Rev: 26283 $
Author:
Florian Deissenboeck, Benjamin Hummel, $Author: juergens $
Rating:
GREEN Hash: B550212FE943BEBCD0FD6F32553ABF78

Constructor Summary
GraphvizGenerator()
          Create a new generator that uses dot and expects it to be on the path.
GraphvizGenerator(java.lang.String layoutEnginePath)
          Create a new generator by specifying the executable of the layout engine.
 
Method Summary
 void generateFile(java.lang.String description, java.io.File file, EGraphvizOutputFormat format)
          Export a graph to a file.
 java.lang.String generateFileAndImageMap(java.lang.String description, java.io.File file, EGraphvizOutputFormat format)
          Export a graph to a file and return the HTML image map code.
 java.awt.image.BufferedImage generateImage(java.lang.String description)
          Generate an image from a graph description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphvizGenerator

public GraphvizGenerator()
Create a new generator that uses dot and expects it to be on the path.


GraphvizGenerator

public GraphvizGenerator(java.lang.String layoutEnginePath)
Create a new generator by specifying the executable of the layout engine. This may be used if dot is not on the path or if another layout engine like neato should be used.

Parameters:
layoutEnginePath - path to layout engine excutable
Method Detail

generateFile

public void generateFile(java.lang.String description,
                         java.io.File file,
                         EGraphvizOutputFormat format)
                  throws java.io.IOException,
                         GraphvizException
Export a graph to a file.

Parameters:
description - the graph description
file - the file to export to.
format - the export format.
Throws:
java.io.IOException - if an I/O problem occurrs.
GraphvizException - if Graphviz produced an error (exit code != 0)

generateFileAndImageMap

public java.lang.String generateFileAndImageMap(java.lang.String description,
                                                java.io.File file,
                                                EGraphvizOutputFormat format)
                                         throws java.io.IOException,
                                                GraphvizException
Export a graph to a file and return the HTML image map code.

Parameters:
description - the graph description
file - the file to export to.
format - the export format.
Returns:
the generated image map. These are only area-tags. The map tags including the name of the map must be created by the calling application.
Throws:
java.io.IOException - if an I/O problem occurrs.
GraphvizException - if Graphviz produced an error (exit code != 0)

generateImage

public java.awt.image.BufferedImage generateImage(java.lang.String description)
                                           throws java.io.IOException,
                                                  GraphvizException
Generate an image from a graph description. This uses Graphviz to generate a PNG image of the graph and javax.imageio to create the image object. All communication with Graphviz is handled via streams so no temporary files are used.

Parameters:
description - the graph description.
Returns:
the image
Throws:
java.io.IOException - if an I/O problem occurrs.
GraphvizException - if Graphviz produced an error (exit code != 0)

TUM CCSM Commons

TUM CCSM Commons - 2.7