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

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

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

GC.fillOval介绍

[英]Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.
[中]在指定的矩形区域内,用接收器的背景色填充椭圆形的内部。

代码示例

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

int y_oval = TOP + i * ( fontheight + 2 ) + offset.y;
gc.drawOval( x_oval, y_oval, fontwidth, fontheight );
gc.fillOval( x_oval, y_oval, fontwidth, fontheight );
gc.setForeground( black );
gc.setBackground( bg );

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

int y_oval = TOP + i * ( fontheight + 2 ) + offset.y;
gc.drawOval( x_oval, y_oval, fontwidth, fontheight );
gc.fillOval( x_oval, y_oval, fontwidth, fontheight );
gc.setForeground( black );
gc.setBackground( bg );

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

public void fillOval(int x, int y, int width, int height) {
  _gc.fillOval(x, y, width, height);
}

代码示例来源:origin: rinde/RinSim

void fillCircle(Point p, int radiusInPixels) {
 gc.get().fillOval(
  vp.get().toCoordX(p.x) - radiusInPixels,
  vp.get().toCoordY(p.y) - radiusInPixels,
  radiusInPixels * 2,
  radiusInPixels * 2);
}

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

/**
 * Fills an oval bounded by the specified rectangle with the current color.
 * 
 * @param x the x coordinate of the upper left corner of the oval to be
 *            filled.
 * @param y the y coordinate of the upper left corner of the oval to be
 *            filled.
 * @param width the width of the oval to be filled.
 * @param height the height of the oval to be filled.
 */
public void fillOval(final double x, final double y, final double width, final double height) {
  TEMP_RECT.setRect(x, y, width, height);
  SWTShapeManager.transform(TEMP_RECT, transform);
  gc.fillOval((int) (TEMP_RECT.getX() + 0.5), (int) (TEMP_RECT.getY() + 0.5), (int) (TEMP_RECT.getWidth() + 0.5),
      (int) (TEMP_RECT.getHeight() + 0.5));
}

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

public void drawOpenConnection(GC gc, int toX, int toY, Type type) {
  gc.setBackground(resourceManager.typeColor(type, false));
  int r = Math.round(cellSize / 16);
  gc.fillOval(toX - r, toY - r, 2 * r, 2 * r);
}

代码示例来源:origin: rinde/RinSim

void fillCircle(Point p, double radius) {
 gc.get().fillOval(
  vp.get().toCoordX(p.x - radius),
  vp.get().toCoordY(p.y - radius),
  vp.get().scale(radius * 2),
  vp.get().scale(radius * 2));
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

@Override
public void draw(FigureDrawContext fdc) {
  Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
  fdc.gc.setBackground(color);
  fdc.gc.fillOval(r.x, r.y, r.width, r.height);
}
@Override

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

/**
 * Fills an oval that fits within the specified rectangular region.
 *
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 * @param width  the frame width.
 * @param height  the frame height.
 *
 * @see #drawOval(int, int, int, int)
 * @see #fill(Shape)
 */
@Override
public void fillOval(int x, int y, int width, int height) {
  switchColors();
  this.gc.fillOval(x, y, width - 1, height - 1);
  switchColors();
}

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

ScrolledComposite scroll = new ScrolledComposite(shell, SWT.V_SCROLL|SWT.H_SCROLL);
scroll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));

Group grpDraw = new Group(scroll, SWT.V_SCROLL|SWT.H_SCROLL);
grpDraw.setText("Picture");
grpDraw.setBounds(0, 0, 200, 200);

Button btnPaint = new Button(shell, SWT.NONE);
btnPaint.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
btnPaint.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      Image image = new Image(display, 1000, 1000);
      GC gc = new GC(image);
      gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
      gc.fillOval(50,50,100,100);
      gc.setForeground(display.getSystemColor(SWT.COLOR_DARK_GREEN));
      gc.dispose();
      grpDraw.setBackgroundImage(image);
      scroll.setContent(grpDraw);
    }
  });
btnPaint.setText("paint");

代码示例来源:origin: com.github.rinde/rinsim-example

@Override
public void renderDynamic(GC gc, ViewPort vp, long time) {
 final int radius = 2;
 gc.setBackground(new Color(gc.getDevice(), RED, 0, 0));
 final Map<RoadUser, Point> objects = rm.getObjectsAndPositions();
 synchronized (objects) {
  for (final Entry<RoadUser, Point> entry : objects.entrySet()) {
   final Point p = entry.getValue();
   gc.fillOval((int) (vp.origin.x + (p.x - vp.rect.min.x) * vp.scale)
    - radius, (int) (vp.origin.y + (p.y - vp.rect.min.y) * vp.scale)
     - radius,
    2 * radius, 2 * radius);
  }
 }
}

代码示例来源:origin: rinde/RinSim

@Override
public void renderDynamic(GC gc, ViewPort vp, long time) {
 final int radius = 2;
 gc.setBackground(new Color(gc.getDevice(), RED, 0, 0));
 final Map<RoadUser, Point> objects = rm.getObjectsAndPositions();
 synchronized (objects) {
  for (final Entry<RoadUser, Point> entry : objects.entrySet()) {
   final Point p = entry.getValue();
   gc.fillOval((int) (vp.origin.x + (p.x - vp.rect.min.x) * vp.scale)
    - radius, (int) (vp.origin.y + (p.y - vp.rect.min.y) * vp.scale)
     - radius,
    2 * radius, 2 * radius);
  }
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

@Override
public void paint(GC gc, int width, int height) {
  Device device = gc.getDevice();
  gc.setBackground(device.getSystemColor(SWT.COLOR_BLACK));
  gc.fillOval((width - size) / 2, (height - size) / 2, size, size);
}
}

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

protected void drawDot(final Color outline, final Color fill, final int x,
    final int y, final int w, final int h) {
  int dotX = cellX + x + 2;
  int dotY = cellY + y + 1;
  int dotW = w - 2;
  int dotH = h - 2;
  g.setBackground(fill);
  g.fillOval(dotX, dotY, dotW, dotH);
  g.setForeground(outline);
  g.setLineWidth(2);
  g.drawOval(dotX, dotY, dotW, dotH);
}

代码示例来源:origin: com.github.rinde/rinsim-example

gc.fillOval(x, y, dia, dia);

代码示例来源: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.xworker/xworker_swt

@ActionParams(names="canvas,gc,shape")
  public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) {
    if(shape.getThing().getBoolean("fill")) {
      gc.fillOval(0, 0, shape.getWidth(), shape.getHeight());
    }else {
      gc.drawOval(0, 0, shape.getWidth(), shape.getHeight());
    }
  }
}

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

public static void drawBoolean(GC gc, boolean value, int x, int y, int size) {
 Device device = gc.getDevice();
 gc.setBackground(device.getSystemColor(value ? SWT.COLOR_GREEN : SWT.COLOR_RED));
 gc.fillOval(x, y, size, size);
 gc.setForeground(device.getSystemColor(SWT.COLOR_WHITE));
 gc.setLineWidth(Math.max(1, size / 8));
 gc.setLineCap(value ? SWT.CAP_ROUND : SWT.CAP_FLAT);
 int d = size / 4;
 int cx = x + size / 2;
 int cy = y + size / 2;
 if (value) {
  gc.drawLine(cx - d, cy, cx-d/4, cy + d);
  gc.drawLine(cx-d/4, cy + d, cx + d, cy - d);
 } else {
  gc.drawLine(cx - d, cy - d, cx + d, cy + d);
  gc.drawLine(cx - d, cy + d, cx + d, cy - d);
 }
}

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

private void drawIndicators( GC gc ) {
 for( int i = 0; i < getCount(); i++ ) {
  if( i == getActive() ) {
   gc.setBackground( getActiveColor() );
  } else {
   gc.setBackground( getInactiveColor() );
  }
  int x = ( getDiameter() + getSpacing() ) * i;
  gc.fillOval( x, 0, getDiameter(), getDiameter() );
 }
 gc.dispose();
}

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

public static ImageData createSampleImage(Display display) {
  Image image = new Image(display, 100, 100);
  Rectangle bounds = image.getBounds();
  GC gc = new GC(image);
  gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
  gc.fillRectangle(bounds);
  gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
  gc.fillOval(0, 0, bounds.width, bounds.height);
  gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
  gc.drawLine(0, 0, bounds.width, bounds.height);
  gc.drawLine(bounds.width, 0, 0, bounds.height);
  gc.dispose();
  ImageData data = image.getImageData();
  image.dispose();
  return data;
}

相关文章

微信公众号

最新文章

更多

GC类方法