Search in sources :

Example 1 with IDiagramModelImage

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);
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IBounds(com.archimatetool.model.IBounds) IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 2 with IDiagramModelImage

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));
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) Test(org.junit.Test)

Example 3 with IDiagramModelImage

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);
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) Image(org.eclipse.swt.graphics.Image) IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) File(java.io.File) Test(org.junit.Test)

Example 4 with IDiagramModelImage

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();
}
Also used : IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) File(java.io.File) Test(org.junit.Test)

Example 5 with IDiagramModelImage

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));
}
Also used : INameable(com.archimatetool.model.INameable) IDiagramModelImage(com.archimatetool.model.IDiagramModelImage) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Aggregations

IDiagramModelImage (com.archimatetool.model.IDiagramModelImage)10 Test (org.junit.Test)9 File (java.io.File)3 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)1 DiagramImageEditPart (com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart)1 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)1 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)1 IBounds (com.archimatetool.model.IBounds)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 INameable (com.archimatetool.model.INameable)1 ISketchModel (com.archimatetool.model.ISketchModel)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 Image (org.eclipse.swt.graphics.Image)1