uni-graphs-2.2.1.1: Graphs

Safe HaskellNone
LanguageHaskell98

Graphs.GraphDisp

Contents

Description

In UniForM we need ways of displaying typed directed graphs. In the original UniForM, it was only possible to use the DaVinci encapsulation for displaying directed graphs. While this is very good, in the new UniForM it is intended to factor out this encapsulation so that it will not be too difficult to replace DaVinci by other graph-drawing package (or variants of DaVinci) for particular graphs. Example alternatives that might be considered: (1) some sort of text-only interface. (2) Windows-style displaying of a tree structure using clickable folders. In this module we present the classes that any such "graph-drawing package" is supposed to implement.

This module is in two parts.

The first part contains the "user-friendly" versions of the functions. For these, it is assumed (as will usually be the case) that there is only one node/nodeType/arc/arcType around for a particular graph. The whole lot is indexed by the GraphAll, which contains ALL the functionality required for accessing the graphs (apart from configuration options). For example, the only daVinci-specific thing you should need to use to write a program which calls daVinci will be the daVinciSort variable.

The second part contains the "user-hateful" versions. All the user-hateful functions have names ending in "Prim". Graph display implementations only have to implement the user-hateful versions. The user-hateful versions should only be of interest to other people if the graph display provides more than one implementation of the NodeClass, NodeTypeClass (or whatever) implementation. One disadvantage to the user of using the user-hateful versions of the functions is that because of all the overloading, you have to put in lots of explicit types, or else get the most hideous type errors.

Configuring things like graph titles, shape of node boxes, menus, and so on should also be implemented, where possible, by graph display interfaces. The various options are documented in GraphConfigure.hs. They should be applied using the Computation.HasConfig interface.

The types which are supposed in various combinations to be instances of the classes are as follows:

graph. This corresponds to one graph display. graphConfig. This is configuration information for a graph. This might be a window title or size for example. graphParms. This is a collection of graphConfig's used to construct a graph.

Nodes and arcs carry values. Thus all the following carry a type parameter. But, for ease of implementation with, for example, DaVinci, the type parameter is required to be an instance of Typeable.

  • node. A value of this type is an actual node in a graph. (Will be an instance of Typeable via Typeable.)
  • nodeType. Nodes are created with a particular UniForM "type" which is a Haskell value of type nodetype. In fact a graph might conceivably have multiply Haskell types corresponding to node and nodeType, meaning that nodes, or their UniForM types, will be distinguished additionally by the Haskell type system.
  • nodeTypeConfig. Configuration information for a nodeType. This might include how a node with this type is to be displayed graphically. This also includes information on what to do when the node is clicked.
  • nodeTypeParms. A collection of nodeTypeConfig's used to construct a nodeType

Similar constructions for arcs . . . arc. arcType. arcTypeConfig. arcTypeParms.

There are quite a lot of classes. This is partly because of the need to have a separate class for each subset of the type variables which is actually used in the type of a function.

This file is fairly repetitive, mainly because of the need to repeat the configuration machinery over and over again.

The functionality provided in this file is inspired by that provided by DaVinci. However we extend it by allowing nodes to have labels.

This file should be read in conjunction with GraphConfigure, which contains various configuration options to be used for graph objects.

Additional Notes ----------------

  1. At the end of a program using a GraphDisp instance, shutdown should be called. For example, in the case of the DaVinci instance this is required to get rid of the DaVinci and HTk processes.
  2. It is more cumbersome writing the Graph Editor than I would like because the menu code doesn't give you direct access to the node or arc type. Unfortunately doing this would make the classes in this file even more complicated than they are now.
Synopsis

User-Friendly Interface.

You should not need any more than this for drawing graphs.

newtype GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms Source #

The graph implementation will provide a value of this type to get you started. For example, for daVinci this is called daVinciSort. However you then need to use it as an argument to newGraph to construct the actual graph.

Constructors

Graph graph 
Instances
Eq graph => Eq (Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms) Source # 
Instance details

Defined in Graphs.GraphDisp

Methods

(==) :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Bool #

(/=) :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Bool #

Ord graph => Ord (Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms) Source # 
Instance details

Defined in Graphs.GraphDisp

Methods

compare :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Ordering #

(<) :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Bool #

(<=) :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Bool #

(>) :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Bool #

(>=) :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Bool #

max :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms #

min :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms #

GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => Destroyable (Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms) Source # 
Instance details

Defined in Graphs.GraphDisp

Methods

destroy :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> IO () #

GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => Destructible (Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms) Source # 
Instance details

Defined in Graphs.GraphDisp

Methods

destroyed :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Event () #

GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => HasDelayer (Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms) Source # 
Instance details

Defined in Graphs.GraphDisp

Methods

toDelayer :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> Delayer #

newGraph :: GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> graphParms -> IO (Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms) Source #

Construct a new graph. The input value will be something like DaVinciGraph's value daVinciSort; the resulting graph will be returned.

redraw :: GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> IO () Source #

Redraw the graph. This is needed when you want to show updates.

getMultipleNodes :: GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> (Event (WrappedNode node) -> IO a) -> IO a Source #

Take over all interaction on the graph, and perform the given action, supplying it with an event which is activated when the user double-clicks a node. This is helpful when you need an interaction selecting several nodes.

class GraphParms graphParms where Source #

Minimal complete definition

emptyGraphParms

Methods

emptyGraphParms :: graphParms Source #

newNode :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> nodeType value -> value -> IO (node value) Source #

construct a new node.

setNodeType :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> node value -> nodeType value -> IO () Source #

set a node's type

deleteNode :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> node value -> IO () Source #

delete a node

setNodeFocus :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> node value -> IO () Source #

getNodeValue :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> node value -> IO value Source #

get the value associated with a node

setNodeValue :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> node value -> value -> IO () Source #

set the value associated with a node.

newNodeType :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> nodeTypeParms value -> IO (nodeType value) Source #

construct a node type.

class NodeTypeParms nodeTypeParms where Source #

Minimal complete definition

emptyNodeTypeParms, coMapNodeTypeParms

Methods

emptyNodeTypeParms :: Typeable value => nodeTypeParms value Source #

coMapNodeTypeParms :: (Typeable value1, Typeable value2) => (value2 -> value1) -> nodeTypeParms value1 -> nodeTypeParms value2 Source #

newArc :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value, Typeable nodeFromValue, Typeable nodeToValue) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> arcType value -> value -> node nodeFromValue -> node nodeToValue -> IO (arc value) Source #

construct a new arc.

data WrappedNode node Source #

Constructors

Typeable value => WrappedNode (node value) 

newArcListDrawer :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value, Typeable nodeFromValue) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> node nodeFromValue -> ListDrawer (arcType value, value, WrappedNode node) (arc value) Source #

Given a node, construct a ListDrawer which can be used as a way of drawing ordered sets of out-arcs from that node. (NB. At the moment daVinci does not do this properly, but that is daVinci's fault, not mine.)

deleteArc :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> arc value -> IO () Source #

delete an arc

setArcValue :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> arc value -> value -> IO () Source #

set the value associated with an arc

setArcType :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> arc value -> arcType value -> IO () Source #

getArcValue :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> arc value -> IO value Source #

get the value associated with an arc

newArcType :: (GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms, Typeable value) => Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms -> arcTypeParms value -> IO (arcType value) Source #

create a new arc type

class ArcTypeParms arcTypeParms where Source #

Methods

emptyArcTypeParms :: Typeable value => arcTypeParms value Source #

invisibleArcTypeParms :: Typeable value => arcTypeParms value Source #

coMapArcTypeParms :: (Typeable value1, Typeable value2) => (value2 -> value1) -> arcTypeParms value1 -> arcTypeParms value2 Source #

class Eq1 takesParm where Source #

Minimal complete definition

eq1

Methods

eq1 :: takesParm value1 -> takesParm value1 -> Bool Source #

class Eq1 takesParm => Ord1 takesParm where Source #

Minimal complete definition

compare1

Methods

compare1 :: takesParm value1 -> takesParm value1 -> Ordering Source #

User-Hateful Interface

This is only needed by people wanting to implement new implementations of the interface.

class (GraphClass graph, NewGraph graph graphParms, GraphParms graphParms, NewNode graph node nodeType, DeleteNode graph node, SetNodeFocus graph node, NodeClass node, Typeable node, NodeTypeClass nodeType, NewNodeType graph nodeType nodeTypeParms, NodeTypeParms nodeTypeParms, NewArc graph node node arc arcType, SetArcType graph arc arcType, DeleteArc graph arc, ArcClass arc, Typeable arc, ArcTypeClass arcType, NewArcType graph arcType arcTypeParms) => GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms where Source #

Minimal complete definition

displaySort

Methods

displaySort :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms Source #

Instances
(GraphClass graph, NewGraph graph graphParms, GraphParms graphParms, NewNode graph node nodeType, DeleteNode graph node, SetNodeFocus graph node, NodeClass node, NodeTypeClass nodeType, NewNodeType graph nodeType nodeTypeParms, NodeTypeParms nodeTypeParms, NewArc graph node node arc arcType, SetArcType graph arc arcType, DeleteArc graph arc, ArcClass arc, ArcTypeClass arcType, NewArcType graph arcType arcTypeParms) => GraphAll graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms Source # 
Instance details

Defined in Graphs.GraphDisp

Methods

displaySort :: Graph graph graphParms node nodeType nodeTypeParms arc arcType arcTypeParms Source #

class (Destructible graph, Ord graph, Typeable graph, HasDelayer graph) => GraphClass graph where Source #

Minimal complete definition

redrawPrim

Methods

redrawPrim :: graph -> IO () Source #

class (GraphClass graph, GraphParms graphParms) => NewGraph graph graphParms where Source #

Minimal complete definition

newGraphPrim

Methods

newGraphPrim :: graphParms -> IO graph Source #

class GraphConfig graphConfig Source #

Instances
GraphConfig Delayer Source #

Allows the user to specify a Delayer. This will postpone redrawing on the graph.

Instance details

Defined in Graphs.GraphConfigure

GraphConfig ActionWrapper Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig Orientation Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig FileMenuAct Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig AllowClose Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig AllowDragging Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig SurveyView Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig OptimiseLayout Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig GraphGesture Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig GraphTitle Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig GlobalMenu Source # 
Instance details

Defined in Graphs.GraphConfigure

GraphConfig (SimpleSource GraphTitle) Source # 
Instance details

Defined in Graphs.GraphConfigure

class (GraphClass graph, NodeClass node, NodeTypeClass nodeType) => NewNode graph node nodeType where Source #

Minimal complete definition

newNodePrim, setNodeTypePrim

Methods

newNodePrim :: Typeable value => graph -> nodeType value -> value -> IO (node value) Source #

setNodeTypePrim :: Typeable value => graph -> node value -> nodeType value -> IO () Source #

class (GraphClass graph, NodeClass node) => DeleteNode graph node where Source #

Methods

deleteNodePrim :: Typeable value => graph -> node value -> IO () Source #

getNodeValuePrim :: Typeable value => graph -> node value -> IO value Source #

setNodeValuePrim :: Typeable value => graph -> node value -> value -> IO () Source #

getMultipleNodesPrim :: graph -> (Event (WrappedNode node) -> IO a) -> IO a Source #

class (GraphClass graph, NodeClass node) => SetNodeFocus graph node where Source #

Minimal complete definition

setNodeFocusPrim

Methods

setNodeFocusPrim :: Typeable value => graph -> node value -> IO () Source #

class (Typeable node, Ord1 node) => NodeClass node Source #

class Typeable (nodeType :: * -> *) => NodeTypeClass nodeType Source #

class (GraphClass graph, NodeTypeClass nodeType, NodeTypeParms nodeTypeParms) => NewNodeType graph nodeType nodeTypeParms where Source #

Minimal complete definition

newNodeTypePrim

Methods

newNodeTypePrim :: Typeable value => graph -> nodeTypeParms value -> IO (nodeType value) Source #

class Kind1 nodeTypeConfig => NodeTypeConfig nodeTypeConfig Source #

class (GraphClass graph, NodeClass nodeFrom, NodeClass nodeTo, ArcClass arc, ArcTypeClass arcType) => NewArc graph nodeFrom nodeTo arc arcType where Source #

Minimal complete definition

newArcPrim, newArcListDrawerPrim

Methods

newArcPrim :: (Typeable value, Typeable nodeFromValue, Typeable nodeToValue) => graph -> arcType value -> value -> nodeFrom nodeFromValue -> nodeTo nodeToValue -> IO (arc value) Source #

newArcListDrawerPrim :: (Typeable value, Typeable nodeFromValue) => graph -> nodeFrom nodeFromValue -> ListDrawer (arcType value, value, WrappedNode nodeTo) (arc value) Source #

class (ArcClass arc, ArcTypeClass arcType) => SetArcType graph arc arcType where Source #

Minimal complete definition

setArcTypePrim

Methods

setArcTypePrim :: Typeable value => graph -> arc value -> arcType value -> IO () Source #

class (GraphClass graph, ArcClass arc) => DeleteArc graph arc where Source #

Minimal complete definition

deleteArcPrim, setArcValuePrim, getArcValuePrim

Methods

deleteArcPrim :: Typeable value => graph -> arc value -> IO () Source #

setArcValuePrim :: Typeable value => graph -> arc value -> value -> IO () Source #

getArcValuePrim :: Typeable value => graph -> arc value -> IO value Source #

class (Typeable arc, Ord1 arc) => ArcClass arc Source #

class (Typeable arcType, Ord1 arcType) => ArcTypeClass arcType where Source #

Minimal complete definition

invisibleArcType

Methods

invisibleArcType :: Typeable value => arcType value Source #

class (GraphClass graph, ArcTypeClass arcType, ArcTypeParms arcTypeParms) => NewArcType graph arcType arcTypeParms where Source #

Minimal complete definition

newArcTypePrim

Methods

newArcTypePrim :: Typeable value => graph -> arcTypeParms value -> IO (arcType value) Source #

class Kind1 arcTypeConfig => ArcTypeConfig arcTypeConfig Source #

Instances
ArcTypeConfig Head Source # 
Instance details

Defined in Graphs.GraphConfigure

ArcTypeConfig EdgeDir Source # 
Instance details

Defined in Graphs.GraphConfigure

ArcTypeConfig EdgePattern Source # 
Instance details

Defined in Graphs.GraphConfigure

ArcTypeConfig Color Source # 
Instance details

Defined in Graphs.GraphConfigure

ArcTypeConfig DoubleClickAction Source # 
Instance details

Defined in Graphs.GraphConfigure

ArcTypeConfig ValueTitle Source # 
Instance details

Defined in Graphs.GraphConfigure

ArcTypeConfig LocalMenu Source # 
Instance details

Defined in Graphs.GraphConfigure