Here you can find the source of drawCircle(Graphics g, int centerX, int centerY, int diameter)
Parameter | Description |
---|---|
g | Graphics context |
centerX | X coordinate of circle center |
centerY | Y coordinate of circle center |
diameter | Circle diameter |
public static void drawCircle(Graphics g, int centerX, int centerY, int diameter)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.Point; public class Main { /**//from w w w .j av a 2 s . co m * Draws a circle with the specified diameter using the given point as center. * @param g Graphics context * @param center Circle center * @param diameter Circle diameter */ public static void drawCircle(Graphics g, Point center, int diameter) { drawCircle(g, (int) center.getX(), (int) center.getY(), diameter); } /** * Draws a circle with the specified diameter using the given point coordinates as center. * @param g Graphics context * @param centerX X coordinate of circle center * @param centerY Y coordinate of circle center * @param diameter Circle diameter */ public static void drawCircle(Graphics g, int centerX, int centerY, int diameter) { g.drawOval((int) (centerX - diameter / 2), (int) (centerY - diameter / 2), diameter, diameter); } }