Search in sources :

Example 31 with Path

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

the class DriverFigure 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);
    graphics.setBackgroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);
    Point pt = getIconOrigin();
    Path path = new Path(null);
    graphics.setLineWidthFloat(1.2f);
    path.addArc(pt.x, pt.y, 13, 13, 0, 360);
    path.addArc(pt.x + 5f, pt.y + 5f, 3, 3, 0, 360);
    path.addArc(pt.x + 6f, pt.y + 6f, 1f, 1f, 0, 360);
    graphics.drawPath(path);
    path.dispose();
    graphics.setLineWidth(1);
    path = new Path(null);
    path.moveTo(pt.x - 2, pt.y + 6.5f);
    path.lineTo(pt.x + 15, pt.y + 6.5f);
    path.moveTo(pt.x + 6.5f, pt.y - 2);
    path.lineTo(pt.x + 6.5f, pt.y + 15);
    path.moveTo(pt.x + 0.5f, pt.y + 0.5f);
    path.lineTo(pt.x + 12.5f, pt.y + 12.5f);
    path.moveTo(pt.x + 0.5f, pt.y + 12.5f);
    path.lineTo(pt.x + 12.5f, pt.y + 0.5f);
    graphics.drawPath(path);
    path.dispose();
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Point(org.eclipse.draw2d.geometry.Point)

Example 32 with Path

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

the class EventFigure 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);
    // arc
    path.moveTo(pt.x, pt.y);
    path.addArc(pt.x - 4, pt.y, 8, 9, 270, 180);
    graphics.drawPath(path);
    path.dispose();
    path = new Path(null);
    path.moveTo(pt.x, pt.y);
    path.addArc(pt.x + 8, pt.y, 8, 9, 270, 180);
    // lines
    path.moveTo(pt.x, pt.y);
    path.lineTo(pt.x + 12, pt.y);
    path.moveTo(pt.x, pt.y + 9);
    path.lineTo(pt.x + 12, pt.y + 9);
    graphics.drawPath(path);
    path.dispose();
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Point(org.eclipse.draw2d.geometry.Point)

Example 33 with Path

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

the class FunctionFigure method getFigurePath.

private Path getFigurePath(Rectangle rect) {
    Path path = new Path(null);
    float y1 = rect.y + (rect.height / OFFSET);
    float y2 = rect.y + rect.height - (rect.height / OFFSET);
    path.moveTo(rect.x, rect.y + rect.height);
    path.lineTo(rect.x, y1);
    path.lineTo(rect.x + (rect.width / 2), rect.y);
    path.lineTo(rect.x + rect.width, y1);
    path.lineTo(rect.x + rect.width, rect.y + rect.height);
    path.lineTo(rect.x + (rect.width / 2), y2);
    path.close();
    return path;
}
Also used : Path(org.eclipse.swt.graphics.Path)

Example 34 with Path

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

the class GoalFigure 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);
    graphics.setBackgroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);
    Point pt = getIconOrigin();
    Path path = new Path(null);
    graphics.setLineWidthFloat(1.2f);
    path.addArc(pt.x, pt.y, 13, 13, 0, 360);
    path.addArc(pt.x + 2.5f, pt.y + 2.5f, 8, 8, 0, 360);
    path.addArc(pt.x + 5f, pt.y + 5f, 3, 3, 0, 360);
    path.addArc(pt.x + 6f, pt.y + 6f, 1f, 1f, 0, 360);
    graphics.drawPath(path);
    path.dispose();
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Point(org.eclipse.draw2d.geometry.Point)

Example 35 with Path

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

the class DeliverableFigure 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
    int lineWidth = 1;
    setLineWidth(graphics, lineWidth, bounds);
    int offset = 11;
    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();
    // Icon
    // drawIconImage(graphics, bounds);
    drawIconImage(graphics, bounds, 0, 0, -14, 0);
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Aggregations

Path (org.eclipse.swt.graphics.Path)103 Point (org.eclipse.draw2d.geometry.Point)49 Pattern (org.eclipse.swt.graphics.Pattern)40 Rectangle (org.eclipse.draw2d.geometry.Rectangle)37 Device (org.eclipse.swt.graphics.Device)13 Point (org.eclipse.swt.graphics.Point)11 Transform (org.eclipse.swt.graphics.Transform)10 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)8 Font (org.eclipse.swt.graphics.Font)8 Rectangle (org.eclipse.swt.graphics.Rectangle)7 PointList (org.eclipse.draw2d.geometry.PointList)6 GC (org.eclipse.swt.graphics.GC)6 PolarPoint (com.archimatetool.editor.diagram.figures.PolarPoint)4 Color (org.eclipse.swt.graphics.Color)4 Image (org.eclipse.swt.graphics.Image)4 Region (org.eclipse.swt.graphics.Region)4 IIconic (com.archimatetool.model.IIconic)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 SWTException (org.eclipse.swt.SWTException)2 Cursor (org.eclipse.swt.graphics.Cursor)2