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

The following examples show how to use org.eclipse.draw2d.Graphics#getForegroundColor() . 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: TextFlow.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void paintSpecial_old( Graphics g, String text, int x, int y,
		boolean firstBox )
{
	if ( firstBox
			&& specialPREFIX.length( ) != 0
			&& text.indexOf( specialPREFIX ) == 0 )
	{
		int with = FigureUtilities.getTextWidth( specialPREFIX, g.getFont( ) );
		Color c = g.getForegroundColor( );

		g.setForegroundColor( ReportColorConstants.textFillColor );

		g.drawString( specialPREFIX, x, y );

		g.setForegroundColor( c );
		g.drawString( text.substring( specialPREFIX.length( ) ),
				x + with,
				y );
	}
	else
	{
		g.drawString( text, x, y );
	}
}
 
Example 2
Source File: AreaFigure.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void paintFigure( Graphics graphics )
{
	Rectangle rect = getClientArea( ).expand( DEFAULT_EXPAND );
	Color forecolor = graphics.getForegroundColor( );

	if ( getBackgroundColor( ).equals( ColorConstants.blue ) )
	{
		//paint the figure with blue when it's highlighted
		graphics.fillRectangle( rect );
	}

	graphics.setForegroundColor( ReportColorConstants.MarginBorderColor );

	drawLine( graphics, rect, SWT.LEFT, LINE_STYLE );
	drawLine( graphics, rect, SWT.TOP, LINE_STYLE );
	drawLine( graphics, rect, SWT.RIGHT, LINE_STYLE );
	drawLine( graphics, rect, SWT.BOTTOM, LINE_STYLE );

	graphics.setForegroundColor( forecolor );
}
 
Example 3
Source File: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void drawTexts(Graphics g, String single, String total) {
	Point loc = getLocation();
	Font normalFont = g.getFont();
	Font boldFont = getBoldFont(normalFont);
	g.setFont(boldFont);
	Color black = g.getForegroundColor();
	g.setForegroundColor(Colors.white());
	String name = Strings.cut(node.getName(), 30);
	g.drawText(name, loc.x + 5, loc.y + 5);
	g.setFont(normalFont);
	g.drawText(M.DirectContribution + ":", loc.x + 5, loc.y + 35);
	g.drawText(single, loc.x + 5, loc.y + 50);
	g.drawText(M.UpstreamTotal + ":", loc.x + 5, loc.y + 80);
	g.drawText(total, loc.x + 5, loc.y + 95);
	g.setForegroundColor(black);
}
 
Example 4
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 5
Source File: PagableFreeformRootEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintGrid(final Graphics g) {
    super.paintGrid(g);

    final Rectangle clip = g.getClip(Rectangle.SINGLETON);

    final PageSetting pageSetting = diagram.getPageSetting();

    final int width = pageSetting.getWidth();
    final int height = pageSetting.getHeight();

    final Rectangle rect = clip;

    final Color color = g.getForegroundColor();
    g.setForegroundColor(ColorConstants.lightGray);

    int startX = rect.x;
    if (startX > 0) {
        startX = 0;
    }
    int startY = rect.y;
    if (startY > 0) {
        startY = 0;
    }

    for (int i = startX; i < rect.x + rect.width; i += width) {
        g.drawLine(i, rect.y, i, rect.y + rect.height);
    }

    for (int i = startY; i < rect.y + rect.height; i += height) {
        g.drawLine(rect.x, i, rect.x + rect.width, i);
    }

    g.setForegroundColor(color);

    i++;
    if (i > 0) {
        i = -1;
        repaint();
    }
}
 
Example 6
Source File: PagableFreeformRootEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected void paintGrid(Graphics g) {
    super.paintGrid(g);

    Rectangle clip = g.getClip(Rectangle.SINGLETON);

    PageSettings pageSetting = diagram.getPageSetting();

    int width = pageSetting.getWidth();
    int height = pageSetting.getHeight();

    Rectangle rect = clip;

    Color color = g.getForegroundColor();
    g.setForegroundColor(ColorConstants.lightGray);

    int startX = rect.x;
    if (startX > 0) {
        startX = 0;
    }
    int startY = rect.y;
    if (startY > 0) {
        startY = 0;
    }

    for (int i = startX; i < rect.x + rect.width; i += width) {
        g.drawLine(i, rect.y, i, rect.y + rect.height);
    }

    for (int i = startY; i < rect.y + rect.height; i += height) {
        g.drawLine(rect.x, i, rect.x + rect.width, i);
    }

    g.setForegroundColor(color);

    i++;
    if (i > 0) {
        i = -1;
        repaint();
    }
}
 
Example 7
Source File: BorderUtil.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Draws a 3D style line with the specified side, style & width.
 * 
 * @param g
 *            The graphics object used for drawing
 * @param side
 *            the side to draw.
 * @param style
 *            the style to draw.
 * @param width
 *            the border width array, arranged by {top, bottom, left,
 *            right};
 * @param r
 *            the rectangle for drawing.
 */
public static void draw3DLine( Graphics g, int side, int style,
		int[] width, Rectangle r )
{
	if ( width.length <= side || width[side] <= 0 )
	{
		return;
	}

	Color foreColor = g.getForegroundColor( );
	Color inSideColor = foreColor;
	Color outSideColor = foreColor;
	Color darkColor = ColorManager.darker( foreColor );
	Color brightColor = ColorManager.brighter( foreColor, ColorConstants.white );

	switch ( style )
	{
		case BaseBorder.LINE_STYLE_RIDGE :
			if ( side == TOP || side == LEFT )
			{
				inSideColor = darkColor;
				outSideColor = brightColor;
			}
			else if ( side == BOTTOM || side == RIGHT )
			{
				inSideColor = brightColor;
				outSideColor = darkColor;
			}
			break;
		case BaseBorder.LINE_STYLE_GROOVE :
			if ( side == TOP || side == LEFT )
			{
				inSideColor = brightColor;
				outSideColor = darkColor;
			}
			else if ( side == BOTTOM || side == RIGHT )
			{
				inSideColor = darkColor;
				outSideColor = brightColor;
			}
			break;
		case BaseBorder.LINE_STYLE_INSET :
			if ( side == TOP || side == LEFT )
			{
				inSideColor = darkColor;
				outSideColor = darkColor;
			}
			else if ( side == BOTTOM || side == RIGHT )
			{
				inSideColor = brightColor;
				outSideColor = brightColor;
			}
			break;
		case BaseBorder.LINE_STYLE_OUTSET :
			if ( side == TOP || side == LEFT )
			{
				inSideColor = brightColor;
				outSideColor = brightColor;
			}
			else if ( side == BOTTOM || side == RIGHT )
			{
				inSideColor = darkColor;
				outSideColor = darkColor;
			}
			break;
	}

	int inSideWidth = ( width[side] + 1 ) / 2;
	int outSideWidth = width[side] - inSideWidth;

	// Draws the outside line.
	g.setForegroundColor( outSideColor );
	drawSingleLine( g, side, SWT.LINE_SOLID, width, outSideWidth, 0, r );

	// Draws the inside line.
	g.setForegroundColor( inSideColor );
	drawSingleLine( g, side, SWT.LINE_SOLID, width, inSideWidth, outSideWidth, r );
}
 
Example 8
Source File: PagableFreeformRootEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintGrid(Graphics g) {
	super.paintGrid(g);

	Rectangle clip = g.getClip(Rectangle.SINGLETON);

	PageSetting pageSetting = diagram.getPageSetting();

	int width = pageSetting.getWidth();
	int height = pageSetting.getHeight();

	Rectangle rect = clip;

	Color color = g.getForegroundColor();
	g.setForegroundColor(ColorConstants.lightGray);

	int startX = rect.x;
	if (startX > 0) {
		startX = 0;
	}
	int startY = rect.y;
	if (startY > 0) {
		startY = 0;
	}

	for (int i = startX; i < rect.x + rect.width; i += width) {
		g.drawLine(i, rect.y, i, rect.y + rect.height);
	}

	for (int i = startY; i < rect.y + rect.height; i += height) {
		g.drawLine(rect.x, i, rect.x + rect.width, i);
	}

	g.setForegroundColor(color);

	i++;
	if (i > 0) {
		i = -1;
		repaint();
	}
}