/* * (non-Javadoc) * * @see org.talend.commons.ui.swt.drawing.link.AbstractDrawableLink#drawBody(org.eclipse.swt.graphics.GC) */ @Override protected void drawBody(GC gc) { boolean point1Above = point1.y > point2.y; int mult = point1Above ? 1 : -1; int keyLinksCounter = 0; int xOffset = 4 * keyLinksCounter + 1; gc.drawLine(point1.x, point1.y, point1.x - connectorWidth - xOffset, point1.y); gc.drawArc( point1.x - connectorWidth - radius - xOffset, point1.y - (point1Above ? 2 * radius : 0), 2 * radius, 2 * radius, point1Above ? 180 : 90, 90); // // in1 pr gc.drawLine( point1.x - connectorWidth - radius - xOffset, point1.y - mult * radius, point2.x - connectorWidth - radius - xOffset, point2.y + mult * radius); gc.drawArc( point2.x - connectorWidth - radius - xOffset, point2.y - (point1Above ? 0 : 2 * radius), 2 * radius, 2 * radius, point1Above ? 90 : 180, 90); // // connector pr (in) gc.drawLine(point2.x - connectorWidth - xOffset, point2.y, point2.x, point2.y); keyLinksCounter++; }
protected void drawRect(GC g2, int x, int y, int width, int height) { g2.drawArc(x, y, width, height, (int) arcStart, (int) arcAngle); }
private void drawAttitudeControls(GC gc, int width, int height) { int size = Math.min(width / 2, height); int verticalOffset = (height - size) / 2; gc.setLineWidth(2); gc.setBackground(background1); gc.fillArc(width / 2 - size, verticalOffset, size, size, 0, 360); gc.fillArc(width / 2, verticalOffset, size, size, 0, 360); gc.setBackground(background2); gc.fillArc(width / 2 - size, verticalOffset, size, size, (int) pitch, -180); gc.fillArc(width / 2, verticalOffset, size, size, (int) roll, -180); gc.setForeground(foregroundWhite); gc.drawArc(width / 2 - size, verticalOffset, size, size, 0, 360); gc.drawArc(width / 2, verticalOffset, size, size, 0, 360); String value = ""; gc.setForeground(foregroundWhite); for (int i = 0; i < 2; i++) { int centerX = width / 2 - i * size; int tickSize = 20; int step = 20; for (int theta = 10; theta <= 360; theta += step) { int x = (int) (size / 2 + size / 2 * Math.cos(theta * Math.PI / 180.0)) + centerX; int y = (int) (size / 2 + size / 2 * Math.sin(theta * Math.PI / 180.0)); int xx = (int) ((size) / 2 + (size - tickSize) / 2 * Math.cos(theta * Math.PI / 180.0)) + centerX; int yy = (int) ((size) / 2 + (size - tickSize) / 2 * Math.sin(theta * Math.PI / 180.0)); gc.drawLine(x, verticalOffset + y, xx, verticalOffset + yy); if (theta < 180) { if (theta > 90 && theta < 180) { yy = yy - 15; xx = xx + 2; value = String.valueOf(theta); } else if (theta > 45 && theta <= 90) { yy = yy - 15; xx = xx - 10; value = String.valueOf(theta); } else if (theta < 45) { yy = yy - 15; xx = xx - 15; value = String.valueOf(theta); } gc.drawText(value, xx, verticalOffset + yy, true); } else { if (theta > 270) { xx = xx - 9; value = String.valueOf(theta - 360); } else { xx = xx - 3; value = String.valueOf(theta - 360); } if (theta == 180) { yy = yy - 7; xx = xx + 10; } else if (theta == 360) { yy = yy - 7; xx = xx - 3; } gc.drawText(value, xx, verticalOffset + yy, true); } } } }