use of org.eclipse.swt.graphics.Pattern 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.Pattern 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.Pattern in project archi by archimatetool.
the class CollaborationFigure 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 'diameter'
setFigurePositionFromTextPosition(rect, 1.5);
if (!isEnabled()) {
setDisabledState(graphics);
}
graphics.setAlpha(getAlpha());
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, rect);
int diameter;
int x1 = rect.x, x2;
// width < height or same
if (rect.width <= rect.height) {
diameter = (rect.width / 3) * 2;
} else // height < width
{
// minimum of height or 2/3 of width
diameter = Math.min(rect.height, (rect.width / 3) * 2);
x1 += (rect.width / 2) - (diameter * .75);
}
x2 = x1 + diameter / 2;
int y = rect.y + (rect.height - diameter) / 2;
graphics.fillOval(x1, y, diameter, diameter);
graphics.fillOval(x2, y, diameter, diameter);
disposeGradientPattern(graphics, gradient);
// Line
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawOval(x1, y, diameter, diameter);
graphics.drawOval(x2, y, diameter, diameter);
// 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 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.Pattern in project archi by archimatetool.
the class ApplicationComponentFigure 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);
if (!isEnabled()) {
setDisabledState(graphics);
}
graphics.setAlpha(getAlpha());
// Main Fill
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRectangle(bounds.x + INDENT, bounds.y, bounds.width - INDENT, bounds.height);
disposeGradientPattern(graphics, gradient);
graphics.setAlpha(getLineAlpha());
// Outline
graphics.setForegroundColor(getLineColor());
PointList points = new PointList();
Point pt1 = new Point(bounds.x + INDENT, bounds.y + 10);
points.addPoint(pt1);
Point pt2 = new Point(pt1.x, bounds.y);
points.addPoint(pt2);
Point pt3 = new Point(bounds.x + bounds.width, bounds.y);
points.addPoint(pt3);
Point pt4 = new Point(pt3.x, bounds.y + bounds.height);
points.addPoint(pt4);
Point pt5 = new Point(pt1.x, pt4.y);
points.addPoint(pt5);
Point pt6 = new Point(pt1.x, bounds.y + 43);
points.addPoint(pt6);
graphics.drawPolyline(points);
graphics.drawLine(bounds.x + INDENT, bounds.y + 23, bounds.x + INDENT, bounds.y + 30);
graphics.setAlpha(getAlpha());
// Nubs Fill
graphics.setBackgroundColor(ColorFactory.getDarkerColor(getFillColor()));
graphics.fillRectangle(bounds.x, bounds.y + 10, INDENT * 2, 13);
graphics.fillRectangle(bounds.x, bounds.y + 30, INDENT * 2, 13);
graphics.setAlpha(getLineAlpha());
// Nubs Outline
graphics.setForegroundColor(getLineColor());
graphics.drawRectangle(bounds.x, bounds.y + 10, INDENT * 2, 13);
graphics.drawRectangle(bounds.x, bounds.y + 30, INDENT * 2, 13);
// Icon
// drawIconImage(graphics, bounds);
drawIconImage(graphics, bounds, 0, 0, 0, INDENT * 2);
graphics.popState();
}
Aggregations