When the reader is launched from rules or Java code, you can set options to tweak the reader's behavior.
Map options = new HashMap(); options.put(Options.OPTION_XMI_READ_PROFILES_STANDARDIZED, Boolean.TRUE); Model umlModel =... umlModel.read("Enterprise Architect Application", "", options);
The model reader can be configured.
Options.OPTION_XMI_READ_PROFILES_STANDARDIZED
true
.Options.OPTION_XMI_READ_DIAGRAM_ZOOM
1.0f
.Options.OPTION_XMI_READ_EXTENSIONS
false
.Options.OPTION_XMI_READ_EXTENSIONS_SUBSET
category.propertyKey
.null
.Options.OPTION_APP_XMI_VERSION
EA241
Options.OPTION_APP_XMI_FORMATTED
true
.Options.OPTION_APP_XMI_DTD
false
.Options.OPTION_APP_DIAGRAM_XML_EXPORT
EXPORT
- Export Diagram data.EXPORT_ALONG_ALTERNATE_IMAGES
- Export Diagram data and Diagram images.EXPORT
.Options.OPTION_APP_DIAGRAM_IMAGE_FORMAT
.
Options.OPTION_APP_DIAGRAM_XML_EXPORT
must be set to EXPORT_ALONG_ALTERNATE_IMAGES
.NONE
.import com.sodius.mdw.metamodel.uml21.io.ea.Options; ... Map<String, Object> options = new HashMap<String, Object>(); options.put(Options.OPTION_APP_DIAGRAM_XML_EXPORT, DiagramXMLExport.EXPORT_ALONG_ALTERNATE_IMAGES); options.put(Options.OPTION_APP_DIAGRAM_IMAGE_FORMAT, DiagramImageFormat.PNG); MDWorkbench workbench = MDWorkbenchFactory.create(); Model umlModel = workbench.getMetamodelManager().getMetamodel("uml21").createModel(); umlModel.read("Enterprise Architect Application", "", options); // loop on all diagrams for (Diagram diagram : model.<Diagram>getInstances("Diagram")) { System.out.println("Diagram: " + diagram.getName()); // query the diagram image DiagramFileImage image = (DiagramFileImage) model.getDiagram(diagram, new DiagramOptions()); System.out.println("Image: " + image.getFile()); image.dispose(); } ... umlModel.clear();
Options.OPTION_APP_PACKAGE_SELECTION
Options.OPTION_GRAPH_NODES_HIERARCHY
Options.OPTION_IMPROVE_WAYPOINTS
Diagram Interchange
Profile and Stereotypes
Reading UML Data
Reading Enterprise Architect Data
Reading a Package
Reading Extensions
Managing Ids
MDAccess UML API Reference
MDAccess for MagicDraw API Reference