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

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

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

GC.fillPolygon介绍

[英]Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using the receiver's background color. The array contains alternating x and y values which are considered to represent points which are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array.
[中]使用接收器的背景色填充由指定整数坐标数组定义的闭合多边形的内部。该数组包含交替的x和y值,这些值被视为表示作为多边形顶点的点。在每个连续对之间以及阵列中第一对和最后一对之间绘制线。

代码示例

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

public void fillPolygon( int[] polygon ) {
 gc.fillPolygon( polygon );
}

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

public void fillPolygon( int[] polygon ) {
 gc.fillPolygon( polygon );
}

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

private void drawMarker( GC gc, int x, int maxy ) {
 int[] triangle =
  new int[] {
   LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3,
   TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 };
 gc.fillPolygon( triangle );
 gc.drawPolygon( triangle );
 gc
  .drawLine(
   LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy );
}

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

private void drawMarker( GC gc, int x, int maxy ) {
 int[] triangle =
  new int[] {
   LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3,
   TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 };
 gc.fillPolygon( triangle );
 gc.drawPolygon( triangle );
 gc
  .drawLine(
   LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy );
}

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

Color back = gc.getBackground();
gc.setBackground( fore );
gc.fillPolygon( new int[] { mx, my, x3, y3, x4, y4 } );
gc.setBackground( back );

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

public void fillPolygon(int[] pointArray) 
{
  gc.fillPolygon(pointArray);
}

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

@Override
public void draw(FigureDrawContext fdc) {
  int[] drawPoints = new int[points.length];
  for (int i = 0; i < points.length; i += 2) {
    drawPoints[i] = points[i] * fdc.xScale - fdc.xOffset;
    drawPoints[i + 1] = points[i + 1] * fdc.yScale - fdc.yOffset;
  }
  fdc.gc.setBackground(color);
  fdc.gc.fillPolygon(drawPoints);
}
@Override

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

/** {@inheritDoc} */
public void fillPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) {
  final int[] ptArray = new int[2 * nPoints];
  for (int i = 0; i < nPoints; i++) {
    TEMP_POINT.setLocation(xPoints[i], yPoints[i]);
    transform.transform(TEMP_POINT, TEMP_POINT);
    ptArray[2 * i] = xPoints[i];
    ptArray[2 * i + 1] = yPoints[i];
  }
  gc.fillPolygon(ptArray);
}

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

/**
 * Fill a polyline from the specified double array of points.
 *
 * @param pts double array of points
 */
public void fillPolygon(final double[] pts) {
  final int[] intPts = SWTShapeManager.transform(pts, transform);
  gc.fillPolygon(intPts);
}

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

void fillPolygon(Point... points) {
 gc.get().fillPolygon(toCoordinates(points));
}

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

void fillRect(Point corner, double radius) {
 final int x1 = vp.get().toCoordX(corner.x - radius);
 final int y1 = vp.get().toCoordY(corner.y - radius);
 final int x2 = vp.get().toCoordX(corner.x + radius);
 final int y2 = vp.get().toCoordY(corner.y + radius);
 gc.get().fillPolygon(new int[] {x1, y1, x2, y1, x2, y2, x1, y2});
}

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

void fillRect(Point corner1, Point corner2) {
 final int x1 = vp.get().toCoordX(corner1.x);
 final int y1 = vp.get().toCoordY(corner1.y);
 final int x2 = vp.get().toCoordX(corner2.x);
 final int y2 = vp.get().toCoordY(corner2.y);
 gc.get().fillPolygon(new int[] {x1, y1, x2, y1, x2, y2, x1, y2});
}

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

/**
 * Fills the specified polygon.
 *
 * @param xPoints  the x-coordinates.
 * @param yPoints  the y-coordinates.
 * @param npoints  the number of points.
 */
@Override
public void fillPolygon(int[] xPoints, int[] yPoints, int npoints) {
  int[] pointArray = new int[npoints * 2];
  for (int i = 0; i < npoints; i++) {
    pointArray[2 * i] = xPoints[i];
    pointArray[2 * i + 1] = yPoints[i];
  }
  switchColors();
  this.gc.fillPolygon(pointArray);
  switchColors();
}

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

@Override
  public void paintControl(PaintEvent e) {
    /*
     * The graphic is drawn to the left of the titleLabel so define the offset from the titleLabel
     */
    int offsetX = titleLabel.getBounds().x - 10;
    int offsetY = titleLabel.getBounds().y + 3;
    if (null != twistieColor) {
      e.gc.setBackground(twistieColor);
    } else {
      e.gc.setBackground(getForeground());
    }
    if (isCollapsed) {
      e.gc.fillPolygon(translate(points_for_collapsed, offsetX, offsetY));
    } else {
      e.gc.fillPolygon(translate(points_for_expanded, offsetX, offsetY));
    }
  }
});

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

private void drawCutout(GC gc, int x, int y, int radius, CirclePart side) {
  int centerX = x + (side.isLeft() ? radius : -radius);
  int centerY = y + (side.isTop() ? radius : -radius);
  int[] circle = drawCircle(centerX, centerY, radius, side);
  int[] result = new int[circle.length + 2];
  result[0] = x;
  result[1] = y;
  int count = circle.length / 2;
  for (int idx = 0; idx < count; idx++) {
    int destIdx = idx * 2 + 2;
    int srcIdx = (count - 1 - idx) * 2;
    result[destIdx] = circle[srcIdx];
    result[destIdx + 1] = circle[srcIdx + 1];
  }
  gc.fillPolygon(result);
}

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

@Override
public void paint(GC gc, int width, int height) {
  int centerX = width / 2;
  int centerY = height / 2;
  int pos = 0;
  for (int i = 0; i < POINTS; ++i) {
    double r = Math.PI*2 * pos/POINTS;
    radial[i*2] = (int)((1+Math.cos(r))*centerX);
    radial[i*2+1] = (int)((1+Math.sin(r))*centerY);
    pos = (pos + POINTS/2) % POINTS;
  }
  gc.setFillRule(fillRuleCb.getSelectionIndex() != 0 ? SWT.FILL_WINDING : SWT.FILL_EVEN_ODD);
  gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_YELLOW));
  gc.fillPolygon(radial);
  gc.drawPolygon(radial);
}
}

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

private void paintBottom(GC gc) {
  int[] left = simple ? SIMPLE_TOP_LEFT_CORNER : TOP_LEFT_CORNER;
  int[] right = simple ? SIMPLE_TOP_RIGHT_CORNER : TOP_RIGHT_CORNER;
  int[] shape = new int[left.length + right.length + 4];
  int index = 0;
  Point size = container.getSize();
  int x = 0;
  int y = 0;
  index = fillShape(shape, left, index, x, y, false);
  x = size.x - 1;
  index = fillShape(shape, right, index, x, y, false);
  shape[index++] = size.x - 1;
  shape[index++] = size.y;
  shape[index++] = 0;
  shape[index++] = size.y;
  gc.fillPolygon(shape);
  gc.drawPolygon(shape);
}

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

private void paintLeft(GC gc) {
  int[] top = simple ? SIMPLE_TOP_RIGHT_CORNER : TOP_RIGHT_CORNER;
  int[] bot = simple ? SIMPLE_BOTTOM_RIGHT_CORNER : BOTTOM_RIGHT_CORNER;
  int[] shape = new int[top.length + bot.length + 4];
  int index = 0;
  Point size = container.getSize();
  int x = size.x - 1;
  int y = 0;
  index = fillShape(shape, top, index, x, y, false);
  y = size.y - 1;
  index = fillShape(shape, bot, index, x, y, true);
  shape[index++] = -1;
  shape[index++] = size.y - 1;
  shape[index++] = -1;
  shape[index++] = 0;
  gc.fillPolygon(shape);
  gc.drawPolygon(shape);
}

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

@Override
  public void paintControl(PaintEvent e) {
    Control c = (Control) e.widget;
    Point size = c.getSize();
    int arrowSize = 8;
    int xStart = size.x - arrowSize;
    int yStart = size.y - (size.y + arrowSize) / 2;
    e.gc.setBackground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_FOREGROUND));
    e.gc.setAntialias(SWT.ON);
    e.gc.fillPolygon(new int[] {
      xStart,
      yStart,
      xStart + arrowSize,
      yStart + (arrowSize / 2),
      xStart,
      yStart + arrowSize,
    });
  }
};

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

private static void drawViewMenu(GC gc, GC maskgc) {
  Display display = Display.getCurrent();
  gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
  gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
  int[] shapeArray = new int[] {1, 1, 10, 1, 6, 5, 5, 5};
  gc.fillPolygon(shapeArray);
  gc.drawPolygon(shapeArray);
  Color black = display.getSystemColor(SWT.COLOR_BLACK);
  Color white = display.getSystemColor(SWT.COLOR_WHITE);
  maskgc.setBackground(black);
  maskgc.fillRectangle(0,0,12,16);
  maskgc.setBackground(white);
  maskgc.setForeground(white);
  maskgc.fillPolygon(shapeArray);
  maskgc.drawPolygon(shapeArray);
}

相关文章

GC类方法