Search in sources :

Example 51 with Pattern

use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.

the class ProcessFigureDelegate method drawFigure.

@Override
public void drawFigure(Graphics graphics) {
    graphics.pushState();
    graphics.setAlpha(getAlpha());
    if (!isEnabled()) {
        setDisabledState(graphics);
    }
    graphics.setBackgroundColor(getFillColor());
    Rectangle bounds = getBounds();
    bounds.width--;
    bounds.height--;
    // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
    int lineWidth = 1;
    setLineWidth(graphics, lineWidth, bounds);
    Pattern gradient = applyGradientPattern(graphics, bounds);
    Path path = new Path(null);
    float x1 = bounds.x + (bounds.width * 0.7f);
    float y1 = bounds.y + (bounds.height / 5);
    float y2 = bounds.y + bounds.height - (bounds.height / 5);
    float lineOffset = (float) lineWidth / 2;
    path.moveTo(bounds.x, y1);
    path.lineTo(x1, y1);
    path.lineTo(x1, bounds.y);
    path.lineTo(bounds.x + bounds.width, bounds.y + (bounds.height / 2));
    path.lineTo(x1, bounds.y + bounds.height);
    path.lineTo(x1, y2);
    path.lineTo(bounds.x, y2);
    path.lineTo(bounds.x, y1 - lineOffset);
    graphics.fillPath(path);
    disposeGradientPattern(graphics, gradient);
    // Line
    graphics.setForegroundColor(getLineColor());
    graphics.setAlpha(getLineAlpha());
    graphics.drawPath(path);
    path.dispose();
    // Icon
    // getOwner().drawIconImage(graphics, bounds);
    getOwner().drawIconImage(graphics, bounds, bounds.height / 5 + 1, (int) -(bounds.width * 0.2f), -(bounds.height / 5 + 1), 0);
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 52 with Pattern

use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.

the class RepresentationFigure method drawFigure.

@Override
public 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
    int lineWidth = 1;
    setLineWidth(graphics, lineWidth, bounds);
    int offset = 6;
    int curve_y = bounds.y + bounds.height - offset;
    graphics.setAlpha(getAlpha());
    if (!isEnabled()) {
        setDisabledState(graphics);
    }
    // Main Fill
    Path path = new Path(null);
    path.moveTo(bounds.x, bounds.y);
    path.lineTo(bounds.x, curve_y - 1);
    path.quadTo(bounds.x + (bounds.width / 4), bounds.y + bounds.height + offset, bounds.x + bounds.width / 2 + 1, curve_y);
    path.quadTo(bounds.x + bounds.width - (bounds.width / 4), curve_y - offset - 1, bounds.x + bounds.width, curve_y);
    path.lineTo(bounds.x + bounds.width, bounds.y);
    graphics.setBackgroundColor(getFillColor());
    Pattern gradient = applyGradientPattern(graphics, bounds);
    graphics.fillPath(path);
    disposeGradientPattern(graphics, gradient);
    // Outline
    graphics.setAlpha(getLineAlpha());
    graphics.setForegroundColor(getLineColor());
    float lineOffset = (float) lineWidth / 2;
    path.lineTo(bounds.x - lineOffset, bounds.y);
    graphics.drawPath(path);
    path.dispose();
    // Line
    graphics.drawLine(bounds.x, bounds.y + TOP_MARGIN, bounds.x + bounds.width, bounds.y + TOP_MARGIN);
    // Icon
    // drawIconImage(graphics, bounds);
    drawIconImage(graphics, bounds, TOP_MARGIN, 0, -TOP_MARGIN, 0);
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 53 with Pattern

use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.

the class ResourceFigure 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);
    // Lines
    graphics.setAlpha(getLineAlpha());
    graphics.setForegroundColor(getLineColor());
    graphics.drawPath(path);
    path.dispose();
    Dimension nubSize = new Dimension(rect.width / 10, rect.height / 3);
    graphics.drawLine(rect.x + rect.width - nubSize.width, rect.y + (rect.height - nubSize.height) / 2, rect.x + rect.width - nubSize.width, rect.y + (rect.height - nubSize.height) / 2 + nubSize.height);
    int lineTop = rect.y + rect.height / 5;
    int lineBottom = rect.y + rect.height * 4 / 5;
    int lineGap = rect.width / 6;
    graphics.drawLine(rect.x + lineGap, lineTop, rect.x + lineGap, lineBottom);
    graphics.drawLine(rect.x + lineGap * 2, lineTop, rect.x + lineGap * 2, lineBottom);
    graphics.drawLine(rect.x + lineGap * 3, lineTop, rect.x + lineGap * 3, lineBottom);
    // Image Icon
    drawIconImage(graphics, rect, 0, 0, 0, 0);
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 54 with Pattern

use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.

the class EllipseFigureDelegate method drawFigure.

@Override
public void drawFigure(Graphics graphics) {
    graphics.pushState();
    Rectangle bounds = getBounds();
    bounds.width--;
    bounds.height--;
    // Line Width
    setLineWidth(graphics, 1, bounds);
    graphics.setAlpha(getAlpha());
    if (!isEnabled()) {
        setDisabledState(graphics);
    }
    graphics.setBackgroundColor(getFillColor());
    Pattern gradient = applyGradientPattern(graphics, bounds);
    graphics.fillOval(bounds);
    disposeGradientPattern(graphics, gradient);
    // Outline
    graphics.setAlpha(getLineAlpha());
    graphics.setForegroundColor(getLineColor());
    graphics.drawOval(bounds);
    // Image Icon
    Rectangle imageArea = new Rectangle(bounds.x + (bounds.width / 6), bounds.y + (bounds.height / 6), bounds.width - (bounds.width / 3), bounds.height - (bounds.height / 3));
    getOwner().drawIconImage(graphics, bounds, imageArea, 0, 0, 0, 0);
    graphics.popState();
}
Also used : Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 55 with Pattern

use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.

the class AssessmentFigure 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);
    setFigurePositionFromTextPosition(rect);
    if (!isEnabled()) {
        setDisabledState(graphics);
    }
    int radius = getRadius(rect);
    Point center = getCenter(rect);
    // Fill
    graphics.setAlpha(getAlpha());
    graphics.setBackgroundColor(getFillColor());
    Pattern gradient = applyGradientPattern(graphics, rect);
    Path path = new Path(null);
    path.addArc((float) center.preciseX() - radius, (float) center.preciseY() - radius, (radius * 2), (radius * 2), 0.0F, 360.0F);
    graphics.fillPath(path);
    disposeGradientPattern(graphics, gradient);
    // Lines
    graphics.setAlpha(getLineAlpha());
    graphics.setForegroundColor(getLineColor());
    graphics.drawPath(path);
    path.dispose();
    double ratio = 2.5d;
    int x1 = (int) (center.x - radius * ratio);
    int y1 = (int) (center.y + radius * ratio);
    Point intersection = getCircleIntersection(x1, y1, center.preciseX(), center.preciseY(), center.preciseX(), center.preciseY(), radius);
    if (intersection != null) {
        // Need this so line doesn't draw out of bounds at bottom of rect
        graphics.setClip(rect);
        graphics.drawLine((int) Math.round(intersection.preciseX()), (int) Math.round(intersection.preciseY() - 1), x1, y1);
    }
    // Image Icon
    drawIconImage(graphics, imageBounds, 0, 0, 0, 0);
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Aggregations

Pattern (org.eclipse.swt.graphics.Pattern)71 Rectangle (org.eclipse.draw2d.geometry.Rectangle)44 Path (org.eclipse.swt.graphics.Path)40 Point (org.eclipse.draw2d.geometry.Point)22 Device (org.eclipse.swt.graphics.Device)12 Point (org.eclipse.swt.graphics.Point)11 Rectangle (org.eclipse.swt.graphics.Rectangle)10 Color (org.eclipse.swt.graphics.Color)7 Font (org.eclipse.swt.graphics.Font)6 Image (org.eclipse.swt.graphics.Image)6 Transform (org.eclipse.swt.graphics.Transform)6 GC (org.eclipse.swt.graphics.GC)5 IIconic (com.archimatetool.model.IIconic)4 PointList (org.eclipse.draw2d.geometry.PointList)4 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)4 Region (org.eclipse.swt.graphics.Region)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Cursor (org.eclipse.swt.graphics.Cursor)2 RGB (org.eclipse.swt.graphics.RGB)2 TextLayout (org.eclipse.swt.graphics.TextLayout)2