org.eclipse.swt.graphics.GC.setForeground()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中org.eclipse.swt.graphics.GC.setForeground()方法的一些代码示例,展示了GC.setForeground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.setForeground()方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:setForeground

GC.setForeground介绍

[英]Sets the foreground color. The foreground color is used for drawing operations including when text is drawn.
[中]设置前景色。前景色用于绘制操作,包括绘制文本时。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public void setForeground( int r, int g, int b ) {
 Color color = getColor( r, g, b );
 gc.setForeground( color );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void setForeground( int r, int g, int b ) {
 Color color = getColor( r, g, b );
 gc.setForeground( color );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void setForeground( EColor color ) {
 gc.setForeground( getColor( color ) );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void setForeground( EColor color ) {
 gc.setForeground( getColor( color ) );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawMessage( GC gc ) {
 gc.setForeground( blue );
 gc.drawText(
  getMessageString(), size_up.x + size_up.width + offsetx + 40, size_up.y + 1 + offsety,
  SWT.DRAW_TRANSPARENT );
 // widget.setToolTipText(getMessageString());
}

代码示例来源:origin: pentaho/pentaho-kettle

public void switchForegroundBackgroundColors() {
 Color fg = gc.getForeground();
 Color bg = gc.getBackground();
 gc.setForeground( bg );
 gc.setBackground( fg );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void switchForegroundBackgroundColors() {
 Color fg = gc.getForeground();
 Color bg = gc.getBackground();
 gc.setForeground( bg );
 gc.setBackground( fg );
}

代码示例来源:origin: pentaho/pentaho-kettle

private void drawNegated( GC gc, int x, int y, Condition condition ) {
 Color color = gc.getForeground();
 if ( hover_not ) {
  gc.setBackground( gray );
 }
 gc.fillRectangle( Real2Screen( size_not ) );
 gc.drawRectangle( Real2Screen( size_not ) );
 if ( condition.isNegated() ) {
  if ( hover_not ) {
   gc.setForeground( green );
  }
  gc.drawText( STRING_NOT, size_not.x + 5 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
  gc.drawText( STRING_NOT, size_not.x + 6 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
  if ( hover_not ) {
   gc.setForeground( color );
  }
 } else {
  if ( hover_not ) {
   gc.setForeground( red );
   gc.drawText( STRING_NOT, size_not.x + 5 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
   gc.drawText( STRING_NOT, size_not.x + 6 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
   gc.setForeground( color );
  }
 }
 if ( hover_not ) {
  gc.setBackground( bg );
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

protected void drawRect( GC gc, Rectangle rect ) {
 if ( rect == null ) {
  return;
 }
 gc.setLineStyle( SWT.LINE_DASHDOT );
 gc.setLineWidth( 1 );
 gc.setForeground( GUIResource.getInstance().getColorDarkGray() );
 // PDI-2619: SWT on Windows doesn't cater for negative rect.width/height so handle here.
 Point s = new Point( rect.x + offset.x, rect.y + offset.y );
 if ( rect.width < 0 ) {
  s.x = s.x + rect.width;
 }
 if ( rect.height < 0 ) {
  s.y = s.y + rect.height;
 }
 gc.drawRoundRectangle( s.x, s.y, Math.abs( rect.width ), Math.abs( rect.height ), 3, 3 );
 gc.setLineStyle( SWT.LINE_SOLID );
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * Get the image for when all other fallbacks have failed.  This is an image
 * drawn on the canvas, a square with a red X.
 *
 * @param display the device to render the image to
 * @return the missing image
 */
public static SwtUniversalImage getMissingImage( Display display ) {
 Image img = new Image( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE );
 GC gc = new GC( img );
 gc.setForeground( new Color( display, 0, 0, 0 ) );
 gc.drawRectangle( 4, 4, ConstUI.ICON_SIZE - 8, ConstUI.ICON_SIZE - 8 );
 gc.setForeground( new Color( display, 255, 0, 0 ) );
 gc.drawLine( 4, 4, ConstUI.ICON_SIZE - 4, ConstUI.ICON_SIZE - 4 );
 gc.drawLine( ConstUI.ICON_SIZE - 4, 4, 4, ConstUI.ICON_SIZE - 4 );
 gc.dispose();
 return new SwtUniversalImageBitmap( img );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawPentahoGradient( Display display, GC gc, Rectangle rect, boolean vertical ) {
 if ( !vertical ) {
  gc.setForeground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
  gc.setBackground( GUIResource.getInstance().getColorPentaho() );
  gc.fillGradientRectangle( rect.x, rect.y, 2 * rect.width / 3, rect.height, vertical );
  gc.setForeground( GUIResource.getInstance().getColorPentaho() );
  gc.setBackground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
  gc.fillGradientRectangle( rect.x + 2 * rect.width / 3, rect.y, rect.width / 3 + 1, rect.height, vertical );
 } else {
  gc.setForeground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
  gc.setBackground( GUIResource.getInstance().getColorPentaho() );
  gc.fillGradientRectangle( rect.x, rect.y, rect.width, 2 * rect.height / 3, vertical );
  gc.setForeground( GUIResource.getInstance().getColorPentaho() );
  gc.setBackground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
  gc.fillGradientRectangle( rect.x, rect.y + 2 * rect.height / 3, rect.width, rect.height / 3 + 1, vertical );
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

private void drawVersionWarning( GC gc, Display display ) {
 gc.setBackground( versionWarningBackgroundColor );
 gc.setForeground( new Color( display, 65, 65, 65 ) );
 // gc.fillRectangle(290, 231, 367, 49);
 // gc.drawRectangle(290, 231, 367, 49);
 gc.drawImage( exclamation_image, 304, 243 );
 gc.setFont( devWarningFont );
 gc.drawText( BaseMessages.getString( PKG, "SplashDialog.DevelopmentWarning" ), 335, 241, true );
}

代码示例来源:origin: pentaho/pentaho-kettle

e.gc.setForeground( new Color( display, 65, 65, 65 ) );
e.gc.drawText( fullVersionText, 290, 205, true );
e.gc.setForeground( new Color( display, 65, 65, 65 ) );
e.gc.setForeground( new Color( display, 65, 65, 65 ) );
e.gc.drawText( version, 290, 235, true );
e.gc.drawText( buildDate, 290, 250, true );

代码示例来源:origin: pentaho/pentaho-kettle

gc.setForeground( black );
   gc.setForeground( red );
   gc.setBackground( red );
   int x_oval = LEFT + MARGIN + str.length() * fontwidth + offset.x;
   gc.drawOval( x_oval, y_oval, fontwidth, fontheight );
   gc.fillOval( x_oval, y_oval, fontwidth, fontheight );
   gc.setForeground( black );
   gc.setBackground( bg );
gc.setForeground( red );
gc.setBackground( red );
int position = 0;
 gc.setForeground( blue );
 gc.setBackground( blue );
 drawMarker( gc, potential_click, area.y );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( final PaintEvent event ) {
  if ( transGraph.trans != null && transGraph.trans.isFinished() ) {
   refreshImage( event.gc );
   if ( image != null && !image.isDisposed() ) {
    event.gc.drawImage( image, 0, 0 );
   }
  } else {
   Rectangle bounds = canvas.getBounds();
   if ( bounds.width <= 0 || bounds.height <= 0 ) {
    return;
   }
   event.gc.setForeground( GUIResource.getInstance().getColorWhite() );
   event.gc.setBackground( GUIResource.getInstance().getColorWhite() );
   event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) );
   event.gc.setForeground( GUIResource.getInstance().getColorBlack() );
   String metricsMessage =
    BaseMessages.getString( PKG, "TransMetricsDelegate.TransformationIsNotRunning.Message" );
   org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage );
   event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent event ) {
  if ( jobGraph.job != null && ( jobGraph.job.isFinished() || jobGraph.job.isStopped() ) ) {
   refreshImage( event.gc );
   if ( image != null && !image.isDisposed() ) {
    event.gc.drawImage( image, 0, 0 );
   }
  } else {
   Rectangle bounds = canvas.getBounds();
   if ( bounds.width <= 0 || bounds.height <= 0 ) {
    return;
   }
   event.gc.setForeground( GUIResource.getInstance().getColorWhite() );
   event.gc.setBackground( GUIResource.getInstance().getColorWhite() );
   event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) );
   event.gc.setForeground( GUIResource.getInstance().getColorBlack() );
   String metricsMessage = BaseMessages.getString( PKG, "JobMetricsDelegate.JobIsNotRunning.Message" );
   org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage );
   event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent e ) {
 Point area = getArea();
 if ( area.x == 0 || area.y == 0 ) {
  return; // nothing to do!
 }
 Display disp = shell.getDisplay();
 Image img = getTransformationImage( disp, area.x, area.y, magnification );
 e.gc.drawImage( img, 0, 0 );
 if ( transMeta.nrSteps() == 0 ) {
  e.gc.setForeground( GUIResource.getInstance().getColorCrystalTextPentaho() );
  e.gc.setFont( GUIResource.getInstance().getFontMedium() );
  Image pentahoImage = GUIResource.getInstance().getImageTransCanvas();
  int leftPosition = ( area.x - pentahoImage.getBounds().width ) / 2;
  int topPosition = ( area.y - pentahoImage.getBounds().height ) / 2;
  e.gc.drawImage( pentahoImage, leftPosition, topPosition );
 }
 img.dispose();
 // spoon.setShellText();
}

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent e ) {
 Point area = getArea();
 if ( area.x == 0 || area.y == 0 ) {
  return; // nothing to do!
 }
 Display disp = shell.getDisplay();
 Image img = getJobImage( disp, area.x, area.y, magnification );
 e.gc.drawImage( img, 0, 0 );
 if ( jobMeta.nrJobEntries() == 0 ) {
  e.gc.setForeground( GUIResource.getInstance().getColorCrystalTextPentaho() );
  e.gc.setBackground( GUIResource.getInstance().getColorBackground() );
  e.gc.setFont( GUIResource.getInstance().getFontMedium() );
  Image pentahoImage = GUIResource.getInstance().getImageJobCanvas();
  int leftPosition = ( area.x - pentahoImage.getBounds().width ) / 2;
  int topPosition = ( area.y - pentahoImage.getBounds().height ) / 2;
  e.gc.drawImage( pentahoImage, leftPosition, topPosition );
 }
 img.dispose();
}

代码示例来源:origin: pentaho/pentaho-kettle

gc.drawText( left, size_left.x + 1 + offsetx, size_left.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
} else {
 gc.setForeground( gray );
 gc.drawText( "<field>", size_left.x + 1 + offsetx, size_left.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
 gc.setForeground( black );
 } else {
  String nothing = rightex == null ? "<field>" : "";
  gc.setForeground( gray );
  gc.drawText( nothing, size_rightval.x + 1 + offsetx, size_rightval.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
  if ( condition.getRightValuename() == null ) {
   gc.setForeground( black );
 } else {
  String nothing = condition.getRightValuename() == null ? "<value>" : "";
  gc.setForeground( gray );
  gc.drawText( nothing, size_rightex.x + 1 + offsetx, size_rightex.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
  gc.setForeground( black );

代码示例来源:origin: pentaho/pentaho-kettle

gc.setForeground( black );
gc.fillRectangle( 0, 0, width, height );

相关文章

GC类方法