Intellij Idea 高级用法之使用UML类图插件

idea (38) 2023-03-24 22:20

大家好,我是编程小6,很高兴遇见你,有问题可以及时留言哦。

一、检查UML类图插件是否开启

idea默认已经集成了该功能,只是默认没打开,我们要手动打开它,参考下图:

File——Settings——Plugins——UML Support:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第1张

 

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第2张

 

确认UML 这个勾已经勾上了,然后点击Apply,重启idea,然后您就可以使用该功能了,当然你可以自己个爽,但推荐你继续往下看,你会更爽

二、详细使用

你有以下方式来使用UML类图:

1)在类的内部,点击右键,选择 Diagrams——Show Diagram

2)在左侧栏中选择某一个类,点击右键,选择 Diagrams——Show Diagram

3)你甚至可以选择一个包,再点击右键,选择 Diagrams——Show Diagram(接下来的演示,我们就是通过选择一个包)

注释:show 和 show ... Popup的区别,只是前者新建在标签页内,后者以浮窗的形式展示:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第3张

 

结果图:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第4张

 

1、依次展开各个包下的所有节点

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第5张

 

结果图:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第6张

 

2、调整布局

布局功能按钮十分常用,当你应用某项功能时,图形可能你会发生变化,此时就可以显示以下命令的威力了

1)适配当前窗口

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第7张

 

2)回到真实大小

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第8张

 

3)按当前布局刷新页面

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第9张

 

4)调整布局样式

右键——Layout——选择你自己喜欢的展现样式

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第10张

 

3、查看类的依赖关系

右键——选择Show Dependencies

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第11张

 

此时,你发现界面很乱,线的关系也很乱,此时你可以综合使用调整布局的相关命令了

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第12张

 

注释:

继承关系:蓝色实线箭头

接口实现关系:绿色虚线箭头

4、去掉不关心的类

通过第3步,你发现类太多了,图形太大了我们根本理不清了,此时,我们可以手动删除我们不关心的类

点击选择你想要删除的类,然后直接使用键盘上的delete键就行了。清理后的类关系图如下:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第13张

 

我们仅保留了一个控制器的类关系图

5、查看类的详细信息

右键——Show Categories:可以选择Fields、Constructors、Methods、Properties

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第14张

 

结果图:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第15张

 

有人说,诶,这怎么够呢,那继承下来的那些方法我也想看啊?简单,IDEA通通满足你。

什么,方法里你还想筛选,比如说想看protected权限及以上范围的?简单,右键选择 Change Visibility Level,根据需要调整即可。

也可以调整类的显示级别:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第16张

 

6、手动加入 其它 类到现有类图中

在页面点击右键,选择 Add Class to Diagram或者直接按下空格,然后输入你想加入的类就可以了:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第17张

 

7、查看类的实现/继承/父类

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第18张

 

结果图:

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第19张

 

8、查看类的具体代码

Intellij Idea 高级用法之使用UML类图插件_https://bianchenghao6.com/blog_idea_第20张

 

9、放大镜功能

按住键盘的Alt,可以调出放大镜功能,惊不惊喜,意不意外!!!

 

转:www.toutiao.com/i6589439160…

发表回复