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

The following examples show how to use org.eclipse.draw2d.Graphics#drawRectangle() . 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: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void drawDqBar(Graphics g) {
	DQResult dqResult = ((ProductSystemNode) node.parent).editor.dqResult;
	if (!DQUI.displayProcessQuality(dqResult))
		return;
	Point loc = getLocation();
	Dimension size = getSize();
	Color fColor = g.getForegroundColor();
	Color bColor = g.getBackgroundColor();
	g.setForegroundColor(Colors.white());
	g.setBackgroundColor(Colors.white());
	int x = loc.x + size.width - 30;
	int y = loc.y + 10;
	int w = 20;
	DQSystem system = dqResult.setup.processSystem;
	int h = (size.height - 20) / system.indicators.size();
	int[] values = dqResult.get(node.process);
	for (int i = 0; i < values.length; i++) {
		Color color = DQUI.getColor(values[i], system.getScoreCount());
		g.setBackgroundColor(color);
		g.drawRectangle(x, y, w, h);
		g.fillRectangle(x + 1, y + 1, w - 1, h - 1);
		y += h;
	}
	g.setForegroundColor(fColor);
	g.setBackgroundColor(bColor);
}
 
Example 2
Source File: PlotArea.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void paintClientArea(final Graphics graphics) {
	super.paintClientArea(graphics);
	if (showBorder) {
		graphics.setLineWidth(2);
		graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);
		graphics.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height);
	}
	// Show the start/end cursor or the 'rubberband' of a zoom operation?
	if (armed && end != null && start != null) {
		switch (zoomType) {
		case RUBBERBAND_ZOOM:
		case DYNAMIC_ZOOM:
		case HORIZONTAL_ZOOM:
		case VERTICAL_ZOOM:
			graphics.setLineStyle(SWTConstants.LINE_DOT);
			graphics.setLineWidth(1);
			graphics.setForegroundColor(revertBackColor);
			graphics.drawRectangle(start.x, start.y, end.x - start.x, end.y - start.y);
			break;

		default:
			break;
		}
	}
}
 
Example 3
Source File: RectangleFigureExtension.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see Shape#outlineShape(Graphics)
 */
@Override
protected void outlineShape ( final Graphics graphics )
{
    final float lineInset = Math.max ( 1.0f, getLineWidthFloat () ) / 2.0f;
    final int inset1 = (int)Math.floor ( lineInset );
    final int inset2 = (int)Math.ceil ( lineInset );

    final Rectangle r = Rectangle.SINGLETON.setBounds ( getBounds () );
    r.x += inset1;
    r.y += inset1;
    r.width -= inset1 + inset2;
    r.height -= inset1 + inset2;

    graphics.drawRectangle ( r );
}
 
Example 4
Source File: ReportRootFigure.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void paintFigure( Graphics graphics )
	{
		graphics.fillRectangle( getBounds( ) );
		super.paintFigure( graphics );		
		
//		graphics.setForegroundColor( ReportColorConstants.MarginBorderColor );
//		graphics.drawRectangle( getBounds( ).getCopy( )
//				.crop( getInsets( ) )
//				.crop( DEFAULT_CROP ) );
		
		graphics.setForegroundColor( ReportColorConstants.ReportForeground );
		graphics.drawRectangle( getBounds( ).getCopy( ).crop( new Insets(0, 0, 1,1) ) );
		
//		Rectangle rect = getBounds( );
//		
//		graphics.setForegroundColor( ColorConstants.white );
//		graphics.setBackgroundColor( ColorConstants.gray );
//		graphics.fillGradient( rect.x, rect.y, 5, rect.height, false );

	}
 
Example 5
Source File: DirectEditManagerEx.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	Rectangle rect = getPaintRectangle(figure, insets);
	graphics.setForegroundColor(ColorConstants.white);
	graphics.drawLine(rect.x, rect.y, rect.x, rect.bottom());
	rect.x++;
	rect.width--;
	rect.resize(-1, -1);
	graphics.setForegroundColor(ColorConstants.black);
	graphics.drawLine(rect.x + 2, rect.bottom(), rect.right(),
			rect.bottom());
	graphics.drawLine(rect.right(), rect.bottom(), rect.right(),
			rect.y + 2);

	rect.resize(-1, -1);
	graphics.setForegroundColor(BLUE);
	graphics.drawRectangle(rect);
}
 
Example 6
Source File: ReportFigureUtilities.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Paints expand handle
 * 
 * @param graphics
 * @param height
 * @param center
 * @param collapsed
 */
public static void paintExpandHandle( Graphics graphics, int height,
		Point center, boolean collapsed )
{
	graphics.drawRectangle( center.x - height / 2,
			center.y - height / 2,
			height,
			height );

	graphics.drawLine( center.x - height / 2 + 2, center.y, center.x
			+ height
			/ 2
			- 2, center.y );

	if ( collapsed )
	{
		graphics.drawLine( center.x,
				center.y - height / 2 + 2,
				center.x,
				center.y + height / 2 - 2 );
	}
}
 
Example 7
Source File: MultipleGuideHandle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void paintFigure( Graphics graphics )
{
	Rectangle rect = getBounds( );

	graphics.setLineWidth( 2 );
	graphics.drawRectangle( rect );

	graphics.drawLine( rect.x,
			rect.y - 1,
			rect.x + rect.width,
			rect.y - 1 );
	graphics.drawLine( rect.x, rect.y, rect.x, rect.y + rect.height );

	graphics.setLineWidth( 3 );
	graphics.drawLine( rect.x + rect.width,
			rect.y,
			rect.x + rect.width,
			rect.y + rect.height );
	graphics.drawLine( rect.x, rect.y + rect.height, rect.x
			+ rect.width, rect.y + rect.height );

}
 
Example 8
Source File: ERDiagramLineBorder.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private void paint1(int i, Color color, Rectangle tempRect,
		Graphics graphics) {
	tempRect.x++;
	tempRect.y++;
	tempRect.width -= 2;
	tempRect.height -= 2;

	graphics.setForegroundColor(color);
	graphics.drawRectangle(tempRect);
}
 
Example 9
Source File: RectangleFigure.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void outlineShape( Graphics graphics )
{
	Rectangle bounds = getBounds( ).getCopy( );
	Border border = getBorder( );
	if ( border != null )
	{
		bounds = bounds.crop( border.getInsets( null ) );
	}
	graphics.drawRectangle( bounds.x,
			bounds.y,
			bounds.width - 1,
			bounds.height - 1 );

}
 
Example 10
Source File: ListBandControlFigure.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void paintFigure( Graphics graphics )
{
	graphics.setForegroundColor( ReportColorConstants.ShadowLineColor );
	graphics.setLineStyle( SWT.LINE_SOLID );
	graphics.drawRectangle( getBounds( ).getCopy( ).shrink( 2, 1 ) );
	graphics.setBackgroundColor( ReportColorConstants.ListControlFillColor );
	graphics.fillRectangle( getBounds( ).getCopy( ).shrink( 3, 2 ) );
}
 
Example 11
Source File: ERDiagramLineBorder.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void paint1(int i, Color color, Rectangle tempRect, Graphics graphics) {
    tempRect.x++;
    tempRect.y++;
    tempRect.width -= 2;
    tempRect.height -= 2;

    graphics.setForegroundColor(color);
    graphics.drawRectangle(tempRect);
}
 
Example 12
Source File: ERDiagramLineBorder.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void paint1(final int i, final Color color, final Rectangle tempRect, final Graphics graphics) {
    tempRect.x++;
    tempRect.y++;
    tempRect.width -= 2;
    tempRect.height -= 2;

    graphics.setForegroundColor(color);
    graphics.drawRectangle(tempRect);
}
 
Example 13
Source File: ListBandRenderFigure.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void paintFigure( Graphics graphics )
{
	graphics.setForegroundColor( ReportColorConstants.ShadowLineColor );
	graphics.setLineStyle( SWT.LINE_SOLID );
	graphics.drawRectangle( getBounds( ).getCopy( ).shrink( 2, 2 ) );
}
 
Example 14
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();
}
 
Example 15
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
	super.paintFigure(graphics);
	if (trace != null && currentSnappedSample == null && !pointerDragged)
		updateToDefaultPosition();

	if (Preferences.useAdvancedGraphics())
		graphics.setAntialias(SWT.ON);
	Color tempColor;
	if (annotationColor == null) {
		tempColor = yAxis.getForegroundColor();
	} else
		tempColor = annotationColor;
	infoLabel.setForegroundColor(tempColor);
	pointer.setForegroundColor(tempColor);
	if (vLine != null)
		vLine.setForegroundColor(tempColor);
	if (hLine != null)
		hLine.setForegroundColor(tempColor);
	graphics.setForegroundColor(tempColor);

	if (infoLabelArmed) // draw infoLabel Armed rect
		graphics.drawRectangle(infoLabel.getBounds());
	if (showName || showPosition || showSampleInfo) {
		// draw indicate line
		graphics.drawLine(currentPosition.x + (int) dx, currentPosition.y + (int) dy, currentPosition.x,
				currentPosition.y);
		// draw Arrow
		int x1 = (int) (ARROW_LINE_LENGTH * Math.cos(Math.atan(-dy / dx) - Math.PI / 9));
		int y1 = (int) (ARROW_LINE_LENGTH * Math.sin(Math.atan(-dy / dx) - Math.PI / 9));
		if (dx < 0) {
			x1 = -x1;
			y1 = -y1;
		}
		graphics.drawLine(currentPosition.x + x1, currentPosition.y - y1, currentPosition.x, currentPosition.y);
		x1 = (int) (ARROW_LINE_LENGTH * Math.cos(Math.atan(-dy / dx) + Math.PI / 9));
		y1 = (int) (ARROW_LINE_LENGTH * Math.sin(Math.atan(-dy / dx) + Math.PI / 9));
		if (dx < 0) {
			x1 = -x1;
			y1 = -y1;
		}
		graphics.drawLine(currentPosition.x + x1, currentPosition.y - y1, currentPosition.x, currentPosition.y);
	}
	// draw Cursor Line
	switch (cursorLineStyle) {
	case NONE:
		// left
		graphics.drawLine(currentPosition.x - POINT_SIZE / 2, currentPosition.y,
				currentPosition.x - POINT_SIZE / 2 - CURSOR_LINE_LENGTH, currentPosition.y);
		// right
		graphics.drawLine(currentPosition.x + POINT_SIZE / 2, currentPosition.y,
				currentPosition.x + POINT_SIZE / 2 + CURSOR_LINE_LENGTH, currentPosition.y);
		// up
		graphics.drawLine(currentPosition.x, currentPosition.y - POINT_SIZE / 2, currentPosition.x,
				currentPosition.y - POINT_SIZE / 2 - CURSOR_LINE_LENGTH);
		// down
		graphics.drawLine(currentPosition.x, currentPosition.y + POINT_SIZE / 2, currentPosition.x,
				currentPosition.y + POINT_SIZE / 2 + CURSOR_LINE_LENGTH);
		break;
	case FOUR_DIRECTIONS:
	case LEFT_RIGHT:
		// left
		graphics.drawLine(currentPosition.x - POINT_SIZE / 2, currentPosition.y,
				xAxis.getValuePosition(xAxis.getRange().getLower(), false), currentPosition.y);
		// right
		graphics.drawLine(currentPosition.x + POINT_SIZE / 2, currentPosition.y,
				xAxis.getValuePosition(xAxis.getRange().getUpper(), false), currentPosition.y);
		if (cursorLineStyle != CursorLineStyle.FOUR_DIRECTIONS)
			break;
	case UP_DOWN:
		// up
		graphics.drawLine(currentPosition.x, currentPosition.y - POINT_SIZE / 2, currentPosition.x,
				yAxis.getValuePosition(yAxis.getRange().getUpper(), false));
		// down
		graphics.drawLine(currentPosition.x, currentPosition.y + POINT_SIZE / 2, currentPosition.x,
				yAxis.getValuePosition(yAxis.getRange().getLower(), false));
		break;
	default:
		break;
	}

}
 
Example 16
Source File: StatisticFigure.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
private void drawBox(Graphics graphics, Point boxSize, Point topLeft) {
	graphics.drawRectangle(topLeft.x, topLeft.y, boxSize.x, boxSize.y);
	graphics.fillRectangle(topLeft.x + 1, topLeft.y + 1, boxSize.x - 1,
			boxSize.y - 1);
}
 
Example 17
Source File: Axis.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void paintClientArea(final Graphics graphics) {
	// Don't do anything when hidden
	if (!isVisible())
		return;

	super.paintClientArea(graphics);

	// graphics.pushState();
	if (title != null) {
		graphics.setFont(titleFont);
		final Dimension titleSize = FigureUtilities.getTextExtents(title, titleFont);
		if (isHorizontal()) {
			if (getTickLabelSide() == LabelSide.Primary)
				graphics.drawText(title, bounds.x + bounds.width / 2 - titleSize.width / 2,
						bounds.y + bounds.height - titleSize.height);
			else
				graphics.drawText(title, bounds.x + bounds.width / 2 - titleSize.width / 2, bounds.y);
		} else {
			final int w = titleSize.height;
			final int h = titleSize.width + 1;

			if (getTickLabelSide() == LabelSide.Primary) {
				GraphicsUtil.drawVerticalText(graphics, title, bounds.x, bounds.y + bounds.height / 2 - h / 2,
						false);
			} else {
				GraphicsUtil.drawVerticalText(graphics, title, bounds.x + bounds.width - w,
						bounds.y + bounds.height / 2 - h / 2, true);
			}
		}
	}
	// graphics.popState();

	// Show the start/end cursor or the 'rubberband' of a zoom operation?
	if (armed && end != null && start != null) {
		switch (zoomType) {
		case RUBBERBAND_ZOOM:
		case HORIZONTAL_ZOOM:
		case VERTICAL_ZOOM:
		case DYNAMIC_ZOOM:
			graphics.setLineStyle(SWTConstants.LINE_DOT);
			graphics.setLineWidth(1);
			graphics.setForegroundColor(revertBackColor);
			graphics.drawRectangle(start.x, start.y, end.x - start.x - 1, end.y - start.y - 1);
			break;

		default:
			break;
		}
	}
}
 
Example 18
Source File: ScaledSliderFigure.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
		protected void fillShape(Graphics graphics) {		
			
			graphics.setAntialias(SWT.ON);			
			int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false);
			boolean support3D = GraphicsUtil.testPatternSupported(graphics);
			if(effect3D && support3D) {		
				//fill background
				graphics.setBackgroundColor(fillBackgroundColor);
				super.fillShape(graphics);
				Pattern backGroundPattern; 
				if(horizontal)
					backGroundPattern= GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(),
						bounds.x, bounds.y,
						bounds.x, bounds.y + bounds.height,
						WHITE_COLOR, 255,
						fillBackgroundColor, 0);
				else
					backGroundPattern= GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(),
						bounds.x, bounds.y,
						bounds.x + bounds.width, bounds.y,
						WHITE_COLOR, 255,
						fillBackgroundColor, 0);
				graphics.setBackgroundPattern(backGroundPattern);
				super.fillShape(graphics);
				graphics.setForegroundColor(fillBackgroundColor);
				outlineShape(graphics);
				backGroundPattern.dispose();
				
				//fill value
				if(horizontal)
					backGroundPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(),
						bounds.x, bounds.y,
						bounds.x, bounds.y + bounds.height,
						WHITE_COLOR, 255,
						fillColor, 0);
				else
					backGroundPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(),
						bounds.x, bounds.y,
						bounds.x + bounds.width, bounds.y,
						WHITE_COLOR, 255,
						fillColor, 0);
				
				graphics.setBackgroundColor(fillColor);
				graphics.setForegroundColor(fillColor);
				if(horizontal){
					int fillWidth = valuePosition - bounds.x;				
					graphics.fillRectangle(new Rectangle(bounds.x,
						bounds.y, fillWidth, bounds.height));
					graphics.setBackgroundPattern(backGroundPattern);
					graphics.fillRectangle(new Rectangle(bounds.x,
						bounds.y, fillWidth, bounds.height));
					
					graphics.drawRectangle(new Rectangle(bounds.x + lineWidth / 2,
						bounds.y + lineWidth / 2, 
						fillWidth - Math.max(1, lineWidth),
						bounds.height - Math.max(1, lineWidth)));
					
					
				}else {
					int fillHeight = bounds.height - (valuePosition - bounds.y);				
					graphics.fillRectangle(new Rectangle(bounds.x,
						valuePosition, bounds.width, fillHeight));
					graphics.setBackgroundPattern(backGroundPattern);
					graphics.fillRectangle(new Rectangle(bounds.x,
						valuePosition, bounds.width, fillHeight));
					
					graphics.drawRectangle(new Rectangle(bounds.x + lineWidth / 2,
						valuePosition+ lineWidth / 2, 
						bounds.width- Math.max(1, lineWidth),
						fillHeight - Math.max(1, lineWidth)));
				}		
				
				backGroundPattern.dispose();
				
				
				
				
			}else {
				graphics.setBackgroundColor(fillBackgroundColor);
				super.fillShape(graphics);				
				graphics.setBackgroundColor(fillColor);
				if(horizontal)
					graphics.fillRectangle(new Rectangle(bounds.x,
							bounds.y, 						
							valuePosition - bounds.x, 
							bounds.height));
				else
					graphics.fillRectangle(new Rectangle(bounds.x,
							valuePosition,
							bounds.width,
							bounds.height - (valuePosition - bounds.y)));
//				graphics.setForegroundColor(outlineColor);
			}			
		}