码迷,mamicode.com
首页 > 编程语言 > 详细

How to generate UML Diagrams from Java code in Eclipse

时间:2014-04-30 03:48:50      阅读:716      评论:0      收藏:0      [点我收藏+]

标签:des   com   http   blog   class   div   img   code   java   log   tar   

UML diagrams compliment inline documentation ( javadoc ) and allow to better explore / understand a design. Moreover, you can print and bring them to table to discuss a design.

In this post, we will install and use the ObjectAid plugin for Eclipse to produce jUnit lib class diagrams. Then, we will be able to generate UML diagrams by simply dragging and dropping classes into the editor. We can further manipulate the diagram by selecting which references, operations or attributes to display.  

  • Open Eclipse and go to Help > Install New Software
  • Click on add to add a new repository
  • Enter name ObjectAid UML Explorer
  • Enter Location http://www.objectaid.net/update
mamicode.com,码迷


Next, select the ObjectAid Class Diagram plugin - it is free - and click Next. The Sequence Diagram one requires a paid license.

mamicode.com,码迷


Click Finish to confirm your choices and start the instalation process.

  • Click Ok on the security warning
  • Select Restart Now after the installation completes to restart Eclipse.
mamicode.com,码迷


To create a new UML diagram we start the ObjectAid wizard with File > New > Other... and start typing in the textbox Class Diagram to filter the desired wizard. Click Next, and enter a directory and name for the diagram.

mamicode.com,码迷


Drop java source or compiled class files into the visual UML editor to start populating the diagram. Right click on a generated class to bring up a context menu and adjust visibility, operations attributes, etc as you like.
Below, we see the Assert class from the jUnit library with all operations and fileds hidden.

 
mamicode.com,码迷


From the context menu, we can add implementations and associations for a selected class. In the following screen, we add the interface Test implemented by the TestCase class.

mamicode.com,码迷


This is how part of the jUnit UML class diagram look after adding some more classes.

mamicode.com,码迷


To auto layout the diagram right click anywhere within the editor and select Layout Diagram. From the same menu, you can export the diagram to an image ( gif png jpeg ) by clicking the Save As Image... menu item

mamicode.com,码迷

How to generate UML Diagrams from Java code in Eclipse,码迷,mamicode.com

How to generate UML Diagrams from Java code in Eclipse

标签:des   com   http   blog   class   div   img   code   java   log   tar   

原文地址:http://www.cnblogs.com/bruceyo/p/3695801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!