import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;

class genelModel extends AbstractTableModel
{
  Object[][] veri;
  String[] baslik;

  public genelModel(Object[][] verii,String[] basliki)
  {
    int n=veri.length;
    int m=veri[0].length;
    veri=new Object[n][m];
    baslik=new String[m];
    for(int j=0;j<m;j++)
    {for(int i=0;i<n;i++)
       {veri[i][j]=verii[i][j];}
       baslik[j]=basliki[i]
    }
  }
  
  public static doubletoDouble(double xi[][])
  {
  int n=veri.length;
  int m=veri[0].length;
  Double X[][]=new Double[n][m];
  for(int j=0;j<m;j++)
    {for(int i=0;i<n;i++)
       {X[i][j]=new Double(xi[i][j]);}	  
    }
    return X;
  }  
   
  public static double[][] verioku(String filename)
      {
        //veriyi oku bu metodun verisayısı sınırı yoktur
        //istediğimiz uzunluktaki veriyi okuyabilir
        Vector xi=new Vector(); 
        int nn;
        int m=2;
        int i=0;
        BufferedReader fin;
        try{
	    fin=new BufferedReader(new FileReader(filename));
	    try {
		try{ 
		try{            	    
	    String s1=Text.readStringLine(fin);        
        //System.out.println(s1);
	    StringTokenizer token=new StringTokenizer(s1);
        int n=token.countTokens()-1;
        m=n+1;        //m tokens boyutludeğişken kolon sayısı  
        while(token.hasMoreTokens())
        {
        String s2=token.nextToken();
        xi.add(s2);
        }
        i=0;              
        while(fin != null)
        {
        i++;
	    String s11=Text.readStringLine(fin);
	    //System.out.println(s11);        
        if(s11=="") break;
	    StringTokenizer token1=new StringTokenizer(s11);       
        while(token1.hasMoreTokens())
        {
        String s2=token1.nextToken();
        xi.add(s2);
        }
        }
        } catch(ArrayIndexOutOfBoundsException e_eof) { }
        } catch(StringIndexOutOfBoundsException e_eof) { }
        } catch(EOFException e_eof) {System.out.println("end of file"); }
        } catch(IOException e_io) {System.out.println("file name is not existed"); }      
        nn=i;
        //System.out.println("m="+m+"nn="+nn);
        double aa[][]=new double[m][nn];
        Enumeration nx=xi.elements();
        for(i=0;i<nn;i++)
        {
        for(int j=0;j<m;j++)
        {
	    String s1=(String)nx.nextElement();    
	    Double ax=new Double(s1);
        aa[j][i]=ax.doubleValue();  
        }
      } 
        return aa;
     }
     
     
  public int getRowCount() {return veri.length;}
  public int getColumnCount() {return baslik.length;}
  public Object getValueAt(int satir,int sutun) {return veri[satir][sutun];}
  public String getColumnName(int c) {return baslik[c];}
  public void setValueAt(Object val, int row, int col)
  {veri[row][col] = val;}
  public void setValues(String filename)
  {veri=doubletoDouble(verioku(filename));}
  public Object[][] getValues(){return veri;}
  public boolean isCellEditable(int row, int col) {return true;}
}


