Как сделать диаграмму классов в intellij idea
Перейти к содержимому

Как сделать диаграмму классов в intellij idea

  • автор:

Как сделать диаграмму классов в intellij idea

Helen Scott

You can use ⌥⇧⌘U (macOS) / Ctrl+Alt+Shift+U (Windows/Linux) to generate a UML diagram for your code which can help you and your team to read and understand the codebase.

Related Resources

Generate UML diagrams for your Kotlin code

JVM developers working with Kotlin code can create UML diagrams for their Kotlin classes, just like they could with Java classes

Dependency Matrix

Explore project structure with the Dependency Matrix

UML class diagrams

This functionality relies on the Diagrams plugin, which is bundled and enabled in IntelliJ IDEA by default. If the relevant features aren’t available, make sure that you didn’t disable the plugin.

  1. Press Control+Alt+S to open the IDE settings and then select Plugins .
  2. Open the Installed tab, find the Diagrams plugin, and select the checkbox next to the plugin name.

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

  1. In the Project tool window, right-click a package for which you want to create a diagram and select Diagrams | Show Diagram Control+Alt+Shift+U ).
  2. In the list that opens, select Java Class Diagram . IntelliJ IDEA generates a UML diagram for classes and their dependencies.

You can view your VCS local changes as a diagram. Select VCS | Uncommitted Changes| Show Local Changes as UML Control+Alt+Shift+D .

Analyze class diagram

You can press Control+F12 on the element to view a list of diagram elements and navigate between them.

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.

Diagram editor

The lists are displayed based on the selected visibility level, which you can change. For example, to view protected methods, click on the diagram toolbar and select protected from the list. IntelliJ IDEA displays members with visibility not less than protected, such as public, package local, and protected ones. The protected methods are displayed with modifier icons next to them.

Visibility level

You can click the icon to see class dependencies. IntelliJ IDEA follows the UML conventions in showing relationships between the classes.

Class dependencies

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.

Different packages

To save the diagram as a file, right-click the diagram editor and from the context menu, select Export Diagram | Export to File and then the file extension in which you want to save the diagram.

Manage class diagram

When working with diagrams, use the context menu in the diagram editor to perform different tasks. You can view members of the class, add new, delete the existing ones, see implementations, check parent classes, perform basic refactoring, add notes, and so on.

You can select the icon on the diagram toolbar to draw relationship links between elements in your graph. To delete the existing links, select the ones you don’t need and press Delete . IntelliJ IDEA will update the source code accordingly.

View the diagram structure

  1. Generate a diagram.
  2. Click Structure in the left toolbar. IntelliJ IDEA opens the Structure tool window that displays a map of your diagram with a small preview of the selected block and its neighbors. the Structure viewUse the context menu to zoom in and out, move canvas, change layout, and export part of the diagram into an image. the context menu

Add an existing class to a diagram

  1. Press Space .
  2. In the search field that opens, start typing a name of the class you want to add. Then, select the desired class from the suggestion list. If you want to add a class that is out of the project scope, select the Include non-project items checkbox. Alternatively, select one or more elements in the Project tool window and drag them to the diagram.

Delete a node element from the diagram

  1. In the diagram editor, select a node element you want to delete.
  2. Right-click the element and from the context menu, select Delete Delete . Alternatively, select Refactor | Safe Delete Alt+Delete . In this case, IntelliJ IDEA checks for usages before applying the changes.

You can quickly search for usages by pressing Alt+F7 on a code element.

Add new members to a class

You can perform some forward engineering while in the diagram editor.

  1. In the diagram editor, right-click anywhere and from the context menu, select Content | New . Then select a code element you want to create.
  2. Depending on your selection, 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.

  1. In the diagram editor, select an item for which you want to see implementations or parent classes.
  2. Right-click the items and from the context menu, select the Show Implementations Control+Alt+B or Show Parents Control+Alt+P respectively.
  3. In the popup that opens, select items you need and press Enter . To extend your selection up or down while in the popup, press Shift+Up or Shift+Down respectively.

Configure diagram settings

You can configure the diagram settings so that you have certain options available by default when you create a diagram.

  1. Press Control+Alt+S to open the IDE settings and then select Tools | Diagrams .
  2. In the right-hand pane, select the options that you want to see by default and click OK to apply your changes.

Analyze graph

The Analyze Graph action group lets you analyze the graph in various ways such as perform auto clusterization, measure the node centrality, search cycles, filter path between two nodes, and so on.

Filter paths between two nodes

Most of the time, generated diagrams are big and complicated. Typically, you want to concentrate only on the specific part of the diagram. IntelliJ IDEA lets you filter paths between two diagram elements.

the Focus on Paths between Two Nodes dialog

  1. In the diagram editor, select two nodes on which you want to focus and right-click one of them to open the context menu.
  2. From the context menu, select Analyze Graph | Focus On Paths Between Two Nodes . If you want to focus not only on just two nodes, but on how the selected node is connected with its neighbors, select the Focus on Node Neighborhood option from the context menu.
  3. In the dialog that opens, select additional options if needed and click Find . IntelliJ IDEA displays connections associated only with the selected nodes.

Measure diagram centrality

You can use this action to identify the important nodes in the graph.

  1. In the diagram editor, right-click anywhere in the editor to open the context menu.
  2. From the context menu, select Analyze Graph | Measure Centrality .
  3. In the dialog that opens, select additional options if needed and click Measure . Measure CentralityThe node «importance» is expressed via fractional value from 0.0 to 1.0 measurement, and the brightest node selection should be explored first. Measure Nodes

Press Control+Z to cancel the actions.

Как сгенерировать UML диаграмму по проекту из Intellij IDEA

Поставил плагин ArgoUML для Intellij IDEA. Возможно ли из проекта получить UML диаграмму всего проекта?

Intellij IDEA: 122.202 ArgoUML v.0.34

amazpyel ★★★
27.08.12 16:08:53 MSK

Вообще-то код пишут по диаграмме, а не наоборот. Ничего интересного ты там не увидишь.

anonymous
( 27.08.12 17:10:30 MSK )
Ответ на: комментарий от anonymous 27.08.12 17:10:30 MSK

Но возможность экспорта в диаграмму по идее есть

amazpyel ★★★
( 27.08.12 17:28:50 MSK ) автор топика

это что за вид диаграмм такой?

vostrik ★★★☆
( 27.08.12 17:29:57 MSK )
Ответ на: комментарий от anonymous 27.08.12 17:10:30 MSK

Если есть проект, который разрабатывался не мной, то есть возможность получить диаграмму и получить визуальную карту проекта в виде UML диаграммы

amazpyel ★★★
( 27.08.12 17:30:05 MSK ) автор топика
Ответ на: комментарий от vostrik 27.08.12 17:29:57 MSK

amazpyel ★★★
( 27.08.12 17:31:17 MSK ) автор топика
Ответ на: комментарий от amazpyel 27.08.12 17:31:17 MSK

vostrik ★★★☆
( 27.08.12 17:34:54 MSK )
Ответ на: комментарий от vostrik 27.08.12 17:34:54 MSK

Т.е. нельзя получить диаграмму ВСЕГО проекта, я правильно понял?)

amazpyel ★★★
( 27.08.12 17:36:14 MSK ) автор топика
Ответ на: комментарий от amazpyel 27.08.12 17:36:14 MSK

блин, диаграмму ЧЕГО всего проекта?

vostrik ★★★☆
( 27.08.12 18:15:24 MSK )
Ответ на: комментарий от vostrik 27.08.12 18:15:24 MSK

😀 Классов, диаграмму классов

amazpyel ★★★
( 27.08.12 18:31:52 MSK ) автор топика
Ответ на: комментарий от amazpyel 27.08.12 17:30:05 MSK

Если есть проект, который разрабатывался не мной, то есть возможность получить диаграмму и получить визуальную карту проекта в виде UML диаграммы

Ну будет у тебя лабиринт из тысяч классов, и что дальше?

Используйте IntelliJ для генерации диаграммы классов

Как мне получить IntelliJ 10.5 (на Mac), чтобы создать диаграмму классов, показывающую все классы в моем проекте? Я уверен, что я пропускаю что-то очевидное, но я могу получить только функцию «Показать диаграмму», чтобы показывать один класс за раз. (Я также понял, как добавить дополнительные классы, но опять же, только по одному.)

Zack 20 янв. 2012, в 15:27
Поделиться
Поделиться:
intellij-idea
class-diagram

4 ответа

Лучший ответ

Использовать Diagrams | Show Diagram из контекстного меню пакета. Вызов его в корне проекта будет отображать диаграмму зависимостей модулей. Если вам нужно несколько пакетов, вы можете перетащить их на уже открытую диаграмму для первого пакета и нажать e , чтобы развернуть его. Также проверьте это видео для другого подхода. Примечание. Эта функция доступна в Ultimate Edition, а не в бесплатном выпуске Community Edition.

CrazyCoder 20 янв. 2012, в 15:45
Поделиться

Означает ли это, что для версии сообщества нет доступных плагинов для создания диаграммы классов, сейчас и в будущем?

Bruce Sun 20 сен. 2016, в 03:50
@BruceSun не в данный момент
CrazyCoder 21 сен. 2016, в 00:09

@CrazyCoder Как вы используете это, чтобы просмотреть UML-диаграмму для класса и его ребер, .. я думаю, найти мои узлы, отдел 3 . или все . сейчас это довольно бесполезно. он показывает только иерархию классов, а не то, какой объект он использует, и что эти объекты в свою очередь используют. Этот плагин UML не является полезным.

momomo 21 дек. 2016, в 21:03
Ссылка вниз 🙁 не могли бы вы исправить это, пожалуйста?
Pipo 03 авг. 2018, в 17:10
Показать ещё 2 комментария

IntelliJ IDEA 14 и 15

Изображение 115178

  • Показать всплывающее окно диаграммы Щелкните правой кнопкой мыши по типу/классу/пакету > Диаграммы > Показать всплывающее окно диаграммы.
    или Ctrl + Alt + U
  • Показать диаграмму (открывает новую вкладку) Щелкните правой кнопкой мыши по типу/классу/пакету > Диаграммы > Показать диаграмму.
    или Ctrl + Alt + Shift + U

По умолчанию вы видите только имена классов/интерфейсов. Если вы хотите увидеть более подробную информацию, перейдите в Файл > Настройки. > Инструменты > Диаграммы и проверьте, что вы хотите (например: Поля, Методы и т.д.)

P.S.: Вам нужен IntelliJ IDEA Ultimate, потому что эта функция не поддерживается в Community Edition. Если вы перейдете в меню «Файл» > «Настройки. » > «Плагины», вы увидите, что в Community Edition отсутствует плагин поддержки UML.

ROMANIA_engineer 14 нояб. 2014, в 10:03
Поделиться

Привет, ребята, я использую Intellij 15.0.2, и я хочу просмотреть диаграмму классов моего проекта, однако я не вижу выбора Диаграммы / Показать диаграмму, когда я щелкаю правой кнопкой мыши в пакете или классе. Может кто-нибудь мне помочь?

Ectoras 13 янв. 2016, в 16:02

@Ectoras, я полагаю, что вы используете Community Edition, а не Ultimate. Это не доступно для Community Edition (см. PS: добавлено в посте). Я тестировал его в IntelliJ IDEA 15.0.2 Ultimate, и он работал.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *