|
[
Introduction
Characteristics
Existing Alternatives
Design Decisions
The Applet
Possible Problems
Basic Usage
Creating a Diagram
Editing
Selection and Grouping
Retrieving the Output
Acknowledgements
User Guide ] |
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 ‘PAH-see’) 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. 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:
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. 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. 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.
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 any kind of shape 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.) 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. 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 simply by clicking at them. (Entity and contour nodes can also be selected by drawing a box around them. Usually, however, this will ignore connector nodes. In order to select those as well, you will have to keep the Alt key pressed.) When you select a contour node, all the other nodes of that contour will (usually) become selected as well, but only the marker of the primarily selected node will be blinking. 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. (Alternatively, you may draw a box around all the to-be-deselected nodes, holding the Control key pressed when starting to draw the box.) 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 Ctrl and Shift, 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 (see Keyboard Commands). 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 blue portion is the code generated by Pasi:
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 program dvipng, 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. I would like to thank my teachers Gillian Russell and Joe Ullian for giving seminars that provided me with the opportunity to develop Pasi. |
| © 2007–09 Jan Plate | Valid XHTML and CSS |