package com.ethon;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;

import com.ethon.ui.DataField;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		DataField df=new DataField();
		df.setVisible(true);
		
//		BufferedReader reader=new BufferedReader(new FileReader(new File("C:\\Users\\ethon\\Desktop\\Dataset\\t8.8k.dat")));
//		BufferedWriter writer=new BufferedWriter(new FileWriter(new File("C:\\Users\\ethon\\Desktop\\Dataset\\data_t8.8k.txt")));
//		
//		String str=reader.readLine();
//		while(str!=null){
//			str=str.trim();
//			String[] re = str.split(" ");
//			if(re.length<2){
//				str=reader.readLine();
//				continue;
//			}
//			writer.write(re[0]+","+re[1]+",1");
//			writer.newLine();
//			str=reader.readLine();
//		}
//		reader.close();
//		writer.flush();
//		writer.close();
		
			
//		Main m=new Main();
//				
//		BufferedWriter writer=new BufferedWriter(new FileWriter(new File("C:\\Users\\Alex\\Desktop\\data3.txt")));
//		ArrayList<String> list=new ArrayList<String>();
		
//		for(int i=0;i<300;i++){
//			double x=m.randomNum(300, 80);
//			double y=m.randomNum(300, 80);
//			
//			double t=(x-300)*(x-300)+(y-300)*(y-300);
//			if(t>10000&&t<40000){
//				String str=m.toStr(x)+","+m.toStr(y);
//				if(list.contains(str)){
//					i--;
//					continue;
//				}
//						
//				writer.write(str+",1");
//				
//				writer.newLine();
//			}
//			
//			
//		}
		
//		double sigma2=100;
//		for(double x=0;x<50;x+=0.1){
//			double y=Math.pow(Math.E, -x*x/sigma2);
//			writer.write(Double.toString(x)+"\t"+Double.toString(y));
//			writer.newLine();
//		}
//		
//		writer.flush();
//		
//		writer.close();	
	}
	
	class Point{
		public double x;
		public double y;
		
		Point(double x, double y){
			this.x=x;
			this.y=y;
		}
	}
	
	Point toPoint(String str){
		String[] array=str.split(",");
		double x=Double.parseDouble(array[0]);
		double y=Double.parseDouble(array[1]);
		
		return new Point(x,y);
	}
	
	double randomNum(double mean, double sigma){
		double r1=Math.random();
		double r2=Math.random();
		return mean+Math.sqrt(-2*Math.log(r1))*Math.cos(2*Math.PI*r2)*Math.abs(sigma);
	}
	
	String toStr(double r){
		String str=Double.toString(r);
		
		if(str.contains("."))	return str.substring(0, str.indexOf(".")+3>str.length()?str.length():str.indexOf(".")+3);
		else return str;
	}
}