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

The following examples show how to use org.eclipse.draw2d.Graphics#fillRectangle() . 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: 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 2
Source File: ScaledSliderFigure.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void paintClientArea(Graphics graphics) {
	super.paintClientArea(graphics);
	if(hasFocus() && drawFocus){
		graphics.setForegroundColor(ColorConstants.black);
		graphics.setBackgroundColor(ColorConstants.white);

		Rectangle area = getClientArea();					
		graphics.drawFocus(area.x, area.y, area.width-1, area.height-1);
	}
	if(!isEnabled()) {
		graphics.setAlpha(DISABLED_ALPHA);
		graphics.setBackgroundColor(GRAY_COLOR);
		graphics.fillRectangle(bounds);
	}
}
 
Example 3
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 4
Source File: SelectionBorder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void paintRegular( IFigure figure, Graphics graphics, Insets insets )
{
	Rectangle bounds = figure.getBounds( ).getCopy( );
	graphics.translate( bounds.getLocation( ) );

	graphics.setBackgroundColor( ReportColorConstants.SelctionFillColor );

	graphics.fillRectangle( 0, 0, bounds.width, lineWidth );
	graphics.fillRectangle( bounds.width - lineWidth,
			0,
			lineWidth,
			bounds.height );
	graphics.fillRectangle( 0,
			bounds.height - lineWidth,
			bounds.width,
			lineWidth );
	graphics.fillRectangle( 0, 0, lineWidth, bounds.height );

	graphics.translate( bounds.getLocation( ).getNegated( ) );
}
 
Example 5
Source File: CollapsableEventSubprocessFigure.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void fillShape(Graphics graphics) {
	if(useGradient){
		Rectangle r = getBounds().getCopy();
		Point topLeft = r.getTopLeft();
		Point bottomRight = r.getBottomRight();
		Pattern pattern = new Pattern(Display.getCurrent(), topLeft.x +2,
				topLeft.y+2 , bottomRight.x-2, bottomRight.y-2,gradientColor,255,getBackgroundColor(),90);
		graphics.setBackgroundPattern(pattern);
		graphics.fillRectangle(r.crop(new Insets(2,2,2,2)));
		graphics.setBackgroundPattern(null);
		pattern.dispose();
	}else{
		super.fillShape(graphics) ;
	}

}
 
Example 6
Source File: ColumnHandle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void paintFigure( Graphics graphics )
	{
		if ( isSelect( ) )
		{
			graphics.setBackgroundColor( ReportColorConstants.SelctionFillColor );
		}
		else
		{
			graphics.setBackgroundColor( ReportColorConstants.TableGuideFillColor );
		}
		graphics.setLineStyle( SWT.LINE_SOLID );
		Rectangle bounds = getBounds( ).getCopy( );
		graphics.fillRectangle( bounds.resize( -1, -1 ) );
		graphics.setBackgroundColor( ColorConstants.black  );

//		ReportFigureUtilities.paintBevel( graphics,
//				getBounds( ).getCopy( ),
//				true );
	}
 
Example 7
Source File: AlphaLabel.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
	graphics.pushState();
	graphics.setAlpha(alpha);
	graphics.fillRectangle(bounds);
	graphics.popState();
	super.paintFigure(graphics);
}
 
Example 8
Source File: RectangleFigure.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void fillShape( Graphics graphics )
{
	Rectangle bounds = getBounds( ).getCopy( );
	Border border = getBorder( );
	if ( border != null )
	{
		bounds = bounds.crop( border.getInsets( null ) );
	}
	if ( isOpaque( ) )
		graphics.fillRectangle( bounds );
}
 
Example 9
Source File: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics g) {
	g.pushState();
	g.setBackgroundColor(ColorConstants.white);
	g.fillRectangle(new Rectangle(getLocation(), getSize()));
	paintTop(g);
	if (!node.isMinimized() || Animation.isRunning())
		paintTable(g);
	g.popState();
	super.paintFigure(g);
}
 
Example 10
Source File: XYGraph.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void paintFigure(final Graphics graphics) {
	if (!transparent) {
		graphics.fillRectangle(getClientArea());
	}
	super.paintFigure(graphics);
}
 
Example 11
Source File: KnobFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintClientArea(Graphics graphics) {
	
	super.paintClientArea(graphics);
	if(!isEnabled()) {
		graphics.setAlpha(DISABLED_ALPHA);
		graphics.setBackgroundColor(GRAY_COLOR);
		graphics.fillRectangle(bounds);
	}		
}
 
Example 12
Source File: MaterialShape.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Actually draws the circle using the radius and max radius.
 */
@Override
protected void fillShape(Graphics g) {
	// Compute the center (x-value).
	int center = bounds.x + bounds.width / 2;

	// Compute the radius in pixels.
	int r = (int) (bounds.width * radius / (2.0 * maxRadius));

	// Draw the rectangle.
	g.fillRectangle(center - r, bounds.y, r * 2, bounds.height);
}
 
Example 13
Source File: ThermometerFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void outlineShape(Graphics graphics) {
	boolean support3D = false;
	if(effect3D)
		 support3D = GraphicsUtil.testPatternSupported(graphics);
	
	if(effect3D && support3D)
		graphics.setForegroundColor(EFFECT3D_BULB_COLOR);
	else
		graphics.setForegroundColor(BLACK_COLOR);
	super.outlineShape(graphics);			
	//draw a small rectangle to hide the joint  
	
	
	if(effect3D && support3D) {
		graphics.setBackgroundColor(fillColor);
		graphics.fillRectangle(new Rectangle(pipe.getBounds().x + pipe.getLineWidth(),
			((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false),
			Pipe.PIPE_WIDTH- pipe.getLineWidth() *2, 2));
		Pattern backPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), 
			pipe.getBounds().x, ((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false),
			pipe.getBounds().x + Pipe.PIPE_WIDTH,
			((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false),
			WHITE_COLOR,255, fillColor, 0);					
		graphics.setBackgroundPattern(backPattern);
		graphics.fillRectangle(new Rectangle(pipe.getBounds().x + pipe.getLineWidth(),
			((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false),
			Pipe.PIPE_WIDTH- pipe.getLineWidth() *2, 2));
		backPattern.dispose();

	}else{
		graphics.setBackgroundColor(fillColor);
		
		graphics.fillRoundRectangle(new Rectangle(pipe.getBounds().x + pipe.getLineWidth(),
				((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false),
				Pipe.PIPE_WIDTH- pipe.getLineWidth() *2, ((LinearScale) scale).getMargin()),
				Pipe.FILL_CORNER, Pipe.FILL_CORNER);			
	}
		
}
 
Example 14
Source File: ROIFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
	if(roiInfoProvider!=null && roiDataBounds!=null){
		String text = roiInfoProvider.getROIInfo(roiDataBounds.x, roiDataBounds.y, 
				roiDataBounds.width, roiDataBounds.height);
		Dimension size = TextUtilities.INSTANCE.getTextExtents(text, getFont());
		graphics.pushState();
		graphics.translate(getLocation());
		graphics.fillRectangle(roiGeoBounds.x, roiGeoBounds.y - size.height, size.width, size.height);
		graphics.drawText(text, roiGeoBounds.x, roiGeoBounds.y - size.height);
		graphics.popState();
	}
	super.paintFigure(graphics);
	
}
 
Example 15
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 16
Source File: RectangleFigureExtension.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see Shape#fillShape(Graphics)
 */
@Override
protected void fillShape ( final Graphics graphics )
{
    graphics.fillRectangle ( getBounds () );
}
 
Example 17
Source File: CrosstabFirstCellEditPart.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void paintFigure( Graphics graphics )
{
	graphics.setBackgroundColor( ReportColorConstants.greyFillColor );
	graphics.fillRectangle( getClientArea( ) );
	graphics.drawImage( image, getImagePoint( ) );
}
 
Example 18
Source File: RowHandle.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void paintFigure( Graphics graphics )
{
	if ( isSelect( ) )
	{
		graphics.setBackgroundColor( ReportColorConstants.SelctionFillColor );
	}
	else
	{
		graphics.setBackgroundColor( ReportColorConstants.TableGuideFillColor );
	}

	graphics.setLineStyle( SWT.LINE_SOLID );
	Rectangle bounds = getBounds( ).getCopy( ).resize( -1, -1 );
	graphics.fillRectangle( bounds );

	Font font = FontManager.getFont( "Dialog", 7, SWT.NORMAL );//$NON-NLS-1$

	graphics.setFont( font );

	Image image = getImage( );
	if ( image == null )
		return;

	graphics.setForegroundColor( ColorConstants.white );
	graphics.setXORMode( true );
	
	org.eclipse.swt.graphics.Rectangle rect = image.getBounds( );
	int x = bounds.x + ( bounds.width - rect.width ) / 2;
	int y = bounds.y + ( bounds.height - rect.height ) / 2;
	graphics.drawImage( image, x, y );

	TableEditPart part = (TableEditPart) getOwner( );
	RowHandleAdapter rowHandleAdapter = HandleAdapterFactory.getInstance( )
			.getRowHandleAdapter( part.getRow( getRowNumber( ) ) );
	String type = rowHandleAdapter.getType( );
	String displayName = rowHandleAdapter.getDisplayName( );

	if ( TableHandleAdapter.TABLE_GROUP_HEADER.equals( type )
			|| TableHandleAdapter.TABLE_GROUP_FOOTER.equals( type ) )
	{
		graphics.drawString( displayName, x + rect.width + 2, y + 2 );
	}

	graphics.setBackgroundColor( ColorConstants.black );

	//		ReportFigureUtilities.paintBevel( graphics,
	//				getBounds( ).getCopy( ),
	//				true );

	graphics.setXORMode( false );
}
 
Example 19
Source File: TableFigure.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
 */
protected void paintFigure( Graphics graphics )
{
	if ( isOpaque( ) )
	{
		if ( getBorder( ) instanceof BaseBorder )
		{
			graphics.fillRectangle( getBounds( ).getCopy( )
					.crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) );
		}
		else
		{
			graphics.fillRectangle( getBounds( ) );
		}
	}

	Image image = getImage( );
	if ( image == null )
	{
		return;
	}

	int x, y;
	Rectangle area = getBounds( );

	// Calculates X
	if ( position != null && position.x != -1 )
	{
		x = area.x + position.x;
	}
	else
	{
		switch ( alignment & PositionConstants.EAST_WEST )
		{
			case PositionConstants.EAST :
				x = area.x + area.width - size.width;
				break;
			case PositionConstants.WEST :
				x = area.x;
				break;
			default :
				x = ( area.width - size.width ) / 2 + area.x;
				break;
		}
	}

	// Calculates Y
	if ( position != null && position.y != -1 )
	{
		y = area.y + position.y;
	}
	else
	{
		switch ( alignment & PositionConstants.NORTH_SOUTH )
		{
			case PositionConstants.NORTH :
				y = area.y;
				break;
			case PositionConstants.SOUTH :
				y = area.y + area.height - size.height;
				break;
			default :
				y = ( area.height - size.height ) / 2 + area.y;
				break;
		}
	}

	ArrayList xyList = createImageList( x, y );

	Iterator iter = xyList.iterator( );
	while ( iter.hasNext( ) )
	{
		Point point = (Point) iter.next( );
		graphics.drawImage( image, point );
	}
	xyList.clear( );
}
 
Example 20
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);
			}			
		}