//======================================================
// Termodinamik-nümerik analiz paketleri
// Plot (Çizim ) - Wet air simulasyon programı integrasyonu
// Dr. Turhan Coban
// EGE Üniversitesi Mühendislik Fakultesi, Makina Bölümü
// turhan.coban@ege.edu.tr
// =====================================================
/*
 * Bu proğram yaş hava için 
 */

import java.lang.Integer;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.Locale;
import java.text.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.table.*;
//import java.io.*;
//import Plot2D2;
//import PlotShapesSW;
//import BasicWindowMonitor;

public class psT extends JApplet implements ItemListener,ActionListener, MouseListener,MouseMotionListener
{
  Container contentPane;
  JPanel inputPanel;
  JPanel outputPanel;
  JPanel totalPanel;
  JLabel l1[]=new JLabel[5];           // Label prompt unit
  JLabel l2[]=new JLabel[5];           // Label prompt unit
  JTextField t1[]=new JTextField[4];
  JComboBox c1[]=new JComboBox[2];
  JTextArea output;
  JTable jt;
  yashavaModel wam;
  yashava wa;
  double aa[]=new double[14];  //controls wet air output variables
  public String unit;
  public String pair;
  public double v1;
  public double v2;
  public double P;
  protected StringTokenizer token;
  String s1[]={"SI","EN"};
  String s2[]={"tdb_w","tdb_twb","tdb_rh","tdb_tdew","tdb_pv","tdb_dos","tdb_h","tdb_s","w_rh","w_h"};
  Color bg;  
  double xx[];
  double yy[];
  int xn;
  String line="";
  //public double P;
  private String s="";
	f2 ff=new f2();
	boolean inAnApplet = true;
    final static String KONTROLPANEL = "Kontrol sayfası     ";
    final static String    PLOTPANEL = "Psikometrik diyagram";
    final static String   psikometri = "Yaş havanın özellikleri";
    public Plot2D2 jta;
    double xi1,yi1,xi2,yi2,xi,yi;
    JTable ajt,ajt2;          //table
    JTextArea textA;           //Text Area 
    JLabel altbar;           //writing area   
    JLabel promptXmin;       // Label prompt in Xmin field
    JLabel promptXmax;       // Label prompt in Xmax field
    JLabel promptYmin;       // Label prompt in Ymin field
    JLabel promptYmax;       // Label prompt in Ymax field
    JLabel promptLabel;      // Label prompt Plot Label
    JLabel promptXLabel;     // Label prompt Plot XLabel
    JLabel promptYLabel;     // Label prompt Plot YLabel
    JLabel promptXntic;      // Label prompt in Xmin field
    JLabel promptYntic;      // Label prompt in Xmax field
    JLabel promptXgridon;    // Label prompt in Ymin field
    JLabel promptYgridon;    // Label prompt in Ymax field
    JTextField inputXmin;    // input field Xmin
    JTextField inputXmax;    // input field Xmax
    JTextField inputYmin;    // input field Ymin
    JTextField inputYmax;    // input field Ymax
    JTextField inputLabel;   // input field Label
    JTextField inputXLabel;  // input field XLabel
    JTextField inputYLabel;  // input field YLabel
    JTextField inputXntic;   // input field xntic
    JTextField inputYntic;   // input field yntic
    JCheckBox inputXgridon;  // input field xgridon
    JCheckBox inputYgridon;  // input field ygridon
    JButton printButton; 

    public void setP(double ppi)
    {
    P=ppi;
	}
	
    public double getP(double ppi)
    {
    return P;
	}
	
    public double readP()
    {
	// pressure input from screen    
    // not that you can change pressure value inside program but you can draw 
    // psychrometric diagram only once for the pressure set up by this method
    String s;
    s=JOptionPane.showInputDialog("Basınç değerini bar cinsinden giriniz (1 atm = 1.01325 bar)");
    double pi=Double.parseDouble(s);     
    if(pi<=0 ) pi=1.01325;
    P=pi;
    return pi;
    }
   
   public void setArea()
   {
    String s="";
    s+="TÜRKOĞLU MAKİNA SAN. VE TİC. LTD. ŞTİ.\n";
	s+="Atatürk Organize Sanayi Bölgesi 10027 Sokak NO:5 (35620)\n";
	s+="Tel : 0(232)376 80 07 - 0 (232) 80 08 Faks: (232) 376 80 09\n";
	s+="e-mail : yto@yto-tr.com  www : yto-tr.com\n";  
    s+="Program : Dr. Turhan Çoban, \n";
    s+="Ege Üniversitesi, Mühendislik Bilimleri Fak., Makina Bölümü\n";
    s+="e-posta : turhan.coban@ege.edu.tr\n";   

    output.setText(s);
    wam.setValues(unit,pair,v1,v2,P);
    output.setBackground(contentPane.getBackground());
   }
    public void init()
    {
	init1(readP());
	}
	
    public void init1(double pp1)
    {      
	//super(pi.label);
      double P1=pp1;
      yashava w=new yashava();
	  double aa[]=new double[14];  
      double bb[]=new double[14];  
	  f2 ff=new f2();
	  double x1[][]=new double[62][51];
	  double y1[][]=new double[62][51];
	  double A[][][]=new double[2][62][51];
	  A=psplot(P1);
	  for(int i=0;i<A[0].length;i++)
	   for(int j=0;j<A[0][0].length;j++)
	       {x1[i][j]=A[0][i][j];y1[i][j]=A[1][i][j];}
      Plot2 pi=new Plot2(x1,y1);
      String ss2="psikometrik diyagram "+P+" bar";
      pi.setPlabel(ss2);
      pi.setXlabel("T Kuru termometre sıcaklıgı derece C");
      pi.setYlabel("w mutlak nem kg nem/kg kuru hava");
      pi.setMinMax(0.0,50.0,0,0.05);
      pi.setXgrid(1);
      pi.setYgrid(1);
	  xx=new double[200];
      yy=new double[200];
      xn=0;
      String s="";
      s+="TÜRKOĞLU MAKİNA SAN. VE TİC. LTD. ŞTİ.\n";
	  s+="Atatürk Organize Sanayi Bölgesi 10027 Sokak NO:5 (35620)\n";
	  s+="Tel : 0(232)376 80 07 - 0 (232) 80 08 Faks: (232) 376 80 09\n";
	  s+="e-mail : yto@yto-tr.com  www : yto-tr.com\n"; 
      s+="Program : Dr. Turhan Çoban, \n";
      s+="Ege Üniversitesi, Mühendislik Bilimleri Fak., Makina Bölümü\n";
      s+="e-posta : turhan.coban@ege.edu.tr\n";   
      //note if you would like to list additional information on the screen
      //add to string s
      P=pp1;
      output=new JTextArea(s);    
      contentPane = getContentPane();
      output.setBackground(contentPane.getBackground());
      JTabbedPane tabbedPane = new JTabbedPane();
      bg=contentPane.getBackground();
        promptXmin=new JLabel("Xmin ");
        inputXmin=new JTextField(5);
        promptXmax=new JLabel("Xmax ");
        inputXmax=new JTextField(5);
        promptYmin=new JLabel("Ymin ");
        inputYmin=new JTextField(5);
        promptYmax=new JLabel("Ymax ");
        inputYmax=new JTextField(5);
        //*******
        promptLabel=new  JLabel("           Plot başlığı     : ");
        promptXLabel=new JLabel("           x ekseni başlığı : ");
        promptYLabel=new JLabel("           y ekseni başlığı : ");
        inputLabel=new JTextField(30);
        inputXLabel=new JTextField(30);
        inputYLabel=new JTextField(30);
        //*******
        promptXntic=new JLabel("X tik no");
        inputXntic=new JTextField(5);
        promptYntic=new  JLabel("Y tik no");
        inputYntic=new JTextField(5);
        promptXgridon=new JLabel("X grid (küçük kare)");
        inputXgridon=new JCheckBox(" ");
        promptYgridon=new JLabel("Y grid (küçük kare)");
        inputYgridon=new JCheckBox(" ");
        textA=new JTextArea(line,10,30);
        //*******
        JPanel pane1 = new JPanel()
        {
        public Dimension getPrefferedSize()
        {
            Dimension size=super.getPreferredSize();
            size.width=800;
            return size;
        }
        };
        pane1.add(output,BorderLayout.NORTH);
        JPanel mpane=new JPanel();
        mpane.setLayout(new GridLayout(1,8));
        altbar=new JLabel();
        mpane.add(altbar,BorderLayout.SOUTH);
        mpane.add(promptXmin);
        mpane.add(inputXmin);
        mpane.add(promptXmax);
        mpane.add(inputXmax);
        mpane.add(promptYmin);
        mpane.add(inputYmin);
        mpane.add(promptYmax);
        mpane.add(inputYmax);
        pane1.add(mpane,BorderLayout.NORTH);
        JPanel xpane=new JPanel();
        xpane.setLayout(new GridLayout(1,8));
        xpane.add(promptXntic);
        xpane.add(inputXntic);
        xpane.add(promptYntic);
        xpane.add(inputYntic);
        xpane.add(promptXgridon);
        xpane.add(inputXgridon);
        xpane.add(promptYgridon);
        xpane.add(inputYgridon);
        pane1.add(xpane,BorderLayout.NORTH);
        //********
        JPanel lpane=new JPanel();
        lpane.setLayout(new GridLayout(3,2));
        lpane.add(promptLabel);
        lpane.add(inputLabel);
        lpane.add(promptXLabel);
        lpane.add(inputXLabel);
        lpane.add(promptYLabel);
        lpane.add(inputYLabel);
        pane1.add(lpane,BorderLayout.SOUTH);
        //*********
        inputXmin.addActionListener(this);
        inputXmax.addActionListener(this);
        inputYmin.addActionListener(this);
        inputYmax.addActionListener(this);
        inputLabel.addActionListener(this);
        inputXLabel.addActionListener(this);
        inputYLabel.addActionListener(this);
        inputXntic.addActionListener(this);
        inputYntic.addActionListener(this);
        inputXgridon.addItemListener(this);
        inputYgridon.addItemListener(this);
        jta=new Plot2D2(pi);
        inputXmin.setText(Double.toString(jta.p1.xmin));
        inputXmax.setText(Double.toString(jta.p1.xmax));
        inputYmin.setText(Double.toString(jta.p1.ymin));
        inputYmax.setText(Double.toString(jta.p1.ymax));
        inputXntic.setText(Integer.toString(jta.p1.xntic));
        inputYntic.setText(Integer.toString(jta.p1.yntic));
        inputLabel.setText(jta.p1.label);
        inputXLabel.setText(jta.p1.xlabel);
        inputYLabel.setText(jta.p1.ylabel);
        //printButton=new JButton("Yazdır");
        JPanel pane2 = new JPanel();
        JPanel pane3 = new JPanel();
        pane2.setLayout(new BorderLayout());
        altbar=new JLabel();
        pane2.add(altbar,BorderLayout.SOUTH);
        pane2.addMouseListener(this);
        pane2.addMouseMotionListener(this);
        
        //pane1.add(printButton,BorderLayout.SOUTH);
        //printButton.addActionListener(this);
        wam=new yashavaModel("SI","tdb_w",20.0,0.004,P);
        line=wam.readName()+"\n";
        line+=wam.readUnit()+"\n";        
        //wam2=new yashavaModel("SI","tdb_w",40.0,0.01,P);
        //ajt=new JTable(wam);
        //ajt2=new JTable(wam2);
        
        pane2.add(jta,BorderLayout.CENTER);
        //pane2.add(ajt,BorderLayout.WEST);
        //pane1.add(ajt,BorderLayout.SOUTH);
        textA=new JTextArea(line,10,80);
        JScrollPane textAP=new JScrollPane(textA);        
        wa=new yashava();
        unit="SI";
        pair="tdb_w";
        v1=20.0;
        v2=0.015;
        wa.setUnit(unit);
        wam=new yashavaModel(unit,pair,v1,v2,P);
        inputPanel=new JPanel();
        inputPanel.setLayout(new GridLayout(5,3));
        outputPanel=new JPanel();
        outputPanel.setLayout(new BorderLayout());
        totalPanel=new JPanel();
        totalPanel.setLayout(new BorderLayout());
        l1[0]=new JLabel("birim sistemi");
        l1[1]=new JLabel("bilinen özellikler çiftini giriniz : ");
        l1[2]=new JLabel("Basınç");
        l1[3]=new JLabel(" kuru termometre sıcaklığı");
        l1[4]=new JLabel(" özgül nem");
        l2[0]=new JLabel("");
        l2[1]=new JLabel("");
        l2[2]=new JLabel(" bar");
        l2[3]=new JLabel(" derece C");
        l2[4]=new JLabel(" kg buhar/kg karışım");
        c1[0]=new JComboBox(s1);
        c1[1]=new JComboBox(s2);
        t1[0]=new JTextField(""+P);
        t1[1]=new JTextField(""+v1);
        t1[2]=new JTextField(""+v2);
        t1[3] = new JTextField();
        t1[3].setText(pair);
    inputPanel.add(l1[0]);
    inputPanel.add(c1[0]);
    inputPanel.add(l2[0]);
    inputPanel.add(l1[1]);
    inputPanel.add(c1[1]);
    inputPanel.add(t1[3]);
    inputPanel.add(l1[2]);
    inputPanel.add(t1[0]);
    inputPanel.add(l2[2]);
    inputPanel.add(l1[3]);
    inputPanel.add(t1[1]);
    inputPanel.add(l2[3]);
    inputPanel.add(l1[4]);
    inputPanel.add(t1[2]);
    inputPanel.add(l2[4]);
    t1[0].setBackground(bg);
    t1[1].setBackground(bg);
    t1[2].setBackground(bg);
    t1[3].setBackground(bg);
    t1[0].setFont(l1[0].getFont());
    t1[1].setFont(l1[0].getFont());
    t1[2].setFont(l1[0].getFont());
    t1[3].setFont(l1[0].getFont());
    c1[0].setBackground(bg);
    c1[1].setBackground(bg);
    c1[0].addItemListener(this);
    c1[1].addItemListener(this);
    t1[0].addActionListener(this);
    t1[1].addActionListener(this);
    t1[2].addActionListener(this);
    t1[3].addActionListener(this);
    output=new JTextArea();
    setArea();
    jt=new JTable(wam);
    jt.setBackground(bg);
    jt.setFont(l1[0].getFont());
    output.setFont(l1[0].getFont());
    output.setForeground(l1[0].getForeground());
    outputPanel.add(output,BorderLayout.NORTH);
    outputPanel.add(jt,BorderLayout.SOUTH);
    totalPanel.add(inputPanel,BorderLayout.NORTH);
    totalPanel.add(outputPanel,BorderLayout.SOUTH);        
        pane3.add(totalPanel);
        textA.setBackground(bg);
        pane3.add(textAP,BorderLayout.SOUTH);
        tabbedPane.addTab(PLOTPANEL,    pane2);
        tabbedPane.addTab(KONTROLPANEL, pane1);
        tabbedPane.addTab(psikometri, pane3);
        contentPane.add(  tabbedPane, BorderLayout.CENTER);
    }

    public void itemStateChanged(ItemEvent e)
    {
    inputXmin.setText(Double.toString(jta.p1.xmin));
    inputXmax.setText(Double.toString(jta.p1.xmax));
    inputYmin.setText(Double.toString(jta.p1.ymin));
    inputYmax.setText(Double.toString(jta.p1.ymax));
    inputXntic.setText(Integer.toString(jta.p1.xntic));
    inputYntic.setText(Integer.toString(jta.p1.yntic));
    Object source=e.getItemSelectable();
    if(source==inputXgridon)
    {
     if (e.getStateChange() == ItemEvent.DESELECTED)
     {
     jta.p1.xgridon=0;
     }
     else
     {
      jta.p1.xgridon=1;
     }
    }
    else if(source==inputYgridon)
    {
     if (e.getStateChange() == ItemEvent.DESELECTED)
     {
     jta.p1.ygridon=0;
     }
     else
     {
      jta.p1.ygridon=1;
     }
    }
    inputLabel.setText(jta.p1.label);
    inputXLabel.setText(jta.p1.xlabel);
    inputYLabel.setText(jta.p1.ylabel);
      unit=(String)c1[0].getSelectedItem();
  pair=(String)c1[1].getSelectedItem();
  int loc=pair.indexOf('_');
  String ss1=pair.substring(0,loc);
  String ss2=pair.substring((loc+1),pair.length());
  t1[3].setText(pair);
  if(ss1.equals("tdb")) l1[3].setText(" kuru hava sıcaklığı ");
  else if(ss1.equals("w")) l1[3].setText(" özgül nem ");
  if(ss2.equals("twb")) l1[4].setText(" yaş hava sıcaklığı ");
  else if(ss2.equals("rh")) l1[4].setText(" bağıl nem ");
  else if(ss2.equals("w")) l1[4].setText(" özgül nem ");
  else if(ss2.equals("tdew")) l1[4].setText(" çiğ noktası sıcaklığı ");
  else if(ss2.equals("pv")) l1[4].setText(" buhar basıncı ");
  else if(ss2.equals("dos")) l1[4].setText(" doyma derecesi ");
  else if(ss2.equals("h")) l1[4].setText(" entalpi ");
  else if(ss2.equals("s")) l1[4].setText(" entropi ");

  if(unit.equals("SI"))
  {
  l2[2].setText(" bar");
  if(ss1.equals("tdb")) l2[3].setText(" derece C ");
  else if(ss1.equals("w")) l2[3].setText(" kg su buharı/kg kuru hava");
  if(ss2.equals("twb")) l2[4].setText(" derece C");
  else if(ss2.equals("rh")) l2[4].setText(" ");
  else if(ss2.equals("w")) l2[4].setText(" kg su buharı/kg kuru hava");
  else if(ss2.equals("tdew")) l2[4].setText(" derece C");
  else if(ss2.equals("pv")) l2[4].setText(" bar");
  else if(ss2.equals("dos")) l2[4].setText(" ");
  else if(ss2.equals("h")) l2[4].setText(" KJ/kg kuru hava");
  else if(ss2.equals("s")) l2[4].setText(" KJ/K kg kuru hava");
  }
  else
  {
  l2[2].setText(" lbf/in^2 (psia)");
  if(ss1.equals("tdb")) l2[3].setText(" derece F ");
  else if(ss1.equals("w")) l2[3].setText(" lbm su buharı/lbm kuru hava");
  if(ss2.equals("twb")) l2[4].setText(" derece F");
  else if(ss2.equals("rh")) l2[4].setText(" ");
  else if(ss2.equals("w")) l2[4].setText(" lbm su buharı/lbm kuru hava");
  else if(ss2.equals("tdew")) l2[4].setText(" derece F");
  else if(ss2.equals("pv")) l2[4].setText(" lbf/in^2 (psia)");
  else if(ss2.equals("dos")) l2[4].setText(" ");
  else if(ss2.equals("h")) l2[4].setText(" BTU/lbm kuru hava");
  else if(ss2.equals("s")) l2[4].setText(" BTU/R lbm kuru hava");
  }
  t1[1].setText("");
  t1[2].setText("");
  jta.yenidenciz();
  repaint();
    }

    public void actionPerformed(ActionEvent e)
    {
    //if (e.getSource()==printButton )
    //{
    //jta.yazdir();
    //}
    Double valXmin=new Double(inputXmin.getText());
    jta.p1.xmin=valXmin.doubleValue();
    Double valXmax=new Double(inputXmax.getText());
    jta.p1.xmax=valXmax.doubleValue();
    Double valYmin=new Double(inputYmin.getText());
    jta.p1.ymin=valYmin.doubleValue();
    Double valYmax=new Double(inputYmax.getText());
    jta.p1.ymax=valYmax.doubleValue();
    //*****
    Integer valXntic=new Integer(inputXntic.getText());
    jta.p1.xntic=valXntic.intValue();
    Integer valYntic=new Integer(inputYntic.getText());
    jta.p1.yntic=valYntic.intValue();
    //*****
    jta.p1.label=inputLabel.getText();
    jta.p1.xlabel=inputXLabel.getText();
    jta.p1.ylabel=inputYLabel.getText();
    jta.yenidenciz();
    if(e.getSource()==t1[3])
  {
  String st1=(String)c1[1].getSelectedItem();
  pair=st1;
  String st2=t1[3].getText();
     for(int j=0;j<s2.length;j++)
     {
        if(s2[j].equals(st2))
        {   pair=st2;
            c1[1].setSelectedItem(st2);
            break;
        }
     }
  }
  else
  {
  double P0=P;	  
  Double V0=new Double(t1[0].getText());
  P=V0.doubleValue();
  //redraw graphic screen if pressure changed
  //if(P!=P0)  init1(P);
  Double V1=new Double(t1[1].getText());
  v1=V1.doubleValue();
  Double V2=new Double(t1[2].getText());
  v2=V2.doubleValue();
  wam.setValues(unit,pair,v1,v2,P);
  aa=wa.property(pair,v1,v2,P);
  xi=aa[1];
  yi=aa[5];
  xn++;
  xx[xn-1]=xi;yy[xn-1]=yi;
  jta.setXY(xx,yy,xn);
  line=wam.readValue()+"\n";
  textA.append(line);
  //System.out.print(line);   
  jta.yenidenciz();
  //setArea();
  repaint();
  }
}            


      public void degerleriGir(String e,int x,int y)
      {
	  //fare tiki ile girilen değerleri(pixel değerleri) gerçek değişkenlere çevirir    
      s=e;
      xi=jta.p1.xmin+(double)(x-jta.p1.xabsmin)/(double)jta.p1.abswidth*(jta.p1.xmax-jta.p1.xmin);
      yi=jta.p1.ymin-(double)(y-jta.p1.yabsmin-jta.p1.absheight)/(double)jta.p1.absheight*(jta.p1.ymax-jta.p1.ymin);
      double aa[]=wa.property("tdb_rh",xi,1.0,P);
      if(yi>aa[5]) yi=aa[5];
      xn++;
      xx[xn-1]=xi;yy[xn-1]=yi;
      jta.setXY(xx,yy,xn);
      altbar.setText(e+" ["+toString(xi,5,2)+" , "+toString(yi,6,4)+"] ");
      wam.setValues(unit,"tdb_w",xi,yi,P);
      line=wam.readValue()+"\n";
      textA.append(line);
      pair="tdb_w";
      int loc=pair.indexOf('_');
      String ss1=pair.substring(0,loc);
      String ss2=pair.substring((loc+1),pair.length());
      t1[3].setText(pair);
      t1[1].setText(""+xi);
      t1[2].setText(""+yi);
      ss1="tdb";
      l1[3].setText(" Kuru hava sıcaklığı");
      ss2="w";
      l1[4].setText(" özgül nem ");
      l2[2].setText(" bar");
      l2[3].setText(" derece C ");
      l2[4].setText(" kg su buharı/kg kuru hava");
      t1[1].setText(""+xi);
      t1[2].setText(""+yi);
      //System.out.print(line);   
      jta.yenidenciz();
      repaint();
  }
      
      public void degerleriGir1(String e,int x,int y)
      {
      s=e;
      xi1=jta.p1.xmin+(double)(x-jta.p1.xabsmin)/(double)jta.p1.abswidth*(jta.p1.xmax-jta.p1.xmin);
      yi1=jta.p1.ymin-(double)(y-jta.p1.yabsmin-jta.p1.absheight)/(double)jta.p1.absheight*(jta.p1.ymax-jta.p1.ymin);
      altbar.setText(e+" ["+toString(xi1,5,2)+" , "+toString(yi1,6,4)+"] ");
      }
      
 public void mouseClicked(MouseEvent e)
 {  }

 public void mousePressed(MouseEvent e)
 { 
   degerleriGir("Basıldı",e.getX(),e.getY());
 }

  public void mouseReleased(MouseEvent e)
 { 
 }

 public void mouseEntered(MouseEvent e)
 { }

 public void mouseExited(MouseEvent e)
 { }

//MouseMotionListener (fare hareket dinleyicisi) metotlari

 public void mouseDragged(MouseEvent e)
 {degerleriGir1("Fare tuş basılı hareket ediyor",e.getX(),e.getY());}
 
 public void mouseMoved(MouseEvent e)
 {degerleriGir1("Fare hareket ediyor",e.getX(),e.getY());}
 

  public static String toString(double left, int w, int d)
  // converts a double to a string with given width and decimals.
  {
	NumberFormat df=NumberFormat.getInstance(Locale.US);
	df.setMaximumFractionDigits(d);
    df.setMinimumFractionDigits(d);
    df.setGroupingUsed(false);
    String s = df.format(left);
    while (s.length() < w)
      s = " " + s;
    if (s.length() > w)
    {
        s = "";
        for (int i=0; i<w; i++)
          s = s + "-";
    }
    return s;
 }
 
 public static double[][][] psplot(double P)
 {
	 //prepare pyschrometric chart data for pressure P
     yashava w=new yashava();
	 double aa[]=new double[14];  
     double bb[]=new double[14];  
	 f2 ff=new f2();
	 //double x1[][]=new double[62][51];
	 //double y1[][]=new double[62][51];
	 double A[][][]=new double[2][62][51];
     //initilise as a function plot
     int i,j;
     i=0;
     double h;
     for(double rh=0.1;rh<=1.0;rh+=0.1)
     {   j=0;
         for(double t=0.0;t<=50.0;t+=1.0)
         {
	     aa=w.property1("tdb_rh",t,rh,P);
	     h=aa[8];
	        if(rh>0.99) 
            { 
	        h=aa[8];
            A[0][11+j][0]=t;A[1][11+j][0]=aa[5];bb=w.property1("w_h",0.0,h,P);
            A[0][11+j][1]=bb[10];A[1][11+j][1]=0.0;
            }
	        A[0][i][j]=t;
            A[1][i][j]=aa[5];
	        j++;
            }
         i++;
     }	 
     return A;
     }

    public static void open()
    {
        //main program for applet input
	    JFrame f = new JFrame("hava su buharı karışımının termodinamik özellikleri-psikometrik diyagram");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new psT();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(1000,800));
        f.setVisible(true);
    }
    
    public static void main(String s[])
    {
        //main program
	    JFrame f = new JFrame("hava su buharı karışımının termodinamik özellikleri-psikometrik diyagram");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new psT();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(1000,800));
        f.setVisible(true);
    }    
 }

