Package COM.INFORMATIMAGO.COMMON-LISP.PICTURE.TREE-TO-ASCII

This package draws a tree onto an ASCII-ART picture
The tree drawn is a list whose car is the node displayed, and
whose cdr is the list of children.


License:

    AGPL3

    Copyright Pascal J. Bourguignon 2002 - 2012

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.
    If not, see <http://www.gnu.org/licenses/>


(tree-decorate tree make-decoration)
function
DO:      Converts the list based tree to a decorated tree.
         The building of the decoration is done by the make-decoration
         function.
RETURN:  The decorated tree.
(tree-to-ascii tlee &key boxed format-fun background to-length from-length base)
function
tlee:        is a list-based tree, whose car is a "node",
             and whose cdr is the list of children.
boxed:       t if boxes should be drawn around the nodes.
format-fun:  a function taking a node (one of the car's) and
             returning a string to be displayed as the node.
             Defaults merely use (format nil "~S" node).
background:  is a character used as background. Default: space.
DO:          Draw the tree onto an ASCII-art picture.
RETURNS:     The string containing the ASCII-ART tree.

EXAMPLE:     (tree-to-ascii '(if (= a b) (decf b a) (decf a b)))
             -->
            "          +--a
                 +--=--+
                 |     +--b
                 |
                 |        +--b
             if--+--decf--+
                 |        +--a
                 |
                 |        +--a
                 +--decf--+
                          +--b
             "
(tree-to-ascii-draw-to-pict tree pict left bottom &key boxed to-length from-length)
function
DO:      Draw the decorated TREE into the PICT.