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

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

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

GC.getBackground介绍

[英]Returns the background 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 back = gc.getBackground();
gc.setBackground( fore );
gc.fillPolygon( new int[] { mx, my, x3, y3, x4, y4 } );

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

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

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

/** {@inheritDoc} */
public Color getBackground() {
  final org.eclipse.swt.graphics.Color color = gc.getBackground();
  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: 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

public static void drawPie(GC gc,int x, int y,int width,int height,int percent) {
  Color background = gc.getBackground();
  gc.setForeground(Colors.blue);
  int angle = (percent * 360) / 100;
  if(angle<4)
    angle = 0; // workaround fillArc rendering bug
  gc.setBackground(Colors.white);
  gc.fillArc(x,y,width,height,0,360);
  gc.setBackground(background);
  gc.fillArc(x,y,width,height,90,angle*-1);
  gc.drawOval(x , y , width-1, height-1);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

void drawBackgroundInPixels(GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
  if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
  if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
  RECT rect = new RECT ();
  OS.SetRect (rect, x, y, x + width, y + height);
  int /*long*/ hDC = gc.handle;
  int pixel = background == -1 ? gc.getBackground ().handle : -1;
  drawBackground (hDC, rect, pixel, offsetX, offsetY);
}

代码示例来源:origin: stefanhaustein/flowgrid

public static void drawHalo(GC gc, int x, int y, int r, Color color) {
    Color background = gc.getBackground();
    int alpha = gc.getAlpha();
    gc.setAlpha(127);
    gc.setBackground(color);
    gc.fillOval(x - r, y - r, 2 * r, 2 * r);
    gc.setAlpha(alpha);
    gc.setBackground(background);
  }
}

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

public void paintBullet(GC gc, Rectangle repaintRegion,
      Hashtable<String, Object> resourceTable) {
    if (bbounds == null)
      return;
    int x = bbounds.x;
    int y = bbounds.y;
    if (repaintRegion != null) {
      x -= repaintRegion.x;
      y -= repaintRegion.y;
    }
    if (style == CIRCLE) {
      Color bg = gc.getBackground();
      Color fg = gc.getForeground();
      gc.setBackground(fg);
      gc.fillRectangle(x, y + 1, 5, 3);
      gc.fillRectangle(x + 1, y, 3, 5);
      gc.setBackground(bg);
    } else if (style == TEXT && text != null) {
      gc.drawText(text, x, y);
    } else if (style == IMAGE && text != null) {
      Image image = (Image) resourceTable.get(text);
      if (image != null)
        gc.drawImage(image, x, y);
    }
  }
}

代码示例来源:origin: stackoverflow.com

table.addListener(SWT.EraseItem, new Listener() {
  public void handleEvent(Event event) {
   event.detail &= ~SWT.HOT;
   if ((event.detail & SWT.SELECTED) == 0) 
    return; 
   int clientWidth = ((Composite)event.widget).getClientArea().width;
   GC gc = event.gc;
   Color oldForeground = gc.getForeground();
   Color oldBackground = gc.getBackground();
   gc.setBackground(event.display.getColor(SWT.COLOR_YELLOW));
   gc.setForeground(event.display.getColor(SWT.COLOR_BLUE));
   gc.fillGradientRectangle(0, event.y, clientWidth, event.height, true);
   gc.setForeground(oldForeground);
   gc.setBackground(oldBackground);
   event.detail &= ~SWT.SELECTED;
  }
});

代码示例来源:origin: stackoverflow.com

table.addListener(SWT.EraseItem, new Listener() {
  public void handleEvent(Event event) {
    event.detail &= ~SWT.HOT;
    if ((event.detail & SWT.SELECTED) == 0) return; /// item not selected

    Table table =(Table)event.widget;
    TableItem item =(TableItem)event.item;
    int clientWidth = table.getClientArea().width;

    GC gc = event.gc;               
    Color oldForeground = gc.getForeground();
    Color oldBackground = gc.getBackground();

    gc.setBackground(colorBackground);
    gc.setForeground(colorForeground);              
    gc.fillRectangle(0, event.y, clientWidth, event.height);

    gc.setForeground(oldForeground);
    gc.setBackground(oldBackground);
    event.detail &= ~SWT.SELECTED;
  }
});

代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui

public void paintControl(PaintEvent e) {
//                Rectangle bounds = composite.getClientArea();
        GC gc = e.gc;

        gc.setForeground(gc.getBackground());
        gc.setBackground(getWidgetFactory().getColors().getColor(
          FormColors.TB_BG));

//                gc.fillGradientRectangle(4 + bounds.width / 2, 0,
//                    bounds.width / 2 - 9, bounds.height, false);

        gc.setForeground(getWidgetFactory().getColors().getColor(
          FormColors.TB_BORDER));
//                gc.drawLine(bounds.width - 5, 0, bounds.width - 5,
//                    bounds.height);
      }

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.css.swt

@Override
public void doPaintControl(GC gc, Rectangle currClientArea, Scrollable scrollable) {
  if (fHandleDrawnRect != null) {
    StyledText styledText = (StyledText) scrollable;
    int lineWidth = getCurrentScrollBarWidth();
    int w = currClientArea.width - (styledText.getLeftMargin() + styledText.getRightMargin());
    int h = currClientArea.height;
    int borderRadius = Math.min(fScrollBarSettings.getScrollBarBorderRadius(), lineWidth);
    // Fill the background (same thing as the
    // getFullBackgroundRect).
    gc.fillRoundRectangle(styledText.getLeftMargin(), h - lineWidth, w, lineWidth, borderRadius,
        borderRadius);
    // Fill the foreground.
    Color foreground = gc.getForeground();
    Color background = gc.getBackground();
    gc.setBackground(foreground);
    gc.fillRoundRectangle(fHandleDrawnRect.x, fHandleDrawnRect.y, fHandleDrawnRect.width,
        fHandleDrawnRect.height, borderRadius, borderRadius);
    gc.setBackground(background);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.css.swt

@Override
public void doPaintControl(GC gc, Rectangle currClientArea, Scrollable scrollable) {
  if (fHandleDrawnRect != null) {
    StyledText styledText = (StyledText) scrollable;
    int lineWidth = getCurrentScrollBarWidth();
    int w = currClientArea.width;
    int h = currClientArea.height - (styledText.getTopMargin() + styledText.getBottomMargin());
    int borderRadius = Math.min(fScrollBarSettings.getScrollBarBorderRadius(), lineWidth);
    // Fill the background (same thing as the
    // getFullBackgroundRect).
    gc.fillRoundRectangle(w - lineWidth, styledText.getTopMargin(), lineWidth, h, borderRadius,
        borderRadius);
    // Fill the foreground.
    Color foreground = gc.getForeground();
    Color background = gc.getBackground();
    gc.setBackground(foreground);
    gc.fillRoundRectangle(fHandleDrawnRect.x, fHandleDrawnRect.y, fHandleDrawnRect.width,
        fHandleDrawnRect.height, borderRadius, borderRadius);
    gc.setBackground(background);
  }
}

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

public void draw(Canvas canvas, GC gc){
  //打开反锯齿
  int antialias = gc.getAntialias();
  if(antialias != SWT.ON) {
    gc.setAntialias(SWT.ON);
  }
  
  //先填充画面
  Color oldColor = gc.getBackground();
  gc.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_WHITE));
  gc.fillRectangle(canvas.getClientArea());
  gc.setBackground(oldColor);
  
  if(backgroundImage != null){
    gc.drawImage(backgroundImage, 0, 0);
  }
  
  //绘画各种形状
  for(SimpleShape shape : shapes){			
    try {
      shape.draw(canvas, gc);
    }catch(Exception e) {
      logger.warn("Draw SimpleDraw2d shape exception, path=" + shape.getThing().getMetadata().getPath(), e);
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.renderers.swt

void drawCorners(GC gc, Rectangle bounds) {
  Color bg = gc.getBackground();
  Color fg = gc.getForeground();
  Color toFill = parent.getParent().getBackground();
  gc.setAlpha(255);
  gc.setBackground(toFill);
  gc.setForeground(toFill);
  int radius = cornerSize / 2 + 1;
  int leftX = bounds.x - 1;
  int topY = bounds.y - 1;
  int rightX = bounds.x + bounds.width;
  int bottomY = bounds.y + bounds.height;
  drawCutout(gc, leftX, topY, radius, CirclePart.LEFT_TOP);
  drawCutout(gc, rightX, topY, radius, CirclePart.RIGHT_TOP);
  drawCutout(gc, leftX, bottomY, radius, CirclePart.LEFT_BOTTOM);
  drawCutout(gc, rightX, bottomY, radius, CirclePart.RIGHT_BOTTOM);
  gc.setBackground(bg);
  gc.setForeground(fg);
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer

public void drawImage(FSImage image, int x, int y) {
  Image img = ((SWTFSImage) image).getImage();
  if (img == null) {
    int width = image.getWidth();
    int height = image.getHeight();
    Color oldBG = _gc.getBackground();
    Color oldFG = _gc.getForeground();
    _gc.setBackground(_gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
    _gc.setForeground(_gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
    _gc.fillRectangle(x, y, width, height);
    _gc.drawRectangle(x, y, width, height);
    _gc.drawLine(x, y, x + width - 1, y + height - 1);
    _gc.drawLine(x, y + height - 1, x + width - 1, y);
    _gc.setBackground(oldBG);
    _gc.setForeground(oldFG);
  } else {
    Rectangle bounds = img.getBounds();
    _gc.drawImage(img, 0, 0, bounds.width, bounds.height, x, y, image
      .getWidth(), image.getHeight());
  }
}

相关文章

微信公众号

最新文章

更多

GC类方法