{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
module Data.GraphViz.Attributes
(
Attribute
, Attributes
, toLabel
, textLabel
, xLabel
, xTextLabel
, forceLabels
, textLabelValue
, Labellable(..)
, X11Color(..)
, bgColor
, bgColors
, fillColor
, fillColors
, fontColor
, penColor
, color
, penWidth
, gradientAngle
, style
, styles
, Style
, dashed
, dotted
, solid
, bold
, invis
, filled
, diagonals
, striped
, wedged
, rounded
, tapered
, radial
, shape
, Shape(..)
, arrowTo
, arrowFrom
, edgeEnds
, DirType(..)
, Arrow
, box
, crow
, diamond
, dotArrow
, inv
, noArrow
, normal
, tee
, vee
, oDot
, invDot
, invODot
, oBox
, oDiamond
, ordering
, Order(..)
, rank
, RankType(..)
) where
import Data.GraphViz.Attributes.Arrows
import Data.GraphViz.Attributes.Colors
import Data.GraphViz.Attributes.Colors.X11
import Data.GraphViz.Attributes.Complete (Attribute (..),
Attributes)
import qualified Data.GraphViz.Attributes.HTML as Html
import Data.GraphViz.Attributes.Internal
import Data.GraphViz.Attributes.Values
import qualified Data.Text as ST
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy as T
class Labellable a where
toLabelValue :: a -> Label
toLabel :: (Labellable a) => a -> Attribute
toLabel :: forall a. Labellable a => a -> Attribute
toLabel = Label -> Attribute
Label (Label -> Attribute) -> (a -> Label) -> a -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Label
forall a. Labellable a => a -> Label
toLabelValue
textLabel :: Text -> Attribute
textLabel :: Text -> Attribute
textLabel = Text -> Attribute
forall a. Labellable a => a -> Attribute
toLabel
xLabel :: (Labellable a) => a -> Attribute
xLabel :: forall a. Labellable a => a -> Attribute
xLabel = Label -> Attribute
XLabel (Label -> Attribute) -> (a -> Label) -> a -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Label
forall a. Labellable a => a -> Label
toLabelValue
xTextLabel :: Text -> Attribute
xTextLabel :: Text -> Attribute
xTextLabel = Text -> Attribute
forall a. Labellable a => a -> Attribute
xLabel
forceLabels :: Attribute
forceLabels :: Attribute
forceLabels = Bool -> Attribute
ForceLabels Bool
True
textLabelValue :: Text -> Label
textLabelValue :: Text -> Label
textLabelValue = Text -> Label
forall a. Labellable a => a -> Label
toLabelValue
instance Labellable Text where
toLabelValue :: Text -> Label
toLabelValue = Text -> Label
StrLabel
instance Labellable ST.Text where
toLabelValue :: Text -> Label
toLabelValue = Text -> Label
forall a. Labellable a => a -> Label
toLabelValue (Text -> Label) -> (Text -> Text) -> Text -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
T.fromStrict
instance Labellable Char where
toLabelValue :: Char -> Label
toLabelValue = Text -> Label
forall a. Labellable a => a -> Label
toLabelValue (Text -> Label) -> (Char -> Text) -> Char -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton
instance Labellable String where
toLabelValue :: String -> Label
toLabelValue = Text -> Label
forall a. Labellable a => a -> Label
toLabelValue (Text -> Label) -> (String -> Text) -> String -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
instance Labellable Int where
toLabelValue :: Int -> Label
toLabelValue = String -> Label
forall a. Labellable a => a -> Label
toLabelValue (String -> Label) -> (Int -> String) -> Int -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String
forall a. Show a => a -> String
show
instance Labellable Double where
toLabelValue :: Double -> Label
toLabelValue = String -> Label
forall a. Labellable a => a -> Label
toLabelValue (String -> Label) -> (Double -> String) -> Double -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> String
forall a. Show a => a -> String
show
instance Labellable Bool where
toLabelValue :: Bool -> Label
toLabelValue = String -> Label
forall a. Labellable a => a -> Label
toLabelValue (String -> Label) -> (Bool -> String) -> Bool -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> String
forall a. Show a => a -> String
show
instance Labellable Html.Label where
toLabelValue :: Label -> Label
toLabelValue = Label -> Label
HtmlLabel
instance Labellable Html.Text where
toLabelValue :: Text -> Label
toLabelValue = Label -> Label
forall a. Labellable a => a -> Label
toLabelValue (Label -> Label) -> (Text -> Label) -> Text -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Label
Html.Text
instance Labellable Html.Table where
toLabelValue :: Table -> Label
toLabelValue = Label -> Label
forall a. Labellable a => a -> Label
toLabelValue (Label -> Label) -> (Table -> Label) -> Table -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Table -> Label
Html.Table
instance Labellable RecordFields where
toLabelValue :: RecordFields -> Label
toLabelValue = RecordFields -> Label
RecordLabel
instance Labellable RecordField where
toLabelValue :: RecordField -> Label
toLabelValue = RecordFields -> Label
forall a. Labellable a => a -> Label
toLabelValue (RecordFields -> Label)
-> (RecordField -> RecordFields) -> RecordField -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RecordField -> RecordFields -> RecordFields
forall a. a -> [a] -> [a]
:[])
instance Labellable PortName where
toLabelValue :: PortName -> Label
toLabelValue = RecordField -> Label
forall a. Labellable a => a -> Label
toLabelValue (RecordField -> Label)
-> (PortName -> RecordField) -> PortName -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PortName -> RecordField
PortName
instance Labellable (PortName, EscString) where
toLabelValue :: (PortName, Text) -> Label
toLabelValue = RecordField -> Label
forall a. Labellable a => a -> Label
toLabelValue (RecordField -> Label)
-> ((PortName, Text) -> RecordField) -> (PortName, Text) -> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PortName -> Text -> RecordField)
-> (PortName, Text) -> RecordField
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry PortName -> Text -> RecordField
LabelledTarget
bgColor :: (NamedColor nc) => nc -> Attribute
bgColor :: forall nc. NamedColor nc => nc -> Attribute
bgColor = ColorList -> Attribute
BgColor (ColorList -> Attribute) -> (nc -> ColorList) -> nc -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Color] -> ColorList
toColorList ([Color] -> ColorList) -> (nc -> [Color]) -> nc -> ColorList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Color -> [Color] -> [Color]
forall a. a -> [a] -> [a]
:[]) (Color -> [Color]) -> (nc -> Color) -> nc -> [Color]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor
bgColors :: (NamedColor nc) => nc -> nc -> Attribute
bgColors :: forall nc. NamedColor nc => nc -> nc -> Attribute
bgColors nc
c1 nc
c2 = ColorList -> Attribute
BgColor (ColorList -> Attribute)
-> ([Color] -> ColorList) -> [Color] -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Color] -> ColorList
toColorList ([Color] -> Attribute) -> [Color] -> Attribute
forall a b. (a -> b) -> a -> b
$ (nc -> Color) -> [nc] -> [Color]
forall a b. (a -> b) -> [a] -> [b]
map nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor [nc
c1,nc
c2]
fillColor :: (NamedColor nc) => nc -> Attribute
fillColor :: forall nc. NamedColor nc => nc -> Attribute
fillColor = ColorList -> Attribute
FillColor (ColorList -> Attribute) -> (nc -> ColorList) -> nc -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Color] -> ColorList
toColorList ([Color] -> ColorList) -> (nc -> [Color]) -> nc -> ColorList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Color -> [Color] -> [Color]
forall a. a -> [a] -> [a]
:[]) (Color -> [Color]) -> (nc -> Color) -> nc -> [Color]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor
fillColors :: (NamedColor nc) => nc -> nc -> Attribute
fillColors :: forall nc. NamedColor nc => nc -> nc -> Attribute
fillColors nc
c1 nc
c2 = ColorList -> Attribute
FillColor (ColorList -> Attribute)
-> ([Color] -> ColorList) -> [Color] -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Color] -> ColorList
toColorList ([Color] -> Attribute) -> [Color] -> Attribute
forall a b. (a -> b) -> a -> b
$ (nc -> Color) -> [nc] -> [Color]
forall a b. (a -> b) -> [a] -> [b]
map nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor [nc
c1,nc
c2]
fontColor :: (NamedColor nc) => nc -> Attribute
fontColor :: forall nc. NamedColor nc => nc -> Attribute
fontColor = Color -> Attribute
FontColor (Color -> Attribute) -> (nc -> Color) -> nc -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor
penColor :: (NamedColor nc) => nc -> Attribute
penColor :: forall nc. NamedColor nc => nc -> Attribute
penColor = Color -> Attribute
PenColor (Color -> Attribute) -> (nc -> Color) -> nc -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor
color :: (NamedColor nc) => nc -> Attribute
color :: forall nc. NamedColor nc => nc -> Attribute
color = ColorList -> Attribute
Color (ColorList -> Attribute) -> (nc -> ColorList) -> nc -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Color] -> ColorList
toColorList ([Color] -> ColorList) -> (nc -> [Color]) -> nc -> ColorList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Color -> [Color] -> [Color]
forall a. a -> [a] -> [a]
:[]) (Color -> [Color]) -> (nc -> Color) -> nc -> [Color]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. nc -> Color
forall nc. NamedColor nc => nc -> Color
toColor
type Style = StyleItem
style :: Style -> Attribute
style :: Style -> Attribute
style = [Style] -> Attribute
styles ([Style] -> Attribute) -> (Style -> [Style]) -> Style -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Style -> [Style] -> [Style]
forall a. a -> [a] -> [a]
:[])
styles :: [Style] -> Attribute
styles :: [Style] -> Attribute
styles = [Style] -> Attribute
Style
dashed :: Style
dashed :: Style
dashed = StyleName -> [Text] -> Style
SItem StyleName
Dashed []
dotted :: Style
dotted :: Style
dotted = StyleName -> [Text] -> Style
SItem StyleName
Dotted []
solid :: Style
solid :: Style
solid = StyleName -> [Text] -> Style
SItem StyleName
Solid []
invis :: Style
invis :: Style
invis = StyleName -> [Text] -> Style
SItem StyleName
Invisible []
bold :: Style
bold :: Style
bold = StyleName -> [Text] -> Style
SItem StyleName
Bold []
filled :: Style
filled :: Style
filled = StyleName -> [Text] -> Style
SItem StyleName
Filled []
rounded :: Style
rounded :: Style
rounded = StyleName -> [Text] -> Style
SItem StyleName
Rounded []
diagonals :: Style
diagonals :: Style
diagonals = StyleName -> [Text] -> Style
SItem StyleName
Diagonals []
striped :: Style
striped :: Style
striped = StyleName -> [Text] -> Style
SItem StyleName
Striped []
wedged :: Style
wedged :: Style
wedged = StyleName -> [Text] -> Style
SItem StyleName
Wedged []
tapered :: Style
tapered :: Style
tapered = StyleName -> [Text] -> Style
SItem StyleName
Tapered []
radial :: Style
radial :: Style
radial = StyleName -> [Text] -> Style
SItem StyleName
Radial []
penWidth :: Double -> Attribute
penWidth :: Double -> Attribute
penWidth = Double -> Attribute
PenWidth
gradientAngle :: Int -> Attribute
gradientAngle :: Int -> Attribute
gradientAngle = Int -> Attribute
GradientAngle
shape :: Shape -> Attribute
shape :: Shape -> Attribute
shape = Shape -> Attribute
Shape
type Arrow = ArrowType
arrowTo :: Arrow -> Attribute
arrowTo :: Arrow -> Attribute
arrowTo = Arrow -> Attribute
ArrowHead
arrowFrom :: Arrow -> Attribute
arrowFrom :: Arrow -> Attribute
arrowFrom = Arrow -> Attribute
ArrowTail
edgeEnds :: DirType -> Attribute
edgeEnds :: DirType -> Attribute
edgeEnds = DirType -> Attribute
Dir
box, crow, diamond, dotArrow, inv, noArrow, tee, vee :: Arrow
oDot, invDot, invODot, oBox, oDiamond :: Arrow
inv :: Arrow
inv = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
Inv)]
dotArrow :: Arrow
dotArrow = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
DotArrow)]
invDot :: Arrow
invDot = [(ArrowModifier, ArrowShape)] -> Arrow
AType [ (ArrowModifier
noMods, ArrowShape
Inv)
, (ArrowModifier
noMods, ArrowShape
DotArrow)]
oDot :: Arrow
oDot = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowFill -> ArrowSide -> ArrowModifier
ArrMod ArrowFill
OpenArrow ArrowSide
BothSides, ArrowShape
DotArrow)]
invODot :: Arrow
invODot = [(ArrowModifier, ArrowShape)] -> Arrow
AType [ (ArrowModifier
noMods, ArrowShape
Inv)
, (ArrowModifier
openMod, ArrowShape
DotArrow)]
noArrow :: Arrow
noArrow = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
NoArrow)]
tee :: Arrow
tee = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
Tee)]
diamond :: Arrow
diamond = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
Diamond)]
oDiamond :: Arrow
oDiamond = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
openMod, ArrowShape
Diamond)]
crow :: Arrow
crow = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
Crow)]
box :: Arrow
box = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
Box)]
oBox :: Arrow
oBox = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
openMod, ArrowShape
Box)]
vee :: Arrow
vee = [(ArrowModifier, ArrowShape)] -> Arrow
AType [(ArrowModifier
noMods, ArrowShape
Vee)]
ordering :: Order -> Attribute
ordering :: Order -> Attribute
ordering = Order -> Attribute
Ordering
rank :: RankType -> Attribute
rank :: RankType -> Attribute
rank = RankType -> Attribute
Rank