CIS Header Left CIS Header Center
C-2-100 Mackinac Hall
1 Campus Drive
Allendale, MI 49401

Phone:616-331-2060
Fax:616-331-2106
email: info@cis.gvsu.edu


ABET Accredited Symbol

The Computer Science and Information Systems programs are accredited by the Computing Accreditation Commission of ABET.
Find us on Facebook

Find us on Twitter
Using Dia for UML

Index->Using Dia for UML

Using Dia for UML

Overview and Goals

At the completion of this lab, you will be able to...

  1. create UML diagrams using Dia.

The following utilities are used in this lab: dia(1x)

Dia: A Diagram Drawing Tool

From the man page for dia:

Dia is used to create diagrams. Dia has a number of basic tools, like lines and boxes but can also dynamically load "sheets". A sheet is a collection of tools that are used in a certain type of diagram.

To start Dia, type "dia" at the command line. Dia should start and you should see a window with a "File" and "Help" menu, and a set of drawing tools. These are generic drawing tools that you can use in any Dia drawing.

In the middle of this window is a select box that probably says "Chronogram". This select box allows you to choose tools to draw various kinds of diagrams. Select "UML" and you should see a set of more than two dozen UML objects.

Menu ==>
General Tools ==>
UML Specific Tools ==>
Line Mode ==>

Choose "File--New diagram" to create a new diagram. Select the first UML object "Create a class". Click in the new diagram and a new UML class should appear. Double click on the class to bring up the properties.

Let's create a Student class. Change the class name to "Student". Don't change anything else on the "Class" tab. However, it is on this tab that you can specify that the class is "abstract" and how much detail you want to show on the diagram (e.g., like not displaying the data members of your classes).

The "Attributes" tab allows you to add data members to your class. "Name" is the name of your variable. "Type" is its data type. "Value" is its default value. "Visibility" determines who can access the variable. "Class scope" means is the variable "static" or not. Add a private "Name" String and a "sid" String to the Student class.

The "Operations" tag allows you to add methods. On the left are fields about the method name and return type. On the right are fields for adding method parameters. On the left, "Name" is the method name, "Type" is the return type. "Visibility" determines who can access the method. "Class scope" determines if it is "static" or not. "Inheritance type" determines if the method is "abstract", "final", or regular (virtual). "Query" should be checked if the method is an accessor (i.e., not a mutator).

For method parameters, "Name" is the parameter name. "Type" is the data type. "Def. value" is the parameter's default value. "Direction" specifies if the parameters is an input parameter, output parameter, or an in/out parameter.

Add the methods "getName()", "setName()", "getSID()" and "setSID()" to the Student class.

Select the "OK" button and the Student class should be updated. Other classes can be created similarly. Use the different arrows to define relationships between objects.

To save your document, click with the right mouse button in your document. You will get a menu that allows you to change various parts of your diagram, as well as saving it to a file, and printing it.

Drawing Lines

With the UML tools selected, you can draw lines/arrows of predefined type to show different kinds of relationship among the classes. These predefined lines/arrows are zigzag (consist of vertical and horizontal line segments only). When there are so many classes in your UML diagram, the arrows connecting them may overlap each other and the correct relationships among the classes are not shown correctly.

To avoid the above problem, you can draw different shapes of lines by selecting the appropriate icons from the "General Tools". The following shapes are available: straight line, 3-point arc, zig-zag line (the default shape used by UML tools), polyline, and Bezier line. In addition to that, line type and arrow head type can be selected by clicking the three buttons on the "Line Mode".

When connecting two classes with an arrow/line make sure the end points are attached to the connection points. If they are attached correctly, dia shows the end points as a red square, otherwise it shows green.

Exercise

  1. Just for fun, create the following UML diagram for the "Shape" and "Circle". You should get something that looks like this:

  2. Print your UML diagram. First, right click, and choose File---Page Setup. Select "Letter" sized paper and "Fit to 1 by 1". This is to fit your diagram on a single page. If this setting is not selected, dia will print the diagram in its default size across several pages. The "Fit to m by n" setting will automatically resize the page boundary when any items close the page boundary is moved around. Click "OK", then right click again and choose File---Print Diagram.

Reference

See the dia website for more information on this drawing tool and how to download your own copy of the software (available for Windows, Linux, and other platforms).

Top

This page was last modified May 25 2005.
Send comments to the CIS School Webmaster.
Copyright ©1995 - 2009 Grand Valley State University.
GVSU is an Equal Opportunity/Affirmative Action Institution.