use of org.eclipse.swt.graphics.Path in project n4js by eclipse.
the class GraphUtils method arcSelf.
/**
* Paints an looping arc from scr to tgt.
* <p/>
* <b>Assumption:</b> The tgt is located right/below of the src.
*/
public static float[] arcSelf(GC gc, Point src, Point tgt) {
Path path = new Path(gc.getDevice());
int diffH = 10;
int diff = diffH * 3;
path.moveTo((int) src.x, (int) src.y);
path.cubicTo((int) src.x + diff, (int) src.y - diffH, (int) tgt.x, (int) tgt.y - diff, (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 liferay-ide by liferay.
the class GearControl method _drawGear.
private Path _drawGear(GC gc, Display display, double cx, double cy, double outerR, double innerR, float angleOffset) {
double radian2 = _teethAngle / 2 * _radian;
double radian3 = .06;
Path path = new Path(display);
for (int i = 0; i < _teeth; i++) {
double radian = (i * _teethAngle + angleOffset) * _radian;
double x = cx + outerR * Math.cos(radian);
double y = cy - outerR * Math.sin(radian);
if (i == 0) {
path.moveTo((int) x, (int) y);
}
double r1 = radian + radian3;
double r3 = radian + radian2;
double r2 = r3 - radian3;
double r4 = r3 + radian2;
x = cx + innerR * Math.cos(r1);
y = cy - innerR * Math.sin(r1);
path.lineTo((int) x, (int) y);
x = cx + innerR * Math.cos(r2);
y = cy - innerR * Math.sin(r2);
path.lineTo((int) x, (int) y);
x = cx + outerR * Math.cos(r3);
y = cy - outerR * Math.sin(r3);
path.lineTo((int) x, (int) y);
x = cx + outerR * Math.cos(r4);
y = cy - outerR * Math.sin(r4);
path.lineTo((int) x, (int) y);
}
path.close();
gc.fillPath(path);
gc.drawPath(path);
return path;
}
use of org.eclipse.swt.graphics.Path in project statecharts by Yakindu.
the class ExitFigure method paint.
@Override
public void paint(Graphics graphics) {
graphics.pushState();
graphics.setForegroundColor(getForegroundColor());
graphics.setBackgroundColor(getBackgroundColor());
super.paint(graphics);
Path path = new Path(Display.getDefault());
path.addArc(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1, 0, 360);
graphics.setClip(path);
graphics.setLineWidth(2);
graphics.drawLine(bounds.getTopLeft(), bounds.getBottomRight());
graphics.drawLine(bounds.getTopRight(), bounds.getBottomLeft());
path.dispose();
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project statecharts by Yakindu.
the class GraphicsUtil method fillVerticalGradientRoundedRectangle.
/**
* This function fills a rounded rectangle with a vertical gradient. This
* implementation does not use the gradient mechanism based on background
* patterns since they do not work stable on all systems.
*
* @param graphics
* @param bounds
* @param corner
* @param c1
* @param c2
*/
public static void fillVerticalGradientRoundedRectangle(Graphics graphics, Rectangle bounds, Dimension corner, Color c1, Color c2) {
graphics.pushState();
graphics.setForegroundColor(c2);
graphics.setBackgroundColor(c1);
graphics.fillGradient(bounds.x, bounds.y + (corner.height >> 1), bounds.width, bounds.height - corner.height, true);
Path p = new Path(null);
p.addArc(bounds.x, bounds.y + bounds.height - corner.height - 1, corner.width, corner.height, 180, 90);
p.addArc(bounds.x + bounds.width - corner.width - 1, bounds.y + bounds.height - corner.height - 1, corner.width, corner.height, 270, 90);
graphics.fillPath(p);
p.dispose();
p = new Path(null);
graphics.setBackgroundColor(c2);
p.addArc(bounds.x + bounds.width - corner.width - 1, bounds.y, corner.width, corner.height, 0, 90);
p.addArc(bounds.x, bounds.y, corner.width, corner.height, 90, 90);
graphics.fillPath(p);
p.dispose();
graphics.popState();
}
use of org.eclipse.swt.graphics.Path in project tesb-studio-se by Talend.
the class SearchControl method paintControl.
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setAntialias(SWT.ON);
Rectangle bounds = getBounds();
Path path = new Path(getDisplay());
path.addArc(bounds.x, bounds.y, arcSize, arcSize, 90, 180);
// path.addRectangle(bounds.x + arcSize / 2, bounds.y, bounds.width - arcSize,
// arcSize);
path.addArc(bounds.x + bounds.width - arcSize, bounds.y, arcSize, arcSize, 270, 180);
// gc.setClipping(path);
Color b = gc.getBackground();
gc.setBackground(backgroundColor);
gc.fillPath(path);
path.dispose();
gc.setAntialias(SWT.OFF);
gc.setBackground(b);
}
Aggregations