- UML Modeling on NetBeans, Part 1: Installation
- UML Modeling on NetBeans, Part 2: Create a Use Case Diagram
- UML Modeling on NetBeans, Part 3: Generate code from UML Diagram
- UML Modeling on NetBeans, Part 4: Generate UML Diagram from Code
UML Modeling on NetBeans, Part 4: Generate UML Diagram from Code
Now I will show about how to generate a diagram from an existing code. It also can be called reverse engineering method. This example I will generate a class diagram from my existing source codes.
- Create a new Project. File -> New Project
On left side, Category, select UML.
On right side, Projects, select Reverse Engineer a Java Project. Then click Next.
- Project Name, type ‘UMLDemo’ or any name you want.
On the middle, you’ll see Java Project, select the project that contain existing source code that you want to create a diagram. Then move down a bit, ensure the check box has been checked on the folder that contain the source code.
In this example, I select Dicomu project and check only src folder which contain my source code.
- When the project has created, try expand Model -> your source project name on the Projects window. You’ll see the files from your source project has been created here as in the figure below.
- Select the file names that you want to create a diagram by highlight them (hold shift + select first and last file). I select almost all files from my source project except TestDicom.
- Then right click on the highlight files, select Create Diagram From Selected Elements…
- In Diagram type, select Class Diagram and Name as DicomuClassDiagram.
The namespace leave it as the same. Click Finish.
- The class diagram will be generated as the figure below. Notice that the relation also been created from the source code automatically. For how to export a diagram to image can be found at the bottom in Part II.
That’s all. Complete all 4 parts. I think these series of tutorial can help you understanding and using UML Modeling on NetBeans better.