Search in sources :

Example 11 with Path

use of org.eclipse.swt.graphics.Path in project n4js by eclipse.

the class GraphUtils method arc.

/**
 * Paints an arc from src to tgt using the given control point ctr.
 */
public static float[] arc(GC gc, Point ctr, Point src, Point tgt) {
    Path path = new Path(gc.getDevice());
    path.moveTo((int) src.x, (int) src.y);
    path.quadTo((int) ctr.x, (int) ctr.y, (int) tgt.x, (int) tgt.y);
    gc.drawPath(path);
    float[] pp = path.getPathData().points;
    return pp;
}
Also used : Path(org.eclipse.swt.graphics.Path)

Example 12 with Path

use of org.eclipse.swt.graphics.Path in project BiglyBT by BiglySoftware.

the class PieUtils method drawPie.

public static void drawPie(GC gc, Image image, int x, int y, int width, int height, int percent, boolean draw_border) {
    Rectangle image_size = image.getBounds();
    int width_pad = (width - image_size.width) / 2;
    int height_pad = (height - image_size.height) / 2;
    int angle = (percent * 360) / 100;
    if (angle < 4) {
        // workaround fillArc rendering bug
        angle = 0;
    }
    Region old_clipping = new Region();
    gc.getClipping(old_clipping);
    Path path_done = new Path(gc.getDevice());
    path_done.addArc(x, y, width, height, 90, -angle);
    path_done.lineTo(x + width / 2, y + height / 2);
    path_done.close();
    gc.setClipping(path_done);
    gc.drawImage(image, x + width_pad, y + height_pad + 1);
    Path path_undone = new Path(gc.getDevice());
    path_undone.addArc(x, y, width, height, 90 - angle, angle - 360);
    path_undone.lineTo(x + width / 2, y + height / 2);
    path_undone.close();
    gc.setClipping(path_undone);
    gc.setAlpha(75);
    gc.drawImage(image, x + width_pad, y + height_pad + 1);
    gc.setAlpha(255);
    gc.setClipping(old_clipping);
    if (draw_border) {
        gc.setForeground(Colors.blue);
        if (percent == 100) {
            gc.drawOval(x, y, width - 1, height - 1);
        } else {
            if (angle > 0) {
                gc.drawPath(path_done);
            }
        }
    }
    path_done.dispose();
    path_undone.dispose();
    old_clipping.dispose();
}
Also used : Path(org.eclipse.swt.graphics.Path) Rectangle(org.eclipse.swt.graphics.Rectangle) Region(org.eclipse.swt.graphics.Region)

Example 13 with Path

use of org.eclipse.swt.graphics.Path in project SIMVA-SoS by SESoS.

the class SWTGraphics2D method setClip.

/**
 * Sets the clip region.
 *
 * @param clip  the clip.
 */
public void setClip(Shape clip) {
    if (clip == null) {
        return;
    }
    Path clipPath = toSwtPath(clip);
    this.gc.setClipping(clipPath);
    clipPath.dispose();
}
Also used : Path(org.eclipse.swt.graphics.Path)

Example 14 with Path

use of org.eclipse.swt.graphics.Path in project SIMVA-SoS by SESoS.

the class SWTGraphics2D method fill.

/**
 * Fills the specified shape using the current paint.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 *
 * @see #getPaint()
 * @see #draw(Shape)
 */
public void fill(Shape shape) {
    Path path = toSwtPath(shape);
    // Note that for consistency with the AWT implementation, it is
    // necessary to switch temporarily the foreground and background
    // colours
    switchColors();
    this.gc.fillPath(path);
    switchColors();
    path.dispose();
}
Also used : Path(org.eclipse.swt.graphics.Path)

Example 15 with Path

use of org.eclipse.swt.graphics.Path in project SIMVA-SoS by SESoS.

the class SWTGraphics2D method clip.

/**
 * Applies the specified clip.
 *
 * @param s  the shape for the clip.
 */
public void clip(Shape s) {
    Path path = toSwtPath(s);
    this.gc.setClipping(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