Next Prev Up Top Contents Index

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 keyword denoting how 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 the children-function on each of its roots, and then calling it again on each of the children recursively until it runs out of children. The children-function gets called with a node of the graph and should return a list of the children of that node.

The layout-function tells the graph pane how to lay out its children. It can take these values:

:left-right

Lay the graph out from the left to the right.

:top-down

Lay the graph out from the top down.

:right-left

Lay the graph out from the right to the left.

:bottom-up

Lay the graph out from the bottom up.

 

When a graph pane wants to display nodes and edges, it creates instances of node-pinboard-class and edge-pinboard-class which default to item-pinboard-object and line-pinboard-object respectively. These classes must be subclasses of simple-pane or pinboard-object , and there are some examples of the use of these keywords below.

The node-pane-function is called to create a node for each pane, and by default it creates an instance of node-pinboard-class . It gets passed the graph pane and the node, and should return an instance of simple-pane or pinboard-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
             :process nil))
(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)
See also

item-pinboard-object
line-pinboard-object


LispWorks CAPI Reference Manual - 14 Dec 2001

Next Prev Up Top Contents Index