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

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

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

Graphics2D.drawOval介绍

暂无

代码示例

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

@Override
  public void draw(ColorMapper colorMapper, Graphics2D g2d) {
    g2d.setColor(Color.BLACK);
    final int delta = diameterExternal - diameterInternal + 1;
    g2d.drawOval(0, 0, diameterExternal, diameterExternal);
    g2d.fillOval(delta / 2, delta / 2, diameterInternal, diameterInternal);
  }
}

代码示例来源:origin: looly/hutool

/**
 * 画随机干扰
 * 
 * @param g {@link Graphics2D}
 */
private void drawInterfere(Graphics2D g) {
  final ThreadLocalRandom random = RandomUtil.getRandom();
  for (int i = 0; i < this.interfereCount; i++) {
    g.setColor(ImageUtil.randomColor(random));
    g.drawOval(random.nextInt(width), random.nextInt(height), random.nextInt(height >> 1), random.nextInt(height >> 1));
  }
}
// ----------------------------------------------------------------------------------------------------- Private method end

代码示例来源:origin: looly/hutool

/**
 * 画随机干扰
 * 
 * @param g {@link Graphics2D}
 */
private void drawInterfere(Graphics2D g) {
  final ThreadLocalRandom random = RandomUtil.getRandom();
  for (int i = 0; i < this.interfereCount; i++) {
    g.setColor(ImageUtil.randomColor(random));
    g.drawOval(random.nextInt(width), random.nextInt(height), random.nextInt(height >> 1), random.nextInt(height >> 1));
  }
}
// ----------------------------------------------------------------------------------------------------- Private method end

代码示例来源:origin: MovingBlocks/Terasology

@Override
public void render(BufferedImage img, Region region) {
  TreeFacet treeFacet = region.getFacet(TreeFacet.class);
  Graphics2D g = img.createGraphics();
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  for (Entry<BaseVector3i, TreeGenerator> entry : treeFacet.getRelativeEntries().entrySet()) {
    TreeGenerator treeGen = entry.getValue();
    int wx = entry.getKey().getX();
    int wz = entry.getKey().getZ();
    int r = radiusFunc.apply(treeGen);
    Color color = colorFunc.apply(treeGen);
    // the fill area is offset by +1/+1 pixel
    // otherwise it will bleed out at the top left corner
    g.setColor(color);
    g.fillOval(wx - r + 1, wz - r + 1, r * 2 - 1, r * 2 - 1);
    g.setColor(color.darker());
    g.drawOval(wx - r, wz - r, r * 2, r * 2);
  }
  g.dispose();
}

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

@Signature
public void ellipse(int x, int y, int width, int height, DrawOptions options) {
  applyOptions(options);
  if (options.isOutline()) {
    gc.drawOval(x, y, width, height);
  } else {
    gc.fillOval(x, y, width, height);
  }
}

代码示例来源: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 circle(int x, int y, int radius, DrawOptions options) {
  applyOptions(options);
  if (options.isOutline()) {
    gc.drawOval(x, y, radius * 2, radius * 2);
  } else {
    gc.fillOval(x, y, radius * 2, radius * 2);
  }
}

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

r = 4 * m / 5;
int r2 = Math.abs(m - r) / 2;
g2d.drawOval(a - r, b - r, 2 * r, 2 * r);
g2d.setColor(Color.blue);
for (int i = 0; i < n; i++) {

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

/**
 * 画随机码图
 *
 * @param fontcolor 随机字体颜色
 * @param strs      字符数组
 * @param flag      透明度使用
 * @return BufferedImage
 */
private BufferedImage graphicsImage(Color[] fontcolor, char[] strs, int flag) {
  BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
  // 或得图形上下文
  Graphics2D g2d = (Graphics2D) image.getGraphics();
  // 利用指定颜色填充背景
  g2d.setColor(Color.WHITE);
  g2d.fillRect(0, 0, width, height);
  AlphaComposite ac3;
  int h = height - ((height - font.getSize()) >> 1);
  int w = width / len;
  g2d.setFont(font);
  for (int i = 0; i < len; i++) {
    ac3 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getAlpha(flag, i));
    g2d.setComposite(ac3);
    g2d.setColor(fontcolor[i]);
    g2d.drawOval(num(width), num(height), 5 + num(10), 5 + num(10));
    g2d.drawString(strs[i] + "", (width - (len - i) * w) + (w - font.getSize()) + 1, h - 4);
  }
  g2d.dispose();
  return image;
}

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

@Override
public Dimension render(Graphics2D graphics)
{
  //Construct the arc
  Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE);
  arc.setAngleStart(90);
  arc.setAngleExtent(progress * 360);
  arc.setFrame(position.getX() - diameter / 2, position.getY() - diameter / 2, diameter, diameter);
  //Draw the inside of the arc
  graphics.setColor(fill);
  graphics.fill(arc);
  //Draw the outlines of the arc
  graphics.setStroke(stroke);
  graphics.setColor(borderColor);
  graphics.drawOval(position.getX() - diameter / 2, position.getY() - diameter / 2, diameter, diameter);
  return new Dimension(diameter, diameter);
}

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

color = color(150, 250);
g.setColor(color);
g.drawOval(num(width), num(height), 5 + num(10), 5 + num(10));
color = null;

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

public BufferedImage createBufferedImage() {
  final BufferedImage im = new BufferedImage(widthCell * 15, heightCell * 15, BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2d = im.createGraphics();
  g2d.setColor(Color.WHITE);
  g2d.fillRect(0, 0, im.getWidth(), im.getHeight());
  g2d.setColor(Color.BLACK);
  for (ANode n : board.getNodes()) {
    final int x = board.getCol(n) * widthCell;
    final int y = n.getRow() * heightCell;
    g2d.drawString(n.getCode(), x + 5, y + heightCell / 2 - 5);
    g2d.drawOval(x, y, widthCell / 2, heightCell / 2);
  }
  for (ALink link : board.getLinks()) {
    final ANode n1 = link.getNode1();
    final ANode n2 = link.getNode2();
    final int x1 = 10 + board.getCol(n1) * widthCell;
    final int y1 = 10 + n1.getRow() * heightCell;
    final int x2 = 10 + board.getCol(n2) * widthCell;
    final int y2 = 10 + n2.getRow() * heightCell;
    g2d.drawLine(x1, y1, x2, y2);
  }
  return im;
}

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

g.fillOval(0, 0, 30, 30); //adds color to circle
g.setColor(Color.black);
g2.drawOval(0, 0, 30, 30); //draws circle

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

g2d.setColor(Color.red);
g2d.drawOval(lX, lY, MARKER_SIZE, MARKER_SIZE);

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

graphics.drawOval(
  point.getX() - totalWidth / 2 + currentPosX - bgPadding,
  point.getY() - icon.getHeight() / 2 - OVERLAY_ICON_DISTANCE - bgPadding,

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

graphics.drawOval(orbInnerX, orbInnerY, orbInnerSize, orbInnerSize);

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

@Override
public void drawOval(int x, int y, int width, int height)
{
  groupG2D.drawOval(x, y, width, height);
  alphaG2D.drawOval(x, y, width, height);
}

代码示例来源:origin: kiegroup/optaplanner

int circleX = x - (TIME_WINDOW_DIAMETER / 2);
int circleY = y + 5;
g.drawOval(circleX, circleY, TIME_WINDOW_DIAMETER, TIME_WINDOW_DIAMETER);
g.fillArc(circleX, circleY, TIME_WINDOW_DIAMETER, TIME_WINDOW_DIAMETER,
    90 - calculateTimeWindowDegree(timeWindowedCustomer.getReadyTime()),

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

@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
 Graphics2D g = getGraphics();
 Color s = cpool.getColor(color.x, color.y, color.z, 1f);
 saveState(g);
 transformGraphics(g, center);
 g.setStroke(stroke);
 g.scale(radius, radius);
 g.setColor(s);
 g.drawOval(-1, -1, 2, 2);
 restoreState(g);
}

相关文章

Graphics2D类方法