Java – a tool for generating graphical data for class dependencies

Are there any tools that can analyze java source files, build graphics from them, and provide graphics data in some standard / understandable format?

It absolutely doesn't need GUI. I prefer command-line things, so I can deal with various tools for output (segmentation, visualization,...)

Solution

I'm not sure about command line tools, but I like to reverse engineer objectaid into class diagrams:

http://www.objectaid.com/

You can easily add any class and its relationship to the objectaid diagram It uses the ucls extension to save the file in XML format Here is an example:

<?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 reverse engineering is better than reverse engineering:

http://plantuml.sourceforge.net/

Plantuml has its own unique syntax, and you can get the source code, but it is not as simple as objectaid

Both are eclipse plug-ins. Sorry, I don't know more about any command line tool that may do what you require

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>