View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

An Intro to Dia

Brought to you by the Squeak Assassins.

To produce the UML for our group's milestones, our group used a program called "Dia", which we heard about from two of our friends in /dev/random who had taken CS2340 the semester before us. Dia is a fairly easy to use tool, it's available free of charge, and best of all, it's already pre-installed on the Linux machines in the CoC. This makes it a great choice when your group meets in the CoC, as ours did.

Starting dia is easy: Just run "dia"! So open up Dia and follow along.

Uploaded Image: pic01.GIF

You'll be greeted by Dia's toolbar.

Uploaded Image: pic02.GIF

Before you can begin work on the class diagrams for your classes, there are two things you'll need to do. First, you need to open a new diagram. This is probably done in the fashion you'd most expect: choose the "New Diagram" option under the "File" menu.

Uploaded Image: pic03.GIF

Secondly, you'll need to put Dia into UML mode. This may not be quite as obvious. See the box labeled "Circuit"? It's actually a drop-down box, and one of the options is UML.

Uploaded Image: pic04.GIF

If you look in the bottom part of the toolbox (right under where it says UML), you'll notice lots of new UMLish icons. For example, the top-left icon is a class in UML. You'll also notice atleast a half dozen different line variants that represent the different relations in UML (inheritance, aggregation, .etc). If you scroll down far enough, you'll even see the stick figures, bubbles, and other representations used in use cases and sequence diagrams (which makes a Dia a great tool for CS2335, as well!).

Uploaded Image: pic05.GIF

Click on the top-left icon (the one that looks like a class in UML). Then, click somewhere in the diagram and – viola! – a new class is born.

Uploaded Image: pic06.GIF

To change the properties of an object, double click on it. In this case, if we double click on "class", we'll get the dialog box shown below. From here, we can change the class's name or switch to another tab for even more options.

Uploaded Image: pic07.GIF

Switch to the "Attributes" tab. From here, we can add and remove variables from the class. To add a new variable to a class, simply click "new" and then enter the appropriate information in the "Attribute data" area of the dialog box. Since Squeak is a typeless language and all variables are private, you'll just need to enter a name. By default, all variables are instance variables. If you want to indicate that a variable is a class variable (known as a "static" variable in C++/Java), check the "Class Scope" box.

Uploaded Image: pic08.GIF

Now switch to the "Operations" tab. From here, we can add and remove methods from the class. Once again, click the new button and type the name of the method in Name under "Operation data". (If this is a class rather than an instance method, check the "Class Scope" box.)
Note: Dia will automatically add () to the end of every method name. We do not know how to prevent this behavior, and if you ever figure it out, be sure to let us all know. Fortunately, however, the TAs are nice about this!

Uploaded Image: pic09.GIF

Now, place a line on the diagram. (Any line is fine. You can change the type of line later by double-clicking on it.) Note that at the end of the line, there are two small green squares. Drag one of the green squares so it's on top of one of the blue spots on the boxes, and the green square will become red – indicating that it has latched onto the box. Try moving the box. The line will now move with it!

Uploaded Image: pic10.GIF

Finally, right click on the diagram. You'll get a menu with several options, two of which are save and export. Note that we don't recommend printing directly from dia (try it and you'll see why). If you want to print a copy of the diagram, use the "export" option in the menu to export your diagram to an image file, and then open that in your favorite image editor (we recommend Gimp!) and print from there.

Well, I hope you've enjoyed this tour of Dia. It has proved to be a useful tool in CS2200, CS2335, and CS2340. In CS2200, it can be very helpful in constructing state diagrams and pipeline buffers, while in CS2335, it's great for doing use cases and sequence diagrams. Obviously it's also great for UML class diagrams, which are used in both CS2335 and CS2340.

Links to this Page