Search in sources :

Example 21 with Path

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

the class PathDrawnPolygonDecoration method fillShape.

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

Example 22 with Path

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

the class ArtifactFigure 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);
    Point pt = getIconOrigin();
    Path path = new Path(null);
    path.moveTo(pt.x, pt.y);
    path.lineTo(pt.x + 7, pt.y);
    path.lineTo(pt.x + 12, pt.y + 5);
    path.lineTo(pt.x + 12, pt.y + 15);
    path.lineTo(pt.x, pt.y + 15);
    path.lineTo(pt.x, pt.y - 0.5f);
    path.moveTo(pt.x + 7, pt.y);
    path.lineTo(pt.x + 7, pt.y + 5);
    path.lineTo(pt.x + 12, pt.y + 5);
    graphics.drawPath(path);
    path.dispose();
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Point(org.eclipse.draw2d.geometry.Point)

Example 23 with Path

use of org.eclipse.swt.graphics.Path 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();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) IIconic(com.archimatetool.model.IIconic) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 24 with Path

use of org.eclipse.swt.graphics.Path 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();
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 25 with Path

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

the class BusinessRoleFigure 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);
    Point pt = getIconOrigin();
    Path path = new Path(null);
    path.addArc(pt.x, pt.y, 5, 8, 90, 180);
    path.lineTo(pt.x + 12, pt.y + 8);
    path.moveTo(pt.x + 2f, pt.y);
    path.lineTo(pt.x + 12, pt.y);
    graphics.drawPath(path);
    path.dispose();
    graphics.drawOval(pt.x + 10, pt.y, 5, 8);
    graphics.popState();
}
Also used : Path(org.eclipse.swt.graphics.Path) Point(org.eclipse.draw2d.geometry.Point)

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