开发者

Generate Java code from a diagram model

开发者 https://www.devze.com 2023-02-11 05:14 出处:网络
In my application, I model a decision diagram (nodes+connections). I have model classes ready (two basic classes: Node and Connection + subclasses for special cases). This diagram gets very big and ke

In my application, I model a decision diagram (nodes+connections). I have model classes ready (two basic classes: Node and Connection + subclasses for special cases). This diagram gets very big and keeping track of all the connections and nodes only through code is not easy (and take into account future maintenance). I was wondering if there's a tool (Eclipse plugin or other) that I could feed with my model classes (i.e. types of nodes, types of connections), use it to "draw" the diagram graphically (making nodes and connections) and then generate the code of the diagram?

Model classes:

Node: contains List<Connection> of all connections FROM this node

Connection: Node from, Node to

EDIT: I want to generate a method that initializes all the needed nodes and connections (Node and Connection objects) and returns the head/start node. This in-memory struc开发者_JS百科ture is then traversed by the application when it makes decisions.


Sounds a bit like you want something like jgraph? http://www.jgraph.com/jgraph.html


Did you try AndroMDA

AndroMDA (pronounced: andromeda) is an open source code generation framework that follows the Model Driven Architecture (MDA) paradigm. It takes model(s) from CASE-tool(s) and generates fully deployable applications and other components.

If you can create your graph using some UML tools(not sure how easy that would be) AndroMDA can generate the java code for you.

It supports many UML tools including some free tools.


Tale a look on Velocity. It is widely used for code generation.


You might like graphviz. It is very easy to build a directional graph diagram in that application. There are several wrapper libraries to help integrating it if you want to do that. Or if you just want to feed the graph and generate a picture, this is very straightforward. Check out the examples here. FTW: I have used this extensively for class hierarchies, interaction flow description, mind maps.. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消