Java Code Examples for org.eclipse.draw2d.Graphics#drawOval()

The following examples show how to use org.eclipse.draw2d.Graphics#drawOval() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamFigure.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
protected void outlineShape(Graphics graphics) {
	graphics.drawOval(getOptimizedBounds().x + getOptimizedBounds().width * 4 / 5, 
					  getOptimizedBounds().y,
					  getOptimizedBounds().width / 5, 
					  getOptimizedBounds().height);
	//
	graphics.drawArc(getOptimizedBounds().x, 
					 getOptimizedBounds().y, 
					 getOptimizedBounds().width / 5,
					 getOptimizedBounds().height, 90, 180);
	//
	graphics.drawLine(getOptimizedBounds().x + getOptimizedBounds().width * 9 / 10, 
					  getOptimizedBounds().y,
					  getOptimizedBounds().x + getOptimizedBounds().width * 1 / 10, 
					  getOptimizedBounds().y);

	graphics.drawLine(getOptimizedBounds().x + getOptimizedBounds().width * 1 / 10,
					  getOptimizedBounds().y + getOptimizedBounds().height,
					  getOptimizedBounds().x + getOptimizedBounds().width * 9 / 10,
					  getOptimizedBounds().y + getOptimizedBounds().height);
}
 
Example 2
Source File: CircleAnnotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
	if (trace != null && currentSnappedSample == null && !pointerDragged)
		updateToDefaultPosition();

	if (Preferences.useAdvancedGraphics())
		graphics.setAntialias(SWT.ON);

	graphics.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
	xValue = currentSnappedSample.getXValue();
	yValue = currentSnappedSample.getYValue();
	int x = xAxis.getValuePosition(xValue, false);
	int y = yAxis.getValuePosition(yValue, false);
	graphics.drawOval(x - (CIRCLE_DIAMETER / 2), y - (CIRCLE_DIAMETER / 2), CIRCLE_DIAMETER, CIRCLE_DIAMETER);
}
 
Example 3
Source File: Trace.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void drawPoint(Graphics graphics, Point pos, ISample sample) {
	Color renderColor = traceColor;
	PointStyle renderPointStyle = pointStyle;
	int renderPointSize = pointSize;
	try {
		if ((fPointStyleProvider != null) && (sample != null)) {
			renderColor = fPointStyleProvider.getPointColor(sample, this);
			renderPointStyle = fPointStyleProvider.getPointStyle(sample, this);
			renderPointSize = fPointStyleProvider.getPointSize(sample, this);
		}
	} catch (Exception ex) {
		// Draw anyway and log error
		System.err.println(ex.getMessage());
		renderColor = traceColor;
		renderPointStyle = pointStyle;
		renderPointSize = pointSize;
	}
	// Shortcut when no point requested
	if (renderPointStyle == PointStyle.NONE) {
		return;
	}
	graphics.pushState();
	graphics.setBackgroundColor(renderColor);
	graphics.setForegroundColor(renderColor); // Otherwise redraw does not
												// affect lines
	graphics.setLineWidth(1);
	graphics.setLineStyle(SWTConstants.LINE_SOLID);
	int halfSize = renderPointSize / 2;
	switch (renderPointStyle) {
	case POINT:
		graphics.fillOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case CIRCLE:
		graphics.drawOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case FILLED_CIRCLE:
		graphics.fillOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case TRIANGLE:
		graphics.drawPolygon(new int[] { pos.x - halfSize, pos.y + halfSize, pos.x, pos.y - halfSize,
				pos.x + halfSize, pos.y + halfSize });
		break;
	case FILLED_TRIANGLE:
		graphics.fillPolygon(new int[] { pos.x - halfSize, pos.y + halfSize, pos.x, pos.y - halfSize,
				pos.x + halfSize, pos.y + halfSize });
		break;
	case SQUARE:
		graphics.drawRectangle(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case FILLED_SQUARE:
		graphics.fillRectangle(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case BAR:
		graphics.drawLine(pos.x, pos.y - halfSize, pos.x, pos.y + halfSize);
		break;
	case CROSS:
		graphics.drawLine(pos.x, pos.y - halfSize, pos.x, pos.y + halfSize);
		graphics.drawLine(pos.x - halfSize, pos.y, pos.x + halfSize, pos.y);
		break;
	case XCROSS:
		graphics.drawLine(pos.x - halfSize, pos.y - halfSize, pos.x + halfSize, pos.y + halfSize);
		graphics.drawLine(pos.x + halfSize, pos.y - halfSize, pos.x - halfSize, pos.y + halfSize);
		break;
	case DIAMOND:
		graphics.drawPolyline(new int[] { pos.x, pos.y - halfSize, pos.x - halfSize, pos.y,
				pos.x, pos.y + halfSize, pos.x + halfSize, pos.y, pos.x, pos.y - halfSize });
		break;
	case FILLED_DIAMOND:
		graphics.fillPolygon(new int[] { pos.x, pos.y - halfSize, pos.x - halfSize, pos.y,
				pos.x, pos.y + halfSize, pos.x + halfSize, pos.y });
		break;
	default:
		break;
	}
	graphics.popState();
}