Create a Class Diagram

To create a new UML Class Diagram:

  1. Open the Diagram menu.
  2. Select Class Diagram.
    Screenshot: Create Class Diagram menu

A new Class Diagram canvas will appear in the editor.


Auto-create Class Diagrams

Astah can automatically generate Class Diagrams from Packages. This is useful when you want a quick visualization of an existing model or imported source code.

Before You Begin

If you are working with source code, import it first:

Generate a Diagram Automatically

  1. Right-click a Package in the Tree view.
  2. Select Auto Create Class Diagram.
    Screenshot: Auto Create Class Diagram menu

You can choose from three presentation options.

1. Simple

Generates a diagram containing Classes only. Attributes and operations are not displayed.
Auto Create Class Diagram in Simple Way

2. Detailed

Generates a diagram including classes, attributes, and operations.
Auto Create UML Class Diagram

3. Unpack Subpackages

Generates a diagram including all models inside the selected package and its subpackages.
Unpack SubPackages


Class

Create a Class

There are five different ways to create a Class in the Diagram Editor. For a full list, refer to the Diagram Editor documentation.
UML Class


Template Classes

A Template Class allows you to define template parameters (generics).
Template-class

Create a Template Class

You can add template parameters in two ways:

  1. Right-click the class and select Add Template Parameter.
    Screenshot: Add Template Parameter


  2. Enter details in the Template Class tab in the bottom-left Property view.
    Screenshot: Template Class properties

Attributes

Attributes represent the data fields of a Class.
UML Class Attribute

Add an Attribute

You can create attributes using:

1. Draw Suggest

Hover over a Class and click the orange diamond.
Attribute Diamond

2. Keyboard Shortcut

When an attribute is selected, press Enter to create another.
Creating Attributes

3. Paste Text

You can paste copied text to create multiple attributes at once.
Add Operation by text

Attribute Visibility

To show or hide attributes:

  1. Open the Initial Visibility tab in the bottom-left Property view.
  2. Select the visibility options.
  3. Click Apply to existing elements.Initial Visibility in Class Diagram

Operations

You can create Operations by hovering over a Class and clicking the green bar that appears.
Green bar to add operations

Another way is to press the [Enter] key while an operation is selected.
Methods to Class

Moving Attributes/Operations

Attributes and operations can be moved by dragging them within a class or to another class.
Moving attributes

Since version 8.5, you can add Operations by pasting copied text.

Add Operation by text


Anonymous Bound Class

You can create an anonymous bound class by deleting the name of a Bound Class.
Anonymous Bound Class

Anonymous Bound Classes can be specified to the following:

  • Attribute Type
  • Operation Return Value
  • Operation Parameter Type
  • The target of Association End A and Association End B
  • Base Class of Instance Specification in Class
  • Base Class of Object Node in Activity Diagram
  • Base Class of Lifeline in Sequence Diagram and Communication Diagram

Example of creating a Bound Class

  1. Create a bound class.
  2. Create a new class and add an attribute whose type is bound class to it.
    Bound Class

  3. When you add the class, you will be asked if you’d like to create a new class. Click [Yes].
    Box to ask a new class

  4. Right-click and select [Show Hidden Relationship] from its pop-up menu.
    Show hidden menu

  5. Then you will get the relationship of the anonymous bound class.
    Anonymous Bound Class

Nest a Class

You can nest a class within a package by dragging it into the package.
Nested Class


Enumerations

Since version 10.0, creating Enumerations is simpler:

1. Choose [Enumeration] from the Class drop-down menu on the tool palette.
Enumeration

2. Click on a diagram editor to place it.
Enumeration_created


Enumeration Literals

There are three ways to create Enumeration Literals.

1. Using Draw Suggest:
Hover over and Enumeration and click the purple mini bar to add a new enumeration literal.
Adding Enumeration Literals by Draw Suggest


2. Using Context Menu:
Right-click on an Enumeration and select [Add Enumeration Literal].
Enumeration Literal

3. From Property view:
Select an Enumeration, then in the property view(bottom-left pane), click [Enumeration Literal] tab and click [+].
Adding Enumeration Literal from Property View


Association

To create associations, hover over a Class, select the appropriate association type from the icons, and click the target models. For more details, see the “Drawing Lines” section.
Create Associations via Draw Suggest

Jump to Association Ends

You can navigate to the Association ends by right-clicking the association line and selecting [Move to related element].
Move to Related Element

Relocating Association Names

If association names drift from the line, right-click the line and select [Init Label Position] to reset the label’s position.

Bring association name back


Association Class

Create an Association Class

  1. Click the Association Class tool in the palette.
    UML Association Class
  2. Click the two Classes that the Association Class should connect.

Astah will place the Association Class between them.
Association Class on the UML Class Diagram