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

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

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

GC.getForeground介绍

[英]Returns the receiver's foreground color.
[中]返回接收器的前景色。

代码示例

代码示例来源: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

Color fore = gc.getForeground();
Color back = gc.getBackground();
gc.setBackground( fore );

代码示例来源: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: org.microemu/microemu-javase-swt

public Color getForeground() 
{
  return gc.getForeground();
}

代码示例来源:origin: org.jfree/swtgraphics2d

/**
 * Returns the current color for this graphics context.
 *
 * @return The current color.
 *
 * @see #setColor(Color)
 */
@Override
public Color getColor() {
  // TODO: it might be a good idea to keep a reference to the color
  // specified in setPaint() or setColor(), rather than creating a
  // new object every time getPaint() is called.
  return SWTUtils.toAwtColor(this.gc.getForeground());
}

代码示例来源:origin: org.jfree/swtgraphics2d

/**
 * Returns the current paint for this graphics context.
 *
 * @return The current paint.
 *
 * @see #setPaint(Paint)
 */
@Override
public Paint getPaint() {
  // TODO: it might be a good idea to keep a reference to the color
  // specified in setPaint() or setColor(), rather than creating a
  // new object every time getPaint() is called.
  return SWTUtils.toAwtColor(this.gc.getForeground());
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/** {@inheritDoc} */
public Color getColor() {
  final org.eclipse.swt.graphics.Color color = gc.getForeground();
  final Color awtColor = new Color(color.getRed(), color.getGreen(), color.getBlue());
  return awtColor;
}

代码示例来源:origin: org.jfree/swtgraphics2d

/**
 * Perform a switch between foreground and background
 * color of gc. This is needed for consistency with
 * the AWT behaviour, and is required notably for the
 * filling methods.
 */
private void switchColors() {
  org.eclipse.swt.graphics.Color bg = this.gc.getBackground();
  org.eclipse.swt.graphics.Color fg = this.gc.getForeground();
  this.gc.setBackground(fg);
  this.gc.setForeground(bg);
}

代码示例来源:origin: com.eclipsesource.tabris/tabris

private void doDispatch() {
 int lineWidth = gc.getLineWidth();
 Color foreground = gc.getForeground();
 int alpha = gc.getAlpha();
 dispatchOperations();
 restoreLastSettings( lineWidth, foreground, alpha );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.forms

private void drawUnderline(GC gc, int swidth, int x, int y, boolean hover,
    boolean rolloverMode) {
  if (underline || rolloverMode) {
    Color saved = null;
    if (rolloverMode && !hover) {
      saved = gc.getForeground();
      gc.setForeground(gc.getBackground());
    }
    gc.drawLine(x, y, x + swidth-1, y);
    if (saved != null)
      gc.setForeground(saved);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.forms

private void drawUnderline(GC gc, int swidth, int x, int y, boolean hover,
    boolean rolloverMode) {
  if (underline || rolloverMode) {
    Color saved = null;
    if (rolloverMode && !hover) {
      saved = gc.getForeground();
      gc.setForeground(gc.getBackground());
    }
    gc.drawLine(x, y, x + swidth-1, y);
    if (saved != null)
      gc.setForeground(saved);
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
    Color old = event.gc.getForeground();
    event.gc.setForeground(Colors.black);
    int	char_width = event.gc.getFontMetrics().getAverageCharWidth();
    String pb_text = pbt.convert(result.getSelection());
    event.gc.drawText(pb_text, (result.getSize().x - pb_text.length() * char_width )/2, -1, true);
    event.gc.setForeground(old);
  }
});

代码示例来源:origin: org.eclipse.mylyn.commons/screenshots

public void handleEvent(Event e) {
    Color gcForeground = e.gc.getForeground();
    Rectangle bounds = ((Composite) e.widget).getBounds();
    Color border = e.widget.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    e.gc.setForeground(border);
    e.gc.drawLine(bounds.width - 1, 0, bounds.width - 1, bounds.height);
    e.gc.setForeground(gcForeground);
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
void doPaint(GC gc, ILineRange visibleLines) {
  Color foreground= gc.getForeground();
  if (visibleLines != null) {
    if (fRevisionPainter.hasInformation())
      fRevisionPainter.paint(gc, visibleLines);
    else if (fDiffPainter.hasInformation()) // don't paint quick diff colors if revisions are painted
      fDiffPainter.paint(gc, visibleLines);
  }
  gc.setForeground(foreground);
  if (fShowNumbers || fCharacterDisplay)
    super.doPaint(gc, visibleLines);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.forms

@Override
public void paint(GC gc, boolean hover, Hashtable<String, Object> resourceTable,
    boolean selected, SelectionData selData, Rectangle repaintRegion) {
  boolean rolloverMode = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_HOVER;
  underline = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_ALWAYS;
  Color savedFg = gc.getForeground();
  Color newFg = hover ? settings.getActiveForeground() : settings.getForeground();
  if (newFg!=null)
    gc.setForeground(newFg);
  super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, repaintRegion);
  gc.setForeground(savedFg);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.forms

@Override
public void paint(GC gc, boolean hover, Hashtable<String, Object> resourceTable,
    boolean selected, SelectionData selData, Rectangle repaintRegion) {
  boolean rolloverMode = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_HOVER;
  underline = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_ALWAYS;
  Color savedFg = gc.getForeground();
  Color newFg = hover ? settings.getActiveForeground() : settings.getForeground();
  if (newFg!=null)
    gc.setForeground(newFg);
  super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, repaintRegion);
  gc.setForeground(savedFg);
}

代码示例来源:origin: openaudible/openaudible

public static void debugLayout(final Composite c, final int color) {
  c.addPaintListener(e -> {
    Color save = e.gc.getForeground();
    e.gc.setForeground(Display.getCurrent().getSystemColor(color));
    e.gc.drawRectangle(1, 1, c.getBounds().width - 1, c.getBounds().width - 1);
    // e.gc.drawLine(1, 1, c.getBounds().width - 1, c.getBounds().height - 1);
    e.gc.setForeground(save);
  });
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@Override
void doPaint(GC gc, ILineRange visibleLines) {
  Color foreground= gc.getForeground();
  if (visibleLines != null) {
    if (fRevisionPainter.hasInformation()) {
      fRevisionPainter.setZoom(fZoom);
      fRevisionPainter.paint(gc, visibleLines);
    } else if (fDiffPainter.hasInformation()) { // don't paint quick diff colors if revisions are painted
      fDiffPainter.setZoom(fZoom);
      fDiffPainter.paint(gc, visibleLines);
    }
  }
  gc.setForeground(foreground);
  if (fShowNumbers || fCharacterDisplay)
    super.doPaint(gc, visibleLines);
}

代码示例来源:origin: org.xworker/xworker_swt

public void paintControl(PaintEvent event) {
  Control control = (Control) event.widget;
  Rectangle rect = new Rectangle(0, 0,
      control.getSize().x, control.getSize().y);
  
  GC gc = event.gc;
  //System.out.println(event.count);
  Color color = gc.getForeground();
  gc.setForeground(event.display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
  gc.drawLine(rect.x, rect.y, rect.width, rect.y);
  gc.drawLine(rect.x, rect.y, rect.x, rect.height);
  gc.setForeground(event.display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
  gc.drawLine(rect.x, rect.height-1, rect.width, rect.height-1);
  gc.drawLine(rect.width-1, rect.y, rect.width-1, rect.height);
  gc.setForeground(color);
}

相关文章

GC类方法