use of com.archimatetool.editor.diagram.figures.IDiagramModelObjectFigure in project archi by archimatetool.
the class AbstractBaseEditPart method createFigure.
@Override
protected IFigure createFigure() {
/*
* Create a Figure from the given class
*/
IDiagramModelObjectFigure figure = null;
if (figureClass != null) {
try {
figure = (IDiagramModelObjectFigure) figureClass.newInstance();
figure.setDiagramModelObject(getModel());
} catch (Exception ex) {
ex.printStackTrace();
}
}
return figure;
}
use of com.archimatetool.editor.diagram.figures.IDiagramModelObjectFigure in project archi by archimatetool.
the class DefaultEditPartSizeAction method createDefaultSizeCommand.
private Command createDefaultSizeCommand(List<?> objects) {
CompoundCommand command = new CompoundCommand();
for (Object object : objects) {
if (object instanceof GraphicalEditPart) {
GraphicalEditPart part = (GraphicalEditPart) object;
if (part.getModel() instanceof IDiagramModelObject) {
IDiagramModelObject model = (IDiagramModelObject) part.getModel();
if (model instanceof ILockable && ((ILockable) model).isLocked()) {
continue;
}
IFigure figure = part.getFigure();
if (figure instanceof IDiagramModelObjectFigure) {
Dimension defaultSize = ((IDiagramModelObjectFigure) figure).getDefaultSize();
IBounds bounds = model.getBounds().getCopy();
if (bounds.getWidth() != defaultSize.width || bounds.getHeight() != defaultSize.height) {
bounds.setWidth(defaultSize.width);
bounds.setHeight(defaultSize.height);
Command cmd = new SetConstraintObjectCommand(model, bounds);
command.add(cmd);
}
}
}
}
}
return command.unwrap();
}
use of com.archimatetool.editor.diagram.figures.IDiagramModelObjectFigure in project archi by archimatetool.
the class FigureImagePreviewFactory method getPreviewImage.
private static Image getPreviewImage(IArchimateElementUIProvider provider, int type) {
EClass eClass = provider.providerFor();
String key = eClass.getName() + type;
Image image = imageRegistry.get(key);
if (image == null) {
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setArchimateElement((IArchimateElement) IArchimateFactory.eINSTANCE.create(eClass));
dmo.setName(provider.getDefaultName());
dmo.setTextPosition(ITextPosition.TEXT_POSITION_TOP);
ColorFactory.setDefaultColors(dmo);
dmo.setType(type);
provider.setInstance(dmo);
GraphicalEditPart editPart = (GraphicalEditPart) provider.createEditPart();
editPart.setModel(dmo);
IDiagramModelObjectFigure figure = (IDiagramModelObjectFigure) editPart.getFigure();
figure.setSize(provider.getDefaultSize());
figure.refreshVisuals();
figure.validate();
image = DiagramUtils.createImage(figure, 1, 0);
imageRegistry.put(key, image);
}
return image;
}
Aggregations