Pasi: A Tool for Creating Ontological Diagrams

Introduction

Pasi is a Java applet that allows you to create diagrams with an output format suitable for inclusion in TeX or LaTeX files. It relies on Peter Kabal’s texdraw package, which can be downloaded from here, or, as part of the MiKTeX distribution of LaTeX, from here.

The name ‘Pasi’ (read ‘pace-eye’) is short for ‘pasigraphy’, a term that refers to general methods of expressing thoughts in a formal medium. I had originally written this applet, in the last few months of 2006, as a tool to help me create some diagrams for a term paper. It has since grown in various ways.

There also exists a non-text version of this page, which contains only the applet.

Characteristic Features

Still a rather small and simple program, Pasi was originally limited to a very narrow range of application: the creation of diagrams that only consist of circles connected by different kinds of lines or arrows (also called ‘connectors’). This range, however, seems to me reasonably well-covered, due for the most part to the following features:

  • Variability of arrow heads. Users can choose between twelve basic kinds of connectors that can be varied on several dimensions. In addition, two or more connectors that connect the same two nodes can be combined into a ‘compound arrow’ (yielding, e.g., a bidirectional arrow if the original two run in opposite directions, as shown).

A bidirectional Transition arrow.
  • Auto-flexing. This feature really consists of two parts: First, when two nodes linked by a connector are moved too close together (so that a straight would be aesthetically too short), the latter’s contact points on the peripheries of the two nodes are moved apart, resulting in a curved connector. (Similarly if a node is connected with itself.) Second, whenever a node is connected with two or more other nodes, Pasi strives to keep the contact points of these arrows on the first node at a certain minimal distance from each other, so as to prevent the arrowheads from overlapping.

The same arrow, curved by auto-flexing.
  • Support for higher-order connectors. By clicking on the center of any given connector, a small further node can be made visible that denotes the corresponding relationship itself. (In earlier versions of this website, I treated this further node as representing a third relatum.) This node can then again be connected to other nodes, have labels attached to it, etc. (see diagram). I call connectors that are attached to such a node ‘higher-order connectors’.

Demonstration of a higher-order connector.
  • LaTeX-friendliness. Since Pasi’s output is a piece of LaTeX code, it is possible to combine its drawing capability with the type-setting power of LaTeX. Text is added to the canvas by attaching a label to a node. On the screen as well as in Pasi’s output, the content of such a label will appear exactly as entered by the user. But when the output is included in a file and processed by LaTeX, that content will be type-set like ordinary LaTeX code.

Existing Alternatives

If the features just listed should seem unnecessary (or some are needed that Pasi doesn’t have), yWorks offer a very attractive alternative with their freely available yEd graph editor. On the other hand, yEd does not have auto-flexing, does not support second-order connectors as naturally as Pasi does, falls far short in its variety and customizability of arrowheads, and does not generate LaTeX-readable output. Freely available programs that at least offer this latter option include: Ipe, TpX, jfig, TexCAD, and Dia. The first four of these are multi-purpose vector graphics editors, while Dia is designed specifically for the task of drawing diagrams. Ipe has some very clever snapping mechanisms, and TpX sports a wide variety of pre-defined arrow-heads as well as a highly useful hatching tool. Jfig is a Java-based version of the classic xfig. In none of these multi-purpose programs, however, do the arrows or lines stay attached to the connected nodes when the latter are moved; hence, none of them offers auto-flexing. Nor do they support second-order connectors. However, Dia is an extremely versatile tool for drawing diagrams, with a very large variety of predefined vector-graphics objects and customizable arrows. And though it does lack Pasi’s auto-flexing feature (as well as support for second-order connectors), its arrows and lines do stay attached to the objects they’re supposed to connect.

The Rationale Behind Some Basic Design Decisions

That arrows and lines stay attached to the objects they are supposed to connect when these are moved may not sound like a very important feature. But it is a perfectly natural upshot from a design policy that tries to steer a reasonable middle course between a purely logic-driven and a purely graphics-driven interface. By ‘purely logic-driven’, I mean a kind of interface where all one has to do in order to create a diagram is to specify what entities and what relationships between these should be represented. Such an interface could be realized simply in the form of a programming language, which is of course the direction suggested by LaTeX’s approach to type-setting. Consequently, there are several software packages (e.g., xypic, dot2tex) that allow users directly to program diagrams into their LaTeX files. On the other hand, a ‘purely graphics-driven’ interface expects nothing except for the specification of visual information: what colors are displayed at which points, what kinds of lines connect which coordinates, and so on. Though this information can also be expressed with a text-based interface (such as PostScript, when viewed as a human-usable programming language), a much more natural way seems to be via a graphical user interface.

The approach taken by Pasi lies between these two poles, in the following sense: on the one hand, it offers a GUI for the easy placement of nodes and shapes at various locations on the canvas. On the other hand, connectors are not specified by their end points on the canvas, but instead by selecting the nodes they are supposed to connect – just as it would be done on a purely logic-driven approach. If lines and arrows are defined in this way, it is only natural that they should also stay attached to the objects connected by them. Another way of describing this feature would be to say that logic-related effects of logic-related input (i.e., what nodes to connect) cannot be cancelled by the graphics-related input of what object goes where. But this policy can be taken even further, since sometimes graphics- and logic-related input can combine in visually undesirable ways, leading to worries such as: Will my diagram still look good if I connect node A with node B, given that I’ve placed them at such-and-such locations on the canvas? As long as there are worries of this sort, the purpose of having a logic-driven interface could only be fully realized by a system that is able to detect and eliminate aesthetic flaws – clearly an unrealistic task. And at any rate, it seems natural (if not necessary) to let the user impose her own aesthetics on the diagrams she wants to create. So a GUI is clearly called for, but this does not mean giving up on the motivation behind the logic-driven approach. It is still possible to take some measures that help to make sure that a diagram will at least look half-way acceptable regardless of how the nodes are connected. In Pasi, this is attempted by the auto-flexing feature.


The Applet

Needless to say, I disclaim all legally relevant guarantees as to the availability or functionality of Pasi. A passage in the source code of this page has further details.


A user guide with a more detailed description of Pasi’s features is available here.

Also note: The presentation of figures and labels on Pasi’s canvas may not in every aspect be the same as what one will see in the DVI or PDF file that results from processing its output as part of a LaTeX document. In particular, the text of labels is shown in completely unprocessed form and may appear at slightly different locations in the output than on the canvas. Also, the coordinates of arrows and contours are, on the canvas, rounded to integer values (in pixels) and may consequently differ from the output.


Possible Problems for Apple Users

  • The drawing area for entity nodes may be slightly smaller than the nodes themselves. This results in missing pixels, so that the nodes do not appear as perfect circles on the screen. (This problem does not affect the generated LaTeX code.)

  • It may be neither possible to send the LaTeX code to the webpage, nor to copy and paste it by using a browser command. However, it should still be possible to use the mouse cursor to drag the generated code from the applet window into a text editor.


The Basics of Using Pasi

Creating a Diagram

A diagram in Pasi consists, on the ‘gound level’, of nodes that are in some way connected with each other or decorated with labels or pointers. There are two kinds of nodes: ‘entity nodes’ and ‘contour nodes’. The former are connected with various kinds of lines or arrows (and only these can have labels and pointers). Contour nodes, on the other hand, are connected with each other by Bézier curves running through their centers, so as to form various kinds of different figures. Since it is also possible to ‘turn off’ individual curves between any two successive nodes, these figures can be both open and closed.

Entity nodes are added to the diagram by clicking the Add Node button in the top-right corner of the window. The user can select multiple locations first by shift-clicking onto the canvas at the locations where you wish the new nodes to appear. If, instead of the Add Node button, you click on the Add Contour button next to it, you will see rounded rectangles appear instead of the circular entity nodes. Each of those contours has initially eight ‘contour nodes’ that define the end points of its line segments as well as their curvature.

Once you have created a number of entity nodes, the next step is typically to attach ornaments to them or to create connectors between them. First select, by clicking, one or more entity nodes (hold the shift key pressed to select more than one), then choose the kind of connector or ornament you wish to create. Clicking on the Create button will then create the corresponding number of ornaments or connectors. In the case of connectors, the order in which the nodes are selected determines how they are connected with each other. For example, if one first selects node A and then node B, creating an ‘Adjunction’ arrow will result in this arrow’s pointing from A to B. (If more than two nodes are selected – say, A, B, and C (in this order) – then two Adjunction arrows will be created, one pointing from A to B and the other from B to C. Special rules apply for some of the other kinds of arrows, which are detailed in the section on Predicate Symbols in the user guide.)

Almost arbitrary shapes can be created by modifying a contour. Clicking on the Add Contour button will make a contour appear in the middle of the canvas, or at whichever location has been last selected. Initially, this contour will consist of eight nodes defining a rectangle with rounded corners. More nodes can, however, be added to an existing contour by clicking the Add Node button in the editor pane (the left-most tab below the Create button). To delete a node from a contour, one will first have to select just those nodes that one wants to delete (see below for more on selection), and then delete them, using, e.g., the backspace key. (Keyboard commands are also available for adding nodes and a number of other purposes.)

Editing Diagram Elements

All elements of a diagram can be modified via the editor pane. If you click on a entity node, label, or pointer, a corresponding set of controls will appear in that pane, which can be used, for example, to edit the text of a label. Connectors, on the other hand, have initially invisible entity nodes (called ‘connector-nodes’), located near the middle of the connector line, which can be made visible by clicking on them. When one does so, a set of controls will appear in the editor pane that can then be used to change various features of the connector. Due to space limitations, the labels for these controls tend to be very concise, but with some exploration, it should usually be no problem to find out how exactly they affect the appearance of the connector in question. Where this is not the case, it may be helpful to consult the user guide.

Selection and Grouping

The items that can be selected in Pasi are entity nodes, contour nodes, and ornaments (such as labels and pointers). It is also possible to select mere locations on the canvas. When you select a contour node of a freshly created contour, all the other nodes of that contour become selected as well, but only the marker of the primarily selected node continues to blink. This node is the one whose values are displayed in the editor pane. The other nodes are selected by virtue of their being members of the same group as the primarily selected node.

All and only contour nodes are members of a special kind of group, called ‘contour node group’. Entity nodes, ornaments, and groups themselves can, by contrast, become members of ‘standard groups’. The sole effect of two items’ being members of the same group is that, if one is selected, all other members will be selected as well (more precisely, all items directly or indirectly contained in the ‘highest active group’ of the primarily selected item). But this simple fact nevertheless makes grouping a powerful tool, since, along with the primarily selected item, every item selected will also be edited, as long as it has the feature that is being edited. Similarly, by dragging one item to another location, the other selected items will be dragged in parallel with the former, complete with their labels, pointers, and the connectors between them. The same applies to copying and the transformations available under the Transform tab.

An already selected node can be deselected by clicking on it while holding the control key pressed. Clicking on an unselected node with the control key pressed will select only that node and deselect all others, even if they belong to the same group as the first one. By pressing both the control and the shift key, you can add a node to the selection without at the same time selecting all the other nodes of its group. The ‘focus’ (F) and ‘defocus’ (D) keys are also useful for changing the selection.

Retrieving the Output

When the diagram is finished, you can generate the corresponding LaTeX code (together with annotations to help later reconstruction, called ‘metadata’) by clicking on the Generate button in the bottom-right corner of the window. The code will appear in a text area below the diagram, from where one can copy and paste it directly into a LaTeX-file. If this is for some reason not possible (e.g., in some operating systems), there will still be the option of sending the code to this very web-page, by clicking on the button to the bottom right of the applet’s text area. The code will then appear in a further text area below the New Window button. (Apple Users, however, may have to rely exclusively on drag-and-drop.)

The following code example shows how the generated code may be inserted into a LaTeX file. The red portion is the code generated by Pasi:

\documentclass[twoside,10pt]{article}

\usepackage{texdraw}

\begin{document}

\title{}
\author{}

\begin{figure}
\begin{center}
\begin{texdraw}%pasi_codec_version_1
\drawdim pt \setunitscale .9 %450,300,5,5,3,0,0,10,-10,0
\linewd 1 \move(185 165) \lcir r:9.1 %a
\linewd 1 \move(190 173.6603) \clvec(205 199.641)(165 199.641)(179.8 174.0067) \linewd 1 \move(179.8 174.0067) \lvec(180.3119 183.9936) \move(179.8 174.0067) \lvec(173.1404 181.4665) %A1-a,a,b
\end{texdraw}
\end{center}
\caption{\label{f1} A simple diagram.}
\end{figure}

\end{document}

Once the code is copied into a LaTeX file, you can proceed as usual to create for instance a DVI file. (Note that cropping will be performed automatically; the borders of the canvas in Pasi serve only for visual orientation.) DVI files can in turn be translated into PNG image files using the programdvipng, which is already included, e.g., in the MiKTeX distribution of LaTeX. Standard image conversion software can then be used to translate a created PNG file into a JPG, GIF or other kind of image file.

The code generated by Pasi can be ‘read back’ into the applet using the following procedure: First, click on the Load... button in the bottom-right corner; this will open a text area in the lower half of the window, and another Load button will appear along with it. Then paste the code into the text area, and click on this second Load button. Unless the entered code contains changes made after it was generated, Pasi will then reconstruct the original diagram.

Finally, I should note that a web-connection is necessary only for loading Pasi into one’s browser. Once loaded, it will stay fully functional even if the connection is interrupted.


Acknowledgements

I would like to thank my teachers Gillian Russell and Joe Ullian for giving seminars that provided me with the opportunity to develop Pasi.