use of com.archimatetool.model.IDiagramModelImage in project archi by archimatetool.
the class FixDefaultSizesHandler method fixMissingWidthAndHeight.
/**
* Fix missing width and height values
*/
void fixMissingWidthAndHeight(IArchimateModel model) {
for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
// However, here, Images with -1, -1 would be converted to a default box size of 200, 150. So ignore it.
if (eObject instanceof IDiagramModelImage) {
continue;
}
if (eObject instanceof IDiagramModelObject) {
IDiagramModelObject dmo = (IDiagramModelObject) eObject;
Dimension d = getNewSize(dmo);
IBounds bounds = dmo.getBounds();
bounds.setWidth(d.width);
bounds.setHeight(d.height);
}
}
}
use of com.archimatetool.model.IDiagramModelImage in project archi by archimatetool.
the class ArchiveManagerTests method testGetImagePaths.
@Test
public void testGetImagePaths() {
assertTrue(archiveManager.getImagePaths().isEmpty());
IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
dm.getChildren().add(dmImage);
String pathName = "/aPath.png";
dmImage.setImagePath(pathName);
assertEquals(pathName, archiveManager.getImagePaths().get(0));
}
use of com.archimatetool.model.IDiagramModelImage in project archi by archimatetool.
the class ArchiveManagerTests method testCreateImage.
@Test
public void testCreateImage() throws Exception {
IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
dm.getChildren().add(dmImage);
File imgFile = new File(TestSupport.getTestDataFolder(), "/img/img1.png");
String pathName = archiveManager.addImageFromFile(imgFile);
Image image = archiveManager.createImage(pathName);
assertNotNull(image);
}
use of com.archimatetool.model.IDiagramModelImage in project archi by archimatetool.
the class ArchiveManagerTests method testSaveModel.
@Test
public void testSaveModel() throws IOException {
IDiagramModelImage dmImage = IArchimateFactory.eINSTANCE.createDiagramModelImage();
dm.getChildren().add(dmImage);
File file = TestUtils.createTempFile(".archimate");
model.setFile(file);
archiveManager.saveModel();
// Not an archive file
assertTrue(file.exists());
assertFalse(IArchiveManager.FACTORY.isArchiveFile(file));
// Is an archive file
archiveManager.loadImagesFromModelFile(TestSupport.TEST_MODEL_FILE_ZIPPED);
dmImage.setImagePath(archiveManager.getLoadedImagePaths().get(0));
archiveManager.saveModel();
assertTrue(IArchiveManager.FACTORY.isArchiveFile(file));
file.delete();
}
use of com.archimatetool.model.IDiagramModelImage in project archi by archimatetool.
the class ArchiLabelProviderTests method testGetLabel.
@Test
public void testGetLabel() {
// Null object
assertEquals("", ArchiLabelProvider.INSTANCE.getLabel(null));
// Any object
assertEquals("", ArchiLabelProvider.INSTANCE.getLabel(""));
// Nameable
INameable nameable = IArchimateFactory.eINSTANCE.createBusinessActor();
nameable.setName("Hello");
assertEquals("Hello", ArchiLabelProvider.INSTANCE.getLabel(nameable));
// View
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
assertEquals("View", ArchiLabelProvider.INSTANCE.getLabel(dm));
// Sketch
ISketchModel sm = IArchimateFactory.eINSTANCE.createSketchModel();
assertEquals("Sketch", ArchiLabelProvider.INSTANCE.getLabel(sm));
// Image
IDiagramModelImage di = IArchimateFactory.eINSTANCE.createDiagramModelImage();
assertEquals("Image", ArchiLabelProvider.INSTANCE.getLabel(di));
}
Aggregations