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

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

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

GC.fillGradientRectangle介绍

[英]Fills the interior of the specified rectangle with a gradient sweeping from left to right or top to bottom progressing from the receiver's foreground color to its background color.
[中]使用从左到右或从上到下的渐变填充指定矩形的内部,渐变从接收器的前景色逐渐过渡到其背景色。

代码示例

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

public void fillGradientRectangle( int x, int y, int width, int height, boolean vertical ) {
 gc.fillGradientRectangle( x, y, width, height, vertical );
}

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

public void fillGradientRectangle( int x, int y, int width, int height, boolean vertical ) {
 gc.fillGradientRectangle( x, y, width, height, vertical );
}

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

gc.setForeground(color1);
  gc.setBackground(color2);
  gc.fillGradientRectangle(rect.x, rect.y, rect.width,
      rect.height, true);
} finally {

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

Listener listener = new Listener () {
 public void handleEvent (Event e) {
  GC gc = e.gc;
  Rectangle rect = composite.getClientArea ();
  Point offset = ((Control)e.widget).toControl(composite.toDisplay(0, 0));
  Color color1 = new Color (display, 0, 0, 0);
  Color color2 = new Color (display, 255, 255, 255);
  gc.setForeground(color1);
  gc.setBackground(color2);
  gc.fillGradientRectangle (rect.x + offset.x, rect.y + offset.y,
    rect.width, rect.height , true);
 }
}
composite.addListener (SWT.Paint, listener);
label.addListener(SWT.Paint, listener);

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

/**
 * Fills a gradient rectangle of in the direction specified.
 * 
 * @param x left of resulting rectangle
 * @param y top of resulting rectangle
 * @param width width of resulting rectangle
 * @param height height of resulting rectangle
 * @param vertical whether the gradient should be drawn vertically or
 *            horizontally
 */
public void fillGradientRectangle(final double x, final double y, final double width, final double height,
    final boolean vertical) {
  TEMP_RECT.setRect(x, y, width, height);
  SWTShapeManager.transform(TEMP_RECT, transform);
  SWTShapeManager.awtToSWT(TEMP_RECT, SWT_RECT);
  gc.fillGradientRectangle(SWT_RECT.x, SWT_RECT.y, SWT_RECT.width, SWT_RECT.height, vertical);
}

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

@Override
  public void handleEvent(Event e) {
    if (composite.isDisposed())
      return;
    Rectangle bounds = composite.getBounds();
    GC gc = e.gc;
    gc.setForeground(colors.getColor(IFormColors.SEPARATOR));
    if (colors.getBackground() != null)
      gc.setBackground(colors.getBackground());
    gc.fillGradientRectangle(0, 0, bounds.width, bounds.height,
        false);
  }
});

代码示例来源: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: org.eclipse.platform/org.eclipse.ui.forms

/**
 * Creates the composite that can server as a separator between various
 * parts of a form. Separator height should be controlled by setting the
 * height hint on the layout data for the composite.
 *
 * @param parent
 *            the separator parent
 * @return the separator widget
 */
public Composite createCompositeSeparator(Composite parent) {
  checkDisposed();
  final Composite composite = new Composite(parent, orientation);
  composite.addListener(SWT.Paint, e -> {
    if (composite.isDisposed())
      return;
    Rectangle bounds = composite.getBounds();
    GC gc = e.gc;
    gc.setForeground(colors.getColor(IFormColors.SEPARATOR));
    if (colors.getBackground() != null)
      gc.setBackground(colors.getBackground());
    gc.fillGradientRectangle(0, 0, bounds.width, bounds.height, false);
  });
  if (parent instanceof Section)
    ((Section) parent).setSeparatorControl(composite);
  return composite;
}

代码示例来源:origin: Nodeclipse/EditBox

void fillRectangle(Color c, GC gc, int x, int y, int width, int height) {
  if (c == null)
    return;
  
  gc.setBackground(c);
  if (settings.getRoundBox()){
    gc.fillRoundRectangle(x, y, width, height, ROUND_BOX_ARC, ROUND_BOX_ARC);
  }
  else {
    if (settings.getFillGradient() && settings.getFillGradientColor()!=null) {
      gc.setBackground(settings.getFillGradientColor());
      gc.setForeground(c);
      gc.fillGradientRectangle(x, y, width, height, false);
    }else {
      gc.fillRectangle(x, y, width, height);
    }
  }
}

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

@Override
public Image createImage(boolean returnMissingImageOnError, Device device) {
  Image image = new Image(device, 1, fLength);
  Color color1 = new Color(device, fRGBs[0]);
  Color color2 = new Color(device, fRGBs[1]);
  image.setBackground(color1);
  GC gc = new GC(image);
  gc.setBackground(color1);
  gc.fillRectangle(0, 0, 1, fLength);
  gc.setForeground(color2);
  gc.setBackground(color1);
  gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true);
  gc.dispose();
  color1.dispose();
  color2.dispose();
  return image;
}

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

@Override
public Image createImage(boolean returnMissingImageOnError, Device device) {
  Image image = new Image(device, 1, fLength);
  Color color1 = new Color(device, fRGBs[0]);
  Color color2 = new Color(device, fRGBs[1]);
  image.setBackground(color1);
  GC gc = new GC(image);
  gc.setBackground(color1);
  gc.fillRectangle(0, 0, 1, fLength);
  gc.setForeground(color2);
  gc.setBackground(color1);
  gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true);
  gc.dispose();
  color1.dispose();
  color2.dispose();
  return image;
}

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

@Override
  public Image createImage(boolean returnMissingImageOnError,	Device device) {
    Image image = new Image(device, 1, fLength);
    Color color1 = new Color(device, fRGBs[0]);
    Color color2 = new Color(device, fRGBs[1]);
    image.setBackground(color1);
    GC gc = new GC(image);
    gc.setBackground(color1);
    gc.fillRectangle(0, 0, 1, fLength);
    gc.setForeground(color2);
    gc.setBackground(color1);
    gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true);
    gc.dispose();
    color1.dispose();
    color2.dispose();
    return image;
  }
}

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

@Override
  public Image createImage(boolean returnMissingImageOnError,	Device device) {
    Image image = new Image(device, 1, fLength);
    Color color1 = new Color(device, fRGBs[0]);
    Color color2 = new Color(device, fRGBs[1]);
    image.setBackground(color1);
    GC gc = new GC(image);
    gc.setBackground(color1);
    gc.fillRectangle(0, 0, 1, fLength);
    gc.setForeground(color2);
    gc.setBackground(color1);
    gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true);
    gc.dispose();
    color1.dispose();
    color2.dispose();
    return image;
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND));
gc.setBackground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
gc.fillGradientRectangle (x, y, width, headerHeight, true);
if (expanded) {
  gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));

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

protected void paintRect(GC gc, int x, int y, Color a, Color b, Color c) {
  int[] p = new int[] { 0, 2, 2, 0, 30, 0, 32, 2, 32, 30, 30, 32, 2, 32, 0, 30};
  
  int[] q = new int[p.length];
  for (int i = 0; i < p.length / 2; i++) {
    q[i*2] = p[i*2] + x;
    q[i*2+1] = p[i*2+1] + y;
  }
  
  Region region = new Region(getDisplay());
  region.add(q);
  
  gc.setClipping(region);
  
  gc.setBackground(a);
  gc.setForeground(b);
  gc.fillGradientRectangle(x, y, 32, 32, true);
  gc.setClipping((Region)null);
  gc.setForeground(c);
  gc.drawPolygon(q);
  
  gc.setForeground(getForeground());
  gc.setBackground(getBackground());
  String st = "Tomcat Test Environment";
  Point stp = gc.stringExtent(st);
  gc.drawString(st, x+16 - stp.x / 2, y + 32 + 2);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND));
gc.setBackground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
gc.fillGradientRectangle (x, y, width, headerHeight, true);
if (expanded) {
  gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));

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

public void handleEvent(Event event) {
  if (shouldApplyGradient(event)) {
    Scrollable scrollable = (Scrollable) event.widget;
    GC gc = event.gc;
    Rectangle area = scrollable.getClientArea();
    Rectangle rect = event.getBounds();
    /* Paint the selection beyond the end of last column */
    expandRegion(event, scrollable, gc, area);
    /* Draw Gradient Rectangle */
    Color oldForeground = gc.getForeground();
    Color oldBackground = gc.getBackground();
    gc.setForeground(categoryGradientEnd);
    gc.drawLine(0, rect.y, area.width, rect.y);
    gc.setForeground(categoryGradientStart);
    gc.setBackground(categoryGradientEnd);
    // gc.setForeground(categoryGradientStart);
    // gc.setBackground(categoryGradientEnd);
    // gc.setForeground(new Clr(Display.getCurrent(), 255, 0, 0));
    gc.fillGradientRectangle(0, rect.y + 1, area.width, rect.height, true);
    /* Bottom Line */
    // gc.setForeground();
    gc.setForeground(categoryGradientEnd);
    gc.drawLine(0, rect.y + rect.height - 1, area.width, rect.y + rect.height - 1);
    gc.setForeground(oldForeground);
    gc.setBackground(oldBackground);
    /* Mark as Background being handled */
    event.detail &= ~SWT.BACKGROUND;
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.views.properties.tabbed

/**
 * @param e
 */
protected void drawTitleBackground(PaintEvent e) {
  Rectangle bounds = getClientArea();
  label.setBackground(new Color[] {
      factory.getColors().getColor(IFormColors.H_GRADIENT_END),
      factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
      new int[] { 100 }, true);
  Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END);
  Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START);
  GC gc = e.gc;
  gc.setForeground(bg);
  gc.setBackground(gbg);
  gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width,
      bounds.height, true);
  // background bottom separator
  gc.setForeground(factory.getColors().getColor(
      IFormColors.H_BOTTOM_KEYLINE1));
  gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1,
      bounds.height - 2);
  gc.setForeground(factory.getColors().getColor(
      IFormColors.H_BOTTOM_KEYLINE2));
  gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1,
      bounds.height - 1);
}

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

private void updateBackgroundImage() {
  FormToolkit toolkit = helpPart.getForm().getToolkit();
  FormColors colors = toolkit.getColors();
  Rectangle carea = container.getClientArea();
  Image oldImage = bgImage;
  if (bgImage!=null) {
    Rectangle ibounds = bgImage.getBounds();
    if (carea.height==ibounds.height)
      return;
  }
  bgImage = new Image(container.getDisplay(), 1, carea.height);
  GC gc = new GC(bgImage);
  gc.setBackground(colors.getColor(IFormColors.H_GRADIENT_END));
  gc.setForeground(colors.getColor(IFormColors.H_GRADIENT_START));
  gc.fillGradientRectangle(0, 0,
      1,
      carea.height,
      true);
  gc.setForeground(colors.getColor(IFormColors.H_BOTTOM_KEYLINE2));
  gc.drawLine(0, 0, 1, 0);
  gc.setForeground(colors.getColor(IFormColors.H_BOTTOM_KEYLINE1));
  gc.drawLine(0, 1, 1, 1);
  gc.dispose();
  container.setBackgroundImage(bgImage);
  if (oldImage != null && !oldImage.isDisposed()) {
    oldImage.dispose();
  }
}

相关文章

GC类方法