Here you can find the source of makeCircle(double xCenter, double yCenter, double r, int nPoints)
static public GeneralPath makeCircle(double xCenter, double yCenter, double r, int nPoints)
//package com.java2s; //License from project: Apache License import java.awt.geom.*; public class Main { static public GeneralPath makeCircle(double xCenter, double yCenter, double r, int nPoints) { if (nPoints < 4) throw new RuntimeException("too few points. n=" + nPoints); GeneralPath gp = new GeneralPath(); for (int i = 0; i < nPoints; i++) { double angle = i / (double) nPoints * Math.PI * 2; double x = r * Math.cos(angle) + xCenter; double y = r * Math.sin(angle) + yCenter; if (i == 0) gp.moveTo(x, y);/*from w w w . jav a2 s .c o m*/ else gp.lineTo(x, y); } gp.closePath(); return gp; } }