您的位置:首页 > 编程语言 > Java开发

Atitit.uml2 api 的编程代码实现设计uml开发 使用eclipse jar java 版本

2016-01-12 00:17 1006 查看
Atitit.uml2 api 的编程代码实现设计uml开发 使用eclipse jar java 版本

 

 

1. clipse提供了UML的底层Java包,
1

2. MDTUML2Getting Started with UML21

3. 要使用的jar2

4. 矢量绘图系统 java2

5. JpGraph 3.0.72

6. Code4

7. Ref8

 

 

 

1. clipse提供了UML的底层Java包,

就是说用纯代码可以构建一个UML模型,当构建完之后需要保存到磁盘上以备以后使用,该UML模型是以XML格式存放在磁盘上的,这篇文章正式演示了这个用纯UML的底层API创建UML模型的。

 

 

2. MDTUML2Getting Started with UML2

1. Contents
1. Summary
1. Prerequisites
2. Introduction
3. Getting Started
4. Creating Models
5. Creating Packages
6. Creating Primitive Types
7. Creating Enumerations
8. Creating Enumeration Literals
9. Creating Classes
10. Creating Generalizations
11. Creating Attributes
12. Creating Associations
13. Saving Models
14. Conclusion
15. References
 
 
["E:\\jar2\\org.eclipse.emf.ecore_2.10.1.v20140901-1043.jar//org.eclipse.emf.ecore.resource.ResourceSet.class",
"E:\\jar2\\org.eclipse.emf.ecore_2.10.2.v20150123-0348.jar//org.eclipse.emf.ecore.resource.ResourceSet.class","
E:\\jar2\\org.eclipse.emf.ecore_2.9.1.v20130827-0309 (2).jar//org.eclipse.emf.ecore.resource.ResourceSet.class",
"E:\\jar2\\org.eclipse.emf.ecore_2.9.1.v20130827-0309 (3).jar//org.eclipse.emf.ecore.resource.ResourceSet.class",
"E:\\jar2\\org.eclipse.emf.ecore_2.9.1.v20130827-0309.jar//org.eclipse.emf.ecore.resource.ResourceSet.class","
E:\\jar2\\sdk-common.jar//com.android.ide.common.res2.ResourceSet.class"]
--f
 

3. 要使用的jar

Elcipse哈面儿的emf,gef,uml关键字的jar

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax akbar al rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

4. 矢量绘图系统 java

5. JpGraph 3.0.7

JpGraph专门提供图表的类库。它使得作图变成了一件非常简单的事情,你只需从数据库中取出相关数据,定义标题,图表类型,然后的事情就交给JpGraph,只需掌握为数不多的JpGraph内置函数(可以参照JpGraph附带例子学习),就可以画出非常炫目的图表!
 

 

 

 

Graphical Editor Framework (GEF)
       GEF允许开发者使用已有的应用模型简便的开发出一个图形化编辑器。GEF可以使开发者快速的将现有的模型移植到一个图形化编辑的环境中。这个图形化环境是基于SWT的绘图插件“draw2d”。GEF是基于MVC框架的,他可以使开发者方便的实现drop/drag、undo/redo、move、delete、resize等图形编辑器的基本功能。GEF非常适合用于开发流程编辑器、GUI Builder、UML图编辑器、workflow编辑器、甚至是像html这种所见即所得的文本编辑器。但是需要注意的是GEF开发的软件必须工作与Eclipse环境下,即作为plug-in程序,如果希望脱离Eclipse平台作为独立软件运行,可以参考Eclipse 3系列正在开发的rich client platform(RCP)。结合GEF和RCP就可以开发出运行与Eclipse平台外的图形编辑器。
     

EMF(Eclipse Model Framework)
      Eclipse Modeling Framework旨在提供一种简便设计和实现结构化模型的框架,emf提供代码生成工具以使得开发者可以把精力集中在模型本身而不是它的实现细节上,这个框架根本的概念是:元数据(meta-data),代码生成(code generation),默认序列化(dafault serialization)
      emf项目的最初目的是实现omg(Object Management Group)的一个元对象工具。同时emf是Ecilpse系列工具目前对mda的部分实现。
      emf可以用于描述和建立模型,在这些定义的基础上java code可以被自动生成,这些实现的模型则可以被作为任何java程序开发的基础。这就是emf所要解决的问题。
      目前为止emf只是mda部分实现,所以它不包括用于混合xml,eai,ejbs,web services等技术的企业级应用所需的map。

 

EMF(Eclipse Modelling Framework)是Eclipse MDA(Model Driven Architecture)的重要组成部分,可以将模型转换成高效的,正确的,易于定制的Java代码。

GMF(Graphical Modeling Framework )

The Eclipse Graphical Modeling Framework (GMF) provides a generative component and runtime infrastructure for developing graphical editors based on EMF and GEF.

 

 

GEF, 全称: Graphical Editor Framework, 它是一套图像编辑框架, 用于开发图形应用, 如果你在Eclipse中使用过基于图形设计的应用, 例如UML建模, 可视化软件界面设计(VE)等, 它们基本上都是基于GEF而开发出来的.

大部分GEF应用都是跟EMF合作完成的, EMF可以生成图形模型和源代码, 通过建立规则来对图形应用进行约束, 使其简化了开发.... 但由于毕竟GEF和EMF是两个独立的项目, 他们之间冗余的东西也不少, 因此Eclipse人为了使它们更好地应用到程序中, 开发了GMF(Graphical Modeling Framework)框架, 这个在The Eclipse Technology Project中可以找到. 

 

6. Code

package umlPrj;
 
import java.io.IOException;
 
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.PrimitiveType;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.eclipse.uml2.uml.resources.util.UMLResourcesUtil;
import org.eclipse.emf.common.util.URI;
 
public class umlTest {
 
public static void main(String[] args) {
 
Model epo2Model = createModel("epo2");
 
org.eclipse.uml2.uml.Package barPackage = UMLFactory.eINSTANCE
.createPackage();
// PrimitiveType intPrimitiveType = createPrimitiveType(epo2Model,
// "int");
org.eclipse.uml2.uml.Class supplierClass = createClass(epo2Model,
"Supplier", false);
// createAttribute(supplierClass, "name", PrimitiveType, 0, 1);
 String fileExtension = UMLResource.FILE_EXTENSION;//zosh .uml
String f = "";//args[0];
f="attilaxUmlOutputFolder";
save(epo2Model, URI.createFileURI(f).appendSegment("UmlFileMainname").appendFileExtension(fileExtension)); 
 
}
 
protected static Model createModel(String name) {
Model model = UMLFactory.eINSTANCE.createModel();
model.setName(name);
 
out("Model '" + model.getQualifiedName() + "' created.");
 
return model;
}
 
private static void out(String string) {
System.out.println(string);
 
}
 
protected static org.eclipse.uml2.uml.Package createPackage(
org.eclipse.uml2.uml.Package nestingPackage, String name) {
org.eclipse.uml2.uml.Package package_ = nestingPackage
.createNestedPackage(name);
 
out("Package '" + package_.getQualifiedName() + "' created.");
 
return package_;
}
 
protected static PrimitiveType createPrimitiveType(
org.eclipse.uml2.uml.Package package_, String name) {
PrimitiveType primitiveType = (PrimitiveType) package_
.createOwnedPrimitiveType(name);
 
out("Primitive type '" + primitiveType.getQualifiedName()
+ "' created.");
 
return primitiveType;
}
 
protected static org.eclipse.uml2.uml.Class createClass(
org.eclipse.uml2.uml.Package package_, String name,
boolean isAbstract) {
org.eclipse.uml2.uml.Class class_ = package_.createOwnedClass(name,
isAbstract);
 
out("Class '" + class_.getQualifiedName() + "' created.");
 
return class_;
}
 
protected static Property createAttribute(
org.eclipse.uml2.uml.Class class_, String name, Type type,
int lowerBound, int upperBound) {
Property attribute = class_.createOwnedAttribute(name, type,
lowerBound, upperBound);
 
out("Attribute '%s' : %s [%s..%s] created.", //
attribute.getQualifiedName(), // attribute name
type.getQualifiedName(), // type name
lowerBound, // no special case for multiplicity lower bound
(upperBound == LiteralUnlimitedNatural.UNLIMITED) ? "*" // special
// case
// for
// unlimited
// bound
: upperBound);
 
return attribute;
}
 
private static void out(String string, String qualifiedName,
String qualifiedName2, int lowerBound, Object object) {
// TODO Auto-generated method stub
 
}
 
protected static void save(org.eclipse.uml2.uml.Package package_, URI uri) {
// Create a resource-set to contain the resource(s) that we are saving
ResourceSet resourceSet = new ResourceSetImpl();
 
// Initialize registrations of resource factories, library models,
// profiles, Ecore metadata, and other dependencies required for
// serializing and working with UML resources. This is only necessary in
// applications that are not hosted in the Eclipse platform run-time, in
// which case these registrations are discovered automatically from
// Eclipse extension points.
UMLResourcesUtil.init(resourceSet);
 
// Create the output resource and add our model package to it.
 
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(package_);
 
// And save
try {
resource.save(null); // no save options needed
out("Done.");
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
 
private static void err(String message) {
// TODO Auto-generated method stub
 
}
}
 

7. Ref

 

MDT UML2 Getting Started with UML2及我自己的一些理解 - xiaogugood的专栏 - 博客频道 - CSDN.NET.htm

使用 UML API 編輯 UML 循序圖.htm

使用 UML API 编辑 UML 序列图.htm

MDT UML2 Getting Started with UML2 - Eclipsepedia.htm

UML建模工具开发实践_图文_百度文库.htm

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: