use of com.archimatetool.model.IIconic in project archi by archimatetool.
the class ValueFigure method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
graphics.pushState();
Rectangle bounds = getBounds().getCopy();
bounds.width--;
bounds.height--;
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillOval(bounds);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawOval(bounds);
// Icon
// drawIconImage(graphics, bounds);
int top = 0, right = 0, left = 0, bottom = 0;
int offset = 6;
switch(((IIconic) getDiagramModelObject()).getImagePosition()) {
case IIconic.ICON_POSITION_TOP_LEFT:
top = bounds.height / offset;
left = bounds.width / offset;
break;
case IIconic.ICON_POSITION_TOP_RIGHT:
top = bounds.height / offset;
right = -(bounds.width / offset);
break;
case IIconic.ICON_POSITION_BOTTOM_LEFT:
bottom = -(bounds.height / offset);
left = bounds.width / offset;
break;
case IIconic.ICON_POSITION_BOTTOM_RIGHT:
bottom = -(bounds.height / offset);
right = -(bounds.width / offset);
break;
}
drawIconImage(graphics, bounds, top, right, bottom, left);
// Rectangle iconArea = new Rectangle(bounds.x + (bounds.width / 6), bounds.y + (bounds.height / 6),
// bounds.width - (bounds.width / 3), bounds.height - (bounds.height / 3));
// drawIconImage(graphics, iconArea, 0, 0, 0, 0);
graphics.popState();
}
use of com.archimatetool.model.IIconic 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 AbstractConnectedEditPart) {
AbstractConnectedEditPart editPart = (AbstractConnectedEditPart) object;
IDiagramModelObject model = editPart.getModel();
// Locked
if (model instanceof ILockable && ((ILockable) model).isLocked()) {
continue;
}
AbstractDiagramModelObjectFigure figure = (AbstractDiagramModelObjectFigure) editPart.getFigure();
IBounds bounds = model.getBounds().getCopy();
// If the object has an icon image and set to image fill and isn't a container with childrem
if (model instanceof IIconic && ((IIconic) model).getImagePosition() == IIconic.ICON_POSITION_FILL && figure.hasIconImage() && !(model instanceof IDiagramModelContainer && !((IDiagramModelContainer) model).getChildren().isEmpty())) {
Rectangle imageBounds = figure.getIconicDelegate().getImage().getBounds();
bounds.setWidth(imageBounds.width);
bounds.setHeight(imageBounds.height);
} else {
Dimension defaultSize = ((IDiagramModelObjectFigure) figure).getDefaultSize();
bounds.setWidth(defaultSize.width);
bounds.setHeight(defaultSize.height);
}
if (bounds.getWidth() != model.getBounds().getWidth() || bounds.getHeight() != model.getBounds().getHeight()) {
Command cmd = new SetConstraintObjectCommand(model, bounds);
command.add(cmd);
}
}
}
return command.unwrap();
}
use of com.archimatetool.model.IIconic in project archi by archimatetool.
the class FunctionFigure method drawFigure.
@Override
protected void drawFigure(Graphics graphics) {
if (getFigureDelegate() != null) {
getFigureDelegate().drawFigure(graphics);
drawIcon(graphics);
return;
}
graphics.pushState();
Rectangle rect = getBounds().getCopy();
rect.width--;
rect.height--;
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, rect);
if (!isEnabled()) {
setDisabledState(graphics);
}
graphics.setAlpha(getAlpha());
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, rect);
Path path = getFigurePath(rect);
graphics.fillPath(path);
disposeGradientPattern(graphics, gradient);
// Line
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
graphics.drawPath(path);
path.dispose();
// Image Icon
// drawIconImage(graphics, bounds, 0, 0, 0, 0);
// drawIconImage(graphics, bounds, bounds.height / 5 + 1, 0, -(bounds.height / 5 + 1), 0);
int top = 0, right = 0, left = 0, bottom = 0;
switch(((IIconic) getDiagramModelObject()).getImagePosition()) {
case IIconic.ICON_POSITION_TOP_LEFT:
case IIconic.ICON_POSITION_TOP_RIGHT:
top = rect.height / OFFSET;
break;
case IIconic.ICON_POSITION_BOTTOM_CENTRE:
bottom = -(rect.height / OFFSET);
break;
case IIconic.ICON_POSITION_BOTTOM_LEFT:
case IIconic.ICON_POSITION_BOTTOM_RIGHT:
bottom = -(rect.height / OFFSET / 3);
break;
}
drawIconImage(graphics, rect, top, right, bottom, left);
graphics.popState();
}
Aggregations