Class diagram
IntelliJ IDEA lets you generate a diagram on a package in your project. Such diagrams always reflect the structure of actual classes and methods in your application.
View diagram on a package
In the Project tool window, right-click a package for which you want to create a diagram and select (Ctrl+Shift+Alt+U).
In the list that opens, select Java Class Diagram. IntelliJ IDEA generates a UML diagram for classes and their dependencies.
Analyze class diagram
After you have generated a diagram, press E to expand the package to see classes and their connections. To collapse them press C.
You can easily distinguish between public and private classes, since they have their own modifiers for public and for private.
If you want to see the list of methods, fields, and other code elements, select the appropriate icon on the diagram toolbar located on top of the diagram editor. The lists are displayed based on the visibility scope which you can change. For example, if you want to see only protected methods, select the protected option from the drop-down list. IntelliJ IDEA displays such methods with a modifier (key image) next to it.
You can click the icon to see class dependencies. IntelliJ IDEA follows the UML conventions in showing relationships between the classes.
When you click through classes in the graph, IntelliJ IDEA greys out classes that do not reside in the same package. This might be helpful, when you generate a diagram on a package that contains inner packages.
Manage class diagram
The context menu in the diagram editor provides the ability to perform different tasks while you work with diagrams. You can view members of the class, add new, delete the existing ones, see implementations, check parent classes, perform basic refactoring, add notes, etc.
Add an existing class to a diagram
Press Space to add an existing class to your diagram.
In the search field that opens, start typing a name of the class you want to add. IntelliJ IDEA displays the list of suggestions. If you want to add a class that is out of the project scope, select the Include non-project items option.
Add new members to a class
You can perform some forward engineering while in the diagram editor.
In the diagram editor, right-click anywhere and from the context menu, select
and a code element you want to create.Depending on what you have selected, IntelliJ IDEA opens the appropriate dialog where you specify the necessary information for creating the new element.
IntelliJ IDEA adds the item to your diagram as well as to your project tree.
View implementations and parent classes
You can view implementations and parent classes in your diagram. If IntelliJ IDEA finds more than one parent class or implementation, it displays a list of appropriate items. Select the one you need to see the connections between the parent and its children.
In the diagram editor, select an item for which you want to see implementations or parent classes.
Right-click the items and from the context menu, select the Show Implementations(Ctrl+Alt+B) or Show Parents(Ctrl+Alt+P) respectively.
Configure diagram settings
You can configure the diagram settings, so that you have certain options available to you by default when you create your diagram.
Press Ctrl+Alt+S to open Settings | Preferences dialog.
From the options on the left, select
.From the options on the right, select options that you want to see by default and click OK to save your changes.