UML Modeling: Creating Activity Diagrams

   

This article applies to NetBeans Enterprise Pack 5.5 (the IDE).

This article describes how to use the UML modeling features of the IDE to create a simple UML Activity diagram. The procedures in this article show one representative way of creating an Activity diagram and introduce you to some of the IDE's UML Modeling features. This article does not teach you about UML concepts or the Java programming language.

 
Contents

To use the following procedures, the NetBeans™ 5.5 IDE with NetBeans Enterprise Pack 5.5 Early Access must be installed on your system. You should be familiar with the basic parts of the IDE and have a basic familiarity with the Java programming language and UML modeling. For a basic understanding of the IDE, see the IDE Basics topics of the online help. A resource for UML modeling techniques and theory is the official UML resource page at http://www.uml.org/


Using Activity Diagrams

An Activity diagram is a visual representation of any system's activities and flows of data or decisions between activities. When you click the Diagram editor tab for an Activity diagram, the IDE displays a specific selection of icons in the IDE Modeling Palette. Activity diagrams provide a very broad view of a business process.

The diagram may be used to:

  • Describe activities and flows of data or decisions between activities
  • Provide a broad view of business processes
  • Describe the activities that occur within a use case
  • Show many different activities using different discrete symbols
  • Show parallel threads
Back to Top


Drawing an Activity Diagram - An Overview

The following table shows the tasks involved in creating an Activity diagram. This table and the following procedures describe one way to create an Activity diagram.

Number one
Set Up the Activity Diagram
  • Create a UML Project
  • Create a Package with Empty Scoped Activity Diagram

Number two
Place Partitions
  • Add Partitions
  • Add Subpartitions

Number three
Identify Action States
  • Add Elements
    • Add Activity Group
    • Add Invocation
    • Add Initial Node Element
    • Add Horizontal Fork Element
    • Add Activity Final Node and Decision Node

Number four
Place Edges and Dependencies
  • Add Activity Edge
  • Add Dependencies
  • Label the Edges

Number five
Work with Group Kinds and Conditions
  • Add Guard Conditions to Activity Edges
  • Select and Modify GroupKinds

Back to Top

Setting Up the Activity Diagram

This section contains the following procedures:

Creating a UML Project
  1.  

  2. From the main menu, choose File > New Project and then do the following:

    1. Under Categories, select UML.
    2. Under Projects, select Platform-Independent Model.
    3. Click Next.
  3. Type a project name and location for your project.

    Notice that when you type the Project Name, the IDE automatically suggests this name for the name of the Project Folder.
  4. Click Finish.

    The New Wizard opens and displays the Create New Diagram page.
  5. For the purposes of this example, click Cancel.


    The IDE does the following:

    • Creates an empty Platform Independent modeling project
    • Displays the project icon in the Projects window
Back to Top

Creating a Package With Scoped Activity Diagram
  1. In the Projects window, right-click the Model node.
  2. Choose Add > Package from the pop-up menu.
  3. In the Name field type a name for your package.
  4. Accept the default value in the Namespace field.
  5. Select the Create Scoped Diagram checkbox.
  6. In the Diagram Name field, type a name for your diagram.
  7. From the Diagram Type list, select Activity Diagram and click OK.


    The IDE does the following:

    • Creates a package node under the Model node with the package name that you entered
    • Creates a Diagrams node under the project node
    • Creates diagram node under the Diagrams node with the diagram name that you entered
    • Displays the new diagram in the Diagram editor (the diagram is empty at this point)
    • Opens the Modeling Palette displaying the icons that are used to build activity diagrams
Back to Top

Placing Partitions

The IDE lets you add partitions to your activity diagram. Partitions divide the nodes and edges to constrain and show a view of the contained nodes.

  1. From the Data section of the Modeling Palette, select the Partition icon Partition icon.
  2. Click in the Diagram editor to place a Partition element on the diagram.
  3. Deselect the Partition icon by right-clicking anywhere inside the Diagram editor.

    An unnamed Partition element is placed on the Diagram editor.
  4. Right-click the Partition element and choose Partitions > Add Partition Column to the Right from the pop-up menu.
  5. Expand the right column of the partition.
  6. Name the partition by double-clicking the word Unnamed in the top portion of the partition and typing Bank.
  7. Press Enter.
  8. Name the left column by double-clicking the word Unnamed in the left column and typing Bank Lobby.
  9. Name the right column Teller.


    Your diagram should resemble the following figure.

    Screen capture showing Use Case diagram with labeled Use Cases
Back to Top

Identifying Action States

This section contains the following procedures:

Adding an Activity Group
  1. From the Basic section of the Modeling Palette, select the Activity Group icon Activity Group icon.
  2. In the Diagram editor, click inside the Bank Lobby subpartition to place the Activity Group element on the diagram inside the left subpartition.

    This nests the Activity Group inside the Bank Lobby subpartition.
  3. Right-click to deselect the Activity Group icon.
  4. Double-click the word Unnamed on the new Activity Group, type Customer and press Enter.
  5. Select the Activity Group that you just added. Move and enlarge it to almost fill this subpartition.
Back to Top

Adding an Invocation
  1. From the Basic section of the Modeling Palette, select the Invocation icon Invocation icon.
  2. Click inside the Customer Activity Group element in the Bank Lobby subpartition to place two operation nodes on the diagram, one directly below the other.
  3. Righ-click to deselect the Invocation icon.
  4. Move and resize the invocation elements so that they fit completely inside the Customer Activity Group as shown in the following figure.


    Screen capture showing Activity diagram with Partitions and Invocations
  5. Double-click the upper invocation node that you just added, type Approach Teller Counter and press Enter to label the element.
  6. Select the lower invocation node and name it Enter Transaction.
  7. Place six more invocation elements inside the Teller subpartition and name them as follows:

    • Receive Transaction Request
    • Search for Customer Info
    • Send to Customer Service
    • Process Transaction
    • Update Account Info
    • Notify Customer

    Your diagram should resemble the following figure.

    Screen capture showing Activity diagram with Labeled Invocations
Back to Top
Adding an Initial Node Element
  1. From the Basic section of the Modeling Palette, select the Initial Node icon Initial Node icon.
  2. Click in the Bank Lobby subpartition to the left of the Approach Teller Counter element.
  3. Deselect the icon.
Back to Top

Adding a Horizontal Fork Element
  1. From the Control section of the Modeling Palette, click the Horizontal Fork icon Horizontal Fork icon.
  2. Place the bar representing the Horizontal Fork element above the Update Account Info and Notify Customer invocation elements and lengthen the bar to span the width of both invocations.
  3. Place another Horizontal Fork element below the Update Account Info and Notify Customer invocation elements and lengthen the bar to span the width of both invocations.
Back to Top

Adding an Activity Final Node and a Decision Node
  1. From the Basic section of the Modeling Palette, select the Activity Final Node icon Activity Final Node icon.
  2. Place the Final Node below the lower Horizontal Fork element.
  3. Right-click to deselect the icon.
  4. From the Control section of the Modeling Palette, select the Decision icon Decision icon.
  5. Place the Decision element on the flow between Search for Customer Info and Send To Customer Service elements.
  6. Deselect the icon.

    Your diagram should resemble the following figure.

    Screen capture showing Activity diagram with control elements
Back to Top

Placing Edges and Dependencies

This section contains the following procedures:

Adding an Activity Edge Element
  1. From the Basic section of the Modeling Palette, select the Activity Edge icon Activity Edge icon.

    You use the Activity Edge to connect the Initial Node element to the Invocation element.
  2. Click once on the Initial Node Initial Node icon element and click again on the invocation element that is labeled Approach Teller Counter.

    An Activity Edge link now connects the two elements. The labels for the Activity Edge links are hidden and need to be displayed.
  3. Deselect the icon by right-clicking.
  4. Select and right-click the Activity Edge element.
  5. Choose Labels > Show Name from the pop-up menu.

    The link is labeled with the highlighted text Unnamed.
  6. To name the link, type Initiate Cash Withdrawal and press Enter.
Back to Top

Adding More Activity Edge Elements
  1. Select the Activity Edge icon from the Basic section of the Palette.
  2. Draw the following links:

    • From Approach Teller Counter to Enter Transaction
    • From Enter Transaction to Receive Transaction Request
    • From Receive Transaction Request to Search for Customer Info
    • From Search for Customer Info to Decision node
    • From Decision node to Send To Customer Service
    • From Decision node to Process Transaction
    • From Process Transaction to Upper Horizontal Fork
    • From Upper Horizontal Fork to Update Account Info and Notify Customer
    • From Notify Customer to Lower Horizontal Fork
    • From Update Account Info to Lower Horizontal Fork
    • From Lower Horizontal Fork to Final State element

      You can left-click any portion of each Activity Edge element to form an angle on the link, as shown with the Activity Edge element drawn from Enter Transaction to Receive Transaction in the figure below.
  3. Right-click to deselect the icon.

    Your completed diagram should resemble the following figure.


    Screen capture showing Activity diagram with Activity Edge elements
Back to Top

Working with Group Kinds and Conditions

This section contains the following procedures:

Adding Guard Conditions to Activity Edges
  1. In the Diagram editor, right-click the Activity Edge element between the Decision node and the Send to Customer Service element.
  2. Choose Labels < Show Guard Condition from the pop-up menu.
  3. Inside the guard condition brackets, type No Customer Info and press Enter.
  4. Repeat steps 2 and 3 for the Activity Edge between Decision node and Process Transaction. Type Customer Info for this guard condition.
Back to Top

Selecting and Modifying the GroupKind Property

In the IDE, an Activity Group depicts a loop in the flow of an activity. For example, an Activity Group calls out an iteration that already exists in the flow. The IDE's UML Modeling feature offers three Group Kinds as follows:

  • Iteration
  • Structured
  • Interruptible
  1. In the Diagram editor, select the Activity Group labeled Customer.
  2. In the GroupKind property row of the Properties window, click the down arrow.
  3. Select Structured from the drop-down list.

    The Customer Activity Group is relabeled on the diagram as a structured group.
Back to Top

Summary

In this article, you created an activity diagram for a simple banking application. You learned how to create a representative Activity diagram.

For more information on UML Modeling , consult the online help in the IDE and visit the NetBeans Enterprise Pack 5.5 portal for UML tutorials. You can find more UML videos and other resources on UML Modeling at the following web site: Sun Java Studio Enterprise UML Modeling Reference.

Back to Top

This page was last modified:  May 4, 2006

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
JavaOne Banner
Java 8 banner (182)