xdot-0.2.1: Parse Graphviz xdot files and interactively view them using GTK and Cairo

Maintainerdennis@felsin9.de
Safe HaskellNone

Graphics.XDot.Parser

Description

After an xdot file has been opened using GraphViz, its drawing operations can be parsed using this module.

 xDotText <- L.readFile "example.xdot"
 let xDotGraph = parseDotGraph xDotText :: G.DotGraph String
 let operations = getOperations xDotGraph

xdot files can be created using the dot binary from the Graphviz package:

 $ cat example.dot
 digraph {
     0 [label=""];
     1 [label=":"];
     0 -> 1 [label="[1..]"];
 }
 $ dot -Txdot example.dot > example.xdot

Or you can skip saving an xdot file and use a dot file directly:

 $ dotText <- L.readFile "example.dot"
 $ let dotGraph = parseDotGraph dotText :: G.DotGraph String
 $ xDotGraph <- graphvizWithHandle Dot dotGraph XDot hGetDot :: IO (G.DotGraph String)
 $ getOperations xDotGraph
 [ (None,Color {rgba = (1.0,1.0,1.0,1.0), filled = False})
 , (None,Color {rgba = (1.0,1.0,1.0,1.0), filled = True})
 , (None,Polygon {points = [(0.0,-1.0),(0.0,130.0),(55.0,130.0),(55.0,-1.0)], filled = True})
 , (Node "0",Color {rgba = (0.0,0.0,0.0,1.0), filled = False})
 , (Node "0",Ellipse {xy = (27.0,112.0), w = 27.0, h = 18.0, filled = False})
 , (Node "1",Color {rgba = (0.0,0.0,0.0,1.0), filled = False})
 , (Node "1",Ellipse {xy = (27.0,19.0), w = 27.0, h = 19.0, filled = False})
 , (Node "1",Font {size = 14.0, name = "Times-Roman"})
 , (Node "1",Color {rgba = (0.0,0.0,0.0,1.0), filled = False})
 , (Node "1",Text {baseline = (27.0,15.0), alignment = CenterAlign, width = 4.0, text = ":"})
 , (Edge "0" "1",Color {rgba = (0.0,0.0,0.0,1.0), filled = False})
 , (Edge "0" "1",BSpline {points = [(27.0,94.0),(27.0,81.0),(27.0,63.0),(27.0,48.0)], filled = False})
 , (Edge "0" "1",Style {style = "solid"})
 , (Edge "0" "1",Color {rgba = (0.0,0.0,0.0,1.0), filled = False})
 , (Edge "0" "1",Color {rgba = (0.0,0.0,0.0,1.0), filled = True})
 , (Edge "0" "1",Polygon {points = [(31.0,48.0),(27.0,38.0),(24.0,48.0)], filled = True})
 , (Edge "0" "1",Font {size = 14.0, name = "Times-Roman"})
 , (Edge "0" "1",Color {rgba = (0.0,0.0,0.0,1.0), filled = False})
 , (Edge "0" "1",Text {baseline = (39.0,62.0), alignment = CenterAlign, width = 24.0, text = "[1..]"})
 ]

The following imports are needed for this:

 import Data.GraphViz
 import Data.GraphViz.Commands.IO
 import qualified Data.Text.Lazy.IO as L
 import qualified Data.GraphViz.Types.Generalised as G

Synopsis

Documentation

getOperations :: DotGraph a -> [(Object a, Operation)]Source

Extract all operations of an xdot graph and connect them to the node they belong to, if any.

getSize :: DotGraph a -> RectangleSource

Extract the dimensions of the graph when drawn.