use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class LocationFigure 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--;
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);
setFigurePositionFromTextPosition(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);
// Lines
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path);
path.dispose();
// Image Icon
drawIconImage(graphics, imageBounds, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class MeaningFigure method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
graphics.pushState();
Rectangle bounds = getBounds().getCopy();
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
// The following is the most awful code to draw a cloud...
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Main fill
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
Path path = new Path(null);
path.addArc(bounds.x, bounds.y, bounds.width / 3 * 2, bounds.height / 3 * 2, 0, 360);
graphics.fillPath(path);
path.dispose();
path = new Path(null);
path.addArc(bounds.x + bounds.width / 3 - 1, bounds.y, bounds.width / 3 * 2, bounds.height / 3 * 2, 0, 360);
graphics.fillPath(path);
path.dispose();
path = new Path(null);
path.addArc(bounds.x, bounds.y + bounds.height / 3, bounds.width / 5 * 3, bounds.height / 3 * 2 - 1, 0, 360);
graphics.fillPath(path);
path.dispose();
path = new Path(null);
path.addArc(bounds.x + bounds.width / 3, bounds.y + bounds.height / 4, bounds.width / 5 * 3, bounds.height / 3 * 2, 0, 360);
graphics.fillPath(path);
path.dispose();
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
path = new Path(null);
path.addArc(bounds.x, bounds.y, bounds.width / 3 * 2, bounds.height / 3 * 2, 60, 149);
graphics.drawPath(path);
path.dispose();
path = new Path(null);
path.addArc(bounds.x + bounds.width / 3 - 1, bounds.y, bounds.width / 3 * 2, bounds.height / 3 * 2, -38, 157);
graphics.drawPath(path);
path.dispose();
path = new Path(null);
path.addArc(bounds.x, bounds.y + bounds.height / 3, bounds.width / 5 * 3, bounds.height / 3 * 2 - 1, -41, -171);
graphics.drawPath(path);
path.dispose();
path = new Path(null);
path.addArc(bounds.x + bounds.width / 3, bounds.y + bounds.height / 4, bounds.width / 5 * 3, bounds.height / 3 * 2, 7, -120);
graphics.drawPath(path);
path.dispose();
// Icon
drawIconImage(graphics, bounds);
graphics.popState();
}
use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class CourseOfActionFigure 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--;
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);
// Should match '3.1 / 2.5' (values used in getRadius() and getCenter())
setFigurePositionFromTextPosition(rect, 1.24);
if (!isEnabled()) {
setDisabledState(graphics);
}
graphics.setAlpha(getAlpha());
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, rect);
Path path = new Path(null);
int radius = getRadius(rect);
Point center = getCenter(rect);
path.addArc((float) center.preciseX() - radius, (float) center.preciseY() - radius, (radius * 2), (radius * 2), 0, 360);
graphics.fillPath(path);
disposeGradientPattern(graphics, gradient);
// Lines
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path);
path.dispose();
graphics.setBackgroundColor(getLineColor());
int radius2 = Math.round(radius * 2f / 3f - (graphics.getLineWidth() / 2));
graphics.drawOval(center.x - radius2, center.y - radius2, 2 * radius2, 2 * radius2);
int radius3 = Math.round(radius / 3.0F - (graphics.getLineWidth() / 2));
graphics.fillOval(center.x - radius3, center.y - radius3, 2 * radius3, 2 * radius3);
int x = Math.round(center.x - radius * 2f);
int y = Math.round(center.y + radius * 2f);
Point intersection = getCircleIntersection(x, y, center.preciseX() - radius3, center.preciseY() - radius3, center.preciseX() - radius3, center.preciseY() - radius3, radius);
if (intersection != null) {
// Need this so line doesn't draw out of bounds at bottom of rect
graphics.setClip(rect);
int arrowLength = (int) (radius3 * 1.5f);
// int arrowLineWidth = Math.round(graphics.getLineWidth() * 1.5f);
int arrowLineWidth = Math.max(3, arrowLength / 5);
graphics.setLineWidth(arrowLineWidth);
graphics.fillPolygon(new int[] { intersection.x, intersection.y, intersection.x - arrowLength, intersection.y - arrowLength / 3, intersection.x - arrowLength / 3, intersection.y + arrowLength });
graphics.setLineCap(SWT.CAP_ROUND);
graphics.drawLine(x, rect.y + rect.height, x + (intersection.x - x) / 3, intersection.y + (y - intersection.y) / 3);
graphics.drawLine(x + (intersection.x - x) / 3, intersection.y + (y - intersection.y) / 3, intersection.x - arrowLineWidth, intersection.y + arrowLineWidth);
}
// Image Icon
drawIconImage(graphics, imageBounds, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Pattern 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.Pattern 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();
}
Aggregations