use of com.archimatetool.model.IBounds in project archi by archimatetool.
the class ArchimateFactory method createBounds.
public IBounds createBounds(int x, int y, int width, int height) {
Bounds bounds = new Bounds();
bounds.setX(x);
bounds.setY(y);
bounds.setWidth(width);
bounds.setHeight(height);
return bounds;
}
use of com.archimatetool.model.IBounds in project archi by archimatetool.
the class DiagramModelObject method setBounds.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public void setBounds(int x, int y, int width, int height) {
IBounds bounds = IArchimateFactory.eINSTANCE.createBounds(x, y, width, height);
setBounds(bounds);
}
use of com.archimatetool.model.IBounds in project archi by archimatetool.
the class DiagramImageFigureTests method testDiagramImageChangesSize.
@Test
public void testDiagramImageChangesSize() throws Exception {
Image image = getPrivateImageField();
assertNull(image);
// Add image
File file = new File(TestSupport.getTestDataFolder().getPath(), "img/img1.png");
addImage(file);
// Check initial Image size
image = getPrivateImageField();
assertEquals(new Rectangle(0, 0, 1024, 1024), image.getBounds());
// Check correct default size of image
assertEquals(new Dimension(1024, 1024), figure.getDefaultSize());
assertEquals(new Dimension(1024, 1024), figure.getPreferredSize(-1, -1));
// Change size of DiagramModelImage and check it was rescaled
IBounds bounds = IArchimateFactory.eINSTANCE.createBounds(0, 0, 512, 512);
dmImage.setBounds(bounds);
// Layout
editor.layoutPendingUpdates();
// Force a mock repaint since we are not using a GUI
figure.paint(mock(Graphics.class));
// Test image was rescaled
image = getPrivateImageField();
assertEquals(new Rectangle(0, 0, 512, 512), image.getBounds());
}
use of com.archimatetool.model.IBounds in project archi by archimatetool.
the class CopySnapshot method createPasteObject.
private IDiagramModelObject createPasteObject(IDiagramModelContainer container, IDiagramModelObject snapshotObject) {
// Don't paste invalid objects
if (!isValidPasteComponent(fTargetDiagramModel, snapshotObject)) {
return null;
}
IDiagramModelObject pasteObject = (IDiagramModelObject) snapshotObject.getCopy();
createID(pasteObject);
// Offset top level objects if container is diagram
if (container instanceof IDiagramModel) {
IDiagramModelObject originalObject = (IDiagramModelObject) fOriginalToSnapshotComponentsMapping.getKey(snapshotObject);
IBounds bounds = originalObject.getBounds().getCopy();
Point pt = new Point(bounds.getX(), bounds.getY());
translateToAbsolute(originalObject, pt);
bounds.setX(pt.x + fXOffSet);
bounds.setY(pt.y + fYOffSet);
pasteObject.setBounds(bounds);
}
// If Archimate object
if (pasteObject instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) pasteObject;
// Re-use original ArchiMate components
if (!fDoCreateNewArchimateComponents) {
IDiagramModelArchimateObject originalDiagramObject = (IDiagramModelArchimateObject) fOriginalToSnapshotComponentsMapping.getKey(snapshotObject);
IArchimateElement element = originalDiagramObject.getArchimateElement();
dmo.setArchimateElement(element);
}
// Provide new names if required
if (fDoCreateNewArchimateComponents && isSourceAndTargetArchiMateModelSame()) {
String name = dmo.getArchimateElement().getName();
// $NON-NLS-1$
dmo.getArchimateElement().setName(name + " " + Messages.CopySnapshot_1);
}
}
// Add to Mapping
fSnapshotToNewComponentMapping.put(snapshotObject, pasteObject);
// Object is Container, so recurse
if (snapshotObject instanceof IDiagramModelContainer) {
for (IDiagramModelObject child : ((IDiagramModelContainer) snapshotObject).getChildren()) {
IDiagramModelObject dmo = createPasteObject((IDiagramModelContainer) pasteObject, child);
if (dmo != null) {
((IDiagramModelContainer) pasteObject).getChildren().add(dmo);
}
}
}
return pasteObject;
}
use of com.archimatetool.model.IBounds in project archi by archimatetool.
the class DefaultEditPartSizeAction method createDefaultSizeCommand.
private Command createDefaultSizeCommand(List<?> objects) {
CompoundCommand command = new CompoundCommand();
for (Object object : objects) {
if (object instanceof GraphicalEditPart) {
GraphicalEditPart part = (GraphicalEditPart) object;
if (part.getModel() instanceof IDiagramModelObject) {
IDiagramModelObject model = (IDiagramModelObject) part.getModel();
if (model instanceof ILockable && ((ILockable) model).isLocked()) {
continue;
}
IFigure figure = part.getFigure();
if (figure instanceof IDiagramModelObjectFigure) {
Dimension defaultSize = ((IDiagramModelObjectFigure) figure).getDefaultSize();
IBounds bounds = model.getBounds().getCopy();
if (bounds.getWidth() != defaultSize.width || bounds.getHeight() != defaultSize.height) {
bounds.setWidth(defaultSize.width);
bounds.setHeight(defaultSize.height);
Command cmd = new SetConstraintObjectCommand(model, bounds);
command.add(cmd);
}
}
}
}
}
return command.unwrap();
}
Aggregations