-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parse Graphviz xdot files and interactively view them using GTK and Cairo -- -- Parse Graphviz xdot files and interactively view them using GTK and -- Cairo. -- -- Currently not all xdot features are supported. Nodes and edges can be -- highlighted by hovering them and clicked. -- -- For an example of using this library try the accompanying -- Demo.hs with the dot-files in dot-examples/. -- -- This library was originally written as part of ghc-vis, but is now a -- separate project, in case anyone else may have a use for it. @package xdot @version 0.3 -- | This module contains various types used to represent xdot parameters. module Graphics.XDot.Types -- | A simple point, consisting of an x and y position. type Point = (Double, Double) -- | A rectangle, x and y position, width and height. type Rectangle = (Double, Double, Double, Double) -- | Alignment of text. data Alignment LeftAlign :: Alignment CenterAlign :: Alignment RightAlign :: Alignment -- | An object an operation can belong to. data Object n None :: Object n Node :: n -> Object n Edge :: n -> n -> Object n -- | Drawing operations supported by xdot. See -- http://www.graphviz.org/doc/info/output.html#d:xdot for more -- information data Operation Ellipse :: Point -> Double -> Double -> Bool -> Operation [xy] :: Operation -> Point [w] :: Operation -> Double [h] :: Operation -> Double [filled] :: Operation -> Bool Polygon :: [Point] -> Bool -> Operation [points] :: Operation -> [Point] [filled] :: Operation -> Bool Polyline :: [Point] -> Operation [points] :: Operation -> [Point] BSpline :: [Point] -> Bool -> Operation [points] :: Operation -> [Point] [filled] :: Operation -> Bool FontCharacteristics :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Operation [bold] :: Operation -> Bool [italic] :: Operation -> Bool [underline] :: Operation -> Bool [superscript] :: Operation -> Bool [subscript] :: Operation -> Bool [strikethrough] :: Operation -> Bool Text :: Point -> Alignment -> Double -> String -> Operation [baseline] :: Operation -> Point [alignment] :: Operation -> Alignment [width] :: Operation -> Double [text] :: Operation -> String Color :: (Double, Double, Double, Double) -> Bool -> Operation [rgba] :: Operation -> (Double, Double, Double, Double) [filled] :: Operation -> Bool Font :: Double -> String -> Operation [size] :: Operation -> Double [name] :: Operation -> String Style :: String -> Operation [style] :: Operation -> String Image :: Point -> Double -> Double -> String -> Operation [xy] :: Operation -> Point [w] :: Operation -> Double [h] :: Operation -> Double [name] :: Operation -> String instance GHC.Show.Show Graphics.XDot.Types.Operation instance GHC.Classes.Eq n => GHC.Classes.Eq (Graphics.XDot.Types.Object n) instance GHC.Show.Show n => GHC.Show.Show (Graphics.XDot.Types.Object n) instance GHC.Show.Show Graphics.XDot.Types.Alignment -- | This module draws the operations of an xdot graph using Cairo and -- Pango on a Gtk canvas. module Graphics.XDot.Viewer -- | Draw an xdot graph, possibly highlighting a node. drawAll :: Eq t => Object t -> Rectangle -> [(Object t, Operation)] -> Render [(Object t, Rectangle)] -- | 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
--   
module Graphics.XDot.Parser -- | Extract all operations of an xdot graph and connect them to the node -- they belong to, if any. getOperations :: DotGraph a -> [(Object a, Operation)] -- | Extract the dimensions of all nodes and edges in the graph. getDimensions :: DotGraph a -> [(Object a, Rectangle)] -- | Extract the dimensions of the graph when drawn. getSize :: DotGraph a -> Rectangle