/* Author: Amay Agrawal
 * Project: Bacteria Cloud
 * Mentor: Prof. Manish K Gupta
 */
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;

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

import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.*;

public class Circle extends JFrame 
{
	//int arr[] = {187,229,233,375,24,29,410,566,626,651,716,832,939,974,1359,1369,1425,1426,1446,1581,1664,1672,2002,2066,2117,2220,2227,2246,2296,2357,2473,2889,3366,3538,3611,3736,3846,4170,4286}; 
    //String arr1[] = {"ClaI","HindIII","EcoRV","NheI","BmtI","BamHI","SgrAI","SphI","EcoNI","SalI","PshAI","BpmI","EagI","NruI",
    		          //"BsmI","StyI","BsoBI","BmeT110I","MscI","Bpu10I","BspEI","BsaBI","BpmI","PvuII","PfoI","PflFI","BsaAI","BstZ17I","NdeI","BspQI","AflIII","AlwNI","AhdI","AseI","PstI","PvuI","ScaI","SspI","ZraI"};
	//int length = arr.length;
	static int count=0;
	static int counter=0;
	static int arr[];
	static String arr1[];
	 int counter100=0;
	int length = 0;
	static int plasmidlength=0;
	static String final1;
	static String finalstring;
	static int ghj=0;
	
	public void Circle1()
	{
		
		 this.getContentPane().setBackground(Color.black);
		setTitle("Bacteria Plasmid Storage System");
		setSize(1200,1200);
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
	}
	
	public Circle(int aab[],String aac[],int z,int y,String x,String w){
		arr = aab;
		arr1 = aac;
		counter = z;
		length = arr.length;
		plasmidlength=y;
		final1=x;
		finalstring=w;
	}
	@Override
	public void paint(Graphics gg)
	{
		if(ghj<=1){
        	ghj++;
        super.paint(gg);
        }
		//super.paint(gg);
		Graphics2D g = (Graphics2D) gg;
        g.setFont(new Font("Times new Roman",Font.PLAIN,25));
        g.setColor(Color.white);
        g.drawString("Restriction Enzymes & MCS", 480, 65);
        g.setFont(new Font("Dialog", Font.PLAIN, 12));
	/* Enable anti-aliasing and pure stroke */
	//g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	//g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
	for(int i=0;i<length;i++){
		if(i%2==0){
			//g.setBackground(Color.YELLOW);
			g.setColor(Color.CYAN);
			String check = Integer.toString(arr[i]);
			String check1 = arr1[i]+" ("+check+")";
			double z = arr[i];
			double x = 300*Math.cos(Math.toRadians((z/plasmidlength)*360));
			double y = 300*Math.sin(Math.toRadians((z/plasmidlength)*360));

			float a = (float) x;
			float b = (float) y;
			
			/* Construct a shape and draw it */
			Ellipse2D.Double shape = new Ellipse2D.Double(600+x, 400+y, 5, 5);
			g.draw(shape);
			g.fill(shape);
			g.drawString(check1,600+ a, 400+b);
		}
		else{
			//g.setBackground(Color.YELLOW);
			g.setColor(Color.yellow);
			String check = Integer.toString(arr[i]);
			String check1 = arr1[i]+" ("+check+")";
			double z = arr[i];
			double x = 300*Math.cos(Math.toRadians((z/plasmidlength)*360));
			double y = 300*Math.sin(Math.toRadians((z/plasmidlength)*360));
			
			float a = (float) x;
			float b = (float) y;

			/* Construct a shape and draw it */
			Ellipse2D.Double shape = new Ellipse2D.Double(600+x, 400+y, 5, 5);
			g.draw(shape);
			g.fill(shape);
			g.drawString(check1,600+ a, 400+b);
		}
	}
	if(counter100==0){
		this.revalidate();
	
	counter100++;
	}
	}

	public void amay()
	{
		
		//Circle t = new Circle();
        Circle1();
		Circle2 c1 = new Circle2(final1,finalstring);
		c1.amay();
		this.paint(null);

		
	}
}