用于生成类依赖关系的图形数据的工具 [英] tool to generate graph data for class dependencies

查看:125
本文介绍了用于生成类依赖关系的图形数据的工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一些工具可以分析Java源文件,从中构建图表并以某种标准/可理解的格式提供图表数据



它最终不需要GUI,我更喜欢命令行,所以我可以通过各种工具处理输出(用于分段,可视化......)。 / p>

解决方案

我不确定命令行工具,但我喜欢使用ObjectAid对类图进行逆向工程:



http://www.objectaid.com/



您可以轻松地将任何类与它的关系添加到ObjectAid图中。它使用ucls扩展名将文件保存为XML格式。以下是一个示例:

 <?xml version =1.0encoding =UTF-8?> 
< class-diagram version =1.1.4icons =true
always-add-relationships =truegeneralizations =truerealizations =true
associations = truedependencies =truenesting-relationships =true>
< class id =1language =java
name =my.classpath.common.controllers.AuthenticationInterceptor
project =MyProject
file = /SpecialPath/common/controllers/AuthenticationInterceptor.java
binary =falsecorner =BOTTOM_RIGHT>
< position height =205width =355x =2222y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =2language =java
name =my.classpath.common.domain.CompanyAssignmentLocationproject =MyProject
file =/ SpecialPath / common /domain/CompanyAssignmentLocation.java
binary =falsecorner =BOTTOM_RIGHT>
< position height = - 1width = - 1x =856y =399/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =3language =java
name =my.classpath.common.domain.LocationsSpreadsheetReaderproject =MyProject
file =/ SpecialPath / common /domain/LocationsSpreadsheetReader.java
binary =falsecorner =BOTTOM_RIGHT>
< position height =115width =348x =680y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =4language =javaname =my.classpath.common.domain.Stock
project =MyProjectfile =/ SpecialPath / common / domain / stock .java
binary =falsecorner =BOTTOM_RIGHT>
< position height =439width =210x =430y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =5language =javaname =my.classpath.common.util.FilesUtil
project =MyProjectfile =/ SpecialPath / common / util / FilesUtil .java
binary =falsecorner =BOTTOM_RIGHT>
< position height =277width =218x =1409y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =6language =javaname =my.classpath.common.util.MyProjectUtil
project =MyProjectfile =/ SpecialPath / common / util / MyProjectUtil .java
binary =falsecorner =BOTTOM_RIGHT>
< position height =439width =349x =41y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =7language =javaname =my.classpath.common.util.SpringUtil
project =MyProjectfile =/ SpecialPath / common / util / SpringUtil .java
binary =falsecorner =BOTTOM_RIGHT>
< position height =133width =246x =1936y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =8language =java
name =my.classpath.common.util.MyProjectUserUtilproject =MyProject
file =/ SpecialPath / common /util/MyProjectUserUtil.javabinary =false
corner =BOTTOM_RIGHT>
< position height =133width =229x =1667y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< class id =9language =javaname =my.classpath.common.util.UnitConversion
project =MyProjectfile =/ SpecialPath / common / util / UnitConversion .java
binary =falsecorner =BOTTOM_RIGHT>
< position height =151width =301x =1068y =37/>
< display autosize =truestereotype =truepackage =true
initial-value =falsesignature =trueaccessors =truevisibility =true>
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / display>
< / class>
< dependency id =10>
< end type =SOURCErefId =3/>
< end type =TARGETrefId =2/>
< / dependency>
< classifier-display autosize =truestereotype =true
package =trueinitial-value =falsesignature =trueaccessors =true
visibility = 真 >
< attributes public =truepackage =trueprotected =true
private =truestatic =true/>
< operations public =truepackage =trueprotected =true
private =truestatic =true/>
< / classifier-display>
< association-display labels =truemultiplicity =true/>
< / class-diagram>

您也可以使用PlantUML,但它对于正向工程比逆向工程更好:



http://plantuml.sourceforge.net/



PlantUML也有自己独特的语法,你也可以获得它的来源 - 但它并不像ObjectAid那样容易结合



<这两个都作为eclipse插件工作,很抱歉,我不知道任何可能能够做你所要求的命令行工具。


Is there some tool that is able to analyze Java source files, construct a graph from it and provide the graph's data in some standard / understandable format ?

It definitively does not need to have GUI, I'd prefer a command line thing so I can process the output by various tools (for segmentation, visualization,...).

解决方案

I'm not certain about command line tools, but I like using ObjectAid for reverse engineering into class diagrams:

http://www.objectaid.com/

You can easily add any class with it's relationships to an ObjectAid graph. It saves the file in an XML format with the ucls extension. Here's a sample:

<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.4" icons="true"
always-add-relationships="true" generalizations="true" realizations="true"
associations="true" dependencies="true" nesting-relationships="true">
<class id="1" language="java"
    name="my.classpath.common.controllers.AuthenticationInterceptor"
    project="MyProject"
    file="/SpecialPath/common/controllers/AuthenticationInterceptor.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="205" width="355" x="2222" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="2" language="java"
    name="my.classpath.common.domain.CompanyAssignmentLocation" project="MyProject"
    file="/SpecialPath/common/domain/CompanyAssignmentLocation.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="-1" width="-1" x="856" y="399" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="3" language="java"
    name="my.classpath.common.domain.LocationsSpreadsheetReader" project="MyProject"
    file="/SpecialPath/common/domain/LocationsSpreadsheetReader.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="115" width="348" x="680" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="4" language="java" name="my.classpath.common.domain.Stock"
    project="MyProject" file="/SpecialPath/common/domain/Stock.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="439" width="210" x="430" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="5" language="java" name="my.classpath.common.util.FilesUtil"
    project="MyProject" file="/SpecialPath/common/util/FilesUtil.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="277" width="218" x="1409" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="6" language="java" name="my.classpath.common.util.MyProjectUtil"
    project="MyProject" file="/SpecialPath/common/util/MyProjectUtil.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="439" width="349" x="41" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="7" language="java" name="my.classpath.common.util.SpringUtil"
    project="MyProject" file="/SpecialPath/common/util/SpringUtil.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="133" width="246" x="1936" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="8" language="java"
name="my.classpath.common.util.MyProjectUserUtil" project="MyProject"
file="/SpecialPath/common/util/MyProjectUserUtil.java" binary="false"
corner="BOTTOM_RIGHT">
    <position height="133" width="229" x="1667" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<class id="9" language="java" name="my.classpath.common.util.UnitConversion"
    project="MyProject" file="/SpecialPath/common/util/UnitConversion.java"
    binary="false" corner="BOTTOM_RIGHT">
    <position height="151" width="301" x="1068" y="37" />
    <display autosize="true" stereotype="true" package="true"
        initial-value="false" signature="true" accessors="true" visibility="true">
        <attributes public="true" package="true" protected="true"
            private="true" static="true" />
        <operations public="true" package="true" protected="true"
            private="true" static="true" />
    </display>
</class>
<dependency id="10">
    <end type="SOURCE" refId="3" />
    <end type="TARGET" refId="2" />
</dependency>
<classifier-display autosize="true" stereotype="true"
    package="true" initial-value="false" signature="true" accessors="true"
    visibility="true">
    <attributes public="true" package="true" protected="true"
        private="true" static="true" />
    <operations public="true" package="true" protected="true"
        private="true" static="true" />
</classifier-display>
    <association-display labels="true" multiplicity="true" />
</class-diagram>

You can also use PlantUML, but it's better for forward engineering than reverse engineering:

http://plantuml.sourceforge.net/

PlantUML has its own unique syntax that you can get source for, too - but it's not nearly as easy to pull together as ObjectAid

Both of these work as eclipse plug-ins, sorry that I don't know more about any command line tools that might be able to do what you're asking.

这篇关于用于生成类依赖关系的图形数据的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆