use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class SketchDNDEditPolicy method getDropCommand.
@Override
protected Command getDropCommand(DiagramDropRequest request) {
if (!(request.getData() instanceof IStructuredSelection)) {
return null;
}
// XY drop point
Point pt = getDropLocation(request);
// Origin
int origin = pt.x;
int x = pt.x;
int y = pt.y;
// Gather an actual list of elements dragged onto the container, omitting duplicates and anything already on the diagram
Object[] objects = ((IStructuredSelection) request.getData()).toArray();
List<IDiagramModel> list = getDiagramRefsToAdd(objects);
// Compound Command
CompoundCommand result = new CompoundCommand(Messages.SketchDNDEditPolicy_0);
for (IDiagramModel diagramModel : list) {
result.add(new AddDiagramModelReferenceCommand(getTargetContainer(), diagramModel, x, y));
x += 150;
if (x > origin + 400) {
x = origin;
y += 100;
}
}
return result;
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramUtilsTests method testCreateImage_Model_Scaled.
@Test
public void testCreateImage_Model_Scaled() {
IDiagramModel dm = model.getDiagramModels().get(2);
// x of furthest object in diagram, and its width
int width = 720 + 193;
// x of furthest object in diagram, and its height
int height = 468 + 85;
Image img = DiagramUtils.createImage(dm, 1, 0);
assertEquals(new Rectangle(0, 0, width, height), img.getBounds());
img.dispose();
img = DiagramUtils.createImage(dm, 0.5, 0);
assertEquals(new Rectangle(0, 0, width / 2, height / 2), img.getBounds());
img.dispose();
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramUtilsTests method testCreateViewer_SketchModel.
@Test
public void testCreateViewer_SketchModel() {
IDiagramModel dm = model.getDiagramModels().get(1);
assertTrue(dm instanceof ISketchModel);
Shell shell = new Shell();
GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
assertNotNull(viewer);
assertTrue(viewer.getEditPartFactory() instanceof SketchEditPartFactory);
assertTrue(viewer.getRootEditPart() instanceof FreeformGraphicalRootEditPart);
assertSame(dm, viewer.getContents().getModel());
assertSame(shell, viewer.getControl().getShell());
shell.dispose();
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramUtilsTests method testCreateImage_GraphicalViewer.
@Test
public void testCreateImage_GraphicalViewer() {
IDiagramModel dm = model.getDiagramModels().get(2);
Shell shell = new Shell();
GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
shell.dispose();
Image img = DiagramUtils.createImage(viewer, 1, 0);
assertNotNull(img);
img.dispose();
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramUtilsTests method testCreateImage_Model_NoChildren.
@Test
public void testCreateImage_Model_NoChildren() {
// This is the blank View
IDiagramModel dm = model.getDiagramModels().get(0);
Image img = DiagramUtils.createImage(dm, 1, 0);
// Blank View is minimum 100 x 100
assertEquals(new Rectangle(0, 0, 100, 100), img.getBounds());
img.dispose();
// Margin will not be used for Blank View
img = DiagramUtils.createImage(dm, 1, 20);
assertEquals(new Rectangle(0, 0, 100, 100), img.getBounds());
img.dispose();
// Margin & Ratio
img = DiagramUtils.createImage(dm, 0.2, 0);
assertEquals(new Rectangle(0, 0, 20, 20), img.getBounds());
img.dispose();
img = DiagramUtils.createImage(dm, 0.5, 10);
assertEquals(new Rectangle(0, 0, 50, 50), img.getBounds());
img.dispose();
}
Aggregations