Mondrian: A Guide to the Demonstration Software

Henry Lieberman

November 1993

About this document

This document is a guide to the distribution package for Mondrian, a graphical editor whose interface can be programmed by the end user through programming by example. Mondrian was written by Henry Lieberman of the Visible Language Workshop of the MIT Media Laboratory. It is described in a companion paper, Mondrian: A Teachable Graphical Editor, by the author. Familiarity with that paper is assumed. This document describes the installation procedure for the software, instructions for running a demonstration session and some other useful information for recipients of the software.

Address

Please address comments and questions to:

Henry Lieberman

Visible Language Workshop

Media Laboratory

Massachusetts Institute of Technology

20 Ames St.

Cambridge, Mass 02139 USA

Telephone: (1-617) 253-0315;

Fax: (1-617) 258-6264

Electronic Mail lieber@media.mit.edu

The Mondrian demonstration software package

The software package contains:

* The Mondrian demonstration software, as a Macintosh "application"

* Some Macintosh "resource" files which must be loaded for the application when it starts up.

* Optionally, the Lisp source code for the Mondrian application.

* Written documentation, inlcuding this guide and the article describing Mondrian referenced above.

Requirements

Mondrian is written in Macintosh Common Lisp [version 2.0.1 as of this writing], making intensive use of the Common Lisp Object System. It normally requires any Macintosh II series computer, a color screen, and a memory allocation for the application of at least 6, and preferably 8 or more megabytes. The complete software package occupies approximately 5 MB, but the application only, excluding source code, may take as little as 2.5 MB. System 6.0.7 or later is recommended. It is compatible with System 7, and virtual memory may be used, though a mimimum of 4 MB of Ram memory is required. It may also run on black-and-white screens, such as Powerbook laptops, but screen displays may not look correct.

Legal Information

Mondrian is Copyright 1991, 1993 by the Massachusetts Institute of Technology Media Laboratory. Copying, distribution and other use may require permission. Contact the Community and Sponsor Relations Office of the MIT Media Lab for details.

Mondrian package folder

Using Mondrian

The folder with the software package will contain

* The Mondrian Application.

* The Henry folder, containing resource files needed by the Mondrian application, and [optionally] the Lisp source code for Mondrian and its support systems.

* [Optionally] A system folder. If you have problems with running your own sytem folder, try this one.

* [Optionally] The Lisp Folder containing the Macintosh Common Lisp system. This is not necessary to run the Mondrian application, but will be if you would like to further modify or extend Mondrian.

Launching Mondrian

Double click on the Mondrian Application icon. You should see something like the following window appear [but don't worry if it differs slightly from the illustration].

Mondrian at startup

The Mondrian window appears.

Rectangle

Click on the Rectangle domino. The before picture of the Rectangle domino represents a blank screen, the after picture a screen containing a rectangle.

Rectangle domino

Click for the upper left corner, then drag to the lower right corner, to draw a rectangle.

Drawing a Rectangle

Move

Click on the Move domino. Then click on the Rectangle you just drew and drag it around.

Move domino

Delete

Click on Delete, then select a rectangle to be deleted.

Delete domino

Select

Click on the Select domino, then on a rectangle. This highlights the rectangle, which can be used an argument to another operation. Shift-Click may be used to select multiple objects.

Select domino

Group

Make several rectangles, Shift-Click on them, then click on the Group domino. Selecting Group when a single group of objects is already selected is equivalent to UnGroup.

Group domino

Color

Clicking this domino brings up the Macintosh Color Wheel. Notice that the Rectangle and Color dominoes change color after a color selection to reflect the new color chosen. If an object is selected when the Color domino is clicked, the color of that object will be changed to the color selected.

Mondrian also has several other operations that may be loaded dynamically. These will be discussed as they are needed for the example demonstrations below.

Mondrian Menu

Contains a command to turn on [or off] the Speech Output feature. See below.

Mondrian Menu

You may also see other Mondrian options on this menu.

Layouts Menu

You may also see other images on this menu.

Teaching Mondrian a New Command

The Arch example

We will go through the Arch example described in the Mondrian article.

Start by drawing a large rectangle. Choose the Color domino to select a constrasting color for subsequent drawing.

Invoking New Command

Select the rectangle. Then, select the New Command domino. This makes the selected rectangle the argument to the New Command operation.

You are then prompted for the name of the new operation. Type "Arch".

The Arch domino

A newly created Arch domino appears. The "before" part reflects the current state of the screen, while the "after" part is a question mark, indicating that it will be filled in later. The New Command domino also displays a question mark.

Drawing the arch

Now, begin drawing the Arch. Inscribe the arch in the background rectangle, as shown. Draw the two vertical columns and the spanning horizontal rectangle. You need not line up the corners precisely, there is some tolerance built in.

Steps in drawing the Arch

When the three rectangles that compose the Arch are complete, you may Delete the original background rectangle.

We now have the three rectangles, but we really would like the arch as a single object. To get this, Shift-Click on the three rectangles, and choose the Group command.

Saving the Arch definition

Click the New Command domino again to signal the end of the definition. A dialog box asks you if you want to save the definition.

If you do not, the definition will be removed and its domino will disappear. If you do save the definition, the after panel of the Arch domino will be filled in with the final state of the screen.

Arch domino

Storyboard for the Arch

To see the "definition" of the Arch operation, Shift-Click on the Arch domino and its storyboard will appear, a cartoon consisting of successive screen states during the definition of the example arch.

Each frame is labeled with the name of the operation chosen. A tiny box in each frame indicates the position of the domino that was selected.

Speech output

Mondrian has a natural language synthesis feature that uses the Gala Tea speech synthesizer. Future versions for the AV Macintoshes will use Plain Talk speech generation and recognition. Mondrian will narrate its interpretation of your actions as you perform them, to give you feedback on how the system is interpreting your actions.

In order to use the speech feature, your Macintosh must have been started with the following in the Extensions folder of the System Folder [these are available from Apple]:

* Speech Manager

* GTEngl

* A voice file, GTEnglFem24 is recommended

Try the Arch example once more. First, make sure that the volume is turned up from the Sound control panel. Just before you invoke the New Command operation and the Arch icon appears, choose Turn on Speech from the Mondrian menu. The machine should now say "Speech is now on".

Lisp code generated

The Lisp program code generated by Mondrian for functions defined by the New Command operation can be examined. Calling the function (Last-Definition) in the Listener window displays the code for the last user function defined. The function call (Definition "Arch") would find the definition of the domino for Arch .

Below the example of code for the Arch example presented earlier [Actual code may slightly differ]:

_____________________________________________________________

(DEFUN ARCH (INTERACTOR SELECTION)

(RECTANGLE-COMMAND (LEFT-TOP (NTH 0 SELECTION))

(POINT-ON-OBJECT (NTH 0 SELECTION)

12/95 1)

INTERACTOR

'RECTANGLE-5)

(RECTANGLE-COMMAND (LEFT-TOP (FIND-OBJECT-NAMED

INTERACTOR

'RECTANGLE-5))

(POINT-ON-OBJECT (NTH 0 SELECTION)

93/95 8/51)

INTERACTOR

'RECTANGLE-6)

(RECTANGLE-COMMAND (POINT-ON-OBJECT (FIND-OBJECT-NAMED

INTERACTOR

'RECTANGLE-6)

76/91

1/14)

(RIGHT-BOTTOM (NTH 0 SELECTION))

INTERACTOR

'RECTANGLE-7)

(REMOVE-OBJECT INTERACTOR (NTH 0 SELECTION))

(GROUP-COMMAND (LIST (FIND-OBJECT-NAMED INTERACTOR

'RECTANGLE-5)

(FIND-OBJECT-NAMED INTERACTOR

'RECTANGLE-6)

(FIND-OBJECT-NAMED INTERACTOR 'RECTANGLE-7))

INTERACTOR

'GROUP-8))

_____________________________________________________________

Understanding the code

Mondrian creates an ordinary Lisp Defun, which takes two arguments: Interactor is the object that represents the graphical editor itself. This argument is passed along to all commands as a way to access the edtior's state. Selection is the list of arguments given to the command; that is all the objects that are selected in the graphical editor when the domino icon representing that command is invoked. Thus (Nth 0 Selection) represents the first argument.

Each of the topmost-level calls, such as those to the function Rectangle-Command, represents an action routine invoked by one of Mondrian's iconic commands. The arguments are expressed in terms of the relations inferred by Mondrian, such as Left-Top. Point-On-Object expresses a point relative to an object using the proportions of its X and Y coordinates; (Point-On-Object ... 1/2 1/3) means an point half the way across and a third of the way down on the object.

Names

The last argument to each action routine is often a generated name, such as Rectangle-7 or Group-8. These are used by the code to refer to the object that is the result of the command. You can see this in the last Group command, which refers to the three previously created rectangles using Find-Object-Named.

Notes about Mondrian's implementation

These notes about the implementation of Mondrian are intended to aid those who are trying to look at the source code with a view towards extending or modifying the code. They are not necessary for simply running the demonstration as explained above.

The implementation of Mondrian roughly consists of three parts.

Suit

* The first is Suit, a user-interface management system. Suit provides a substrate for defining iconic and graphical user interfaces within Macintosh Common Lisp's window system. It provides CLOS objects for graphical objects that can be manipulated on the screen, clicking and dragging objects, a two-and-a-half dimensional screen model for overlapping graphical objects, a structure for iconc commands and arguments, and other services useful for implementing interactive graphical interfaces.

Suit is independent of the rest of Mondrian, and appears in its own folder.

Mondrian proper

* The second is the Mondrian graphical editor, whose files are contained in the Mondrian folder. The major portion appears in the file Mondrian-Editor.

* The third is Mondrian's learning facilities, mostly in the file New-Command in the Mondrian folder. The file Narrate holds the speech output facility.

EzWin Suit is the successor to EzWin, a user-interface system described in the article [Lieberman 85].

Initialization files

The files in the Init directory contain extensions to the Lisp environment, including setting flags for more informative debugging, automatic completion of symbol names typed, and other features. These are not strictly necessary for Mondrian's operation and may be turned off without harm. One feature that is not standard is that evaluation of Lisp forms in the Listener is triggered by the Enter key and not the Return key. This is to allow typing multi-line forms in the Listener. This may be changed without affecting Mondrian.

The file Clos-Extensions in the Init directory defines a simpler syntax, Defob, which replaces CLOS's Defclass and automatically defines accesor functions. It also defines an extension that causes objects to print out with their components rather than with a unique-ID index.

System objects

The files are organized around a kind of CLOS object used to represent a software package which is composed of multiple files. These objects are of class System, defined in System.Lisp in the Init Folder. [These are similar to the DefSystem that appear in several other Lisp implementations, but make more extensive use of CLOS objects.]

Each System object has instance variables to hold names of source code files, pathnames, and other information. There are operations to compile, load, edit, and perform other operations on System objects.

CLOS generally requires that the definition of an object be loaded before it is used, for example, to define a method. The consequence is that object definitions for a single system should be contained in a single file, the Defs- file, which needs to be loaded before source code referencing these objects is loaded or compiled. The methods on the System objects usually take care of this.

Mondrian and Suit each have their own System objects, defined in the files Mondrian-System and Suit-System. You will find Defs files for Mondrian-Defs and Suit-Defs, in their respective folders.

Application, Interactor objects

Applications written with Suit are based on Interactor objects. Minimally, an Interactor keeps a list of Visible objects which it displays, and which can be selected with the mouse. An Interactor may also elect to include a list of Sensitive objects which can be different from the list of Visible objects. An Application object also has a CLOS object that represents a Macintosh window used for display and interaction.

The name "Interactor" was chosen to suggest both "interaction", and also "actor". As in the "actor" systems of Carl Hewitt, an interactor represents a fundamental component out of which everything else is built.

Graphic objects

Objects are defined to represent the basic graphic elements: points, lines, circles, displayable text, images, etc. This code is quite straightforward. Many geometric relations are defined on these objects.

Some objects, like points and colors, are usually "encoded" by Macintosh Lisp into numbers, presumably for "efficiency". This is contrary to the object-oriented paradigm, and here I represent a point by a CLOS object which has its coordinates as instance variables. Rectangle objects hold their Top-Left and Bottom-Right corners., as Point objects.

Objects of class Graphic represent "Platonic" shapes such as points and rectangles. Those of class Geometric can, in addition, have concrete displayable properties such as color or line thickness.

With- macros

Drawing code that uses properties such as color is usually surrounded by a macro such as With-Color that binds the respective property for the duration of the code. These macros are defined in Suit-Defs.

Graphics output protocol

The highest level protocol for display of graphical objects consists of two functions, Appear and Disappear, that take two arguments -- the object to to appear [or to disappear] and the Interactor on which to do the display.

Appear and Disappear take into account the two-and-a-half dimensionality of the display. Objects underneath a Disappeared object will be redisplayed. The algorithm for doing this is simple and straightforward, but perhaps more efficient ones could be found. Appear and Disappear may be changed or redefined in subclasses to implement more sophisticated redisplay algorithms. Overlap testing is done by using bounding boxes, but again, more sophisticated algorithms may be subsituted, by redefining the function Intersect?.

Appear and Disappear are defined in terms of lower-level functions Display and Erase, which do not take into account two-and-a-half dimensionality. Erasing an object will erase any overlapping portions of objects underneath it. Display and Erase with an Interactor as second argument are defined in terms of still lower level functions Display and Erase that take a Macintosh window as a second argument and do display directly to the screen using Macintosh Common Lisp Quickdraw functions.

Because of CLOS's multi-method facility, the output methods may be specialized either on the graphic object argument, or on the Interactor argument. This gives both the object being displayed, and also the containing application a chance to "get a word in" about how display is to occur. This feature is often exploited in applications built with Suit.

Input protocol

There is a two-level protocol for accepting input. The first is a function Activate which is called on the Interactor, and with a second agument of an object representing the Mouse-Gesture, including coordinates of the click. This tells the Interactor "something contained in you has been clicked on".

The second level is the function Touch, which tells an object "you have been clicked on", with the Interactor as second argument. Thus, Activate gives the Interactor a chance to determine what happens, usually forwarding to Touch, which gives the object itself a chance.

The function Hit? is used for determining what object has been clicked on. The default version dispatches Hit? linearly to each object on the Sensitive list. More efficient algorithms, such as Quad Trees, can be installed simply by replacing the Hit? function.

Mouse-Tracker objects

New interaction techniques that involve mouse clicking and dragging are implemented by Mouse-Tracker objects. There are Mouse-Tracker objects for rubber band rectangles, selection, and dragging. The importance of Mouse-Tracker objects is that they take the tight loop of reacting to each mouse movement out of the user's application code, and into the object, where it can be redefined or have additional protocol inserted.

Drag

Mouse-Tracker objects have a method for the Drag function, which contains the interactive loop which tracks cursor movement and button presses. Drag, by default, is built out of three sub-functions,

* Start-Tracking, called once at the start of tracking,

* Move-Tracker, called each time the cursor moves, with old and new positions, and

* Stop-Tracking, called when tracking ends.

Each of these can be redefined to affect the behavior of the tracker, or only the relevant ones, falling back on default behavior for the rest.

Move-Tracker, in turn is defined by

* Erase-Old-Tracker, and

* Draw-New-Tracker

which can be independently redefined.

Easel objects

Some more complicated kinds of Interactors are used for applications that have an iconic interface.

A Palette is a kind of Radio-Buttons interactor object that collects icons representing commands to be invoked in an interactive application. Individual graphic objects representing commands are known as Tools. Tools declare their argument lists and types of arguments. Each type of argument is a subclass of Argument, and contains a method for obtaining that kind of argument interactively from the user.

A Canvas is also a Radio-Buttons interactor that holds of list of graphical objects to be operated upon by the commands in the Palette. Graphical objects visible in the Canvas may be selected as arguments to the commands in the Palette.

Together, an interface containing a single Palette and a single Canvas is an Easel. Argument-Collector objects manage the interactive loop that selects a tool and its associated arguments, and invokes the command. This is like the "read-eval-print" loop of a Lisp interpreter.

Understanding how Suit works

A few simple test functions are included to demonstrate how Suit operates, in the file Test-Suit.

The Trivial-Application object is the simplest possible use. Test-Trivial-Application creates one of these, with a single rectangle object. Clicking on the rectangle or the background simply prints a message in the Listener. Observe how this is done simply by using two Touch methods.

Rectangle-Application is a bit more complicated. It allows you to draw rectangles by rubber-banding their dimensions. You can drag an already-existing rectangle to a new position. Again, it only requires two Touch methods to implement the application. These methods use Mouse-Tracker objects Rubber-Rectangle-Tracker and Drag-Tracker to do their work. The object returned by the tracker is added to the Visible list.

A more substantial example demonstrates an Interactor that can highlight selected objects, defined in the Highlighting file. Radio-Buttons is an Interactor that only permits one Highligted object at a time.

Tracing the various Suit functions or stepping through some of the definitions is a good way to become familiar with the sequence of operations that takes place in the course of a user interaction.

The Mondrian Editor

The file Mondrian-Editor defines an Easel that implements the Mondrian graphical editor. Each tool has an action routine, named after the name of the command. The inital set of domino icons is contained in a resource file named Mondrian Command Icon Resources . They are displayed using Pict-Resource-Tool objects.

Because the collection of arguments and invocation of commands is separated from the actual action performed by the command, all of the action routines can either be invoked by a user interaction or by a program generated by Mondrian.

The New Command Tool keeps a Command-History produced by the recording and generalization process, and a Snapshot-History which is used to record successive graphical states to produce the definition storyboards of recorded procedured.

Recording and Generalization

The file New-Command implements the New Command operation, including the recording of user actions and generalization and synthesis of programs.

The Remember- functions are crucial to this process. For every action performed, there is a Remember- function that yields Lisp code generalizing the particular action. Actions are in general recorded by Remeber-Action, and there are Remember- functions specialized to each kind of action.

Remember- functions for actions in turn call Remember- functions for their arguments. Remember- functions can take advantage of the object hierarchy and be specialized for each type of argument object. Significant-Point determines the relations noticed for a point object. This could be augmented with other relations if desired.

Remember- functions generally take an Environment argument, that records the association between graphical objects and generated code. This is necessary so that when an object is referred to, its intentional description is used, and not the accidental properties of the object, such as its absolute coordinates.

The function Definition-Cartoon draws the frames of the storyboard displayed when you shift-click on a user-defined domino icon.

Speech output

Speech output facilities appear in the file Narrate. The top level speech output function is named Narrate, and it has a group of Narrate- subroutines that handle various aspects of the process. Narration is driven off the generated Lisp code. Each piece of Lisp code has a template that generates an English sentence description. Thus Mondrian is actually "reading you the code".

Bibliography

Lieberman 85

There's More to Menu Systems Than Meets the Screen, ACM SigGraph Conference, San Francisco, 1985.

Lieberman 92

Dominos and Storyboards: Beyond Icons on Strings. IEEE Conference on Visual Languages, Seattle, September 1992.

(Presented as an invited keynote address)

Lieberman 92

Capturing Design Expertise Interactively by Example,

in East-West Conference on Human-Computer Interaction,

St. Petersburg, Russia, August 1992.

Lieberman 93

Graphical Annotation as a Visual Language for Specifying Generalization Relations, in IEEE Symposium on Visual Languages, Bergen, Norway, August 1993.

Lieberman 93

Mondrian: A Teachable Graphical Editor (demonstration), ACM InterCHI Conference, Amsterdam, p. 144, May 1993.

Cypher, et. al. 93

The following three articles appear in a book,

Watch What I Do: Programming by Demonstration

edited by Allen Cypher, co-edited by David Kurlander, Henry Lieberman, David Maulsby Brad Myers, and Alan Turransky,

published by MIT Press, April 1993.

Lieberman 93

Mondrian: A Teachable Graphical Editor, in [Cypher et. al. 93].

Lieberman 93

Making Programming Accessible to Visual Problem Solvers, in [Cypher et. al. 93].

Lieberman 93

Tinker: A Programming by Demonstration System for Beginning Programmers, in [Cypher et. al. 93].

Lieberman 93

From Video to Procedures: Graphical Annotation of Example Video Frames, MIT Media Lab.

Turransky 93

Alan Turransky, Using Voice Input to Disambiguate Intent, in [Cypher, et. al. 93].

Acknowledgments

I would like to thank Muriel Cooper and Ron MacNeil for their support of this work. Alan Turransky assisted in implementation and in reviewing this document.

Major support for this project at The Visible Language Workshop and the Interface Agents group of the MIT Media Laboratory is provided by research grants from Alenia Corp., JNIDS/ARPA, the National Science Foundation and Apple Computer. Additional funding and equipment grants for the Visible Language Workshop come from Digital Equipment Corp., NYNEX, IBM, the US Dept. of Transportation.