Class GraphvizExporter<L extends Label>
java.lang.Object
org.variantsync.diffdetective.variation.diff.serialize.GraphvizExporter<L>
- All Implemented Interfaces:
Exporter<L>
Exporter for the Graphviz dot format.
Using this exporter the Graphviz application can be used to layout a
VariationDiff
for
visualisation.
Currently only basic layout relevant information is exported, so if the result is rendered directly by Graphviz no styling is applied.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<La extends L>
InputStreamcomputeGraphvizLayout
(VariationDiff<La> variationDiff, GraphvizExporter.LayoutAlgorithm algorithm, GraphvizExporter.OutputFormat outputFormat) Runs the Graphvizdot
program returning its result.private static String
Replaces all special characters with uninterpreted escape codes.<La extends L>
voidexportVariationDiff
(VariationDiff<La> variationDiff, OutputStream destination) ExportvariationDiff
as Graphviz graph intodestination
.static <L extends Label>
voidlayoutNodesIn
(VariationDiff<L> variationDiff, Format<? super L> format, GraphvizExporter.LayoutAlgorithm algorithm, TriConsumer<Integer, Double, Double> positionNode)
-
Field Details
-
quotePattern
-
graphvizNodePattern
-
format
-
-
Constructor Details
-
GraphvizExporter
-
-
Method Details
-
exportVariationDiff
public <La extends L> void exportVariationDiff(VariationDiff<La> variationDiff, OutputStream destination) throws IOException ExportvariationDiff
as Graphviz graph intodestination
. The exported graph is unstyled, but includes all necessary layout information.- Specified by:
exportVariationDiff
in interfaceExporter<L extends Label>
- Parameters:
variationDiff
- to be exporteddestination
- where the result should be written- Throws:
IOException
-
computeGraphvizLayout
public <La extends L> InputStream computeGraphvizLayout(VariationDiff<La> variationDiff, GraphvizExporter.LayoutAlgorithm algorithm, GraphvizExporter.OutputFormat outputFormat) throws IOException Runs the Graphvizdot
program returning its result.- Parameters:
variationDiff
- is the tree to be layouted by Graphviz.algorithm
- the layout algorithm used by GraphvizoutputFormat
- is the requested format which is passed to thedot
program with the-T
flag.- Returns:
- a buffered
InputStream
of the Graphviz output - Throws:
IOException
-
escape
Replaces all special characters with uninterpreted escape codes. The Graphviz parser for strings interprets some characters specially. The result of this function can be used in Graphviz strings (surrounded by double quotes) resulting in all characters appearing literally in the output. Note that some backends of Graphviz may still interpret some strings specially, most commonly strings containing HTML tags.- Parameters:
label
- a list of lines to be used as verbatim label- Returns:
- a single string which produces the lines of
label
verbatim
-
layoutNodesIn
public static <L extends Label> void layoutNodesIn(VariationDiff<L> variationDiff, Format<? super L> format, GraphvizExporter.LayoutAlgorithm algorithm, TriConsumer<Integer, Double, throws IOExceptionDouble> positionNode) - Throws:
IOException
-