Graph Editor

This is a graph editor widget implemented in PLT-Scheme.

Example screenshot and example code

Documentation of the objects

graph-editor%

This is the main object containing the full graph.
(new graph-editor% (callback _) (font _))
This object is derived from a canvas% object. Public methods: Overwritten events: Callback function:
The callback function has two arguments. The first argument is a symbol denoting the action that happened in the graph window and the second argument is some data, a symbol, a list or an object depending on the action.
ActionDataDescription
select node% object called when the user clicks on a node
deselect node% object called when the node is deselected
before-line-add (src dst) ccalled before a line is added between the source and the destination, if the return value of the callback function is false the line is not allowed and not added
after-line-add line% object called after the line is added
before-line-del (src dst) called before a line is deleted between the source and the destination, if the return value of the callback function is false the line is not deleted
after-line-del #f called after the line is deleted
before-node-add string called before a node is added, if the return value of the callback function is false the node cannot be added
after-node-add node% object called after the node is added
before-node-del node% object called before the node is deleted, if the return value of the callback function is false the node is not deleted
after-node-del id called after the node has been deleted, the deleted node had the id
before-clear #f called before the full network is deleted, if the callback function returns #f then nothing happens
after-clear #f called after the network is initialised

node%

This object represents a node in the graph.
(new node% (id _) (name _) (x _) (y _) (editor _) (style _))
This object is derived from object%. It can store some user specified data as well. The node does not know anything about this data, the user must handle it! Public methods:

tab%

This object represents an input or output tab of a node.
(new tab% (type _) (x _) (y _) (node _) (editor _))
This object is derived from object%. The lines in the graph will be connected to this object Public methods:

line%

This object represents a line between two nodes.
(new line% (source _) (target _) (editor _))
This object is derived from object%. Public methods:
Back to MrEd Designer
Back to PLT programs