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

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

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

GC.fillPath介绍

[英]Fills the path described by the parameter.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
[中]填充参数描述的路径。
此操作需要操作系统的高级图形子系统,该子系统在某些平台上可能不可用。

代码示例

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

public static void drawArrow(GC gc, int x1, int y1, int x2, int y2, double arrowLength, double arrowAngle) {
  double theta = Math.atan2(y2 - y1, x2 - x1);
  double offset = (arrowLength - 2) * Math.cos(arrowAngle);

  gc.drawLine(x1, y1, (int)(x2 - offset * Math.cos(theta)), (int)(y2 - offset * Math.sin(theta)));

  Path path = new Path(gc.getDevice());
  path.moveTo((float)(x2 - arrowLength * Math.cos(theta - arrowAngle)), (float)(y2 - arrowLength * Math.sin(theta - arrowAngle)));
  path.lineTo((float)x2, (float)y2);
  path.lineTo((float)(x2 - arrowLength * Math.cos(theta + arrowAngle)), (float)(y2 - arrowLength * Math.sin(theta + arrowAngle)));
  path.close();

  gc.fillPath(path);

  path.dispose();
}

...

gc.setLineWidth(1);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
drawArrow(gc, x1, y1, x2, y2, 8, Math.toRadians(40));

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

public void fill(Shape s) {
  Path p = convertToPath(s);
  _gc.fillPath(p);
  p.dispose();
}

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

/**
 * Draws a filled version of the provided path.
 * 
 * @param p path to draw filled
 */
public void fillPath(final Path p) {
  gc.setTransform(swtTransform);
  gc.fillPath(p);
  gc.setTransform(null);
}

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

/**
 * Fills the specified shape using the current paint.
 *
 * @param shape  the shape ({@code null} not permitted).
 *
 * @see #getPaint()
 * @see #draw(Shape)
 */
@Override
public void fill(Shape shape) {
  Path path = toSwtPath(shape);
  // Note that for consistency with the AWT implementation, it is
  // necessary to switch temporarily the foreground and background
  // colors
  switchColors();
  this.gc.fillPath(path);
  switchColors();
  path.dispose();
}

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

gc.fillPath(path);
gc.drawPath(path);

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

gc.fillPath(path);
gc.setForeground(color);
gc.drawPath(path);

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

path.addArc((width-250)/2, (height-400)/2, 500, 400, 90, 180);
if (closeButton.getSelection()) path.close();
if (fillButton.getSelection()) gc.fillPath(path);
if (drawButton.getSelection()) gc.drawPath(path);
path.dispose();
path.cubicTo(-150, 100, 150, 200, 0, 300);
if (closeButton.getSelection()) path.close();
if (fillButton.getSelection()) gc.fillPath(path);
if (drawButton.getSelection()) gc.drawPath(path);
path.dispose();
path.lineTo(3*(width-250)/4 + 25 + 250, height/2 + 50);
if (closeButton.getSelection()) path.close();
if (fillButton.getSelection()) gc.fillPath(path);
if (drawButton.getSelection()) gc.drawPath(path);
path.dispose();

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

gc.setAlpha(255 - i * (255 / ballCollection.capacity));
gc.setBackground(ballCollection.colors[0]);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();

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

@Override
public void paint(GC gc, int width, int height) {
  if (!example.checkAdvancedGraphics()) return;
  Device device = gc.getDevice();

  if (ovalColorGB != null && ovalColorGB.getBgColor1() != null)
    gc.setBackground(ovalColorGB.getBgColor1());

  gc.setAntialias(aliasValues[aliasCombo.getSelectionIndex()]);

  Path path = new Path(device);
  float offsetX = 2*width/3f, offsetY = height/3f;
  for(int i=0; i < 25; i++) {
    path.addArc(offsetX-(50*i), offsetY-(25*i), 50+(100*i), 25+(50*i), 0, 360);
  }
  gc.fillPath(path);
  path.dispose();
}
}

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

path.addRectangle(0, 0, width/4f, height/4f);
path.addRectangle(width/4f, height/4f, width/4f, height/4f);
gc.fillPath(path);
path.dispose();
path.addRectangle(width/4f, 0, width/4f, height/4f);
path.addRectangle(0, height/4f, width/4f, height/4f);
gc.fillPath(path);
path.dispose();

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

@Override
public void paint(GC gc, int width, int height) {
  if (!example.checkAdvancedGraphics()) return;
  Device device = gc.getDevice();

  Font font = new Font(device, getPlatformFontFace(fontFace), fontSize, fontStyle);
  gc.setFont(font);

  Point size = gc.stringExtent(text);
  textWidth = size.x;
  textHeight = size.y;

  Path path = new Path(device);
  path.addString(text, x, y, font);

  gc.setForeground(device.getSystemColor(foreGrdColor));
  gc.setBackground(device.getSystemColor(fillColor));

  gc.fillPath(path);
  gc.drawPath(path);
  font.dispose();
  path.dispose();
}

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

gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
gc.fillPath(path);
gc.drawPath(path);
tr.dispose();

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

gc.fillPath(minuteHand);
tr.rotate((float) -minuteAngle);	
gc.fillPath(hourHand);

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

gc.drawPath(path);
gc.setBackground(device.getSystemColor(SWT.COLOR_RED));
gc.fillPath(path);
path.dispose();

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

gc.fillPath(minuteHand);
tr.rotate((float) -minuteAngle);	
gc.fillPath(hourHand);

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

device.getSystemColor(SWT.COLOR_RED), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();
      device.getSystemColor(SWT.COLOR_WHITE), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();
    device.getSystemColor(SWT.COLOR_DARK_MAGENTA), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();
    device.getSystemColor(SWT.COLOR_YELLOW), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
pattern.dispose();

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

@ActionParams(names="canvas,gc,shape")
public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) {
  Thing thing = shape.getThing();
  Path path = (Path) shape.getData(PATH);        
  if(path != null && !path.isDisposed()) {
    float bounds[] = new float[4];
    path.getBounds(bounds);
    //System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]);
    Transform oldTransform = new Transform(gc.getDevice());
    gc.getTransform(oldTransform);
    Transform transform = new Transform(gc.getDevice());
    transform.translate(shape.getX(), shape.getY());
    transform.scale(shape.getWidth() / (bounds[0] + bounds[2]), shape.getHeight() / (bounds[1] + bounds[3]));
    
    //transform.multiply(oldTransform);
    gc.setTransform(transform);
    if(thing.getBoolean("fill")) {
      gc.fillPath(path);
    }else {
      gc.drawPath(path);
    }
    
    gc.setTransform(oldTransform);
    transform.dispose();
    oldTransform.dispose();
  }
}

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

path.addArc(39f*(width-diameter/25)/100, 67*(height-diameter/25)/100, diameter/25, diameter/25, 0, 360);
gc.fillPath(path);
path.dispose();

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

path.close();
gc.setBackground(device.getSystemColor(SWT.COLOR_GRAY));
gc.fillPath(path);
gc.drawPath(path);
path.dispose();

相关文章

GC类方法