int size = Math.min(w, h);
float ew = size/4;
float eh = size-20;
Ellipse2D ellipse = new Ellipse2D.Float(-ew/2, -eh/2, ew, eh);
for (double angdeg = 0; angdeg < 360; angdeg+=increment) {
if (angdeg % emphasis == 0) {
g2.setColor(Color.gray);
g2.setStroke(new BasicStroke(2.0f));
} else {
g2.setColor(Color.lightGray);
g2.setStroke(new BasicStroke(0.5f));
}
AffineTransform at = AffineTransform.getTranslateInstance(w/2, h/2);
at.rotate(Math.toRadians(angdeg));
g2.draw(at.createTransformedShape(ellipse));
}
g2.setColor(Color.blue);
ellipse.setFrame(w/2-10,h/2-10,20,20);
g2.fill(ellipse);
g2.setColor(Color.gray);
g2.setStroke(new BasicStroke(6));
g2.draw(ellipse);
g2.setColor(Color.yellow);
g2.setStroke(new BasicStroke(4));
g2.draw(ellipse);
g2.setColor(Color.black);
g2.drawString("Rotate", 5, 15);