use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class CourseOfActionFigure method drawIcon.
/**
* Draw the icon
*/
private void drawIcon(Graphics graphics) {
if (!isIconVisible()) {
return;
}
graphics.pushState();
graphics.setLineWidth(1);
graphics.setForegroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);
graphics.setBackgroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);
// triangle of shortcut glyph
Path path = new Path(null);
Point pt = getIconOrigin();
float x = pt.x - 5.4f, y = pt.y + 9f;
path.moveTo(x, y);
path.lineTo(x + 6f, y + 1f);
path.lineTo(x + 3f, y + 6.2f);
graphics.fillPath(path);
path.dispose();
// line of shortcut glyph
path = new Path(null);
graphics.setLineWidthFloat(2f);
path.addArc(pt.x - 7.5f, pt.y + 12f, 10, 10, 90, 80);
graphics.drawPath(path);
path.dispose();
// 2 circles and blob
graphics.setLineWidthFloat(1.2f);
path = new Path(null);
pt = getIconOrigin();
path.addArc(pt.x, pt.y, 13, 13, 0, 360);
path.addArc(pt.x + 2.5f, pt.y + 2.5f, 8, 8, 0, 360);
path.addArc(pt.x + 5f, pt.y + 5f, 3, 3, 0, 360);
path.addArc(pt.x + 6f, pt.y + 6f, 1f, 1f, 0, 360);
graphics.drawPath(path);
path.dispose();
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class GroupFigure method drawFigure.
@Override
protected 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 (getDiagramModelObject().getBorderType() == IDiagramModelGroup.BORDER_TABBED) {
tabWidth = (int) (bounds.width / INSET);
tabHeight = TOPBAR_HEIGHT;
if (getDiagramModelObject().getTextPosition() == ITextPosition.TEXT_POSITION_TOP) {
int textWidth = FigureUtilities.getTextExtents(getText(), getFont()).width;
tabWidth = Math.min(Math.max(tabWidth, textWidth + 8), bounds.width);
// Tab height is calculated from font height
int textHeight = FigureUtilities.getFontMetrics(getFont()).getHeight();
// Tab height is calculated from the text control height which includes all text
// int textHeight = getTextControl().getBounds().height;
tabHeight = Math.max(TOPBAR_HEIGHT, textHeight);
}
// Top Rectangle
graphics.setBackgroundColor(ColorFactory.getDarkerColor(getFillColor()));
Path path1 = new Path(null);
path1.moveTo(bounds.x, bounds.y);
path1.lineTo(bounds.x + tabWidth, bounds.y);
path1.lineTo(bounds.x + tabWidth, bounds.y + tabHeight);
path1.lineTo(bounds.x, bounds.y + tabHeight);
path1.lineTo(bounds.x, bounds.y);
graphics.fillPath(path1);
path1.dispose();
// Main rectangle
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
Path path2 = new Path(null);
path2.moveTo(bounds.x, bounds.y + tabHeight);
path2.lineTo(bounds.x + bounds.width, bounds.y + tabHeight);
path2.lineTo(bounds.x + bounds.width, bounds.y + bounds.height);
path2.lineTo(bounds.x, bounds.y + bounds.height);
graphics.fillPath(path2);
path2.dispose();
disposeGradientPattern(graphics, gradient);
// Icon
if (getIconicDelegate() != null) {
getIconicDelegate().setTopOffset(tabHeight);
drawIconImage(graphics, bounds);
}
// Line
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
Path path = new Path(null);
path.moveTo(bounds.x, bounds.y + tabHeight);
path.lineTo(bounds.x, bounds.y);
path.lineTo(bounds.x + tabWidth, bounds.y);
path.lineTo(bounds.x + tabWidth, bounds.y + tabHeight);
graphics.drawPath(path);
path.dispose();
graphics.drawRectangle(bounds.x, bounds.y + tabHeight, bounds.width, bounds.height - tabHeight);
} else {
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRectangle(bounds);
disposeGradientPattern(graphics, gradient);
// Icon
if (getIconicDelegate() != null) {
getIconicDelegate().setTopOffset(0);
drawIconImage(graphics, bounds);
}
// Line
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
graphics.drawRectangle(bounds);
}
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class AbstractMotivationFigure method drawFigure.
@Override
protected void drawFigure(Graphics graphics) {
if (getFigureDelegate() != null) {
getFigureDelegate().drawFigure(graphics);
return;
}
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);
PointList points = new PointList();
points.addPoint(bounds.x + FLANGE, bounds.y);
points.addPoint(bounds.x + bounds.width - FLANGE, bounds.y);
points.addPoint(bounds.x + bounds.width, bounds.y + FLANGE);
points.addPoint(bounds.x + bounds.width, bounds.y + bounds.height - FLANGE);
points.addPoint(bounds.x + bounds.width - FLANGE, bounds.y + bounds.height);
points.addPoint(bounds.x + FLANGE, bounds.y + bounds.height);
points.addPoint(bounds.x, bounds.y + bounds.height - FLANGE);
points.addPoint(bounds.x, bounds.y + FLANGE);
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Fill
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
// graphics.fillPolygon(points);
Path path = FigureUtils.createPathFromPoints(points);
graphics.fillPath(path);
path.dispose();
disposeGradientPattern(graphics, gradient);
// Line
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPolygon(points);
// Image Icon
Rectangle imageArea = new Rectangle(bounds.x + FLANGE / 2, bounds.y + FLANGE / 2, bounds.width - FLANGE, bounds.height - FLANGE);
drawIconImage(graphics, bounds, imageArea, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class EventFigure method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
if (getFigureDelegate() != null) {
getFigureDelegate().drawFigure(graphics);
drawIcon(graphics);
return;
}
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);
int indent = Math.min(bounds.height / 3, bounds.width / 3);
int centre_y = bounds.y + bounds.height / 2 - 1;
int arc_startx = bounds.x + bounds.width - indent;
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Main Fill
Path path = new Path(null);
path.moveTo(bounds.x, bounds.y);
path.lineTo(bounds.x + indent, centre_y);
path.lineTo(bounds.x, bounds.y + bounds.height);
path.lineTo(arc_startx, bounds.y + bounds.height);
path.addArc(arc_startx - indent, bounds.y, indent * 2, bounds.height, -90, 180);
path.lineTo(bounds.x, bounds.y);
path.lineTo(bounds.x + indent, centre_y);
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillPath(path);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path);
path.dispose();
// Icon
drawIconImage(graphics, bounds);
graphics.popState();
}
use of org.eclipse.swt.graphics.Path 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