package awt;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;

import javax.swing.JFrame;
import javax.swing.JPanel;


public class Donut extends JPanel {
	private static final long serialVersionUID = -1153356523283201001L;


	public void paint(Graphics g) {

        super.paint(g);

        Graphics2D g2 = (Graphics2D)g;

        RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

        rh.put(RenderingHints.KEY_RENDERING,
               RenderingHints.VALUE_RENDER_QUALITY);

        g2.setRenderingHints(rh);

        Dimension size = getSize();
        double w = size.getWidth();
        double h = size.getHeight();

        Ellipse2D e = new Ellipse2D.Double(0, 0, 80, 130);
        g2.setStroke(new BasicStroke(1));
        g2.setColor(Color.gray);

        AffineTransform at =
                AffineTransform.getTranslateInstance(w / 2, h / 2);
        for (double deg = 0; deg < 360; deg += 5) {
            at =  AffineTransform.getTranslateInstance(w / 2, h / 2);
            at.rotate(Math.toRadians(deg));
            g2.draw(at.createTransformedShape(e));
        }
        

        Ellipse2D p = new Ellipse2D.Double(0, 0, 1, 1);
        p.setFrame(200, 200, 1, 1);
        g2.draw(at.createTransformedShape(p));
    }


    public static void main(String[] args) {

        JFrame frame = new JFrame("Donut");
        frame.add(new Donut());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(370, 320);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}
