use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class NoteFigure method paintFigure.
@Override
protected void paintFigure(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
if (getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) {
setLineWidth(graphics, 1, bounds);
}
// Fill
PointList points = new PointList();
if (getDiagramModelObject().getBorderType() == IDiagramModelNote.BORDER_DOGEAR) {
points.addPoint(bounds.x, bounds.y);
points.addPoint(bounds.getTopRight().x, bounds.y);
points.addPoint(bounds.getTopRight().x, bounds.getBottomRight().y - 13);
points.addPoint(bounds.getTopRight().x - 13, bounds.getBottomRight().y);
points.addPoint(bounds.x, bounds.getBottomLeft().y);
} else {
points.addPoint(bounds.x, bounds.y);
points.addPoint(bounds.getTopRight().x, bounds.y);
points.addPoint(bounds.getTopRight().x, bounds.getBottomRight().y);
points.addPoint(bounds.x, bounds.getBottomLeft().y);
}
graphics.setAlpha(getAlpha());
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
Path path = FigureUtils.createPathFromPoints(points);
graphics.fillPath(path);
path.dispose();
disposeGradientPattern(graphics, gradient);
// Icon
drawIconImage(graphics, bounds);
if (getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPolygon(points);
}
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class ApplicationComponentFigure method drawIcon.
/**
* Draw the icon
*/
protected 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);
// start bottom left
path.moveTo(pt.x, pt.y);
path.lineTo(pt.x, pt.y - 4);
path.moveTo(pt.x, pt.y - 6);
path.lineTo(pt.x, pt.y - 8);
path.moveTo(pt.x, pt.y - 11);
path.lineTo(pt.x, pt.y - 13);
// line right
path.lineTo(pt.x + 10, pt.y - 13);
// line down
path.lineTo(pt.x + 10, pt.y);
// line left
path.lineTo(pt.x - 0.5f, pt.y);
path.addRectangle(pt.x - 3, pt.y - 11, 6, 2.5f);
path.addRectangle(pt.x - 3, pt.y - 6, 6, 2.5f);
graphics.drawPath(path);
path.dispose();
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class CylinderFigureDelegate method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
graphics.pushState();
Rectangle rect = getBounds();
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 = new Path(null);
path.addArc(rect.x, rect.y, rect.width / OFFSET, rect.height, 90, 180);
path.lineTo((rect.x + rect.width) - (rect.width / OFFSET * 2), rect.y + rect.height);
path.addArc((rect.x + rect.width) - (rect.width / OFFSET), rect.y, rect.width / OFFSET, rect.height, 270, 180);
graphics.fillPath(path);
disposeGradientPattern(graphics, gradient);
// Lines
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path);
path.dispose();
graphics.drawLine(rect.x + (rect.width / OFFSET / 2), rect.y, (rect.x + rect.width) - (rect.width / OFFSET / 2), rect.y);
graphics.drawArc((rect.x + rect.width) - (rect.width / OFFSET), rect.y, rect.width / OFFSET, rect.height, 90, 180);
// Image Icon
getOwner().drawIconImage(graphics, rect, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class DeviceFigure 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 height_indent = bounds.height / 6;
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Bottom part
graphics.setBackgroundColor(ColorFactory.getDarkerColor(getFillColor()));
Path path = new Path(null);
path.moveTo(bounds.x, bounds.y + bounds.height);
path.lineTo(bounds.x + INDENT + 1, bounds.y + bounds.height - height_indent);
path.lineTo(bounds.x + bounds.width - INDENT, bounds.y + bounds.height - height_indent);
path.lineTo(bounds.x + bounds.width, bounds.y + bounds.height);
path.lineTo(bounds.x, bounds.y + bounds.height);
graphics.fillPath(path);
path.dispose();
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
graphics.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width, bounds.y + bounds.height);
graphics.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + INDENT + 1, bounds.y + bounds.height - height_indent);
graphics.drawLine(bounds.x + bounds.width, bounds.y + bounds.height, bounds.x + bounds.width - INDENT + 1, bounds.y + bounds.height - height_indent);
// Top part
Rectangle rect = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height - height_indent);
graphics.setBackgroundColor(getFillColor());
graphics.setAlpha(getAlpha());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRoundRectangle(rect, 30, 30);
disposeGradientPattern(graphics, gradient);
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
rect = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height - height_indent);
graphics.drawRoundRectangle(rect, 30, 30);
// Image icon
Rectangle imageArea = new Rectangle(bounds.x + 3, bounds.y + 3, bounds.width - 6, bounds.height - height_indent - 6);
drawIconImage(graphics, bounds, imageArea, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project archi by archimatetool.
the class DriverFigure method drawFigure.
@Override
protected void drawFigure(Graphics graphics) {
if (getDiagramModelArchimateObject().getType() == 0) {
super.drawFigure(graphics);
drawIcon(graphics);
return;
}
graphics.pushState();
Rectangle rect = getBounds().getCopy();
// rect.width--;
// rect.height--;
Rectangle imageBounds = rect.getCopy();
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
// setLineWidth(graphics, 1, rect);
int lineWidth = (int) (Math.sqrt(rect.width * rect.height) / 20);
graphics.setLineWidth(lineWidth);
setFigurePositionFromTextPosition(rect);
if (!isEnabled()) {
setDisabledState(graphics);
}
// Fill
graphics.setAlpha(getAlpha());
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, rect);
Path path = new Path(null);
int radius = getRadius(rect);
int actualRadius = getRadius(rect) - Math.round(radius / 10.0f) - lineWidth / 2;
Point center = rect.getCenter();
path.addArc((float) center.preciseX() - actualRadius, (float) center.preciseY() - actualRadius, (actualRadius * 2), (actualRadius * 2), 0, 360);
graphics.fillPath(path);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path);
path.dispose();
graphics.setLineWidth(1);
int topLeftX = (int) Math.round(center.x + radius * Math.cos(TOPLEFT_ANGLE_RADIAN));
int topLeftY = (int) Math.round(center.y + radius * Math.sin(TOPLEFT_ANGLE_RADIAN));
int bottomRightX = (int) Math.round(center.x + radius * Math.cos(BOTTOMRIGHT_ANGLE_RADIAN));
int bottomRightY = (int) Math.round(center.y + radius * Math.sin(BOTTOMRIGHT_ANGLE_RADIAN));
graphics.drawLine(topLeftX, topLeftY, bottomRightX, bottomRightY);
graphics.drawLine(center.x - radius, center.y, center.x + radius, center.y);
int bottomLeftX = (int) Math.round(center.x + radius * Math.cos(BOTTOMLEFT_ANGLE_RADIAN));
int bottomLeftY = (int) Math.round(center.y + radius * Math.sin(BOTTOMLEFT_ANGLE_RADIAN));
int topRightX = (int) Math.round(center.x + radius * Math.cos(TOPRIGHT_ANGLE_RADIAN));
int topRightY = (int) Math.round(center.y + radius * Math.sin(TOPRIGHT_ANGLE_RADIAN));
graphics.drawLine(bottomLeftX, bottomLeftY, topRightX, topRightY);
graphics.drawLine(center.x, center.y - radius, center.x, center.y + radius);
graphics.setBackgroundColor(getLineColor());
radius = Math.round(radius / 4.0f);
graphics.fillOval(center.x - radius, center.y - radius, 2 * radius, 2 * radius);
// Image Icon
drawIconImage(graphics, imageBounds, 0, 0, 0, 0);
graphics.popState();
}
Aggregations