use of org.eclipse.swt.graphics.Path in project eclipse.platform.swt by eclipse.
the class FontBounceTab method paint.
@Override
public void paint(GC gc, int width, int height) {
if (!example.checkAdvancedGraphics())
return;
Device device = gc.getDevice();
Font font = new Font(device, getPlatformFontFace(fontFace), fontSize, fontStyle);
gc.setFont(font);
Point size = gc.stringExtent(text);
textWidth = size.x;
textHeight = size.y;
Path path = new Path(device);
path.addString(text, x, y, font);
gc.setForeground(device.getSystemColor(foreGrdColor));
gc.setBackground(device.getSystemColor(fillColor));
gc.fillPath(path);
gc.drawPath(path);
font.dispose();
path.dispose();
}
use of org.eclipse.swt.graphics.Path in project eclipse.platform.swt by eclipse.
the class GradientTab method createImage.
/**
* Creates and returns an image made up of gradient patterns. The image takes up
* a quarter of the area of the total drawing surface.
*
* @param device
* A Device
* @param color1
* A Color
* @param color2
* A Color
* @param width
* Width of the drawing surface
* @param height
* Height of the drawing surface
*/
Image createImage(Device device, Color color1, Color color2, int width, int height) {
Image image = new Image(device, width / 2, height / 2);
GC gc = new GC(image);
Rectangle rect = image.getBounds();
Pattern pattern1 = new Pattern(device, rect.x, rect.y, rect.width / 2f, rect.height / 2f, color1, color2);
gc.setBackgroundPattern(pattern1);
Path path = new Path(device);
path.addRectangle(0, 0, width / 4f, height / 4f);
path.addRectangle(width / 4f, height / 4f, width / 4f, height / 4f);
gc.fillPath(path);
path.dispose();
Pattern pattern2 = new Pattern(device, rect.width, 0, rect.width / 2f, rect.height / 2f, color1, color2);
gc.setBackgroundPattern(pattern2);
path = new Path(device);
path.addRectangle(width / 4f, 0, width / 4f, height / 4f);
path.addRectangle(0, height / 4f, width / 4f, height / 4f);
gc.fillPath(path);
path.dispose();
gc.dispose();
pattern1.dispose();
pattern2.dispose();
return image;
}
use of org.eclipse.swt.graphics.Path in project liferay-ide by liferay.
the class GearControl method onMouseMove.
@Override
protected void onMouseMove(int x, int y) {
if ((x != Integer.MIN_VALUE) && (y != Integer.MIN_VALUE)) {
GC gc = new GC(this);
int number = UpgradeView.getPageNumber();
for (int i = 0; i < number; i++) {
Path path = _gearPaths[i];
if ((path != null) && path.contains(x, y, gc, false)) {
if (i != _hover) {
_hover = i;
}
return;
}
}
}
_hover = NONE;
}
use of org.eclipse.swt.graphics.Path in project liferay-ide by liferay.
the class GearControl method _paintGear.
private Point _paintGear(GC gc, int i, int alpha) {
double offset = 2 * i * _radius;
double x = _border + _radius + offset;
double y = _border + _radius;
double r2 = (double) _radius * .8F;
double r3 = (double) _radius * .5F;
int selected = 0;
double factor = 1;
if (i == _oldSelection) {
if (_speed < (_teethAngle / 2)) {
selected = 1;
}
} else if (i == _selection) {
if (_speed >= (_teethAngle / 2)) {
selected = 1;
factor += (_teethAngle - _speed) * .02;
} else {
factor += _speed * .02;
}
}
boolean hovered = false;
if (i == _hover) {
factor += .1;
_oldHover = _hover;
if (selected == 0) {
hovered = true;
}
}
double outerR = factor * _radius;
double innerR = factor * r2;
float angleOffset = (_angle + i * _teethAngle) * (i % 2 == 1 ? -1 : 1) / 7;
gc.setForeground(hovered ? _darkGray : _gearForeground[selected]);
gc.setBackground(hovered ? _gray : _gearBackground[selected]);
if (outerR < 32.0) {
outerR = 32.0D;
}
if (innerR < 25.0) {
innerR = 25.600000381469727D;
}
Path path = _drawGear(gc, _display, x, y, outerR, innerR, angleOffset);
if (_gearPaths[i] != null) {
_gearPaths[i].dispose();
}
_gearPaths[i] = path;
int ovalX = (int) (x - factor * r3);
int ovalY = (int) (y - factor * r3);
int ovalR = (int) (2 * factor * r3);
gc.setBackground(_white);
gc.fillOval(ovalX, ovalY, ovalR, ovalR);
gc.drawOval(ovalX, ovalY, ovalR, ovalR);
if (i < _gearMaxNumber) {
String number = Integer.toString(i + 1);
gc.setForeground(selected == 1 ? _gearForeground[1] : _gray);
gc.setFont(_numberFont);
drawText(gc, x, y - 1, number);
}
return _paintBadge(gc, x, y, outerR, i, alpha);
}
use of org.eclipse.swt.graphics.Path in project n4js by eclipse.
the class GraphUtils method arcReversed.
/**
* Paints an arc from src to tgt.
* <p/>
* <b>Assumption:</b> The tgt is located below of the src.
*/
public static float[] arcReversed(GC gc, Point src, Point tgt) {
Path path = new Path(gc.getDevice());
int ydiff = (int) ((tgt.y - src.y) / 3);
path.moveTo((int) src.x, (int) src.y);
path.cubicTo((int) src.x, (int) src.y + ydiff, (int) tgt.x, (int) tgt.y - ydiff * 2, (int) tgt.x, (int) tgt.y);
gc.drawPath(path);
float[] pp = path.getPathData().points;
return pp;
}
Aggregations