Search in sources :

Example 16 with Path

use of org.eclipse.swt.graphics.Path in project pentaho-kettle by pentaho.

the class Sleak method refreshLabel.

void refreshLabel() {
    int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0;
    int paths = 0, patterns = 0, regions = 0, textLayouts = 0, transforms = 0;
    for (int i = 0; i < objects.length; i++) {
        Object object = objects[i];
        if (object instanceof Color) {
            colors++;
        }
        if (object instanceof Cursor) {
            cursors++;
        }
        if (object instanceof Font) {
            fonts++;
        }
        if (object instanceof GC) {
            gcs++;
        }
        if (object instanceof Image) {
            images++;
        }
        if (object instanceof Path) {
            paths++;
        }
        if (object instanceof Pattern) {
            patterns++;
        }
        if (object instanceof Region) {
            regions++;
        }
        if (object instanceof TextLayout) {
            textLayouts++;
        }
        if (object instanceof Transform) {
            transforms++;
        }
    }
    String string = "";
    if (colors != 0) {
        string += colors + " Color(s)\n";
    }
    if (cursors != 0) {
        string += cursors + " Cursor(s)\n";
    }
    if (fonts != 0) {
        string += fonts + " Font(s)\n";
    }
    if (gcs != 0) {
        string += gcs + " GC(s)\n";
    }
    if (images != 0) {
        string += images + " Image(s)\n";
    }
    if (paths != 0) {
        string += paths + " Paths(s)\n";
    }
    if (patterns != 0) {
        string += patterns + " Pattern(s)\n";
    }
    if (regions != 0) {
        string += regions + " Region(s)\n";
    }
    if (textLayouts != 0) {
        string += textLayouts + " TextLayout(s)\n";
    }
    if (transforms != 0) {
        string += transforms + " Transform(s)\n";
    }
    if (string.length() != 0) {
        string = string.substring(0, string.length() - 1);
    }
    label.setText(string);
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Color(org.eclipse.swt.graphics.Color) Cursor(org.eclipse.swt.graphics.Cursor) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) TextLayout(org.eclipse.swt.graphics.TextLayout) Region(org.eclipse.swt.graphics.Region) GC(org.eclipse.swt.graphics.GC) Transform(org.eclipse.swt.graphics.Transform)

Example 17 with Path

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

the class BusinessActorFigure 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, 2 / 3.0);
    if (!isEnabled()) {
        setDisabledState(graphics);
    }
    graphics.setAlpha(getAlpha());
    graphics.setBackgroundColor(getFillColor());
    Pattern gradient = applyGradientPattern(graphics, rect);
    Path path = new Path(null);
    int diameter = Math.min(rect.width / 2, rect.height / 3);
    path.addArc((rect.x + rect.width / 2 - diameter / 2), (rect.y + rect.height / 2 - diameter - diameter / 2), diameter, diameter, 0, 360);
    graphics.fillPath(path);
    disposeGradientPattern(graphics, gradient);
    // Lines
    graphics.setAlpha(getLineAlpha());
    graphics.setForegroundColor(getLineColor());
    graphics.drawPath(path);
    path.dispose();
    graphics.setLineCap(SWT.CAP_ROUND);
    graphics.drawLine(rect.x + rect.width / 2, rect.y + rect.height / 2 - diameter / 2, rect.x + rect.width / 2, rect.y + rect.height / 2 - diameter / 2 + diameter);
    graphics.drawLine(rect.x + rect.width / 2, rect.y + rect.height / 2 - diameter / 2 + diameter, rect.x + rect.width / 2 - diameter, rect.y + rect.height / 2 - diameter / 2 + diameter + diameter);
    graphics.drawLine(rect.x + rect.width / 2, rect.y + rect.height / 2 - diameter / 2 + diameter, rect.x + rect.width / 2 + diameter, rect.y + rect.height / 2 - diameter / 2 + diameter + diameter);
    graphics.drawLine(rect.x + rect.width / 2 - diameter, rect.y + rect.height / 2 - diameter / 4, rect.x + rect.width / 2 + diameter, rect.y + rect.height / 2 - diameter / 4);
    // 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)

Example 18 with Path

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

the class CapabilityFigure 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 = new Path(null);
    // block length
    int blockLength = Math.min(rect.height / 3, rect.width / 3);
    int figureLength = blockLength * 3;
    int xMargin = (rect.width - figureLength) / 2;
    int yMargin = (rect.height - figureLength) / 2;
    path.moveTo(rect.x + xMargin, rect.y + yMargin + 3 * blockLength);
    path.lineTo(rect.x + xMargin, rect.y + yMargin + 2 * blockLength);
    path.lineTo(rect.x + xMargin + 1 * blockLength, rect.y + yMargin + 2 * blockLength);
    path.lineTo(rect.x + xMargin + 1 * blockLength, rect.y + yMargin + 1 * blockLength);
    path.lineTo(rect.x + xMargin + 2 * blockLength, rect.y + yMargin + 1 * blockLength);
    path.lineTo(rect.x + xMargin + 2 * blockLength, rect.y + yMargin);
    path.lineTo(rect.x + xMargin + 3 * blockLength, rect.y + yMargin);
    path.lineTo(rect.x + xMargin + 3 * blockLength, rect.y + yMargin + 3 * blockLength);
    path.close();
    graphics.fillPath(path);
    disposeGradientPattern(graphics, gradient);
    graphics.setAlpha(getLineAlpha());
    graphics.setForegroundColor(getLineColor());
    graphics.drawPath(path);
    path.dispose();
    // Inner lines
    graphics.drawLine(rect.x + xMargin + 1 * blockLength, rect.y + yMargin + 3 * blockLength, rect.x + xMargin + 1 * blockLength, rect.y + yMargin + 2 * blockLength);
    graphics.drawLine(rect.x + xMargin + 2 * blockLength, rect.y + yMargin + 3 * blockLength, rect.x + xMargin + 2 * blockLength, rect.y + yMargin + 1 * blockLength);
    graphics.drawLine(rect.x + xMargin + 1 * blockLength, rect.y + yMargin + 2 * blockLength, rect.x + xMargin + 3 * blockLength, rect.y + yMargin + 2 * blockLength);
    graphics.drawLine(rect.x + xMargin + 2 * blockLength, rect.y + yMargin + 1 * blockLength, rect.x + xMargin + 3 * blockLength, rect.y + yMargin + 1 * blockLength);
    // 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)

Example 19 with Path

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

the class CommunicationNetworkFigure method drawIcon.

/**
 * Draw the icon
 */
protected void drawIcon(Graphics graphics) {
    if (!isIconVisible()) {
        return;
    }
    graphics.pushState();
    graphics.setLineWidthFloat(1);
    graphics.setForegroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);
    Point pt = getIconOrigin();
    Path path = new Path(null);
    path.addArc(pt.x, pt.y, 5, 5, 0, 360);
    path.addArc(pt.x + 2, pt.y - 8, 5, 5, 0, 360);
    path.addArc(pt.x + 10, pt.y - 8, 5, 5, 0, 360);
    path.addArc(pt.x + 8, pt.y, 5, 5, 0, 360);
    path.moveTo(pt.x + 3, pt.y);
    path.lineTo(pt.x + 4, pt.y - 3);
    path.moveTo(pt.x + 11, pt.y);
    path.lineTo(pt.x + 12, pt.y - 3);
    path.moveTo(pt.x + 5, pt.y + 2.5f);
    path.lineTo(pt.x + 8, pt.y + 2.5f);
    path.moveTo(pt.x + 7, pt.y - 5.5f);
    path.lineTo(pt.x + 10, pt.y - 5.5f);
    graphics.drawPath(path);
    path.dispose();
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Point(org.eclipse.draw2d.geometry.Point)

Example 20 with Path

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

the class PathDrawnPolygonDecoration method outlineShape.

@Override
protected void outlineShape(Graphics g) {
    Path path = FigureUtils.createPathFromPoints(getPoints());
    g.drawPath(path);
    path.dispose();
}
Also used : Path(org.eclipse.swt.graphics.Path)

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