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;
}
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();
}
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();
}
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();
}
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();
}
Aggregations