java – 为类依赖生成图形数据的工具

有没有一些能够分析 Java文件的工具,从中构建图形,并以一些标准/可理解的格式提供图形数据?

它绝对不需要GUI,我更喜欢命令行的东西,所以我可以处理输出的各种工具(分割,可视化,…).

解决方法

我不确定命令行工具,但我喜欢将ObjectAid用于逆向工程到类图中:

http://www.objectaid.com/

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

<?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>

您也可以使用PlantUML,但是反向工程比逆向工程更好:

http://plantuml.sourceforge.net/

PlantUML有其自己独特的语法,您也可以获得源代码,但它并不像ObjectAid那么简单

这两个都作为eclipse插件,对不起,我不知道更多关于任何可能做你所要求的命令行工具.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...