java.awt.Graphics2D.drawPolygon()方法的使用及代码示例

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

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

Graphics2D.drawPolygon介绍

暂无

代码示例

代码示例来源:origin: runelite/runelite

public static void renderPolygon(Graphics2D graphics, Polygon poly, Color color)
{
  graphics.setColor(color);
  final Stroke originalStroke = graphics.getStroke();
  graphics.setStroke(new BasicStroke(2));
  graphics.drawPolygon(poly);
  graphics.setColor(new Color(0, 0, 0, 50));
  graphics.fillPolygon(poly);
  graphics.setStroke(originalStroke);
}

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

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

代码示例来源:origin: runelite/runelite

private void renderLocalPoint(Graphics2D graphics, LocalPoint local)
{
  if (local != null)
  {
    Polygon canvasTilePoly = Perspective.getCanvasTilePoly(client, local);
    if (canvasTilePoly != null)
    {
      graphics.drawPolygon(canvasTilePoly);
    }
  }
}

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

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

代码示例来源:origin: runelite/runelite

private void renderPlayerWireframe(Graphics2D graphics, Player player, Color color)
{
  Polygon[] polys = player.getPolygons();
  if (polys == null)
  {
    return;
  }
  graphics.setColor(color);
  for (Polygon p : polys)
  {
    graphics.drawPolygon(p);
  }
}

代码示例来源:origin: libgdx/libgdx

g.setColor(Color.black);
g.drawPolygon(xPoints, yPoints, 3);

代码示例来源:origin: libgdx/libgdx

g.setColor(Color.black);
g.drawPolygon(xPoints, yPoints, 3);

代码示例来源:origin: libgdx/libgdx

g.setColor(Color.black);
g.drawPolygon(xPoints, yPoints, 3);

代码示例来源:origin: libgdx/libgdx

g.setColor(Color.black);
g.drawPolygon(xPoints, yPoints, 3);

代码示例来源:origin: marytts/marytts

protected void drawDot(Graphics2D g, int x, int y, int currentDotStyle) {
  switch (currentDotStyle) {
  case DOT_FULLCIRCLE:
    g.fillOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_FULLSQUARE:
    g.fillRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_FULLDIAMOND:
    g.fillPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y,
        y + dotSize / 2 }, 4);
    break;
  case DOT_EMPTYCIRCLE:
    g.drawOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_EMPTYSQUARE:
    g.drawRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_EMPTYDIAMOND:
    g.drawPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y,
        y + dotSize / 2 }, 4);
    break;
  default:
    break;
  }
}

代码示例来源:origin: marytts/marytts

protected void drawDot(Graphics2D g, int x, int y, int currentDotStyle) {
  switch (currentDotStyle) {
  case DOT_FULLCIRCLE:
    g.fillOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_FULLSQUARE:
    g.fillRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_FULLDIAMOND:
    g.fillPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y,
        y + dotSize / 2 }, 4);
    break;
  case DOT_EMPTYCIRCLE:
    g.drawOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_EMPTYSQUARE:
    g.drawRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize);
    break;
  case DOT_EMPTYDIAMOND:
    g.drawPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y,
        y + dotSize / 2 }, 4);
    break;
  default:
    break;
  }
}

代码示例来源:origin: jphp-group/jphp

@Signature
public void polygon(Environment env, ForeachIterator array, DrawOptions options) {
  List<Integer> xPoints = new ArrayList<>();
  List<Integer> yPoints = new ArrayList<>();
  while (array.next()) {
    Memory value = array.getValue();
    Integer x = null, y = null;
    ForeachIterator sub = value.getNewIterator(env);
    while (sub.next()) {
      if (x == null) {
        y = x = sub.getValue().toInteger();
      } else {
        y = sub.getValue().toInteger();
      }
    }
    if (x != null && y != null) {
      xPoints.add(x);
      yPoints.add(y);
    }
  }
  int[] xs = xPoints.stream().mapToInt(i -> i).toArray();
  int[] ys = yPoints.stream().mapToInt(i -> i).toArray();
  applyOptions(options);
  if (options.isOutline()) {
    gc.drawPolygon(xs, ys, Math.min(xs.length, ys.length));
  } else {
    gc.fillPolygon(xs, ys, Math.min(xs.length, ys.length));
  }
}

代码示例来源:origin: runelite/runelite

if (tile != null)
  graphics2D.drawPolygon(tile);

代码示例来源:origin: runelite/runelite

private void renderDecorObject(Graphics2D graphics, Tile tile, Player player)
{
  DecorativeObject decorObject = tile.getDecorativeObject();
  if (decorObject != null)
  {
    if (player.getLocalLocation().distanceTo(decorObject.getLocalLocation()) <= MAX_DISTANCE)
    {
      OverlayUtil.renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE);
    }
    Polygon p = decorObject.getConvexHull();
    if (p != null)
    {
      graphics.drawPolygon(p);
    }
  }
}

代码示例来源:origin: runelite/runelite

private void renderGameObjects(Graphics2D graphics, Tile tile, Player player)
{
  GameObject[] gameObjects = tile.getGameObjects();
  if (gameObjects != null)
  {
    for (GameObject gameObject : gameObjects)
    {
      if (gameObject != null)
      {
        if (player.getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= MAX_DISTANCE)
        {
          OverlayUtil.renderTileOverlay(graphics, gameObject, "ID: " + gameObject.getId(), GREEN);
        }
        // Draw a polygon around the convex hull
        // of the model vertices
        Polygon p = gameObject.getConvexHull();
        if (p != null)
        {
          graphics.drawPolygon(p);
        }
      }
    }
  }
}

代码示例来源:origin: runelite/runelite

graphics.drawPolygon(p);
graphics.drawPolygon(p);

代码示例来源:origin: apache/pdfbox

@Override
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
{
  groupG2D.drawPolygon(xPoints, yPoints, nPoints);
  alphaG2D.drawPolygon(xPoints, yPoints, nPoints);
}

代码示例来源:origin: geotools/geotools

public void drawPolygon(Polygon p) {
  delegate.drawPolygon(p);
}

代码示例来源:origin: geotools/geotools

public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
  delegate.drawPolygon(xPoints, yPoints, nPoints);
}

代码示例来源:origin: i2p/i2p.i2p

void fillPolygon(double[] x, double[] yBottom, double[] yTop, Paint paint) {
  gd.setPaint(paint);
  PathIterator path = new PathIterator(yTop);
  for (int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) {
    int start = pos[0], end = pos[1], n = end - start;
    int[] xDev = new int[n * 2], yDev = new int[n * 2];
    for (int i = start; i < end; i++) {
      int ix1 = i - start, ix2 = n * 2 - 1 - i + start;
      xDev[ix1] = xDev[ix2] = (int) x[i];
      yDev[ix1] = (int) yTop[i];
      yDev[ix2] = (int) yBottom[i];
    }
    gd.fillPolygon(xDev, yDev, xDev.length);
    gd.drawPolygon(xDev, yDev, xDev.length);
  }
}

相关文章

Graphics2D类方法