1 CAPI Reference Entries

graph-pane

Class

Summary

A graph pane is a pane that displays a hierarchy of items in a graph.

Superclasses

simple-pinboard-layout

choice

x-y-adjustable-layout

Slots

roots
The roots of the graph.

children-function

Returns the children of a node.

layout-function

A function to layout the nodes.

node-pinboard-class

The class of pane to represent nodes.

edge-pinboard-class

The class of pane to represent edges.

node-pane-function

A function to return a pane for each node.

Accessors

graph-pane-roots

Description

A graph pane calculates the graph by calling thechildren-function on each of its roots, and then calling it again on each of the children recursively until it runs out of children. Thechildren-function gets called with a node of the graph and should return a list of the children of that node.

Thelayout-function tells the graph pane how to lay out its children. It can take two values:

:left-right
Lay the graph out from the left to the right.

:top-down
Lay the graph out from the top down.

When a graph pane wants to display nodes and edges, it creates instances ofnode-pinboard-class andedge-pinboard-class which default toitem-pinboard-object andline-pinboard-object respectively. These classes must be subclasses ofsimple-pane orpinboard-object, and there are some examples of the use of these keywords below.

Thenode-pane-function is called to create a node for each pane, and by default it creates an instance ofnode-pinboard-class. It gets passed the graph pane and the node, and should return an instance ofsimple-pane orpinboard-object.

Examples

(defun node-children (node)
  (when (< node 16)
        (list (* node 2)
              (1+ (* node 2)))))

(setq graph (capi:contain (make-instance 'capi:graph-pane :roots '(1) :children-function 'node-children) :best-width 300 :best-height 400))

(setf (capi:graph-pane-roots graph) '(2 6))

(capi:contain (make-instance 'capi:graph-pane :roots '(1) :children-function 'node-children :layout-function :top-down) :best-width 300 :best-height 400)

(capi:contain (make-instance 'capi:graph-pane :roots '(1) :children-function 'node-children :layout-function :top-down :x-adjust :left) :best-width 300 :best-height 400)

This example demonstrates a different style of graph output with right-angle edges and parent nodes being adjusted to the top instead of the center.

(capi:contain (make-instance
               'capi:graph-pane
               :roots '(1)
               :children-function 'node-children
               :y-adjust :top
               :edge-pinboard-class
                 'capi:right-angle-line-pinboard-object)
               :best-width 300
               :best-height 400)

This example demonstrates the use of:node-pinboard-class to specify that the nodes are drawn as push buttons.

(capi:contain (make-instance
               'capi:graph-pane
               :roots '(1)
               :children-function 'node-children
               :node-pinboard-class
                  'capi:push-button)
               :best-width 300
               :best-height 400)

Example File

capi/elements/graph-pane.lisp

See Also

item-pinboard-object
line-pinboard-object


CAPI Reference Manual, Liquid Common Lisp Version 5.0 - 3 OCT 1997

Generated with Harlequin WebMaker