Search in sources :

Example 1 with ICanvasModelSticky

use of com.archimatetool.canvas.model.ICanvasModelSticky in project archi by archimatetool.

the class CanvasModelFactory method getNewObject.

public Object getNewObject() {
    // Create the instance from the registered factory in case of extensions
    Object object = fTemplate.getEPackage().getEFactoryInstance().create(fTemplate);
    // Sticky
    if (object instanceof ICanvasModelSticky) {
        ICanvasModelSticky sticky = (ICanvasModelSticky) object;
        sticky.setTextPosition(ITextPosition.TEXT_POSITION_CENTRE);
        sticky.setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_CENTER);
        if (fParam instanceof Color) {
            String color = ColorFactory.convertColorToString((Color) fParam);
            sticky.setFillColor(color);
        }
        // $NON-NLS-1$
        sticky.setBorderColor("#C0C0C0");
    } else // Block
    if (object instanceof ICanvasModelBlock) {
        ICanvasModelBlock block = (ICanvasModelBlock) object;
        block.setTextPosition(ITextPosition.TEXT_POSITION_TOP);
        block.setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
        // $NON-NLS-1$
        block.setBorderColor("#000000");
    } else // Image
    if (object instanceof ICanvasModelImage) {
        ICanvasModelImage image = (ICanvasModelImage) object;
        // $NON-NLS-1$
        image.setBorderColor("#000000");
    } else // Canvas Connection
    if (object instanceof ICanvasModelConnection) {
        ICanvasModelConnection connection = (ICanvasModelConnection) object;
        if (fParam instanceof Integer) {
            connection.setType((Integer) fParam);
        }
    }
    return object;
}
Also used : ICanvasModelSticky(com.archimatetool.canvas.model.ICanvasModelSticky) ICanvasModelConnection(com.archimatetool.canvas.model.ICanvasModelConnection) Color(org.eclipse.swt.graphics.Color) ICanvasModelBlock(com.archimatetool.canvas.model.ICanvasModelBlock) ICanvasModelImage(com.archimatetool.canvas.model.ICanvasModelImage)

Example 2 with ICanvasModelSticky

use of com.archimatetool.canvas.model.ICanvasModelSticky in project archi by archimatetool.

the class CanvasModelFactoryTests method testGetNewObjectCanvasSticky.

@Test
public void testGetNewObjectCanvasSticky() {
    ICreationFactory factory = new CanvasModelFactory(ICanvasPackage.eINSTANCE.getCanvasModelSticky(), ColorFactory.get(201, 231, 183));
    ICanvasModelSticky sticky = (ICanvasModelSticky) factory.getNewObject();
    assertEquals(ColorFactory.convertColorToString(ColorFactory.get(201, 231, 183)), sticky.getFillColor());
    assertEquals("#C0C0C0", sticky.getBorderColor());
}
Also used : ICanvasModelSticky(com.archimatetool.canvas.model.ICanvasModelSticky) ICreationFactory(com.archimatetool.editor.diagram.ICreationFactory) Test(org.junit.Test)

Example 3 with ICanvasModelSticky

use of com.archimatetool.canvas.model.ICanvasModelSticky in project archi by archimatetool.

the class CanvasModelEditPartFactoryTests method testCanvasStickyEditPart.

@Test
public void testCanvasStickyEditPart() {
    ICanvasModelSticky sticky = ICanvasFactory.eINSTANCE.createCanvasModelSticky();
    EditPart editPart = editPartFactory.createEditPart(null, sticky);
    assertTrue(editPart instanceof CanvasStickyEditPart);
    assertEquals(sticky, editPart.getModel());
}
Also used : ICanvasModelSticky(com.archimatetool.canvas.model.ICanvasModelSticky) DiagramImageEditPart(com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart) DiagramConnectionEditPart(com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) Test(org.junit.Test)

Aggregations

ICanvasModelSticky (com.archimatetool.canvas.model.ICanvasModelSticky)3 Test (org.junit.Test)2 ICanvasModelBlock (com.archimatetool.canvas.model.ICanvasModelBlock)1 ICanvasModelConnection (com.archimatetool.canvas.model.ICanvasModelConnection)1 ICanvasModelImage (com.archimatetool.canvas.model.ICanvasModelImage)1 ICreationFactory (com.archimatetool.editor.diagram.ICreationFactory)1 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 EditPart (org.eclipse.gef.EditPart)1 Color (org.eclipse.swt.graphics.Color)1