Here you can find the source of drawCircle(Graphics g, int x, int y, int diameter)
(x,y)
, having the given diameter.
Parameter | Description |
---|---|
g | the graphics context to draw in |
x | the x coordinate for the center of the circle |
y | the y coordinate for the center of the circle |
diameter | the diameter of the circle |
public static void drawCircle(Graphics g, int x, int y, int diameter)
//package com.java2s; /* Copyright (C) 2015, University of Kansas Center for Research * //w ww .j a va 2 s. c o m * Specify Software Project, specify@ku.edu, Biodiversity Institute, * 1345 Jayhawk Boulevard, Lawrence, Kansas, 66045, USA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; public class Main { /** <code>RenderingHints</code> used to turn on anti-aliased drawing. */ protected static RenderingHints hints; /** * Draws a circle using the given graphics context, centered at <code>(x,y)</code>, * having the given diameter. * * @see #fillCircle(Graphics, int, int, int) * @param g the graphics context to draw in * @param x the x coordinate for the center of the circle * @param y the y coordinate for the center of the circle * @param diameter the diameter of the circle */ public static void drawCircle(Graphics g, int x, int y, int diameter) { ((Graphics2D) g).addRenderingHints(hints); g.drawOval(x - diameter / 2, y - diameter / 2, diameter, diameter); } }