use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class PathDrawnPolygonDecoration method fillShape.
@Override
protected void fillShape(Graphics g) {
Path path = FigureUtils.createPathFromPoints(getPoints());
g.fillPath(path);
path.dispose();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class ArtifactFigure 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);
Point pt = getIconOrigin();
Path path = new Path(null);
path.moveTo(pt.x, pt.y);
path.lineTo(pt.x + 7, pt.y);
path.lineTo(pt.x + 12, pt.y + 5);
path.lineTo(pt.x + 12, pt.y + 15);
path.lineTo(pt.x, pt.y + 15);
path.lineTo(pt.x, pt.y - 0.5f);
path.moveTo(pt.x + 7, pt.y);
path.lineTo(pt.x + 7, pt.y + 5);
path.lineTo(pt.x + 12, pt.y + 5);
graphics.drawPath(path);
path.dispose();
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class ArtifactFigure method drawFigure.
@Override
public 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 path1 = new Path(null);
path1.moveTo(rect.x, rect.y);
path1.lineTo(rect.x + rect.width - FOLD_HEIGHT, rect.y);
path1.lineTo(rect.x + rect.width, rect.y + FOLD_HEIGHT);
path1.lineTo(rect.x + rect.width, rect.y + rect.height);
path1.lineTo(rect.x, rect.y + rect.height);
path1.close();
graphics.fillPath(path1);
disposeGradientPattern(graphics, gradient);
// Fold
graphics.setBackgroundColor(ColorFactory.getDarkerColor(getFillColor()));
Path path2 = new Path(null);
path2.moveTo(rect.x + rect.width - FOLD_HEIGHT, rect.y);
path2.lineTo(rect.x + rect.width, rect.y + FOLD_HEIGHT);
path2.lineTo(rect.x + rect.width - FOLD_HEIGHT, rect.y + FOLD_HEIGHT);
graphics.fillPath(path2);
path2.dispose();
// Lines
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path1);
path1.dispose();
Path path3 = new Path(null);
path3.moveTo(rect.x + rect.width, rect.y + FOLD_HEIGHT);
path3.lineTo(rect.x + rect.width - FOLD_HEIGHT, rect.y + FOLD_HEIGHT);
path3.lineTo(rect.x + rect.width - FOLD_HEIGHT, rect.y);
graphics.drawPath(path3);
path3.dispose();
// Icon
// drawIconImage(graphics, bounds);
int rightOffset = ((IIconic) getDiagramModelObject()).getImagePosition() == IIconic.ICON_POSITION_TOP_RIGHT ? -(FOLD_HEIGHT + 1) : 0;
// int rightOffset = -(FOLD_HEIGHT + 1);
drawIconImage(graphics, rect, 0, rightOffset, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class BoxFigureDelegate method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
graphics.pushState();
Rectangle bounds = getBounds();
bounds.width--;
bounds.height--;
// Set line width here so that the whole figure is consttained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
graphics.setBackgroundColor(ColorFactory.getDarkerColor(getFillColor()));
Path path = new Path(null);
path.moveTo(bounds.x, bounds.y + EDGE_SIZE);
path.lineTo(bounds.x + EDGE_SIZE, bounds.y);
path.lineTo(bounds.x + bounds.width, bounds.y);
path.lineTo(bounds.x + bounds.width, bounds.y + bounds.height - EDGE_SIZE);
path.lineTo(bounds.x + bounds.width - EDGE_SIZE, bounds.y + bounds.height);
path.lineTo(bounds.x, bounds.y + bounds.height);
graphics.fillPath(path);
path.dispose();
// Fill front rectangle
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRectangle(bounds.x, bounds.y + EDGE_SIZE, bounds.width - EDGE_SIZE, bounds.height - EDGE_SIZE);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
path = new Path(null);
path.moveTo(bounds.x, bounds.y + EDGE_SIZE);
path.lineTo(bounds.x + EDGE_SIZE, bounds.y);
path.lineTo(bounds.x + bounds.width, bounds.y);
path.lineTo(bounds.x + bounds.width, bounds.y + bounds.height - EDGE_SIZE);
path.lineTo(bounds.x + bounds.width - EDGE_SIZE, bounds.y + bounds.height);
path.lineTo(bounds.x, bounds.y + bounds.height);
path.lineTo(bounds.x, bounds.y + EDGE_SIZE);
path.lineTo(bounds.x + bounds.width - EDGE_SIZE, bounds.y + EDGE_SIZE);
path.lineTo(bounds.x + bounds.width, bounds.y);
path.moveTo(bounds.x + bounds.width - EDGE_SIZE, bounds.y + EDGE_SIZE);
path.lineTo(bounds.x + bounds.width - EDGE_SIZE, bounds.y + bounds.height);
graphics.drawPath(path);
path.dispose();
// Image icon
Rectangle imageArea = new Rectangle(bounds.x, bounds.y + EDGE_SIZE, bounds.width - EDGE_SIZE, bounds.height - EDGE_SIZE);
getOwner().drawIconImage(graphics, bounds, imageArea, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class BusinessRoleFigure 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);
Point pt = getIconOrigin();
Path path = new Path(null);
path.addArc(pt.x, pt.y, 5, 8, 90, 180);
path.lineTo(pt.x + 12, pt.y + 8);
path.moveTo(pt.x + 2f, pt.y);
path.lineTo(pt.x + 12, pt.y);
graphics.drawPath(path);
path.dispose();
graphics.drawOval(pt.x + 10, pt.y, 5, 8);
graphics.popState();
}
Aggregations