Creating Vector Graphics in Linux
Jana Jaeger
This short article is kind of a by-product of our series on networks. I needed a small and handy vector-based drawing program with a user-friendly interface for my network diagrams and flowcharts. The first two candidates I tested were xfig, a familiar and well-established program, and dia, a newcomer.
These brief program reviews obviously can't do justice to the rich scope of functions offered by each editor, but they do show how each one can be used to achieve the objective - the final network diagram. For the full-blown tutorials and link collections on these two editors, please consult the section at the end.
The problem
The figure below shows a simple network diagram of the kind required in our article.
The editors have to meet the following requirements:
- Support a library specifically for representing networks
- Support various fonts and font sizes
- Support simple object grouping and scaling
- Support different depths and/or layers
- Export to PNG or another suitable bitmap format for embedding in HTML documents
dia
dia is a typical gtk-based program. At first, I actually thought I had opened gimp. Apart from a few special functions, the tool panel is almost exactly the same. The top half offers a selection of basic drawing tools (lines, curves, rectangles, etc.), text and image embedding as well as a pan and zoom feature. Below it is an options menu featuring a range of libraries for different types of diagrams. Among these is the Network sheet, which is exactly what I need. Finally, in the bottom part, one can set the pen color, linetype and line color.
The first thing to do is start a new canvas (File --> New Diagram). The next step is to select the "Network Cloud" (see the tooltips for the network sheet) to represent the Internet. Like all the other insertable objects, the cloud has eight shape handles, enabling comfortable mouse-based moving and resizing.
To label the Internet cloud with the word "Internet" using the font I want, I first insert the text on the cursor that is already integrated in the cloud. A double click brings up the object's menu allowing me to manipulate the alignment, color, size and font type of the word. Apply or OK applies my changes.
The process for inserting pictures to represent the individual computers on the network is the same. The individual computers on the network can now be "connected" using a series of discrete lines on the drafting menu or, more elegantly, by selecting the Ethernet Bus on the network sheet.
Redundant connection points have their own menu via which they can be deleted (click the segment you want to delete with the middle mouse button) Delete Connection Point. Or, if you need more connection points, you can use Add Connection Point to add them.
Line segments and objects are easy to connect in dia. All you need to do is merge the object shape handles with the endpoints of the line segments. Object handles are shown as blue when they cannot be activated. When the endpoint of a line is connected to such a handle, it becomes red. dia will remember and update these associative object connections, i.e. connections do not have to be redrawn whenever an object is moved.
dia includes an object grouping function that is accessible via the right mouse button. This is useful should the size of the network change, for example, and the number of objects to move increase, meaning that entire groups of computers have to be moved around in the diagram. Clicking in the background of the diagram brings up the good old main menu (it resembles the one in gimp). All (well, almost all) the editor functions can be accessed here. Clicking Objects --> Group groups the objects selected beforehand with the mouse. The objects can now easily be moved as a single entity. Of course, the group can also be cleared by clicking Objects --> Ungroup.
To layer objects, I open the layers dialog from the main menu Dialogs --> Layers. This allows objects to be edited completely independently on their separate layers. Alternatively, I can also superimpose the two objects in a layer and use Objects --> Send to Back or Objects --> Bring to Front to put them right at the back or on top of the display respectively. In this case, switching between the individual layers to edit the different elements later is not necessary.
I save the finished drawing in dia's proprietary image format, DIA. I scale the graphic before exporting it by choosing File --> Page Setup on the right mouse button menu. The file can then be exported directly from dia to PNG and integrated directly into the portal article.
xfig
In terms of program navigation, xfig is completely different to dia. Just about all the drawing options and edit tools are accessible by clicking with the mouse on the relevant buttons arranged around the workspace.
To display the networked computers, I click on the library button on the left edge of the workspace and am presented with a range of different libraries for different types of diagrams. The Network library is bit too cluttered for my needs, but I quickly find what I am looking for in the Computer library. Furthermore, I might as well have imported my own pictures available in different format (GIF, TIFF, JPG, ...) into the graphic.
I quickly draw a few lines to connect the computers. First, the drawing option for lines (left window border) is activated and then the line thickness and color at the bottom edge of the border, which requires clicking a button and using a small menu.
I'd better avoid any serious regrouping operations from now on. xfig does actually feature a tool for grouping objects - either based on a region I define with the mouse, or individual elements selected by pointing and clicking - however, a tool to maintain the connections between objects is missing.
xfig also handles different depths easily. I can either set the depth before I draw the first line by clicking on the appropriate button at the bottom edge of the screen, or I use one of my favorite xfig functions, the "Edit" mode (button on the left edge of the screen). Clicking this button opens a menu window, which, at first glance, offers (almost) all of the object's attributes for editing. The finished graphic is saved in xfig's proprietary FIG format. Before the graphic can be saved as PNG, I need to take a detour via the print menu to define the orientation of the graphic and its size as a percentage.
Conclusion
dia
dia scores mainly with its practical little ideas designed to ease the draughtsman's daily work. The tool for permanently connecting objects with each other, for example, is simply brilliant. If a graphic is going to be modified frequently, this tool makes things a lot easier as the framework for the drawing is very flexible. The graphic can be redone without all the connections having to be cleared, the objects moved and then reconnected again. The icon libraries, compared to the wealth of those offered by xfig, are rather spartan. But dia makes up for this with one of its main strengths elsewhere: It offers the option to integrate custom diagram libraries into the standard menu via XML and SVG. Instructions on how to do this are provided in a chapter taken from the book "The GNOME Desktop" by Kayon Toga. The PDF version of this file is available at http://www.togaware.com/linuxbook/dia.html.
A number of crashes at run-time and memory artifacts after saving the file in the DIA format and then re-opening the file detracted somewhat from the initial good impression. And anybody hoping to find advanced help in the Help menu is in for a disappointment. Apart from version information and a reference to the official homepage of the dia project, there's nothing there.
Having said that, the documentation currently available for dia (including a short online tutorial) can be accessed quickly from the site.
These documents, however, are only available in English.
xfig
xfig is significantly different to dia from a purely optical standpoint. Whereas dia gets by with a small tools menu and a separate window for the actual drawing, xfig takes up almost the entire screen after starting. xfig doesn't distinguish between canvas and menus, but it is much more compact for that.
As the illustration shows, the buttons around the workspace are arranged in groups. Central functions (open, save, print, export) can be accessed via the relevant menus in the top left corner. The buttons along the left edge of the window underneath provide access to the essential drawing tools. Attributes like line thickness, color etc. are offered for selection along the bottom edge of the window. The edit tools block has a similar structure. The mouse function indicator in the top right corner shows which mouse button is currently active and in which mode.
The actual drawing process is relatively easy and smooth thanks to the relatively flat menu hierarchy (everything is accessible in an instant). xfig, however, lacks a tool for connecting individual objects which would enable modifications to be made easily and comfortably like in dia. The libraries for the individual types of diagrams make a slightly cluttered impression, which isn't necessarily negative. It isn't the lack of important functions that betray xfig's age; rather, it is the old-fashioned look-and-feel of xfig's graphical interface. After all, 16 years is quite something in the Linux/Unix world. With its three years and typical GNOME look-and-feel, dia makes a much fresher impression. Apart from the fact that most of the xfig functions are accessed by more or less self-explanatory buttons and comprehensible menus, xfig isn't available in German. But don't let that put you off. A browse through the how-to guide, which can be accessed via the Help menu, is recommended for anybody who wants to have a look behind the scenes.
In my view, no clear winner emerges from the comparison of the two programs. xfig meets my (modest) requirements fully and, apart from the unusual graphical interface which takes some getting used to, there are no signs of old age which might in any way hinder any useful work. All the functions it boasts are actually there and work as expected. In this sense, age does have its advantages ;-)
dia trumps with features like platform and application independence thanks to its XML support, the custom diagram classes and downright clever functions like object merging and layer support. On the other hand, it is still suffering from teething troubles like as-yet unimplemented functions - I'm thinking of the tools menu here, which is accessible via the main menu (right mouse button) - and total crashes. dia is fine for getting started and the points mentioned above hold promise for the future. Anybody not prepared to put up with anything other than a stable working environment, however, had better think twice before installing dia.
Related Links
Both dia and xfig have their own homepages. Extensive documentation including tutorials and screenshots can be accessed from or found on the respective sites. Both
programs are included in SUSE LINUX 7.2 (Personal or Professional)
dia in the gra series and xfig in the tex series.
|