简体   繁体   English

从图模型生成Java代码

[英]Generate Java code from a diagram model

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). 我已经准备好模型类(两个基本类: NodeConnection +特殊情况的子类)。 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 (ie 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? 我想知道是否有一个工具(Eclipse插件或其他工具)可以与我的模型类一起使用(即节点类型,连接类型),使用它以图形方式“绘制”图(制作节点和连接),然后生成图的代码?

Model classes: 模型类别:
Node : contains List<Connection> of all connections FROM this node Node :包含此节点所有连接的List<Connection>
Connection : Node from , Node to ConnectionNode fromNode 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. 编辑:我想生成一个方法,该方法初始化所有需要的节点和连接( NodeConnection对象)并返回head / start节点。 This in-memory structure is then traversed by the application when it makes decisions. 然后,应用程序在进行决策时会遍历此内存结构。

Sounds a bit like you want something like jgraph? 听起来有点像您想要jgraph之类的东西? http://www.jgraph.com/jgraph.html http://www.jgraph.com/jgraph.html

Did you try AndroMDA 您尝试过AndroMDA

AndroMDA (pronounced: andromeda) is an open source code generation framework that follows the Model Driven Architecture (MDA) paradigm. AndroMDA(发音:andromeda)是一个遵循模型驱动架构(MDA)范例的开源代码生成框架。 It takes model(s) from CASE-tool(s) and generates fully deployable applications and other components. 它从CASE工具中获取模型,并生成完全可部署的应用程序和其他组件。

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. 如果您可以使用一些UML工具创建图形(不确定这样做有多容易),AndroMDA可以为您生成Java代码。

It supports many UML tools including some free tools. 它支持许多UML工具,包括一些免费工具。

Tale a look on Velocity . 讲述一下Velocity It is widely used for code generation. 它被广泛用于代码生成。

You might like graphviz . 您可能喜欢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.. :) FTW:我已经广泛地将它用于类层次结构,交互流描述,思维导图.. :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM