Java Code Examples for org.eclipse.swt.graphics.GC#setBackground()

The following examples show how to use org.eclipse.swt.graphics.GC#setBackground() . 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: ManageableTableTreeEx.java    From SWET with MIT License 6 votes vote down vote up
TableTreeItem(TableTree parent, TableTreeItem parentItem, int style,
		int index) {
	super(parent, style);
	this.parent = parent;
	this.parentItem = parentItem;
	if (parentItem == null) {
		int tableIndex = parent.addItem(this, index);
		tableItem = new TableItem(parent.getTable(), style, tableIndex);
		tableItem.setData(this);
		addCheck();
		if (parent.sizeImage == null) {
			int itemHeight = parent.getItemHeight();
			parent.sizeImage = new Image(null, itemHeight, itemHeight);
			GC gc = new GC(parent.sizeImage);
			gc.setBackground(parent.getBackground());
			gc.fillRectangle(0, 0, itemHeight, itemHeight);
			gc.dispose();
			tableItem.setImage(0, parent.sizeImage);
		}
	} else {
		parentItem.addItem(this, index);
	}
}
 
Example 2
Source File: SWTResourceManager.java    From Rel with Apache License 2.0 5 votes vote down vote up
/**
 * @return the small {@link Image} that can be used as placeholder for missing image.
 */
public static Image getMissingImage() {
	Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
	//
	GC gc = new GC(image);
	gc.setBackground(getColor(SWT.COLOR_RED));
	gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
	gc.dispose();
	//
	return image;
}
 
Example 3
Source File: SwtScatterChart.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void drawSelectedDot(GC gc) {
    for (SwtChartPoint point : getSelection().getPoints()) {
        ISeries series = point.getSeries();
        Point coor = series.getPixelCoordinates(point.getIndex());
        int symbolSize = ((ILineSeries) series).getSymbolSize();

        Color symbolColor = ((ILineSeries) series).getSymbolColor();
        if (symbolColor == null) {
            continue;
        }
        Color darkColor = IChartViewer.getCorrespondingColor(symbolColor);
        /* Create a colored dot for selection */
        gc.setBackground(darkColor);
        gc.fillOval(coor.x - symbolSize, coor.y - symbolSize, symbolSize * 2, symbolSize * 2);

        /* Configure cross settings */
        gc.setLineWidth(2);
        gc.setLineStyle(SWT.LINE_SOLID);
        int drawingDelta = 2 * symbolSize;

        /* Vertical line */
        gc.drawLine(coor.x, coor.y - drawingDelta, coor.x, coor.y + drawingDelta);

        /* Horizontal line */
        gc.drawLine(coor.x - drawingDelta, coor.y, coor.x + drawingDelta, coor.y);
    }
}
 
Example 4
Source File: Chips.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void drawClose(final GC gc, final int x) {
	final Color foreground = cursorInside ? closeButtonHoverForeground : closeButtonForeground;
	final Color background = cursorInside ? closeButtonHoverBackground : closeButtonBackground;
	final Rectangle rect = getClientArea();

	gc.setBackground(background);
	gc.setForeground(foreground);
	closeCenter = new Point(x + 4 + CLOSE_CIRCLE_RAY, (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2 + CLOSE_CIRCLE_RAY);
	gc.fillOval(x + 4, (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2, 2 * CLOSE_CIRCLE_RAY, 2 * CLOSE_CIRCLE_RAY);

	// Cross
	gc.setLineWidth(2);
	gc.drawLine(closeCenter.x - 3, closeCenter.y - 3, closeCenter.x + 3, closeCenter.y + 3);
	gc.drawLine(closeCenter.x + 3, closeCenter.y - 3, closeCenter.x - 3, closeCenter.y + 3);
}
 
Example 5
Source File: XYChartLegendImageProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void drawStyledDot(GC gc, Color lineColor, int imageWidth, int imageHeight, @NonNull OutputElementStyle appearance) {
    BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider2();
    String symbolStyle = (String) presProvider.getStyleOrDefault(appearance, StyleProperties.SYMBOL_TYPE, StyleProperties.SymbolType.NONE);
    int symbolSize = ((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.HEIGHT, 1.0f)).intValue();
    int centerX = imageWidth / 2;
    int centerY = imageHeight / 2;
    Color prevBg = gc.getBackground();
    Color prevFg = gc.getForeground();
    switch(symbolStyle) {
    case StyleProperties.SymbolType.CIRCLE:
        SymbolHelper.drawCircle(gc, lineColor, symbolSize, centerX, centerY);
        break;
    case StyleProperties.SymbolType.DIAMOND:
        SymbolHelper.drawDiamond(gc, lineColor, symbolSize, centerX, centerY);
        break;
    case StyleProperties.SymbolType.SQUARE:
        SymbolHelper.drawSquare(gc, lineColor, symbolSize, centerX, centerY);
        break;
    case StyleProperties.SymbolType.CROSS:
        SymbolHelper.drawCross(gc, lineColor, symbolSize, centerX, centerY);
        break;
    case StyleProperties.SymbolType.PLUS:
        SymbolHelper.drawPlus(gc, lineColor, symbolSize, centerX, centerY);
        break;

    case StyleProperties.SymbolType.INVERTED_TRIANGLE:
        SymbolHelper.drawInvertedTriangle(gc, lineColor, symbolSize, centerX, centerY);
        break;
    case StyleProperties.SymbolType.TRIANGLE:
        SymbolHelper.drawTriangle(gc, lineColor, symbolSize, centerX, centerY);
        break;

    default:
        // Default is nothing
        break;
    }
    gc.setForeground(prevFg);
    gc.setBackground(prevBg);
}
 
Example 6
Source File: EyeButton.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void drawEye(final GC gc, final Color clr) {
	gc.setAdvanced(true);
	gc.setAntialias(SWT.ON);
	gc.setLineWidth(2);

	final Rectangle rect = getClientArea();
	final int eyeWidth = (int) (rect.width * .7);
	final int eyeHeight = (int) (rect.height * .5);
	gc.setForeground(clr);
	gc.drawOval((int) (rect.width * .15), (int) (rect.height * .25), eyeWidth, eyeHeight);

	gc.setBackground(clr);
	gc.fillOval(rect.width / 2 - CIRCLE_RAY / 2, rect.height / 2 - CIRCLE_RAY / 2, CIRCLE_RAY, CIRCLE_RAY);
}
 
Example 7
Source File: VisualisationCanvas.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
protected void doPaint(GC gc, PaintEvent event) {
	gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
	gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

	gc.fillRectangle(event.x, event.y, event.width, event.height);

	if (graph != null) {
		final Transform tf = new Transform(gc.getDevice());
		tf.translate(-offsetX, -offsetY);
		tf.scale(scale, scale);
		gc.setTransform(tf);

		if (graphNeedsLayout) {
			graph.layout();
			graphNeedsLayout = false;
		}

		graph.getNodes().forEach(n -> n.paint(gc));

		gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));

		gc.setTransform(null);
		tf.dispose();

		if (hawkEye_active && hawkEye_target != null) {
			final int w = Math.round(getSize().x / hawkEye_oldScale * scale);
			final int h = Math.round(getSize().y / hawkEye_oldScale * scale);
			gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
			gc.setAlpha(64);
			gc.fillRectangle(
					(int) hawkEye_target.x - w / 2,
					(int) hawkEye_target.y - h / 2,
					w, h);
			gc.setAlpha(255);
		}
	}
}
 
Example 8
Source File: AbstractContainmentExample.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Draws an ellipse with the given GC at the control points location.
 *
 * @param gc
 */
public void draw(GC gc) {
	// System.out.println(ellipse.toString());
	gc.setBackground(Display.getCurrent().getSystemColor(color));
	gc.fillOval((int) ellipse.getX(), (int) ellipse.getY(),
			(int) ellipse.getWidth(), (int) ellipse.getHeight());
}
 
Example 9
Source File: MinMaxToggleRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void paint(GC gc, Object value)
{

    Transform transform = new Transform(gc.getDevice());
    transform.translate(getBounds().x, getBounds().y);
    gc.setTransform(transform);

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

    if (isHover())
    {
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        gc.drawRoundRectangle(0, 0, 17, 17, 5, 5);
    }

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

    if (isExpanded())
    {
        gc.fillRectangle(4, 3, 9, 3);
        gc.drawRectangle(4, 3, 9, 3);
    }
    else
    {
        gc.fillRectangle(4, 3, 9, 9);
        gc.drawRectangle(4, 3, 9, 9);
        gc.drawLine(4, 5, 13, 5);
    }

    gc.setTransform(null);
    transform.dispose();

}
 
Example 10
Source File: SpanStylePaintInstruction.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void paint(GC gc, Rectangle area) {
	if (this.foregroundColor != null) {
		// remember the previous set value
		// to be able to reset on close
		this.state.addPreviousColor(gc.getForeground());
		// set the style value
		gc.setForeground(this.foregroundColor);
	}

	if (this.backgroundColor != null) {
		// remember the previous set value
		// to be able to reset on close
		this.state.addPreviousBgColor(gc.getBackground());
		// set the style value
		gc.setBackground(this.backgroundColor);
	}

	if (this.fontSize != null || this.fontType != null) {
		Font currentFont = gc.getFont();

		// remember the previous set value
		// to be able to reset on close
		this.state.addPreviousFont(currentFont);

		// set the style value
		gc.setFont(ResourceHelper.getFont(currentFont, this.fontType, this.fontSize));
	}
}
 
Example 11
Source File: ToggleRenderer.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void paintPlusMinus(GC gc) {
	gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

	gc.fillRectangle(getBounds());

	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

	gc.drawRectangle(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1);

	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));

	gc.drawLine(getBounds().x + 2, getBounds().y + 4, getBounds().x + 6, getBounds().y + 4);

	if (!isExpanded()) {
		gc.drawLine(getBounds().x + 4, getBounds().y + 2, getBounds().x + 4, getBounds().y + 6);
	}
}
 
Example 12
Source File: FillChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void paintControl( PaintEvent pe )
{
	Color cBlack = new Color( this.getDisplay( ), 0, 0, 0 );
	Color cWhite = new Color( this.getDisplay( ), 255, 255, 255 );
	GC gc = pe.gc;
	gc.setForeground( cBlack );

	int iCellWidth = this.getSize( ).x / ROW_SIZE;
	int iCellHeight = this.getSize( ).y / COLUMN_SIZE;
	boolean isFound = false;
	for ( int iR = 0; iR < COLUMN_SIZE; iR++ )
	{
		for ( int iC = 0; iC < ROW_SIZE; iC++ )
		{
			int index = iR * ROW_SIZE + iC;
			try
			{
				gc.setBackground( colorMap[index] );
			}
			catch ( Throwable e )
			{
				e.printStackTrace( );
			}
			gc.fillRectangle( iC * iCellWidth,
					iR * iCellHeight,
					iCellWidth,
					iCellHeight );
			// Highlight currently selected color if it exists in this
			// list
			if ( selectedIndex == index
					|| !isFound
					&& colorSelection != null
					&& colorSelection.equals( colorMap[index] ) )
			{
				isFound = true;
				selectedIndex = index;
				if ( colorSelection == null )
				{
					colorSelection = colorMap[index];
				}

				if ( isFocusControl( ) )
				{
					gc.setLineStyle( SWT.LINE_DOT );
				}
				gc.drawRectangle( iC * iCellWidth,
						iR * iCellHeight,
						iCellWidth - 2,
						iCellHeight - 2 );
				gc.setForeground( cWhite );
				gc.drawRectangle( iC * iCellWidth + 1, iR
						* iCellHeight
						+ 1, iCellWidth - 3, iCellHeight - 3 );
				gc.setForeground( cBlack );
			}
		}
	}
	if ( !isFound )
	{
		clearColorSelection( );
	}
	cBlack.dispose( );
	cWhite.dispose( );
	gc.dispose( );
}
 
Example 13
Source File: NebulaToolbar.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Paint widget using Windows Vista mode on graphical canvas.
 * 
 * @param gc GC
 */
private void paintVista(GC gc)
{
	Color defaultForeground = gc.getForeground();
	Color defaultBackground = gc.getBackground();

	Rectangle rect = getClientArea();
	Device device = gc.getDevice();

	Color c1 = new Color(device, 5, 72, 117);
	Color c2 = new Color(device, 25, 108, 119);
	Color c3 = new Color(device, 28, 122, 134);
	Color wh = getDisplay().getSystemColor(SWT.COLOR_WHITE);

	int middle = (int) Math.ceil(rect.height / 2);

	Pattern patternBg1 = new Pattern(device, 0, 0, rect.width, middle, c1, 255, c3, 255);
	gc.setBackgroundPattern(patternBg1);
	gc.fillRectangle(new Rectangle(0, 0, rect.width, middle));
	gc.setBackgroundPattern(null);

	Pattern patternBg2 = new Pattern(device, 0, middle, rect.width, rect.height - middle, c1, 255, c2, 255);
	gc.setBackgroundPattern(patternBg2);
	gc.fillRectangle(new Rectangle(0, middle, rect.width, rect.height - middle));
	gc.setBackgroundPattern(null);

	Pattern patternTopGrad = new Pattern(device, 0, 0, 0, middle, wh, 120, wh, 50);
	gc.setBackgroundPattern(patternTopGrad);
	gc.fillRectangle(new Rectangle(0, 0, rect.width, middle));
	gc.setBackgroundPattern(null);

	Pattern patternBtmGrad = new Pattern(device, 0, middle + 5, 0, rect.height, c1, 0, wh, 125);
	gc.setBackgroundPattern(patternBtmGrad);
	gc.fillRectangle(new Rectangle(0, middle + 5, rect.width, rect.height));
	gc.setBackgroundPattern(null);

	gc.setAlpha(125);
	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
	gc.drawPolygon(new int[]{0, 0, rect.width - 1, 0, rect.width - 1, rect.height - 2, 0, rect.height - 2});

	gc.setAlpha(200);
	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
	gc.drawLine(0, rect.height - 1, rect.width - 1, rect.height - 1);

	gc.setForeground(defaultForeground);
	gc.setBackground(defaultBackground);
	gc.setAlpha(255);

	c1.dispose();
	c2.dispose();
	c3.dispose();

	patternBg1.dispose();
	patternBg2.dispose();
	patternTopGrad.dispose();
	patternBtmGrad.dispose();
}
 
Example 14
Source File: ConditionEditor.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void repaint( GC dgc, int width, int height ) {
  Image im = new Image( display, width, height );
  GC gc = new GC( im );

  // Initialize some information
  size_not = getNotSize( gc );
  size_widget = getWidgetSize( gc );
  size_and_not = getAndNotSize( gc );
  size_up = getUpSize( gc );
  size_add = getAddSize( gc );
  size_left = null;
  size_fn = null;
  size_rightval = null;
  size_rightex = null;

  // Clear the background...
  gc.setBackground( white );
  gc.setForeground( black );
  gc.fillRectangle( 0, 0, width, height );

  // Set the fixed font:
  gc.setFont( fixed );

  // Atomic condition?
  if ( active_condition.isAtomic() ) {
    size_cond = null;
    drawNegated( gc, 0, 0, active_condition );

    drawAtomic( gc, 0, 0, active_condition );

    // gc.drawText("ATOMIC", 10, size_widget.height-20);
  } else {
    drawNegated( gc, 0, 0, active_condition );

    size_cond = new Rectangle[active_condition.nrConditions()];
    size_oper = new Rectangle[active_condition.nrConditions()];

    int basex = 10;
    int basey = size_not.y + 5;

    for ( int i = 0; i < active_condition.nrConditions(); i++ ) {
      Point to = drawCondition( gc, basex, basey, i, active_condition.getCondition( i ) );
      basey += size_and_not.height + to.y + 15;
    }
  }

  gc.drawImage( imageAdd, size_add.x, size_add.y );

  /*
   * Draw the up-symbol if needed...
   */
  if ( parents.size() > 0 ) {
    drawUp( gc );
  }

  if ( messageString != null ) {
    drawMessage( gc );
  }

  /*
   * Determine the maximum size of the displayed items... Normally, they are all size up already.
   */
  getMaxSize();

  /*
   * Set the scroll bars: show/don't show and set the size
   */
  setBars();

  // Draw the result on the canvas, all in 1 go.
  dgc.drawImage( im, 0, 0 );

  im.dispose();
}
 
Example 15
Source File: DefaultEmptyRowHeaderRenderer.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/** 
 * {@inheritDoc}
 */
public void paint(GC gc, Object value)
{

    gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));

    gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width, getBounds().height + 1);

    gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));

    Grid grid = (Grid) value;
    
    if (!grid.getCellSelectionEnabled())
    {
    
        gc.drawLine(getBounds().x, getBounds().y, getBounds().x + getBounds().width - 1,
                    getBounds().y);
        gc.drawLine(getBounds().x, getBounds().y, getBounds().x, getBounds().y + getBounds().height
                                                                 - 1);

        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
        gc.drawLine(getBounds().x + 1, getBounds().y + 1,
                    getBounds().x + getBounds().width - 2, getBounds().y + 1);
        gc.drawLine(getBounds().x + 1, getBounds().y + 1, getBounds().x + 1,
                    getBounds().y + getBounds().height - 2);

        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
        gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x
                                                                          + getBounds().width - 1,
                    getBounds().y + getBounds().height - 1);
        gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x
                                                                           + getBounds().width - 1,
                    getBounds().y + getBounds().height - 1);

        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        gc.drawLine(getBounds().x + getBounds().width - 2, getBounds().y + 1,
                    getBounds().x + getBounds().width - 2, getBounds().y + getBounds().height
                                                           - 2);
        gc.drawLine(getBounds().x + 1, getBounds().y + getBounds().height - 2,
                    getBounds().x + getBounds().width - 2, getBounds().y + getBounds().height
                                                           - 2);
    }
    else
    {
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));

        gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x
                                                                          + getBounds().width - 1,
                    getBounds().y + getBounds().height - 1);
        gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x
                                                                           + getBounds().width - 1,
                    getBounds().y + getBounds().height - 1);
    }

}
 
Example 16
Source File: Chart3DViewer.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private final void showException( GC g2d, Exception ex )
{
	String sWrappedException = ex.getClass( ).getName( );
	Throwable th = ex;
	while ( ex.getCause( ) != null )
	{
		ex = (Exception) ex.getCause( );
	}
	String sException = ex.getClass( ).getName( );
	if ( sWrappedException.equals( sException ) )
	{
		sWrappedException = null;
	}

	String sMessage = null;
	if ( th instanceof BirtException )
	{
		sMessage = ( (BirtException) th ).getLocalizedMessage( );
	}
	else
	{
		sMessage = ex.getMessage( );
	}

	if ( sMessage == null )
	{
		sMessage = "<null>";//$NON-NLS-1$
	}
	StackTraceElement[] stea = ex.getStackTrace( );
	Point d = this.getSize( );

	Device dv = Display.getCurrent( );
	Font fo = new Font( dv, "Courier", SWT.BOLD, 16 );//$NON-NLS-1$
	g2d.setFont( fo );
	FontMetrics fm = g2d.getFontMetrics( );
	g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) );
	g2d.fillRectangle( 20, 20, d.x - 40, d.y - 40 );
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
	g2d.drawRectangle( 20, 20, d.x - 40, d.y - 40 );
	g2d.setClipping( 20, 20, d.x - 40, d.y - 40 );
	int x = 25, y = 20 + fm.getHeight( );
	g2d.drawString( "Exception:", x, y );//$NON-NLS-1$
	x += g2d.textExtent( "Exception:" ).x + 5;//$NON-NLS-1$
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) );
	g2d.drawString( sException, x, y );
	x = 25;
	y += fm.getHeight( );
	if ( sWrappedException != null )
	{
		g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
		g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$
		x += g2d.textExtent( "Wrapped In:" ).x + 5;//$NON-NLS-1$
		g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) );
		g2d.drawString( sWrappedException, x, y );
		x = 25;
		y += fm.getHeight( );
	}
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
	y += 10;
	g2d.drawString( "Message:", x, y );//$NON-NLS-1$
	x += g2d.textExtent( "Message:" ).x + 5;//$NON-NLS-1$
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLUE ) );
	g2d.drawString( sMessage, x, y );
	x = 25;
	y += fm.getHeight( );
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
	y += 10;
	g2d.drawString( "Trace:", x, y );//$NON-NLS-1$
	x = 40;
	y += fm.getHeight( );
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_DARK_GREEN ) );
	for ( int i = 0; i < stea.length; i++ )
	{
		g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$
				+ stea[i].getMethodName( )
				+ "(...):"//$NON-NLS-1$
				+ stea[i].getLineNumber( ), x, y );
		x = 40;
		y += fm.getHeight( );
	}
	fo.dispose( );
}
 
Example 17
Source File: HeadStyleCanvas.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void paintControl( PaintEvent pe )
{
	if ( isEnabled( ) && isFocusControl( ) )
	{
		isFocusIn = true;
	}

	Color cForeground = null;
	Color cBackground = null;
	if ( this.isEnabled( ) )
	{
		cForeground = getDisplay( ).getSystemColor( SWT.COLOR_LIST_FOREGROUND );
		cBackground = getDisplay( ).getSystemColor( SWT.COLOR_LIST_BACKGROUND );
	}
	else
	{
		cForeground = getDisplay( ).getSystemColor( SWT.COLOR_DARK_GRAY );
		cBackground = getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_BACKGROUND );
	}

	GC gc = pe.gc;
	if ( isFocusIn )
	{
		gc.setBackground( getDisplay( ).getSystemColor( SWT.COLOR_LIST_SELECTION ) );
		gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_LIST_SELECTION_TEXT ) );
	}
	else
	{
		gc.setBackground( cBackground );
		gc.setForeground( cForeground );

	}

	gc.fillRectangle( 0, 0, this.getSize( ).x, this.getSize( ).y );
	gc.setLineWidth( 1 );
	gc.drawLine( 10,
			this.getSize( ).y / 2,
			this.getSize( ).x - 10,
			this.getSize( ).y / 2 );
	if ( iLineDecorator == LineDecorator.ARROW )
	{
		int[] points = {
				this.getSize( ).x - 15,
				this.getSize( ).y / 2 - 3,
				this.getSize( ).x - 15,
				this.getSize( ).y / 2 + 3,
				this.getSize( ).x - 10,
				this.getSize( ).y / 2
		};
		gc.setLineWidth( 3 );
		gc.drawPolygon( points );
	}
	else if ( iLineDecorator == LineDecorator.CIRCLE )
	{
		gc.setLineWidth( 4 );
		gc.drawOval( this.getSize( ).x - 14,
				this.getSize( ).y / 2 - 3,
				6,
				6 );
	}

}
 
Example 18
Source File: PaintUtils.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
public static void drawRoundedRectangle(GC gc, Rectangle bounds, Color backgroundColor) {
  Color backupBackground = gc.getBackground();
  gc.setBackground(backgroundColor);
  gc.fillRoundRectangle(bounds.x, bounds.y, bounds.width, bounds.height, ARC, ARC);
  gc.setBackground(backupBackground);
}
 
Example 19
Source File: SymbolHelper.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Draw an isoceles triangle where the summit is facing downwards
 *
 * @param gc
 *            the graphics context to draw to
 * @param color
 *            the color of the symbol
 * @param symbolSize
 *            the size of the symbol (radius in pixels)
 * @param centerX
 *            the center point x coordinate
 * @param centerY
 *            the center point y coordinate
 */
public static void drawInvertedTriangle(GC gc, Color color, int symbolSize, int centerX, int centerY) {
    Color oldColor = gc.getBackground();
    gc.setBackground(color);
    int[] pts = new int[6];
    pts[0] = centerX - symbolSize;
    pts[1] = centerY - symbolSize / 3;
    pts[2] = centerX;
    pts[3] = centerY + symbolSize;
    pts[4] = centerX + symbolSize;
    pts[5] = centerY - symbolSize / 3;
    gc.fillPolygon(pts);
    gc.setBackground(oldColor);
}
 
Example 20
Source File: CellRendererBase.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Draw the cell background.
 * 
 * @param gc GC
 * @param area cell drawing area
 * @param style cell style
 * @param selected true for selected
 * @param printing true if printing
 */
protected void drawBackground(GC gc, Rectangle area, ICellStyle style, boolean selected, boolean printing) {
    Color c = gc.getBackground();
    Color bg;
    bg = getBackgroundColor(style, printing);
    gc.setBackground(bg);
    gc.fillRectangle(area);
    gc.setBackground(c);
}