use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class ArchimateDiagramModelFactory method getNewObject.
public Object getNewObject() {
if (fTemplate == null) {
return null;
}
Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
// Connection created from Relationship Template
if (object instanceof IArchimateRelationship) {
return createDiagramModelArchimateConnection((IArchimateRelationship) object);
} else // Archimate Diagram Object created from Archimate Element Template
if (object instanceof IArchimateElement) {
IArchimateElement element = (IArchimateElement) object;
element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
return createDiagramModelArchimateObject(element);
} else // Group
if (object instanceof IDiagramModelGroup) {
IDiagramModelGroup group = (IDiagramModelGroup) object;
group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
ColorFactory.setDefaultColors(group);
((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
} else // Note
if (object instanceof IDiagramModelNote) {
ColorFactory.setDefaultColors((IDiagramModelObject) object);
((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
} else // Connection
if (object instanceof IDiagramModelConnection) {
ColorFactory.setDefaultColors((IDiagramModelConnection) object);
}
return object;
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class SendBackwardAction method createCommand.
private Command createCommand(List<?> selection) {
GraphicalViewer viewer = getWorkbenchPart().getAdapter(GraphicalViewer.class);
CompoundCommand result = new CompoundCommand(TEXT);
for (Object object : selection) {
if (object instanceof GraphicalEditPart) {
GraphicalEditPart editPart = (GraphicalEditPart) object;
Object model = editPart.getModel();
// This can happen if we do things wrong
if (viewer != editPart.getViewer()) {
// $NON-NLS-1$
System.err.println("Wrong selection for Viewer in " + getClass());
}
// Locked
if (model instanceof ILockable && ((ILockable) model).isLocked()) {
continue;
}
if (model instanceof IDiagramModelObject) {
IDiagramModelObject diagramObject = (IDiagramModelObject) model;
IDiagramModelContainer parent = (IDiagramModelContainer) diagramObject.eContainer();
/*
* Parent can be null when objects are selected (with marquee tool) and transferred from one container
* to another and the Diagram Editor updates the enablement state of Actions.
*/
if (parent == null) {
continue;
}
int originalPos = parent.getChildren().indexOf(diagramObject);
if (originalPos > 0) {
result.add(new SendBackwardCommand(parent, originalPos));
}
}
}
}
return result.unwrap();
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class HTMLReportExporter method writeDiagrams.
/**
* Write diagrams
*/
private void writeDiagrams(File imagesFolder, File viewsFolder, ST stFrame) throws IOException {
if (fModel.getDiagramModels().isEmpty()) {
return;
}
// Save images
saveImages(imagesFolder);
for (IDiagramModel dm : fModel.getDiagramModels()) {
// Add the necessary bounds in order to get correct absolute coordinates for the elements in the generated image
Rectangle bounds = diagramBoundsMap.get(dm);
// process the children
for (IDiagramModelObject dmo : dm.getChildren()) {
addNewBounds(dmo, bounds.x * -1, bounds.y * -1);
}
// $NON-NLS-1$
File viewF = new File(viewsFolder, dm.getId() + ".html");
// $NON-NLS-1$
OutputStreamWriter viewW = new OutputStreamWriter(new FileOutputStream(viewF), "UTF8");
// $NON-NLS-1$
stFrame.remove("element");
// $NON-NLS-1$
stFrame.add("element", dm);
// $NON-NLS-1$
stFrame.remove("map");
// $NON-NLS-1$
stFrame.add("map", childBoundsMap);
viewW.write(stFrame.render());
viewW.close();
}
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class HTMLReportExporter method addNewBounds.
/**
* Add new bounds for each diagram object in relation to its parent offset x,y
*/
private void addNewBounds(IDiagramModelObject dmo, int offsetX, int offsetY) {
// Add new bounds caled to device zoom
BoundsWithAbsolutePosition newBounds = new BoundsWithAbsolutePosition(dmo.getBounds(), ImageFactory.getDeviceZoom() / 100);
// Add offset
newBounds.setOffset(offsetX, offsetY);
childBoundsMap.put(dmo.getId(), newBounds);
// Children
if (dmo instanceof IDiagramModelArchimateObject || dmo instanceof IDiagramModelGroup) {
for (IDiagramModelObject child : ((IDiagramModelContainer) dmo).getChildren()) {
addNewBounds(child, newBounds.getX1(), newBounds.getY1());
}
}
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DiagramModelObject method getCopy.
@Override
public EObject getCopy() {
IDiagramModelObject newObject = (IDiagramModelObject) super.getCopy();
newObject.getSourceConnections().clear();
newObject.getTargetConnections().clear();
return newObject;
}
Aggregations