java.awt.Graphics2D#fillOval ( )源码实例Demo

下面列出了java.awt.Graphics2D#fillOval ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jeveassets   文件: TrackerTab.java
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
	Graphics2D g2d = (Graphics2D) g;
	//Render settings
	//g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
	g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	//Border
	g2d.setColor(Color.BLACK);
	g2d.fillOval(x + 2, y + 2, getIconWidth() - 4, getIconHeight() - 4);

	//Background
	g2d.setColor(color);
	g2d.fillOval(x + 3, y + 3, getIconWidth() - 6, getIconHeight() - 6);
}
 
源代码2 项目: settlers-remake   文件: ClearIcon.java
@Override
public void paintIcon(Component c, Graphics g1, int x, int y) {
	Graphics2D g = (Graphics2D) g1;
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

	Stroke oldStroke = g.getStroke();

	g.setColor(hover ? Color.GRAY : Color.LIGHT_GRAY);
	g.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
	g.fillOval(x + 2, y + 2, 18, 18);
	g.setColor(Color.WHITE);
	g.drawLine(x + 6, y + 6, x + 15, y + 15);
	g.drawLine(x + 15, y + 6, x + 6, y + 15);

	g.setStroke(oldStroke);
}
 
源代码3 项目: openjdk-8-source   文件: TSFrame.java
private static void render(Graphics g, int w, int h, boolean useNonOpaque) {
    if (useNonOpaque) {
        Graphics2D g2d = (Graphics2D)g;
        GradientPaint p =
            new GradientPaint(0.0f, 0.0f,
                              new Color(rnd.nextInt(0xffffff)),
                              w, h,
                              new Color(rnd.nextInt(0xff),
                                        rnd.nextInt(0xff),
                                        rnd.nextInt(0xff), 0),
                              true);
        g2d.setPaint(p);
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.fillOval(0, 0, w, h);
    } else {
        g.setColor(new Color(rnd.nextInt(0xffffff)));
        g.fillRect(0, 0, w, h);
    }
}
 
源代码4 项目: plugins   文件: AntiDragOverlay.java
@Override
public Dimension render(Graphics2D g)
{
	g.setColor(color);

	final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition();
	final Point mousePosition = new Point(mouseCanvasPosition.getX() - RADIUS, mouseCanvasPosition.getY() - RADIUS);
	final Rectangle bounds = new Rectangle(mousePosition.x, mousePosition.y, 2 * RADIUS, 2 * RADIUS);
	g.fillOval(bounds.x, bounds.y, bounds.width, bounds.height);

	return bounds.getSize();
}
 
源代码5 项目: visualvm   文件: XYSelectionOverlay.java
public void paint(Graphics g) {
    if (selectedValues.isEmpty()) return;

    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHints(chart.getRenderingHints());

    Iterator<Point> it = selectedValues.iterator();
    boolean linePainted = false;

    while (it.hasNext()) {
        Point p = it.next();

        if (!linePainted) {
            g2.setPaint(evenPerfPaint);
            g2.setStroke(evenPerfStroke);
            g2.drawLine(p.x, 0, p.x, getHeight());
            g2.setPaint(oddPerfPaint);
            g2.setStroke(oddPerfStroke);
            g2.drawLine(p.x, 0, p.x, getHeight());

            g2.setPaint(markPaint);
            g2.setStroke(markStroke);

            linePainted = true;
        }

        g2.fillOval(p.x - selectionExtent + 1, p.y - selectionExtent + 1,
                    selectionExtent * 2 - 1, selectionExtent * 2 - 1);
    }

}
 
源代码6 项目: openjdk-jdk9   文件: PopupMenuLeakTest.java
private static Image createTrayIconImage() {
    /**
     * Create a small image of a red circle to use as the icon for the tray icon
     */
    int trayIconImageSize = 32;
    final BufferedImage trayImage = new BufferedImage(trayIconImageSize, trayIconImageSize, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D trayImageGraphics = (Graphics2D) trayImage.getGraphics();

    trayImageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    trayImageGraphics.setColor(new Color(255, 255, 255, 0));
    trayImageGraphics.fillRect(0, 0, trayImage.getWidth(), trayImage.getHeight());

    trayImageGraphics.setColor(Color.red);

    int trayIconImageInset = 4;
    trayImageGraphics.fillOval(trayIconImageInset,
            trayIconImageInset,
            trayImage.getWidth() - 2 * trayIconImageInset,
            trayImage.getHeight() - 2 * trayIconImageInset);

    trayImageGraphics.setColor(Color.darkGray);

    trayImageGraphics.drawOval(trayIconImageInset,
            trayIconImageInset,
            trayImage.getWidth() - 2 * trayIconImageInset,
            trayImage.getHeight() - 2 * trayIconImageInset);

    return trayImage;
}
 
源代码7 项目: openjdk-jdk9   文件: BMPPluginTest.java
private static BufferedImage createTestImage(int type) throws IOException {

        int w = 200;
        int h = 200;
        BufferedImage b = new BufferedImage(w, h, type);
        Graphics2D g = b.createGraphics();
        g.setColor(Color.white);
        g.fillRect(0,0, w, h);
        g.setColor(Color.black);
        g.fillOval(10, 10, w -20, h-20);

        return b;
    }
 
源代码8 项目: SPIM_Registration   文件: InterestPointOverlay.java
@Override
public void drawOverlays( final Graphics g )
{
	final Graphics2D graphics = ( Graphics2D ) g;
	final int t = viewer.getState().getCurrentTimepoint();
	final double[] lPos = new double[ 3 ];
	final double[] gPos = new double[ 3 ];
	final AffineTransform3D transform = new AffineTransform3D();

	for ( final InterestPointSource pointSource : interestPointSources )
	{
		pointSource.getLocalToGlobalTransform( t, transform );
		transform.preConcatenate( viewerTransform );

		for ( final RealLocalizable p : pointSource.getLocalCoordinates( t ) )
		{
			p.localize( lPos );
			transform.apply( lPos, gPos );
			final double size = getPointSize( gPos );
			final int x = ( int ) ( gPos[ 0 ] - 0.5 * size );
			final int y = ( int ) ( gPos[ 1 ] - 0.5 * size );
			final int w = ( int ) size;
			graphics.setColor( getColor( gPos ) );
			graphics.fillOval( x, y, w, w );
		}
	}
}
 
源代码9 项目: openjdk-jdk9   文件: BMPCompressionTest.java
private static BufferedImage createTestImage(int type)
  throws IOException {

    int w = 200;
    int h = 200;
    BufferedImage b = new BufferedImage(w, h, type);
    Graphics2D g = b.createGraphics();
    g.setColor(Color.white);
    g.fillRect(0,0, w, h);
    g.setColor(Color.black);
    g.fillOval(10, 10, w -20, h-20);

    return b;
}
 
源代码10 项目: settlers-remake   文件: ShapeIcon.java
@Override
protected void paint(Component c, Graphics2D g, int x, int y) {
	g.fillOval(x + 1, y + 1, 5, 5);
	g.fillOval(x + 2, y + 4, 5, 5);
	g.fillOval(x + 5, y + 7, 5, 5);
	g.fillOval(x + 3, y + 2, 5, 5);
	g.fillOval(x + 10, y + 7, 5, 5);
}
 
源代码11 项目: TencentKona-8   文件: RangeSlider.java
private void paintBar(Graphics2D g) {
    List<String> list = getPaintingModel().getPositions();
    int barStartY = getBarStartY();

    g.setColor(BAR_COLOR);
    g.fillRect(getXPosition(0), barStartY + BAR_HEIGHT / 2 - BAR_THICKNESS / 2, getXPosition(list.size() - 1) - getXPosition(0), BAR_THICKNESS);

    int circleCenterY = barStartY + BAR_HEIGHT / 2;
    for (int i = 0; i < list.size(); i++) {
        int curX = getXPosition(i);
        g.setColor(getPaintingModel().getColors().get(i));
        g.fillOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE);
        g.setColor(Color.black);
        g.drawOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE);


        String curS = list.get(i);
        if (curS != null && curS.length() > 0) {
            int startX = getStartXPosition(i);
            int endX = getEndXPosition(i);
            FontMetrics metrics = g.getFontMetrics();
            Rectangle bounds = metrics.getStringBounds(curS, g).getBounds();
            if (bounds.width < endX - startX && bounds.height < barStartY) {
                g.setColor(Color.black);
                g.drawString(curS, startX + (endX - startX) / 2 - bounds.width / 2, barStartY / 2 + bounds.height / 2);
            }
        }
    }

}
 
源代码12 项目: mtcnn-java   文件: MtcnnUtil.java
public static BufferedImage drawFaceAnnotations(BufferedImage originalImage, FaceAnnotation[] faceAnnotations) {

		Graphics2D g = originalImage.createGraphics();
		g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

		Stroke stroke = g.getStroke();
		Color color = g.getColor();
		g.setStroke(new BasicStroke(3));
		g.setColor(Color.YELLOW);

		int radius = 2;
		for (FaceAnnotation faceAnnotation : faceAnnotations) {
			FaceAnnotation.BoundingBox bbox = faceAnnotation.getBoundingBox();
			g.drawRect(bbox.getX(), bbox.getY(), bbox.getW(), bbox.getH());
			for (FaceAnnotation.Landmark lm : faceAnnotation.getLandmarks()) {
				g.fillOval(lm.getPosition().getX() - radius, lm.getPosition().getY() - radius,
						2 * radius, 2 * radius);
			}
		}

		g.setStroke(stroke);
		g.setColor(color);

		g.dispose();

		return originalImage;
	}
 
源代码13 项目: jeveassets   文件: JTagsDialog.java
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
	Graphics2D g2d = (Graphics2D) g;
	if (image != null) { //Selected
		//Render settings
		//g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
		g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

		//Border
		g2d.setColor(Color.BLACK);
		g2d.fillOval(x, y, getIconWidth() - 1, getIconHeight() - 1);

		//Background
		g2d.setColor(tagColor.getBackground());
		g2d.fillOval(x + 1, y + 1, getIconWidth() - 3, getIconHeight() - 3);

		//Image
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
		g.drawImage(image, x + 2, y + 2, null);
	} else { //Not selected
		//Render settings
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

		//Background
		g2d.setColor(tagColor.getBackground());
		g2d.fillRect(x, y, getIconWidth() - 1, getIconHeight() - 1);

		//Border
		g2d.setColor(Color.BLACK);
		g2d.drawRect(x, y, getIconWidth() - 1, getIconHeight() - 1);

		//Text
		g2d.setFont(new JLabel().getFont());
		g2d.setColor(tagColor.getForeground());
		g2d.drawString("a", x + 5, y + 11);
	}
}
 
源代码14 项目: openjdk-8-source   文件: RangeSlider.java
private void paintBar(Graphics2D g) {
    List<String> list = getPaintingModel().getPositions();
    int barStartY = getBarStartY();

    g.setColor(BAR_COLOR);
    g.fillRect(getXPosition(0), barStartY + BAR_HEIGHT / 2 - BAR_THICKNESS / 2, getXPosition(list.size() - 1) - getXPosition(0), BAR_THICKNESS);

    int circleCenterY = barStartY + BAR_HEIGHT / 2;
    for (int i = 0; i < list.size(); i++) {
        int curX = getXPosition(i);
        g.setColor(getPaintingModel().getColors().get(i));
        g.fillOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE);
        g.setColor(Color.black);
        g.drawOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE);


        String curS = list.get(i);
        if (curS != null && curS.length() > 0) {
            int startX = getStartXPosition(i);
            int endX = getEndXPosition(i);
            FontMetrics metrics = g.getFontMetrics();
            Rectangle bounds = metrics.getStringBounds(curS, g).getBounds();
            if (bounds.width < endX - startX && bounds.height < barStartY) {
                g.setColor(Color.black);
                g.drawString(curS, startX + (endX - startX) / 2 - bounds.width / 2, barStartY / 2 + bounds.height / 2);
            }
        }
    }

}
 
源代码15 项目: openjdk-jdk8u   文件: RangeSlider.java
private void paintBar(Graphics2D g) {
    List<String> list = getPaintingModel().getPositions();
    int barStartY = getBarStartY();

    g.setColor(BAR_COLOR);
    g.fillRect(getXPosition(0), barStartY + BAR_HEIGHT / 2 - BAR_THICKNESS / 2, getXPosition(list.size() - 1) - getXPosition(0), BAR_THICKNESS);

    int circleCenterY = barStartY + BAR_HEIGHT / 2;
    for (int i = 0; i < list.size(); i++) {
        int curX = getXPosition(i);
        g.setColor(getPaintingModel().getColors().get(i));
        g.fillOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE);
        g.setColor(Color.black);
        g.drawOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE);


        String curS = list.get(i);
        if (curS != null && curS.length() > 0) {
            int startX = getStartXPosition(i);
            int endX = getEndXPosition(i);
            FontMetrics metrics = g.getFontMetrics();
            Rectangle bounds = metrics.getStringBounds(curS, g).getBounds();
            if (bounds.width < endX - startX && bounds.height < barStartY) {
                g.setColor(Color.black);
                g.drawString(curS, startX + (endX - startX) / 2 - bounds.width / 2, barStartY / 2 + bounds.height / 2);
            }
        }
    }

}
 
源代码16 项目: lizzie   文件: CountResults.java
public void paint(Graphics g) {
  Graphics2D g2 = (Graphics2D) g;
  Image image = Lizzie.config.theme.background();
  try {
    image = ImageIO.read(getClass().getResourceAsStream("/assets/countbackground.jpg"));
  } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
  }
  int withtimes = (340 / image.getWidth(getOwner())) + 1;
  int highttimes = (260 / image.getHeight(getOwner())) + 1;

  for (int i = 0; i < highttimes; i++) {
    for (int j = 0; j < withtimes; j++) {
      g2.drawImage(image, image.getWidth(getOwner()) * j, image.getHeight(getOwner()) * i, null);
    }
  }
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setColor(Color.BLACK);
  g2.setStroke(new BasicStroke(2f));
  g2.fillOval(30, 58, 20, 20);
  g2.setColor(Color.WHITE);
  g2.fillOval(170, 58, 20, 20);
  g2.setColor(Color.BLACK);
  g2.setFont(new Font(Lizzie.config.uiFontName, Font.BOLD, 25));
  if (allBlackCounts >= allWhiteCounts) {
    g2.setColor(Color.BLACK);
    g2.drawString(resourceBundle.getString("CountDialog.bigBlack"), 25, 50);
  } else {
    g2.setColor(Color.WHITE);
    g2.drawString(resourceBundle.getString("CountDialog.bigWhite"), 25, 50);
  }
  g2.setFont(new Font(Lizzie.config.uiFontName, Font.BOLD, 20));
  g2.drawString(
      resourceBundle.getString("CountDialog.onBoardLead")
          + Math.abs(allBlackCounts - allWhiteCounts)
          + resourceBundle.getString("CountDialog.points"),
      53,
      50);
  g2.setColor(Color.BLACK);
  g2.setFont(new Font(Lizzie.config.uiFontName, Font.BOLD, 17));
  g2.drawString(resourceBundle.getString("CountDialog.areaCount"), 95, 100);
  g2.drawString(resourceBundle.getString("CountDialog.eat"), 95, 130);
  g2.drawString(allBlackCounts + "", 32, 100);
  g2.drawString(blackEat + "", 32, 130);
  g2.setColor(Color.WHITE);
  g2.drawString(allWhiteCounts + "", 172, 100);
  g2.drawString(whiteEat + "", 172, 130);
  button.repaint();
  button2.repaint();
}
 
源代码17 项目: JavaExercises   文件: Cell.java
public void paint(Graphics2D g) {           // object rendering
    g.setColor(color);
    g.fillOval(x * size, y * size,        // upper left corner
            size, size);                  // width and height
}
 
源代码18 项目: FlatLaf   文件: FlatRadioButtonIcon.java
@Override
protected void paintBorder( Graphics2D g2 ) {
	g2.fillOval( 0, 0, 15, 15 );
}
 
源代码19 项目: settlers-remake   文件: ShapeIcon.java
@Override
protected void paint(Component c, Graphics2D g, int x, int y) {
	g.fillOval(x + 1, y + 1, 14, 14);
}
 
源代码20 项目: settlers-remake   文件: ShapeIcon.java
@Override
protected void paint(Component c, Graphics2D g, int x, int y) {
	g.fillOval(x + 5, y + 5, 6, 6);
}