use of com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider in project archi by archimatetool.
the class FixDefaultSizesHandler method getDefaultSize.
Dimension getDefaultSize(IDiagramModelObject dmo) {
IBounds bounds = dmo.getBounds();
if (bounds.getWidth() != -1 && bounds.getHeight() != -1) {
return new Dimension(bounds.getWidth(), bounds.getHeight());
}
// Legacy size of ArchiMate figure
if (dmo instanceof IDiagramModelArchimateObject) {
if (!(((IDiagramModelArchimateObject) dmo).getArchimateElement() instanceof IJunction)) {
return new Dimension(120, 55);
}
}
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(dmo);
return provider != null ? provider.getUserDefaultSize() : new Dimension(120, 55);
}
use of com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider in project archi by archimatetool.
the class ArchimateDiagramModelFactory method createDiagramModelArchimateObject.
/**
* Factory method for creating a new IDiagramModelArchimateObject for an IArchimateElement
* @param element
* @return a new IDiagramModelArchimateObject
*/
public static IDiagramModelArchimateObject createDiagramModelArchimateObject(IArchimateElement element) {
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setArchimateElement(element);
// Figure Type
dmo.setType(Preferences.STORE.getInt(IPreferenceConstants.DEFAULT_FIGURE_PREFIX + element.eClass().getName()));
// Add new bounds with a default user size
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(dmo);
Dimension size = provider.getUserDefaultSize();
dmo.setBounds(0, 0, size.width, size.height);
dmo.setTextPosition(ITextPosition.TEXT_POSITION_TOP);
// Set user default colors as set in prefs
ColorFactory.setDefaultColors(dmo);
return dmo;
}
use of com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider in project archi by archimatetool.
the class AbstractDiagramModelObjectFigureTests method testGetDefaultSize.
@Test
public void testGetDefaultSize() {
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(abstractFigure.getDiagramModelObject());
assertEquals(provider.getUserDefaultSize(), abstractFigure.getDefaultSize());
}
use of com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider in project archi by archimatetool.
the class DiagramImageFigureTests method testGetDefaultSize.
@Override
@Test
public void testGetDefaultSize() {
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(figure.getDiagramModelObject());
Dimension defaultSize = provider.getDefaultSize();
assertEquals(defaultSize, figure.getDefaultSize());
// Add image
try {
File file = new File(TestSupport.getTestDataFolder().getPath(), "img/img1.png");
addImage(file);
Image image = getPrivateImageField();
assertEquals(new Dimension(image), figure.getDefaultSize());
} catch (Exception ex) {
ex.printStackTrace();
}
// Reset
dmImage.setImagePath(null);
assertEquals(defaultSize, figure.getDefaultSize());
}
use of com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider in project archi by archimatetool.
the class CreateDiagramObjectCommand method addChild.
protected void addChild() {
fChild = (IDiagramModelObject) fRequest.getNewObject();
// Default size
if (fBounds.width == -1 && fBounds.height == -1) {
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(fChild);
if (provider != null) {
Dimension size = provider.getUserDefaultSize();
fBounds.width = size.width;
fBounds.height = size.height;
}
}
fChild.setBounds(fBounds.x, fBounds.y, fBounds.width, fBounds.height);
redo();
}
Aggregations