problem in java swings

Discussion in 'Java' started by sweta, May 5, 2006.

  1. sweta

    sweta Guest

    I Have problem related to Internal Frame
    actually In Internal Frame one list is attached in which 1 to 19
    options exists
    In Internal Frame one graph is displaying in which changes occurs with
    respect to only that option which we have already selected in
    list3.java and peakContainer.java in which Instanre of list3 is passed
    file but I Want changes with respect to every Option(1 to 19)in
    Internal Frame's graph ,sir help me.Actually I am working in
    NMR(nuclear Magnetic Resonance) project I am attaching code Below
    (NMRUI.java is main file) actually when we click on file menu and then
    in open option in browsing window we select p38400.7 type file and then
    internal frame will open
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class list3 extends JPanel
    {
    public int Frame_index;
    public list3(int Frame_index)
    {
    this.Frame_index = Frame_index;
    initComponents();
    }

    private void initComponents() {
    scrollPane1 = new JScrollPane();
    list = new JList();

    //======== this ========

    setLayout(new FlowLayout());

    //======== scrollPane1 ========
    {

    //---- list ----
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setModel(new AbstractListModel() {
    String[] values = {
    "1","2","3","4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "10",
    "11",
    "12",
    "13",
    "14",
    "15",
    "16","17","18","19"
    };
    public int getSize() { return values.length; }
    public Object getElementAt(int i) { return values; }
    });
    list.setVisibleRowCount(19);
    list.setSelectedIndex(Frame_index);
    list.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    listValueChanged(e);
    }
    });
    scrollPane1.setViewportView(list);
    }
    add(scrollPane1);
    // JFormDesigner - End of component initialization
    //GEN-END:initComponents
    }

    public void listValueChanged(ListSelectionEvent e) {
    // TODO add your code here
    JList jl = (JList)e.getSource();
    this.Frame_index = jl.getSelectedIndex();
    }

    private JScrollPane scrollPane1;
    private JList list;
    }


    //peakContainer.java
    /*
    * Created on Aug 26, 2004
    *
    */
    //package nmrui.mri;

    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ButtonGroup;
    import javax.swing.JInternalFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPopupMenu;
    import javax.swing.JRadioButtonMenuItem;
    import javax.swing.JRootPane;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import java.io.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.JOptionPane;//new code for pope-up
    import javax.swing.*;
    import javax.swing.event.*;
    /*
    * @ Author ANADI MISHRA
    *
    * @ version 1.00
    */
    public class PeakContainer extends JInternalFrame
    {
    JMenuBar menuBar;
    JMenu fileMenu, dispMenu, psMenu;
    JMenuItem[] fmi;
    JRadioButtonMenuItem[] mmi, tmi, psi;
    JRootPane rootPane;
    public final int inset = 50;
    ButtonGroup mbg, tbg, psbg;
    JRadioButtonMenuItem sb; //new code
    static final Integer DOCLAYER = new Integer(5);
    GraphGE gr;
    GraphDataGE1 gd;
    PeakSupres ps;
    //XAxismod ax; // for pope-up

    JPopupMenu m_menu = new JPopupMenu(); //new codes
    double max, min; // for pope-up
    double xvalue;
    boolean linePresent = false;
    boolean popupPresent = false;
    String msg=" ";
    public int frameindex = 6;
    public PeakContainer()
    {
    super();
    }
    /*
    * @ s the name of the GE File
    * @ data the double array containing file's values
    */
    public PeakContainer(String s, double[][] data)
    {
    super(s);
    final int point = data.length/19;
    rootPane = this.getRootPane();
    //JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    //************************************ codes for pope-up
    ************************************************************
    JMenuItem m_pv = new JMenuItem("Previous view");
    JMenuItem m_iv = new JMenuItem("Initial view");
    JMenuItem m_szr = new JMenuItem("Set zero reference");
    JMenuItem m_sr = new JMenuItem("Set reference");

    m_menu.add (m_pv);
    m_menu.add (m_iv);

    // Separator
    m_menu.add (new JMenuItem("-"));

    m_menu.add (m_szr);
    m_menu.add (m_sr);
    add(m_menu);

    addMouseListener ( new MouseAdapter ()
    {
    public void mouseReleased(MouseEvent e)
    {
    // Check for a right click pop-up
    if (e.isPopupTrigger() )
    {
    int x = e.getX();
    int y = e.getY();
    popupPresent = true;

    genppm_frq pmfr = new genppm_frq(point);
    double[] ppm = pmfr.returnppm();
    max_min mm = new max_min();
    max = mm.getMax(ppm);
    min = mm.getMin(ppm);
    xvalue = -(min+((720-(x-80))*(max-min)/720));
    // Show the popup meun
    m_menu.show (rootPane, x, y );
    }
    }
    });
    m_sr.addActionListener(new PopupMenuListener(this));

    //*************************************************************************************************

    fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    fmi = new JMenuItem[3];

    fmi[0] =
    new JMenuItem(
    "Open",
    (Icon) new ImageIcon("./resources/images/open.gif"));
    fmi[1] =
    new JMenuItem(
    "Save",
    (Icon) new ImageIcon("./resources/images/save.gif"));
    fmi[2] = new JMenuItem("Exit");

    for (int i = 0; i < 3; i++)
    fileMenu.add(fmi);

    for (int i = 0; i < 3; i++)
    fmi.addActionListener(new GraphContainerListener(this));

    dispMenu = new JMenu("Display");
    dispMenu.setMnemonic('D');

    mbg = new ButtonGroup();
    tbg = new ButtonGroup();

    mmi = new JRadioButtonMenuItem[2];
    tmi = new JRadioButtonMenuItem[7];

    mmi[0] = new JRadioButtonMenuItem("FID");
    mmi[0].setActionCommand("fid");
    mmi[1] = new JRadioButtonMenuItem("Spectrum",true);
    mmi[1].setActionCommand("sp");
    tmi[0] = new JRadioButtonMenuItem("Real", true);
    tmi[0].setActionCommand("r");
    tmi[1] = new JRadioButtonMenuItem("Imaginary");
    tmi[1].setActionCommand("i");
    tmi[2] = new JRadioButtonMenuItem("Absolute");
    tmi[2].setActionCommand("a");
    tmi[3] = new JRadioButtonMenuItem("Real^2");
    tmi[3].setActionCommand("r2");
    tmi[4] = new JRadioButtonMenuItem("Imaginary^2");
    tmi[4].setActionCommand("i2");
    tmi[5] = new JRadioButtonMenuItem("Absolute^2");
    tmi[5].setActionCommand("a2");
    tmi[6] = new JRadioButtonMenuItem("Mag[Mag-real]");
    tmi[6].setActionCommand("msr");

    //MyListSelectionListener l2=new MyListSelectionListener();
    //JListSimpleExample1 l=new JListSimpleExample1();


    for (int i = 0; i < 2; i++)
    {
    dispMenu.add(mmi);
    mbg.add(mmi);
    }

    for (int i = 0; i < 2; i++)
    mmi.addActionListener(new GraphContainerListener(this));

    dispMenu.addSeparator();

    for (int i = 0; i < 7; i++)
    {
    dispMenu.add(tmi);
    tbg.add(tmi);
    }

    for (int i = 0; i < 7; i++)
    {
    tmi.addActionListener(new GraphContainerListener(this));

    //new code
    //tmi.addMouseListener(new handelmouse(this));
    //tmi.addMouseMotionListener(new handelmouse(this));
    }

    /////###///////////////////////////////////////////////////////////////////////
    psMenu = new JMenu("PeakSup");
    psMenu.setMnemonic('P');

    psbg = new ButtonGroup();
    psi = new JRadioButtonMenuItem[2];

    psi[0] = new JRadioButtonMenuItem("Water Peak");
    psi[0].setActionCommand("wps");
    psi[1] = new JRadioButtonMenuItem("Viewps");
    psi[1].setActionCommand("vps");

    for (int i = 0; i < 2; i++)
    {
    psMenu.add(psi);
    psbg.add(psi);
    }

    for (int i = 0; i < 2; i++)
    psi.addActionListener(new GraphContainerListener(this));
    /////###//////////////////////////////////////////////////////////////////////



    //new code
    sb = new JRadioButtonMenuItem("SaveData", (Icon) new
    ImageIcon("./resources/images/save.gif"));
    sb.setActionCommand("savedata");
    sb.addActionListener(new GraphContainerListener(this));

    menuBar.add(fileMenu);
    menuBar.add(dispMenu);
    menuBar.add(psMenu);
    menuBar.add(sb);//new code

    rootPane.setJMenuBar(menuBar);
    setClosable(true);
    setIconifiable(true);
    setMaximizable(false);
    setResizable(false);
    setVisible(true);
    this.setBounds(10,10,600,400);

    /*
    * Adding the default Graph
    */
    list3 l3 = new list3(frameindex);
    rootPane.getContentPane().add(l3, BorderLayout.EAST);

    gd = new GraphDataGE1(data.length);

    if (data != null)
    {
    //choicetest t=new choicetest();
    //msg+=t.cbg.getSelectedCheckbox().getLabel();

    //System.out.println("index @nkur:"+l1.getIndex());
    //System.out.println(l3.index);
    gd.addSignals(data,frameindex);
    gd.doPhaseFID();
    gd.doFFT();
    gd.doPhase();
    }
    else
    {
    System.out.println("Cannot Proceed\n System Shall Exit");
    System.exit(0);
    }

    gr = new GraphGE(gd.getPoint(), s);
    gr.clearValues();
    gr.setValues(gd.getReal());
    gr.reDraw();

    rootPane.getContentPane().add(gr, BorderLayout.CENTER);
    //ax = new XAxismod(gd.getPoint())

    }

    public GraphGE getGraphGE()
    {
    return this.gr;
    }

    public GraphDataGE1 getGraphDataGE()
    {
    return this.gd;
    }

    /*public XAxismod gettrans()
    {
    return this.ax; //pope-up
    }*/

    /*public PeakSupres getPeakSupres()
    {
    return this.ps;
    }*/

    public void message()
    {
    System.out.println("Hello!");
    }

    public PeakContainer getPeakContainer()
    {
    return this;
    }

    public int[] getSelectedMenu()
    {
    int [] idx = new int[4];

    if(mmi[0].isSelected())
    idx[0] = 0;
    else
    idx[0] = 1;

    for(int i=0;i<7;i++)
    {
    if(tmi.isSelected())
    {
    idx[1] = i;
    }
    }

    if(sb.isSelected())
    idx[2] = 0;

    for(int i=0;i<2;i++)
    {
    if(psi.isSelected())
    {
    idx[3] = i;
    }
    }
    return idx;
    }

    }

    //###////////////////////////new code for
    popup//////////////////////////////////////
    class PopupMenuListener implements ActionListener
    {
    PeakContainer cp;
    int [] idx = new int[2];
    public PopupMenuListener(PeakContainer cp)
    {
    this.cp = cp;
    }

    public void actionPerformed(ActionEvent e)
    {
    GraphGE grp = cp.getGraphGE();
    GraphDataGE1 gdp = cp.getGraphDataGE();
    int pt = gdp.getPoint();

    if(cp.popupPresent)
    {
    String Input = JOptionPane.showInputDialog("Enter first integer");
    double inputnumber = Double.parseDouble(Input);
    double d = cp.xvalue;
    System.out.println(inputnumber);
    System.out.println(d);
    double numsub = inputnumber - d;
    double numsubfrq = (inputnumber * 63.86) - d;

    ppm_freq_save pfs = new ppm_freq_save(pt, numsub,
    numsubfrq);
    pfs.writefrq();

    idx = cp.getSelectedMenu();
    //System.out.println("Pope-up present"+idx[0]);

    if(idx[0] == 0)
    {
    int ch = idx[1];
    switch (ch)
    {
    case 0: // Real
    grp.clearValues();
    grp.setValues(gdp.getRealFID());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 1: //Imag
    grp.clearValues();
    grp.setValues(gdp.getImagFID());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 2: //Absolute
    grp.clearValues();
    grp.setValues(gdp.getMagnitudeFID());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 3: //Real Square
    grp.clearValues();
    grp.setValues(gdp.getRealFIDSq());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 4 : // Imag Square
    grp.clearValues();
    grp.setValues(gdp.getImagFIDSq());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 5:
    grp.clearValues();
    grp.setValues(gdp.getMagnitudeFIDSq());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    }
    }
    else if(idx[0] == 1)
    {
    int ch = idx[1];

    switch (ch)
    {
    case 0: // Real
    grp.clearValues();
    grp.setValues(gdp.getReal());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 1: //Imag
    grp.clearValues();
    grp.setValues(gdp.getImag());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 2: //Absolute
    grp.clearValues();
    grp.setValues(gdp.getMagnitude());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 3: //Real Square
    grp.clearValues();
    grp.setValues(gdp.getRealSq());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 4 : // Imag Square
    grp.clearValues();
    grp.setValues(gdp.getImagSq());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    case 5:
    grp.clearValues();
    grp.setValues(gdp.getMagnitudeSq());
    grp.settrans(numsub);
    cp.repaint();
    grp.reDraw();
    break;
    }
    }
    }

    }

    }
    //###///////////////////////////////////////////////////////////////////////////////////////////////////

    class GraphContainerListener implements ActionListener
    {
    PeakContainer cg;
    String str = new String("");
    public GraphContainerListener(PeakContainer cg)
    {
    this.cg = cg;
    }

    public String getActionString()
    {
    return str;
    }


    public void actionPerformed(ActionEvent evt)
    {
    str = evt.getActionCommand();
    GraphGE gr = cg.getGraphGE();
    GraphDataGE1 d = cg.getGraphDataGE();
    //PeakSupres s = cg.getPeakSupres();

    fileHandling fw = new fileHandling();
    File fp = new File(".");
    String savepath = fp.getAbsolutePath();
    String foldername = "\\Result\\";

    if (str.equals("fid"))
    {
    return;
    }
    else if (str.equals("sp"))
    {
    return;
    }
    if (str.equals("r"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getReal());
    else
    gr.setValues(d.getRealFID());
    cg.repaint();
    gr.reDraw();

    }
    else if (str.equals("i"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getImag());
    else
    gr.setValues(d.getImagFID());
    cg.repaint();
    gr.reDraw();
    }
    else if (str.equals("a"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getMagnitude());
    else
    gr.setValues(d.getMagnitudeFID());
    cg.repaint();
    gr.reDraw();
    }
    else if (str.equals("r2"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getRealSq());
    else
    gr.setValues(d.getRealFIDSq());
    cg.repaint();
    gr.reDraw();
    }
    else if (str.equals("i2"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getImagSq());
    else
    gr.setValues(d.getImagFIDSq());
    cg.repaint();
    gr.reDraw();
    }
    else if (str.equals("a2"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getMagnitudeSq());
    else
    gr.setValues(d.getMagnitudeFIDSq());
    cg.repaint();
    gr.reDraw();
    }

    else if (str.equals("msr"))
    {
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(d.getMagofMagSubRe());
    else
    gr.setValues(d.getMagofMagSubReFID());
    cg.repaint();
    gr.reDraw();
    }

    ///###///////////////////////////////
    else if (str.equals("wps"))
    {

    PeakSupres s = new PeakSupres(d.getReal(),d.getImag());
    double[] pcreal = s.getpsreal();


    //System.out.println(pcreal[0]);
    gr.clearValues();
    if(cg.mmi[1].isSelected())
    gr.setValues(pcreal);
    //System.out.println("Error1");
    else
    System.out.println("Error2");
    cg.repaint();
    gr.reDraw();
    }

    else if (str.equals("vps"))
    {
    Frame_ParalleDisplay pf = new Frame_ParalleDisplay(d.getReal());
    //Frame f = new Frame_ParalleDisplay();
    System.out.println("ViewWP");
    }

    else if (str.equals("savedata"))
    {
    /*try
    {
    //File fp = new File(".");
    //String savepath = fp.getAbsolutePath();
    String foldername1 = "\\BMP_Graph\\";
    File file = new File(savepath+foldername1);
    file.mkdir();
    File filef = new File(savepath+foldername1+"Mag.bmp");
    Filesave sf = new Filesave();
    sf.saveToFile(cg, filef);
    System.out.println("Done saving File!");
    }
    catch(Exception e)
    {}*/

    if(cg.sb.isSelected())
    {
    double[] pcreal = d.getReal();
    double[] pcimag = d.getImag();
    double[] pcrealtd = d.getRealFID();
    double[] pcimagtd = d.getImagFID();
    fw.filewrite(savepath, pcreal,"pcreal",foldername);
    fw.filewrite(savepath, pcimag,"pcimag",foldername);
    fw.filewrite(savepath, pcrealtd,"pcrealtd",foldername);
    fw.filewrite(savepath, pcimagtd,"pcimagtd",foldername);
    System.out.println("Done saving File!");
    }
    }
    }
    }

    //NMRGUI.java
    /*
    * Created on Aug 25, 2004
    *
    */
    //package nmrui.gui;

    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.GraphicsConfiguration;
    import java.awt.HeadlessException;
    import java.awt.Insets;
    import java.io.File;
    import javax.swing.border.EtchedBorder;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JCheckBoxMenuItem;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuBar;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JRootPane;
    import javax.swing.JToolBar;
    import javax.swing.UIManager;
    import java.awt.*;
    import java.awt.Toolkit;
    //import nmrui.mrs.GraphContainer;
    //import nmrui.mri.PeakContainer;
    //import views.*;
    /**
    * @author ANADI MISHRA
    */
    public class NMRGui extends JFrame {
    private JRootPane rootPane;
    private Container cot;
    private JMenuBar menuBar;
    private JMenu[] menu;
    private JMenuItem[] fmi, emi, dmi, qmi, wmi;
    private JPanel iPanel, up;
    private JToolBar tBar;
    private JButton[] tlb = new JButton[7];
    private JDesktopPane dpane;
    private PeakContainer p;
    static final Integer layer1 = new Integer(0);
    static final Integer layer2 = new Integer(1);
    static final Integer layer3 = new Integer(2);
    /**
    * @throws java.awt.HeadlessException
    */
    public NMRGui() throws HeadlessException {
    super();
    }

    /**
    * @param gc
    */
    public NMRGui(GraphicsConfiguration gc) {
    super(gc);
    }

    /**
    * @param title
    * @param gc
    */
    public NMRGui(String title) {
    super(title);
    try
    {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch (Exception e)
    {
    System.err.println("Error In Look And Feel :" + e);
    e.printStackTrace();
    }

    rootPane = getRootPane();
    //extracting the content-pane
    cot = rootPane.getContentPane();
    cot.setBackground(Color.white);
    //cot.setLayout(new BorderLayout());

    //activating close window button
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    System.exit(0);
    }
    });

    addWindowListener(new WindowAdapter() {
    public void windowActivated(WindowEvent we) {
    }
    });

    /*
    @The following Code is to Add both the Menu bar and the Tool Bar
    * to this upper panel in BorderLayout so that they cover the entire
    * panel

    */
    //creating the menu bar
    menuBar = new JMenuBar();
    menuBar.setBorder(new EtchedBorder(EtchedBorder.RAISED));
    rootPane.setJMenuBar(menuBar);

    //creating upper panel
    JPanel up = new JPanel(new BorderLayout(0, 1));
    cot.add(up, BorderLayout.NORTH,0);

    // creating Menus
    menu = new JMenu[8];

    menu[0] = new JMenu("File", true);
    menu[0].setMnemonic('F');

    menu[1] = new JMenu("Edit");
    menu[1].setMnemonic('E');

    menu[2] = new JMenu("Display");
    menu[2].setMnemonic('D');

    menu[3] = new JMenu("Preprocessing");
    menu[3].setMnemonic('P');

    menu[4] = new JMenu("Quantification");
    menu[4].setMnemonic('Q');

    menu[5] = new JMenu("Options");
    menu[5].setMnemonic('O');

    menu[6] = new JMenu("Window");
    menu[6].setMnemonic('W');

    menu[7] = new JMenu("Help");
    menu[7].setMnemonic('H');

    for (int i = 0; i < 8; i++)
    menuBar.add(menu);

    //Creating Submenus for File

    JMenuItem[] fmi = new JMenuItem[6];

    fmi[0] = new JMenuItem("Show Wizard ");
    fmi[0].setActionCommand("Show");
    fmi[1] = new JMenuItem("Open Ctrl-o", KeyEvent.VK_O);
    fmi[1].setActionCommand("Open");
    /*fmi[1].addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    final Frame c=new choicetest();
    final Frame d=new Test();
    Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize();
    d.setBounds(0,0,screensize.width-150,screensize.height-150);
    d.setVisible(true);

    c.setBounds(200,200,200,200);
    c.setVisible(true);

    }
    });*/
    fmi[2] = new JMenuItem("Open as ", KeyEvent.VK_P);
    //fmi[2].setEnabled(false);
    fmi[2].setActionCommand("Openas");
    fmi[3] = new JMenuItem("Save Ctrl-s", KeyEvent.VK_S);
    //fmi[3].setEnabled(false);
    fmi[3].setActionCommand("Save");
    fmi[4] = new JMenuItem("Save as ", KeyEvent.VK_A);
    //fmi[4].setEnabled(false);
    fmi[4].setActionCommand("Saveas");
    fmi[5] = new JMenuItem("Exit Ctrl-x", KeyEvent.VK_X);
    fmi[5].setActionCommand("Exit");

    for (int i = 0; i < 6; i++) {
    menu[0].add(fmi);
    if (i == 0 || i == 4)
    menu[0].addSeparator();
    }
    //adding Listeners to the MenuItems

    for (int i = 0; i < 6; i++) {
    fmi.addActionListener(new NMRGuiListener(this));
    fmi.addKeyListener(new NMRGuiKeyListener(this));
    }

    //Creating Submenus for edit

    JMenuItem[] emi = new JMenuItem[2];

    emi[0] = new JMenuItem(" Undo ", KeyEvent.VK_U);
    menu[1].add(emi[0]);
    emi[1] = new JMenuItem(" Redo ", KeyEvent.VK_R);
    menu[1].add(emi[1]);

    // adding listeners
    for (int i = 0; i < 2; i++) {
    emi[i].addActionListener(new NMRGuiListener(this));
    emi[i].addKeyListener(new NMRGuiKeyListener(this));
    }

    //Creating SubMenu For Display

    JCheckBoxMenuItem[] dmi = new JCheckBoxMenuItem[4];

    dmi[0] = new JCheckBoxMenuItem("Phase Window", false);
    dmi[1] = new JCheckBoxMenuItem("Aphodize Window", false);
    dmi[2] = new JCheckBoxMenuItem("Zero Fitting Window", false);
    dmi[3] = new JCheckBoxMenuItem("Preprocessing Window", false);

    for (int i = 0; i < 4; i++) {
    menu[2].add(dmi[i]);
    if (i == 2)
    menu[2].addSeparator();
    }

    //adding listsners
    for (int i = 0; i < 4; i++) {
    dmi[i].addActionListener(new NMRGuiListener(this));
    dmi[i].addKeyListener(new NMRGuiKeyListener(this));
    }

    //creating submenu for Preprocessing

    JMenuItem[] pmi = new JMenuItem[2];

    //creating submenus for Quantification

    JMenuItem[] qmi = new JMenuItem[2];

    qmi[0] = new JMenuItem(" PSVD ", KeyEvent.VK_P);
    menu[4].add(qmi[0]);
    qmi[1] = new JMenuItem(" HSVD ", KeyEvent.VK_H);
    menu[4].add(qmi[1]);

    //adding Lsiteners
    for (int i = 0; i < 2; i++) {
    qmi[i].addActionListener(new NMRGuiListener(this));
    qmi[i].addKeyListener(new NMRGuiKeyListener(this));
    }

    //creating submenu for options menu

    JMenuItem[] omi = new JMenuItem[2];

    //creating submenu for Window Menu

    JMenuItem[] wmi = new JMenuItem[2];

    wmi[0] = new JMenuItem("Minimize All Windows", KeyEvent.VK_N);
    menu[6].add(wmi[0]);
    wmi[1] = new JMenuItem("Close All Windows", KeyEvent.VK_C);
    menu[6].add(wmi[1]);

    //adding listeners
    for (int i = 0; i < 2; i++) {
    wmi[i].addActionListener(new NMRGuiListener(this));
    wmi[i].addKeyListener(new NMRGuiKeyListener(this));
    }

    //creating the icon

    Icon open = new ImageIcon("./resources/images/OPEN.GIF");
    Icon save = new ImageIcon("./resources/images/SAVE.GIF");
    Icon print = new ImageIcon("./resources/images/PRINT.GIF");
    Icon wiz = new ImageIcon("./resources/images/wizardMenu2.gif");
    Icon phase = new ImageIcon("./resources/images/phase.gif");
    Icon apodize = new ImageIcon("./resources/images/apodize.gif");
    Icon zero = new ImageIcon("./resources/images/zero.gif");

    // adding the toolbar

    JToolBar tBar = new JToolBar();
    tBar.setMargin(new Insets(5, 5, 5, 5));
    tBar.setFloatable(false);
    up.add(tBar, BorderLayout.NORTH);
    //adding button to the toolbar

    tlb[0] = new JButton(wiz);
    tlb[0].setToolTipText("Show Wizard");
    tlb[0].setActionCommand("wiz");
    tlb[1] = new JButton(open);
    tlb[1].setToolTipText(" Open ");
    tlb[1].setActionCommand("open");
    tlb[2] = new JButton(save);
    tlb[2].setToolTipText(" Save ");
    tlb[2].setActionCommand("save");
    tlb[3] = new JButton(print);
    tlb[3].setToolTipText(" Print ");
    tlb[3].setActionCommand("print");
    tlb[4] = new JButton(phase);
    tlb[4].setToolTipText(" Phase Window ");
    tlb[4].setActionCommand("phase");
    tlb[5] = new JButton(apodize);
    tlb[5].setToolTipText(" Apodize Window ");
    tlb[5].setActionCommand("apo");
    tlb[6] = new JButton(zero);
    tlb[6].setToolTipText(" Zero Fitting Window ");
    tlb[6].setActionCommand("zero");

    for (int i = 0; i < 7; i++) {
    tBar.add(tlb[i]);
    if (i == 3)
    for (int j = 0; j < 3; j++)
    tBar.addSeparator();
    }

    //adding listeners
    for (int i = 0; i < 7; i++)
    tlb[i].addActionListener(new NMRGuiButtonListener(this));

    //create and add the DesktopPane
    dpane = new JDesktopPane();
    rootPane.getContentPane().add(dpane,1);
    dpane.setBackground(Color.white);
    }
    public void addScreenGraph(String s, int type, double[][] data) {
    if (type == 1) {
    System.out.println("Text file Container is not here");
    } else {
    PeakContainer pfr = new PeakContainer(s, data);
    if(cot.getComponentCount() < 2){

    rootPane.getContentPane().add(dpane,1);
    dpane.setBackground(Color.white);
    }
    p = pfr.getPeakContainer();
    dpane.add(pfr, layer1);
    }
    }
    /**
    *
    * @param p
    */
    public void addView(Phaseview p){
    dpane.add(p,layer2);
    }
    /**
    *
    * @param a
    */
    public void addView(Apodizeview a){
    dpane.add(a,layer2);
    }

    /**
    *
    * @return
    */
    public PeakContainer getPeakContianer(){

    if(p == null){
    System.out.println("Fatal : Object Not Initialized");
    }
    return p;
    }

    /**
    *
    *
    */
    public void activateControls() {
    for (int i = 2; i < 6; i++)
    fmi[i].setEnabled(true);
    for (int i = 2; i < 6; i++)
    tlb[i].setEnabled(true);
    }
    }

    class NMRGuiListener implements ActionListener {

    private NMRGui cot;
    private File file;
    private FileHandler fh;
    private Phaseview p;
    private Apodizeview a;
    private PeakContainer pc;

    public NMRGuiListener(NMRGui cot) {
    this.cot = cot;
    }

    public void actionPerformed(ActionEvent evt) {
    JComponent comp = (JComponent) evt.getSource();
    fh = new FileHandler(cot);

    if ((evt.getActionCommand().equals("Open"))
    || (evt.getActionCommand().equals("Openas"))) {
    //cot.activateControls();
    fh.openFile();
    } else if (evt.getActionCommand().equals("Save")) {
    if (file == null)
    fh.callSave();
    else
    fh.saveFile(file);
    } else if (evt.getActionCommand().equals("Saveas"))
    fh.callSaveAs();
    else if(evt.getActionCommand().equals("Phase Window")){

    pc = cot.getPeakContianer();
    p= new Phaseview("Phasing",pc);
    cot.addView(p);
    }
    else if(evt.getActionCommand().equals("Apodize Window")){
    pc = cot.getPeakContianer();
    a= new Apodizeview("Apodize",pc);
    cot.addView(a);
    }
    else if (evt.getActionCommand().equals("Exit"))
    System.exit(0);

    }
    }

    class NMRGuiButtonListener implements ActionListener {
    private NMRGui cot;
    private FileHandler fh;
    private Phaseview p;
    private Apodizeview a;
    private PeakContainer pc;

    public NMRGuiButtonListener(NMRGui cot) {
    this.cot = cot;
    }

    public void actionPerformed(ActionEvent evt) {
    String str = evt.getActionCommand();
    fh = new FileHandler(cot);

    if (str.equals("open"))
    fh.openFile();
    else if (str.equals("save"))
    fh.callSave();
    else if(str.equals("phase")){
    pc = cot.getPeakContianer();
    p = new Phaseview("Phasing",pc);
    cot.addView(p);
    }
    else if(str.equals("apo")){
    pc = cot.getPeakContianer();
    a= new Apodizeview("Apodize",pc);
    cot.addView(a);
    }
    }
    }

    class NMRGuiKeyListener implements KeyListener
    {

    private NMRGui cot;
    private FileHandler fh;

    public NMRGuiKeyListener(NMRGui cot) {
    this.cot = cot;
    }

    public void keyPressed(KeyEvent ke) {
    }
    public void keyReleased(KeyEvent ke) {
    }
    public void keyTyped(KeyEvent ke) {
    }

    }

    main file is NMRUI.java
    //import nmrui.gui.nmrgui;
    import java.awt.toolkit;
    import java.awt.dimension;

    public class nmrui {
    private static final int inset = 50;


    public static void main(string[] args) {

    nmrgui win = new nmrgui("nmr interface");
    dimension screensize = toolkit.getdefaulttoolkit().getscreensize();
    win.setbounds(0, 0, screensize.width, screensize.height);
    win.setvisible(true);
    }
    }



    /*
    * Created on Aug 26, 2004
    *
    */
    //package nmrui.mri;

    import java.util.Vector;
    //import java.io.*;
    import fft.*;
    /*
    * @author ANADI MISHRA
    *
    * @version 1.00
    */

    public class GraphDataGE1
    {
    double[] real;
    double[] imag;
    double[] real_fd;
    double[] imag_fd;
    double[] realTD;
    double[] imagTD;
    double [][] signal;
    double phi;
    int originalLength = 0;
    Vector setOfFIDs,setOFSpectra;
    //////###//////////////////////////////////////////////////////
    double a;
    double dw;
    double d;
    //////###////////////////////////////////////////////////////
    public GraphDataGE1(int size)
    {
    originalLength = size/19;
    //originalLength = size/11;
    System.out.println("originalLength"+originalLength);
    //originalLength = size;
    real = new double[originalLength];
    imag = new double[originalLength];
    real_fd = new double[originalLength];
    imag_fd = new double[originalLength];
    realTD = new double[originalLength];
    imagTD = new double[originalLength];
    signal = new double[originalLength][2];
    phi=0.0D;
    //////###//////////////////////////////////////////////////////
    a=0.0D;
    dw = 0.4;
    d = 0;
    //////###////////////////////////////////////////////////////
    setOfFIDs = new Vector();
    setOFSpectra = new Vector();
    }

    /**
    * @param s
    */
    /*public void addSignals(double[][] s)
    {
    for(int i=0;i<originalLength;i++)
    {
    signal[i][0] = s[i][0];
    signal[i][1] = s[i][1];
    }
    }*/

    public void addSignals(double[][] s,int frameindex)
    {
    //int ctr = 0;
    //int ctr = originalLength;
    int ctr = (frameindex-1)*originalLength;
    //int ctr = 4*originalLength;
    for(int k=0;k<1;k++)
    //for(int k=0;k<1;k++)
    //for(int k=1;k<3;k++)
    for (int l = 0; l < originalLength; l++)
    {
    signal[l][0] += s[ctr][0];
    signal[l][1] += s[ctr][1];
    ctr++;
    }

    }

    public void doPhaseFID()
    {
    for(int i=0; i<originalLength; i++)
    {
    realTD[i]= (Math.cos(Math.toRadians(phi))) * signal[i][0] +
    (Math.sin(Math.toRadians(phi))) * signal[i][1];
    imagTD[i]= -(Math.sin(Math.toRadians(phi))) * signal[i][0] +
    (Math.cos(Math.toRadians(phi))) * signal[i][1];
    }
    }

    //////###////////////////////////////////////////////////////////////////////////////////////////////////////////
    /*public void doApodizeFID()
    {
    for(int i=0; i<originalLength; i++)
    {

    realTD[i]= (Math.exp(-a*i*dw)) * realTD[i];
    imagTD[i]= (Math.exp(-a*i*dw)) * imagTD[i];
    }
    }*/

    //////###//////////////////////////////////////////////////////////////////////////////////////////////////////

    public void doFFT()
    {
    Fft fft = new Fft();
    double [][] input_fft = new double[2][originalLength];
    for(int i=0;i<input_fft[0].length;i++)
    {
    input_fft[0][i] = signal[i][0];
    input_fft[1][i] = signal[i][1];
    }

    double [][] estimate = fft.direct_1D_Estim_fft(input_fft);
    //double[][] output_fft = fft.calcFFTD(estimate,true);
    for (int i = 0; i < originalLength; i++)
    {
    real_fd[i] = estimate[0][i];
    imag_fd[i] = estimate[1][i];
    }
    }

    public int getPoint()
    {
    return originalLength;
    }
    //////###//////////////////////////////////////////////////////////////////////////////////////////////////////////

    public double geta()
    {
    return a;
    }

    public void seta(double a)
    {
    this.a = a;
    }

    public void doApodize()
    {
    Fft fft = new Fft();
    double [][] input_fft_ap = new double[2][originalLength];
    for(int i=0;i<input_fft_ap[0].length;i++)
    {
    d = 1/(a * dw);
    //double bell = (d*d)/(((Math.PI)*i*i) + d*d); // For Lorentzian
    //double bell = Math.exp((-i*i)/(2*d*d)); // For Gaussian
    double bell = Math.exp((i*i)/(2*d*d));
    //input_fft_ap[0][i] =(Math.exp(-a*i*dw))*realTD[i];
    //input_fft_ap[1][i] = (Math.exp(-a*i*dw))*imagTD[i];
    input_fft_ap[0][i] = bell*realTD[i];
    input_fft_ap[1][i] = bell*imagTD[i];
    }
    double [][] estimate_ap =
    fft.direct_1D_Estim_fft(input_fft_ap);
    for (int i = 0; i < originalLength; i++)
    {
    real[i] = estimate_ap[0][i];
    imag[i] = estimate_ap[1][i];
    }
    }

    //////###////////////////////////////////////////////////////////////////////////////////////////////////////////
    public double getPhi()
    {
    return phi;
    }

    public void setPhi(double phi)
    {
    this.phi = phi;
    }

    public void doPhase()
    {
    for(int i=0; i<originalLength; i++)
    {
    real[i]= (Math.cos(Math.toRadians(phi))) * real_fd[i] +
    (Math.sin(Math.toRadians(phi))) * imag_fd[i];
    imag[i]= -(Math.sin(Math.toRadians(phi))) * real_fd[i] +
    (Math.cos(Math.toRadians(phi))) * imag_fd[i];
    }
    }

    public double[][] getSignal()
    {
    return signal;
    }

    public double[] getReal()
    {
    return real;
    }

    public double[] getRealFID()
    {
    return realTD;
    }

    public double[] getImag()
    {
    return imag;
    }

    public double[] getImagFID()
    {
    return imagTD;
    }

    public int getoriginalLength()
    {
    return originalLength;
    }

    public double[] getRealSq()
    {
    double[] sq = new double[real.length];

    for (int i = 0; i < real.length; i++)
    sq[i] = Math.pow(real[i], 2.0);

    return sq;
    }

    public double[] getRealFIDSq()
    {
    double[] sq = new double[realTD.length];

    for (int i = 0; i < realTD.length; i++)
    sq[i] = Math.pow(realTD[i], 2.0);

    return sq;
    }

    public double[] getImagSq()
    {
    double[] sq = new double[imag.length];

    for (int i = 0; i < imag.length; i++)
    sq[i] = Math.pow(imag[i], 2.0);

    return sq;
    }

    public double[] getImagFIDSq()
    {
    double[] sq = new double[imagTD.length];

    for (int i = 0; i < imagTD.length; i++)
    sq[i] = Math.pow(imagTD[i], 2.0);

    return sq;
    }

    public double[] getMagnitude()
    {
    double[] mag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    mag[i] = Math.sqrt((Math.pow(real[i], 2.0) + Math.pow(imag[i],
    2.0)));

    return mag;
    }

    public double[] getMagnitudeFID()
    {
    double[] mag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    mag[i] = Math.sqrt((Math.pow(realTD[i], 2.0) + Math.pow(imagTD[i],
    2.0)));

    return mag;
    }

    public double[] getMagnitudeSq()
    {
    double[] mag = getMagnitude();
    double[] magsq = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    {
    magsq[i] = Math.pow(mag[i], 2.0);
    }

    return magsq;
    }

    public double[] getMagnitudeFIDSq()
    {
    double[] mag = getMagnitudeFID();
    double[] magsq = new double[originalLength];
    for (int i = 0; i < originalLength; i++) {
    magsq[i] = Math.pow(mag[i], 2.0);
    }

    return magsq;
    }


    public double[] getMagofMagSubRe()
    {
    double[] magmsr = new double[originalLength];
    double[] mag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    {
    mag[i] = Math.sqrt((Math.pow(real[i], 2.0) + Math.pow(imag[i],
    2.0)));
    magmsr[i] = Math.sqrt(Math.pow((mag[i] -real[i]), 2.0));
    }

    return magmsr;
    }

    public double[] getMagofMagSubReFID()
    {
    double[] magmsr = new double[originalLength];
    double[] mag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    {
    mag[i] = Math.sqrt((Math.pow(realTD[i], 2.0) + Math.pow(imagTD[i],
    2.0)));
    magmsr[i] = Math.sqrt(Math.pow((mag[i] - real[i]), 2.0));
    }

    return magmsr;
    }

    }
    /*
    * Created on Aug 26, 2004
    *
    */
    //package nmrui.mri;
    /*
    * @ Author Manoj Sarma
    *
    * @version 1.00
    */

    import javax.swing.JPanel;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.event.*;
    import java.io.*;

    public class GraphGE extends JPanel
    {
    // handelmouse hm;
    //int mouseX, mouseY;
    //String msg;
    int point = 0;
    double numsub = 0D;
    double xmax, ymax, xmin, ymin;

    double [] yVal;
    double[] yVal1;
    int[] yVal2;
    int[] yVal3;

    double[] xVal;
    int[] xVal1;
    int[] xVal2;

    String name;
    //XAxis xaxis;
    XAxismod xaxis;
    //YAxis yaxis;
    YAxismod yaxis;

    /////###//////////////////////////////////////////////////////////////////

    boolean tracking = false;
    boolean mouserelese = false;
    int startX = 0;
    int startY = 0;
    int currentX = 0;
    int currentY = 0;
    ////###/////////////////////////////////////////////////////////////////////

    /*
    * @param pt gives the length of the array
    * @param s gives the name of the GE File
    */
    GraphGE(int pt, String s)
    {
    point = pt;
    System.out.println("Point"+point);
    name = s;
    yVal = new double[point];
    yVal1 = new double[point];
    yVal2 = new int[point];
    yVal3 = new int[point];
    xVal = new double[point];
    xVal1 = new int[point];
    xVal2 = new int[point];

    xmax = ymax = xmin = ymin = 0.0;

    setBackground(new Color(255, 255, 255));
    setForeground(new Color(0, 0, 0));
    setOpaque(true);


    /*//###//////////////////////////////////////////////////////////////////////
    this.addMouseListener (new mousePressHandler());
    this.addMouseListener (new mouseReleaseHandler());
    this.addMouseMotionListener (new mouseMotionHandler());

    ///###/////////////////////////////////////////////////////////////////////*/
    }

    /*/###//////////////////////////////////////////////////////////////////////////
    void mouseMotion(int x, int y)
    {
    if(tracking)
    {
    currentX = x;
    currentY = y;
    }
    requestFocus();
    repaint();
    }

    void startMotion(int x, int y)
    {
    tracking = true;
    startX = x;
    startY = y;
    currentX = x+4;
    currentY = y+4; // nonzero size, may choose to ignore later
    requestFocus();
    repaint();
    }

    void stopMotion(int x, int y)
    {
    tracking = false; // no more rubber_rect
    // save final figure data for 'display' to draw
    currentX = x;
    currentY = y;
    requestFocus();
    repaint();
    }

    class mousePressHandler extends MouseAdapter
    {
    public void mousePressed (MouseEvent e)
    {
    int b, x, y;
    b = e.getButton();
    x = e.getX();
    y = e.getY();
    System.out.println("press x="+x+" y="+y+" b="+b); // debug
    print
    if(b==1) startMotion(x, y);
    }
    }

    class mouseReleaseHandler extends MouseAdapter
    {
    public void mouseReleased (MouseEvent e)
    {
    int b, x, y;
    b = e.getButton();
    x = e.getX();
    y = e.getY();
    System.out.println("release x="+x+" y="+y+" b="+b); //
    debug print
    System.out.println("Mouse Starting:"+(startX-80));
    System.out.println("Mouse Ending:"+(x-80));
    int sp = (int)((2047/900)*(startX-80));
    int ep = (int)((2047/900)*(x-80));// Check these instead of
    2047 put point
    //scx = new double[(ep-sp)+1];
    //scy = new double[(ep-sp)+1];
    //System.out.println(scx.length);
    for(int i= sp; i<=ep; i++)
    {
    //scx[i-sp] = ppm[i];
    //scy[i-sp] = real[i];
    //System.out.println(scx[i-sp]);
    }

    if(b==1) stopMotion(x, y);
    mouserelese = true;
    }
    }

    class mouseMotionHandler extends MouseMotionAdapter
    {
    public void mouseDragged (MouseEvent e)
    {
    int b, x, y;
    b = e.getButton();
    x = e.getX();
    y = e.getY();
    System.out.println("motion x="+x+" y="+y+" b="+b); // debug
    print
    mouseMotion(x, y);
    }
    }


    void rubberRect(Graphics g, int x0, int y0, int x1 , int y1)
    {
    // can apply to all figures
    // draw a rubber rectangle, mouse down, tracks mouse
    int x,y,x2,y2,x3,y3; // local coordinates
    x2=x0;
    x3=x1;
    if(x1<x0) {x2=x1; x3=x0;};
    y2=y0;
    y3=y1;
    if(y1<y0) {y2=y1; y3=y0;};
    g.setColor(Color.black);
    for(x=x2; x<x3-3; x=x+8)
    {
    g.drawLine(x, y0, x+4, y0);
    g.drawLine(x, y1, x+4, y1);
    }
    for(y=y2; y<y3-3; y=y+8)
    {
    g.drawLine(x0, y, x0, y+4);
    g.drawLine(x1, y, x1, y+4);
    }
    }
    ////////###////////////////////////////////////////////////////////////////////////*/


    public void paint(Graphics g)
    {
    g.setColor(Color.black);
    g.drawLine(80, 440, 800, 440);
    g.drawLine(80, 35, 80, 440);
    //new code
    //yaxis = new YAxis(this);
    //yaxis.displayY(g);
    xaxis = new XAxismod(point, numsub);
    yaxis = new YAxismod(ymax, ymin);

    //x-axis scale plotting
    xaxis.displayppm(g);

    //y-axis scale plotting
    yaxis.displayY(g);

    g.setColor(Color.blue);
    //if(tracking) rubberRect(g, startX, startY, currentX,
    currentY);
    for (int p = 0; p <(point-1); p++)
    {
    g.drawLine((xVal2[p]),yVal3[p],(xVal2[p + 1]),yVal3[p + 1]);
    }
    }

    public void update(Graphics g)
    {
    paintImmediately(0,0,800,500);
    paint(g);
    }
    /*
    * @param g The current graphics object context
    */
    private void drawMargins(Graphics g)
    {
    }
    /*
    * @param g the current graphics object context
    */
    private void drawValues(Graphics g)
    {
    }

    public void reDraw()
    {
    MinMax();
    scale();
    repaint();
    }

    public void clearValues()
    {

    for(int x = 0; x < point ; x++)
    {
    yVal1[x] = 0;
    yVal2[x] = 0;
    yVal3[x] = 0;
    xVal[x] = 0.0;
    xVal1[x] = 0;
    xVal2[x] = 0;
    }
    ymax = ymin = 0;
    xmax = xmin =0.0;
    }
    /*
    * @param arr the double array whose value is to be stored for y -
    axis
    */
    public void setValues(double[] arr)
    {
    for(int i=0;i<point;i++)
    yVal[i] = arr[i];

    for (int x = 0; x < point; x++)
    {
    xVal[x] = (double)x;
    }

    for (int l = 0; l < point; l++)
    {
    yVal1[l] = arr[l];
    }

    }

    public double gettrans()
    {
    return numsub;
    }
    public void settrans(double numsub)
    {
    this.numsub = numsub;
    //numb = numsub;
    }

    /*
    * @ Provides with the minimum and maximum values
    */
    private void MinMax()
    {
    ymin = ymax = yVal1[0];
    for (int i = 0; i < point; i++)
    {
    if (yVal1[i] > ymax)
    ymax = yVal1[i];
    if (yVal1[i] < ymin)
    ymin = yVal1[i];

    xmin = 0.0;
    xmax = 2047.0;
    }

    }
    /*
    * @ scales the array to screen size
    */
    private void scale() {
    for (int k = 0; k < point; k++) {
    yVal2[k] = (int) (((yVal1[k] - ymin) / (ymax - ymin)) * 400);
    xVal1[k] = (int) (((xVal[k] - xmin) / (xmax - xmin)) * 720);
    }

    for (int l = 0; l < point; l++)
    {
    yVal3[l] = 440 - yVal2[l];
    xVal2[l] = 80 + xVal1[l];
    }

    }

    public double[] getMarginY()
    {
    return yVal;
    }
    //new code
    /* public void start()
    {
    }
    class handelmouse extends MouseAdapter implements MouseMotionListener
    {
    public void mouseMoved(MouseEvent me)
    {
    mouseX = me.getX();
    mouseY = me.getY();
    repaint();
    reDraw();
    }
    public void mouseDragged(MouseEvent me)
    {
    }
    public void mousePressed(MouseEvent me)
    {

    }
    }*/

    }import java.awt.image.*;
    import java.awt.*;
    import java.util.*;
    import java.io.*;

    public class PeakSupres
    {
    GraphDataGE gd;
    int totalpoint = 2048;
    int point = 2048;
    //int point = 300, p =750;
    int pointarpk = point;
    //int pointarpk = 3;
    int iter = 15;
    int p = 0;
    int l= 0;
    int countloop = 0;
    double[] iterreal;
    double[] iterimag;
    double[] ppm;
    double ampl, dc, fr, ph;

    public PeakSupres(double[] realpart, double[] imagpart)
    {
    File fp = new File(".");
    String savepath = fp.getAbsolutePath();
    String foldername = "\\Result\\";
    try
    {
    PrintStream ps1 = new PrintStream(new
    FileOutputStream(savepath+foldername+"\\Out.log", true) ,true);
    System.setOut(ps1);
    PrintStream ps2 = new PrintStream(new
    FileOutputStream(savepath+foldername+"\\Error.txt", true) ,true);
    //Out.Err
    System.setErr(ps2);
    }
    catch(IOException e){};

    iterreal = new double[totalpoint];
    iterimag = new double[totalpoint];
    double x1=0, x2=0, x3=0, x4=0;
    double max, min, max1, min1, max2, min2;
    double[] real = new double[point];
    double[] imag = new double[point];
    double[] imag1 = new double[pointarpk];
    double[] R = new double[pointarpk];
    double[] Rdesh = new double[pointarpk];
    double[] real1 = new double[pointarpk];
    double[] qt = new double[pointarpk];
    double[] ee = new double[pointarpk];
    double[] f = new double[pointarpk];
    double[] g = new double[pointarpk];
    double[] h= new double[pointarpk];
    double[] realdiffsq = new double[pointarpk];
    double[] realdiffsqsum = new double[iter];
    double[] realsq = new double[pointarpk];

    double[] itRp = new double[totalpoint];
    double[] itIp = new double[totalpoint];
    double[] itratpeaks = new double[totalpoint];
    double[] itiatpeaks = new double[totalpoint];

    double[] I = new double[pointarpk];
    double[] Idesh = new double[pointarpk];
    double[] imag2 = new double[point];
    double[] imag3 = new double[point];
    double[] imagdiffsq = new double[pointarpk];
    double[] realimagdiffsqadd = new double[pointarpk];
    double[] imagdiff = new double[pointarpk];
    double[] imagsq = new double[pointarpk];
    double[] imagdiffsqsum = new double[iter];

    double[] edevwamp = new double[pointarpk];
    double[] edevwdc = new double[pointarpk];
    double[] edevwfreq = new double[pointarpk];
    double[] edevwphase = new double[pointarpk];
    double[] fdevwamp = new double[pointarpk];
    double[] fdevwdc = new double[pointarpk];
    double[] fdevwfreq = new double[pointarpk];
    double[] fdevwphase = new double[pointarpk];
    double[] gdevwamp = new double[pointarpk];
    double[] gdevwdc = new double[pointarpk];
    double[] gdevwfreq = new double[pointarpk];
    double[] gdevwphase = new double[pointarpk];
    double[] hdevwamp = new double[pointarpk];
    double[] hdevwdc = new double[pointarpk];
    double[] hdevwfreq = new double[pointarpk];
    double[] hdevwphase = new double[pointarpk];

    double[] amplp = new double[iter+1];
    double[] dcp = new double[iter+1];
    double[] frdp = new double[iter+1];
    double[] phasp = new double[iter+1];

    double[] Fdesh = new double[iter];
    double[] FuncE = new double[iter];
    double[] FuncF = new double[iter];
    double[] FuncG = new double[iter];
    double[] FuncH = new double[iter];
    double[] deltaamp = new double[iter];
    double[] deltadcp = new double[iter];
    double[] deltafrd = new double[iter];
    double[] deltaphas = new double[iter];

    double[] DevFuncE = new double[4];
    double[] DevFuncF = new double[4];
    double[] DevFuncG = new double[4];
    double[] DevFuncH= new double[4];
    double[][] J = new double[4][4];
    double[][] Func = new double[4][1];
    double[][] b = new double[4][1];

    double[] Fdeshexp = new double[iter+1];
    double[] ppm = new double[totalpoint];
    double[] freq = new double[totalpoint];

    double[] output = new double[4];
    double[] realdata = new double[realpart.length];
    double[] imagdata = new double[realpart.length];

    /*if (data != null)
    {
    gd.addSignals(data);
    gd.doPhaseFID();
    gd.doFFT();
    gd.doPhase();
    }
    else
    {
    System.out.println("Cannot Proceed\n System Shall Exit");
    System.exit(0);
    }*/


    /*public GraphDataGE getGraphDataGE()
    {
    return this.gd;
    }*/

    //double[] realdata = gd.getReal();
    //double[] imagdata = gd.getImag();
    for(int i = 0 ; i <realpart.length; i++)
    {
    realdata[i] = realpart[i];
    imagdata[i] = imagpart[i];
    }

    File fp1 = new File(".");
    String path = fp1.getAbsolutePath();


    mainfileread mffr = new mainfileread("C:\\Documents and
    Settings\\manoj\\Desktop\\ApodizeMRS\\Result\\nfreq.txt");
    freq = mffr.returnarray();


    mainfileread mfp = new mainfileread("C:\\Documents and
    Settings\\manoj\\Desktop\\ApodizeMRS\\Result\\nppm.txt");
    ppm = mfp.returnarray();

    for(int i = 0 ; i <point; i++)
    {
    real[i] = realdata[i+p];
    imag[i] = imagdata[i+p];
    }
    for(int i = 0 ; i <point; i++)
    {
    real[i] = realdata[i+p];
    imag[i] = imagdata[i+p];
    }

    max_min mm = new max_min();
    max = mm.getMax(real);
    min = mm.getMin(real);

    int count=0;
    int w=0, w1=0, w2;
    double frd=0.0, length;
    for(int i = 0 ; i < point; i++)
    {
    if(real[i] == max)
    {
    w= count+p;
    System.out.println(" array no" + " " +w);
    System.out.println("imaginary" + " " + imag[count]);
    frd = freq[count+p];
    System.out.println("Height" + " " + max);
    System.out.println("Frequency" + " " + frd);
    }
    count++;
    }

    ArrayList X = new ArrayList();
    ArrayList Y = new ArrayList();
    System.out.println("");
    double frahh=0.0, frahh1=0.0, frahh2=0.0;

    for(int i = 0 ; i <point-1; i++)
    {
    if(((real[i] - (max/2))>0) && ((real[i+1] - (max/2))<0))
    {
    X.add(new Integer(Math.abs(w-(i+p))));
    }

    if(((real[i] - (max/2))<0) && ((real[i+1] - (max/2))>0))
    {
    Y.add(new Integer(Math.abs(w-(i+p))));
    }
    }
    //**********************************************************************************************
    Object[] X1 = X.toArray();
    int min3 =((Integer) X1[0]).intValue();
    for(int i = 0 ; i <X1.length;i++)
    {
    if( ((Integer) X1[i]).intValue()<min3)
    min3 = ((Integer) X1[i]).intValue();
    }

    //***********************************************************************************************
    int r = X1.length;
    double frahh5 = 0.0;
    for(int i = 0 ; i <point-1; i++)
    {
    if(((real[i] - (max/2D))>0) && ((real[i+1] - (max/2D))<0) &&
    (Math.abs(w-(i+p))) == min3)
    {
    w1 = i+p;
    frahh5 = (freq[i+p] + freq[i+p+1])/2D;
    System.out.println(" array no1" + " " + w1 + " " + " array
    no2" + " " + (w1+1));
    }
    }

    //************************************************************************************************
    Object[] Y1 = Y.toArray();
    int min4 =((Integer) Y1[0]).intValue();
    for(int i = 0 ; i <Y1.length;i++)
    {
    if( ((Integer) Y1[i]).intValue()<min4)
    min4 = ((Integer) Y1[i]).intValue();
    }
    //************************************************************************************************
    int r1 = Y1.length;
    double frahh6 = 0.0;
    for(int i = 0 ; i <point-1; i++)
    {
    if(((real[i] - (max/2))<0) && ((real[i+1] - (max/2))>0) &&
    (Math.abs(w-(i+p))) == min4)
    {
    w2 = i+p;
    frahh6 = (freq[i+p] + freq[i+p+1])/2D;
    System.out.println(" array no1" + " " + w2 + " " + " array
    no2" + " " + (w2 +1));
    }
    }

    //************************************************************************************************
    double wahh = Math.abs(frahh5 - frahh6);
    System.out.println("FWHM" + " " + wahh);
    length = max;
    System.out.println("length" + " " + length);

    double dc = wahh * (Math.PI) ;
    double ampl = length * dc;
    System.out.println("DecayConst" + " " + dc);
    System.out.println("Amplitude" + " " + ampl);
    System.out.println("Frequency" + " " + frd);

    amplp[0] = ampl;
    dcp[0] = dc;
    //frdp[0] = -frd;
    frdp[0] = frd;
    //phasp[0] = Math.toRadians(90.0);
    phasp[0] = 0.0;

    for(int i=0; i<iter ; i++ )
    {
    Fdesh[i]= 0.0;
    FuncE[i] = 0.0;
    for(int m=0; m<4; m++)
    {
    DevFuncE[m] = 0.0;
    }

    FuncF[i] = 0.0;
    for(int m=0; m<4; m++)
    {
    DevFuncF[m] = 0.0;
    }

    FuncG[i] = 0.0;
    for(int m=0; m<4; m++)
    {
    DevFuncG[m] = 0.0;
    }

    FuncH[i] = 0.0;
    for(int m=0; m<4; m++)
    {
    DevFuncH[m] = 0.0;
    }


    for(int k=0; k< pointarpk; k++)
    {
    //int j = k + w-p-24;
    int j = k ;
    //int j = k + w-p-((pointarpk-1)/2);
    real1[k] = real[j+l];
    realsq[k] = real[j+l]*real[j+l];
    imag1[k] = imag[j+l];
    imagsq[k] = imag[j+l] * imag[j+l];
    double
    devRwrtamp=0.0,devRwrtdc=0.0,devRwrtfreq=0.0,devIwrtamp=0.0,devIwrtdc=0.0,devIwrtfreq=0.0;
    double term1=0.0, term2=0.0, term3=0.0, term22=0.0;
    //term1 = 2.0*(Math.PI)*(frdp[i] + freq[j+p]);
    term1 = 2.0*(Math.PI)*(frdp[i] - freq[j+p]);
    term2 = term1 * term1;
    term3 = ((dcp[i] * dcp[i]) + term2) * ((dcp[i] * dcp[i]) +
    term2);
    term22 = ((dcp[i]* dcp[i]) + term2) * ((dcp[i] * dcp[i]) +
    term2) * ((dcp[i] * dcp[i]) + term2);
    R[k] = (amplp[i]*dcp[i])/((dcp[i] * dcp[i]) + term2);
    devRwrtamp= dcp[i]/((dcp[i] * dcp[i]) + term2);
    double term4=0.0,term5=0.0;
    term4 = amplp[i]/((dcp[i] * dcp[i]) + term2);
    term5 = (2.0*amplp[i]*dcp[i] * dcp[i])/term3;
    devRwrtdc = term4 - term5;
    devRwrtfreq =
    -(4.0*(Math.PI)*amplp[i]*dcp[i]*term1)/term3;

    I[k] = (amplp[i]*term1)/((dcp[i] * dcp[i]) + term2);
    devIwrtamp = term1/((dcp[i] * dcp[i]) + term2);
    devIwrtdc = -(2.0*amplp[i]*dcp[i]*term1)/term3;
    double term6=0.0,term7=0.0;
    term6 = (2.0*(Math.PI)*amplp[i])/((dcp[i] * dcp[i]) + term2);
    term7 = (4.0*(Math.PI)*amplp[i]*term2)/term3;
    devIwrtfreq = term6 - term7;

    Rdesh[k]= ((Math.cos(phasp[i])) * R[k]) - ((Math.sin(phasp[i]))
    * I[k]);
    realdiffsq[k] = (real1[k] - Rdesh[k]) * (real1[k] - Rdesh[k]);
    realdiffsqsum[i] = realdiffsqsum[i] + realdiffsq[k];

    double
    devrealwrtamp=0.0,devrealwrtdc=0.0,devrealwrtfreq=0.0,
    devrealwrtphase=0.0;
    devrealwrtamp = ((Math.cos(phasp[i])) * devRwrtamp) -
    ((Math.sin(phasp[i])) * devIwrtamp);
    devrealwrtdc = ((Math.cos(phasp[i])) * devRwrtdc) -
    ((Math.sin(phasp[i])) * devIwrtdc);
    devrealwrtfreq = ((Math.cos(phasp[i])) * devRwrtfreq) -
    ((Math.sin(phasp[i])) * devIwrtfreq);
    devrealwrtphase = -((Math.sin(phasp[i])) * R[k]) -
    ((Math.cos(phasp[i])) * I[k]);

    Idesh[k]= ((Math.sin(phasp[i])) * R[k]) +
    ((Math.cos(phasp[i])) * I[k]);
    imagdiff[k]= (imag1[k] - Idesh[k]);
    imagdiffsq[k] = (imag1[k] - Idesh[k]) * (imag1[k] - Idesh[k]);
    imagdiffsqsum[i] = imagdiffsqsum[i] + imagdiffsq[k];


    double devimagwrtamp=0.0,devimagwrtdc=0.0,devimagwrtfreq=0.0,
    devimagwrtphase=0.0;
    devimagwrtamp = ((Math.sin(phasp[i])) * devRwrtamp) +
    ((Math.cos(phasp[i])) * devIwrtamp);
    devimagwrtdc = ((Math.sin(phasp[i])) * devRwrtdc) +
    ((Math.cos(phasp[i])) * devIwrtdc);
    devimagwrtfreq= ((Math.sin(phasp[i])) * devRwrtfreq) +
    ((Math.cos(phasp[i])) * devIwrtfreq);
    devimagwrtphase = ((Math.cos(phasp[i])) * R[k]) -
    ((Math.sin(phasp[i])) * I[k]);

    realimagdiffsqadd[k] = realdiffsq[k] + imagdiffsq[k];
    Fdesh[i] = Fdesh[i] + realimagdiffsqadd[k];

    ee[k] = ((real1[k] - Rdesh[k])*(-devrealwrtamp)) + ((imag1[k] -
    Idesh[k])*(-devimagwrtamp));
    FuncE[i] = FuncE[i] + ee[k];

    f[k] = ((real1[k] - Rdesh[k])*(-devrealwrtdc)) + ((imag1[k] -
    Idesh[k])*(-devimagwrtdc));
    FuncF[i] = FuncF[i] + f[k];

    g[k] = ((real1[k] - Rdesh[k])*(-devrealwrtfreq)) + ((imag1[k] -
    Idesh[k])*(-devimagwrtfreq));
    FuncG[i] = FuncG[i] + g[k];

    h[k] = ((real1[k] - Rdesh[k])*(-devrealwrtphase)) + ((imag1[k] -
    Idesh[k])*(-devimagwrtphase));
    FuncH[i] = FuncH[i] + h[k];
    /**************************************************************************************************************************
    Differentiating Functions E with respect to ampl., dc, freq,
    and phase

    ***************************************************************************************************************************/
    edevwamp[k] = ((devrealwrtamp * devrealwrtamp) +
    (devimagwrtamp * devimagwrtamp));
    DevFuncE[0] = DevFuncE[0] + edevwamp[k];

    double
    term8=0.0,term9=0.0,Rdeshddcamp=0.0,Ideshddcamp=0.0,term10=0.0,
    term11=0.0;
    term8 = (1.0/((dcp[i] * dcp[i]) + term2))-((2.0* dcp[i]
    * dcp[i])/term3);
    term9 = -(2.0*dcp[i]*term1)/term3;
    Rdeshddcamp = ((Math.cos(phasp[i])) * term8) -
    ((Math.sin(phasp[i])) * term9);
    Ideshddcamp = ((Math.sin(phasp[i])) * term8) +
    ((Math.cos(phasp[i])) * term9);
    term10 = ((devrealwrtdc*devrealwrtamp)-((real1[k] -
    Rdesh[k]) * Rdeshddcamp));
    term11 = ((devimagwrtdc * devimagwrtamp)-((imag1[k] -
    Idesh[k]) * Ideshddcamp));
    edevwdc[k] = term10 + term11;
    DevFuncE[1]= DevFuncE[1] + edevwdc[k];

    double
    term12=0.0,term13=0.0,Rdeshdfrqamp=0.0,Ideshdfrqamp=0.0,
    term14=0.0,term15=0.0;
    term12 = -(4.0*(Math.PI)*dcp[i]*term1)/term3;
    term13 = ((2.0*(Math.PI))/((dcp[i] * dcp[i]) + term2))
    - ((4.0*(Math.PI)*term2)/term3);
    Rdeshdfrqamp = ((Math.cos(phasp[i])) * term12) -
    ((Math.sin(phasp[i])) * term13);
    Ideshdfrqamp = ((Math.sin(phasp[i])) * term12) +
    ((Math.cos(phasp[i])) * term13);
    term14 = ((devrealwrtfreq*devrealwrtamp)-((real1[k] -
    Rdesh[k]) * Rdeshdfrqamp));
    term15 = ((devimagwrtfreq*devimagwrtamp)-((imag1[k] -
    Idesh[k]) * Ideshdfrqamp));
    edevwfreq[k] = term14 + term15;
    DevFuncE[2] = DevFuncE[2] + edevwfreq[k];

    double
    Rdeshdphasamp=0.0,Ideshdwphasamp=0.0,term16=0.0,term17=0.0;
    Rdeshdphasamp = -((Math.sin(phasp[i])) * devRwrtamp) -
    ((Math.cos(phasp[i])) * devIwrtamp);
    Ideshdwphasamp = ((Math.cos(phasp[i])) * devRwrtamp) -
    ((Math.sin(phasp[i])) * devIwrtamp);
    term16 = (devrealwrtphase*devrealwrtamp)-((real1[k] -
    Rdesh[k]) * Rdeshdphasamp);
    term17 = (devimagwrtphase*devimagwrtamp)-((imag1[k] -
    Idesh[k]) * Ideshdwphasamp);
    edevwphase[k] = term16 + term17;
    DevFuncE[3] = DevFuncE[3] + edevwphase[k];

    /**************************************************************************************************************************
    Differentiating Functions F with respect to ampl., dc, freq, and
    phase

    ***************************************************************************************************************************/
    double
    term18=0.0,term19=0.0,Rdeshdampdc=0.0,Ideshdampdc=0.0,term20=0.0,term21=0.0;
    term18 = (1.0/((dcp[i] * dcp[i]) + term2)) -
    ((2.0*dcp[i]*dcp[i])/term3);
    term19 = -(2.0*dcp[i]*term1)/term3;
    Rdeshdampdc = ((Math.cos(phasp[i])) * term18) -
    ((Math.sin(phasp[i])) * term19);
    Ideshdampdc = ((Math.sin(phasp[i])) * term18 ) +
    ((Math.cos(phasp[i])) * term19);
    term20 = (devrealwrtamp*devrealwrtdc)-((real1[k] -
    Rdesh[k]) * Rdeshdampdc);
    term21 = (devimagwrtamp*devimagwrtdc)-((imag1[k] -
    Idesh[k]) * Ideshdampdc);
    fdevwamp[k] = term20 + term21;
    DevFuncF[0] = DevFuncF[0] + fdevwamp[k];

    double
    term23=0.0,term24=0.0,Rdeshddcdc=0.0,Ideshddcdc=0.0,term25=0.0,term26=0.0;
    term23 = -((6.0*amplp[i]*dcp[i])/term3) +
    ((8.0*amplp[i]*dcp[i]*dcp[i]*dcp[i])/term22);
    term24 = -((2.0*amplp[i]*term1)/term3) +
    ((8.0*amplp[i]*term1*dcp[i]*dcp[i])/term22);
    Rdeshddcdc = ((Math.cos(phasp[i])) * term23) -
    ((Math.sin(phasp[i])) * term24);
    Ideshddcdc = ((Math.sin(phasp[i])) * term23 ) +
    ((Math.cos(phasp[i])) * term24);
    term25 = (devrealwrtdc*devrealwrtdc)-((real1[k] - Rdesh[k]) *
    Rdeshddcdc );
    term26 = (devimagwrtdc*devimagwrtdc)-((imag1[k] - Idesh[k]) *
    Ideshddcdc);
    fdevwdc[k] = term25 + term26;
    DevFuncF[1] = DevFuncF[1] + fdevwdc[k];

    double
    term27=0.0,term28=0.0,Rdeshdfrqdc=0.0,Ideshdfrqdc=0.0,term29=0.0,term30=0.0;
    term27 = -((4.0*(Math.PI)*amplp[i]*term1)/term3) +
    ((16.0*(Math.PI)*amplp[i]*dcp[i]*dcp[i]*term1)/term22);
    term28 = -((4.0*(Math.PI)*amplp[i]*dcp[i])/term3) +
    ((16.0*(Math.PI)*amplp[i]*dcp[i]*term2)/term22);
    Rdeshdfrqdc = ((Math.cos(phasp[i])) * term27) -
    ((Math.sin(phasp[i])) * term28);
    Ideshdfrqdc = ((Math.sin(phasp[i])) * term27) +
    ((Math.cos(phasp[i])) * term28);
    term29 = (devrealwrtfreq*devrealwrtdc)-((real1[k] - Rdesh[k]) *
    Rdeshdfrqdc);
    term30 = (devimagwrtfreq*devimagwrtdc)-((imag1[k] - Idesh[k]) *
    Ideshdfrqdc);
    fdevwfreq[k] = term29 + term30;
    DevFuncF[2] = DevFuncF[2] + fdevwfreq[k];

    double
    Rdeshdphasdc=0.0,Ideshdphasdc=0.0,term31=0.0,term32=0.0;
    Rdeshdphasdc = -((Math.sin(phasp[i])) * devRwrtdc) -
    ((Math.cos(phasp[i])) * devIwrtdc);
    Ideshdphasdc = ((Math.cos(phasp[i])) * devRwrtdc) -
    ((Math.sin(phasp[i])) * devIwrtdc);
    term31 = (devrealwrtphase*devrealwrtdc)-((real1[k] - Rdesh[k]) *
    Rdeshdphasdc);
    term32 = (devimagwrtphase*devimagwrtdc)-((imag1[k] - Idesh[k]) *
    Ideshdphasdc);
    fdevwphase[k] = term31 + term32;
    DevFuncF[3] = DevFuncF[3] + fdevwphase[k];


    /**************************************************************************************************************************
    Differentiating Functions G with respect to ampl, dc, freq,
    and phase

    ***************************************************************************************************************************/
    double
    term33=0.0,term34=0.0,Rdeshdampfrq=0.0,Ideshdampfrq=0.0,term35=0.0,term36=0.0;
    term33 = -(4.0*(Math.PI)*dcp[i]*term1)/term3;
    term34 = ((2.0*(Math.PI))/((dcp[i] * dcp[i]) + term2))
    - ((4.0*(Math.PI)*term2)/term3);
    Rdeshdampfrq = ((Math.cos(phasp[i])) * term33) -
    ((Math.sin(phasp[i])) * term34);
    Ideshdampfrq = ((Math.sin(phasp[i])) * term33) +
    ((Math.cos(phasp[i])) * term34);
    term35 = (devrealwrtamp*devrealwrtfreq)-((real1[k] - Rdesh[k]) *
    Rdeshdampfrq);
    term36 = (devimagwrtamp*devimagwrtfreq)-((imag1[k] - Idesh[k]) *
    Ideshdampfrq);
    gdevwamp[k] = term35 + term36;
    DevFuncG[0] = DevFuncG[0] + gdevwamp[k];

    double
    term37=0.0,term38=0.0,Rdeshddcfrq=0.0,Ideshddcfrq=0.0,term39=0.0,term40=0.0;
    term37 = -((4.0*(Math.PI)*amplp[i]*term1)/term3) +
    ((16.0*(Math.PI)*amplp[i]*dcp[i] * dcp[i]*term1)/term22);
    term38 = -((4.0*(Math.PI)*amplp[i]*dcp[i])/term3) +
    ((16.0*(Math.PI)*amplp[i]*dcp[i] *term2)/term22);
    Rdeshddcfrq = ((Math.cos(phasp[i])) * term37) -
    ((Math.sin(phasp[i])) * term38);
    Ideshddcfrq = ((Math.sin(phasp[i])) * term37) +
    ((Math.cos(phasp[i])) * term38);
    term39 = (devrealwrtdc*devrealwrtfreq)-((real1[k] - Rdesh[k]) *
    Rdeshddcfrq);
    term40 = (devimagwrtdc*devimagwrtfreq)-((imag1[k] - Idesh[k]) *
    Ideshddcfrq);
    gdevwdc[k] = term39 + term40;
    DevFuncG[1] = DevFuncG[1] + gdevwdc[k];

    double
    term41=0.0,term42=0.0,Rdeshdfrqfrq=0.0,Ideshdfrqfrq=0.0,term43=0.0,term44=0.0;
    term41 =
    -((8.0*(Math.PI)*(Math.PI)*amplp[i]*dcp[i])/term3) +
    ((32.0*(Math.PI)*(Math.PI)*amplp[i]*dcp[i]*term2)/term22);
    term42 = -((24.0*amplp[i]*term1*(Math.PI)*(Math.PI))/term3) +
    ((32.0*(Math.PI)*(Math.PI)*amplp[i]*term1*term1*term1)/term22);
    Rdeshdfrqfrq = ((Math.cos(phasp[i])) * term41) -
    ((Math.sin(phasp[i])) * term42);
    Ideshdfrqfrq = ((Math.sin(phasp[i])) * term41) +
    ((Math.cos(phasp[i])) * term42);
    term43 = (devrealwrtfreq*devrealwrtfreq)-((real1[k] - Rdesh[k]) *
    Rdeshdfrqfrq);
    term44 = (devimagwrtfreq*devimagwrtfreq)-((imag1[k] - Idesh[k]) *
    Ideshdfrqfrq);
    gdevwfreq[k] = term43 + term44;
    DevFuncG[2] = DevFuncG[2] + gdevwfreq[k];

    double
    Rdeshdphasfrq=0.0,Ideshdphasfrq=0.0,term45=0.0,term46=0.0;
    Rdeshdphasfrq = -((Math.sin(phasp[i])) * devRwrtfreq) -
    ((Math.cos(phasp[i])) * devIwrtfreq);
    Ideshdphasfrq = ((Math.cos(phasp[i])) * devRwrtfreq) -
    ((Math.sin(phasp[i])) * devIwrtfreq);
    term45 = (devrealwrtphase*devrealwrtfreq)-((real1[k] - Rdesh[k]) *
    Rdeshdphasfrq);
    term46 = (devimagwrtphase*devimagwrtfreq)-((imag1[k] - Idesh[k]) *
    Ideshdphasfrq);
    gdevwphase[k] = term45 + term46;
    DevFuncG[3] = DevFuncG[3] + gdevwphase[k];


    /**************************************************************************************************************************
    Differentiating Functions H with respect to ampl., dc, freq,
    and phase

    **************************************************************************************************************************/
    double
    Rdeshdampphas=0.0,Ideshdampphas=0.0,term47=0.0,term48=0.0;
    Rdeshdampphas = -((Math.sin(phasp[i])) * devRwrtamp) -
    ((Math.cos(phasp[i])) * devIwrtamp);
    Ideshdampphas = ((Math.cos(phasp[i])) * devRwrtamp) -
    ((Math.sin(phasp[i])) * devIwrtamp);
    term47 = (devrealwrtamp*devrealwrtphase)-((real1[k] - Rdesh[k])
    * Rdeshdampphas);
    term48 = (devimagwrtamp*devimagwrtphase)-((imag1[k] - Idesh[k])
    * Ideshdampphas);
    hdevwamp[k] = term47 + term48;
    DevFuncH[0] = DevFuncH[0] + hdevwamp[k];

    double
    Rdeshddcphas=0.0,Ideshddcphas=0.0,term49=0.0,term50=0.0;
    Rdeshddcphas = -((Math.sin(phasp[i])) * devRwrtdc) -
    ((Math.cos(phasp[i])) * devIwrtdc);
    Ideshddcphas = ((Math.cos(phasp[i])) * devRwrtdc) -
    ((Math.sin(phasp[i])) * devIwrtdc);
    term49 = (devrealwrtdc*devrealwrtphase)-((real1[k] - Rdesh[k]) *
    Rdeshddcphas);
    term50 = (devimagwrtdc*devimagwrtphase)-((imag1[k] - Idesh[k]) *
    Ideshddcphas);
    hdevwdc[k] = term49 + term50;
    DevFuncH[1] = DevFuncH[1] + hdevwdc[k];

    double
    Rdeshdfrqphas=0.0,Ideshdfrqphas=0.0,termpointarpk=0.0,term52=0.0;
    Rdeshdfrqphas = -((Math.sin(phasp[i])) * devRwrtfreq) -
    ((Math.cos(phasp[i])) * devIwrtfreq);
    Ideshdfrqphas = ((Math.cos(phasp[i])) * devRwrtfreq) -
    ((Math.sin(phasp[i])) * devIwrtfreq);
    termpointarpk = (devrealwrtfreq*devrealwrtphase)-((real1[k] -
    Rdesh[k]) * Rdeshdfrqphas);
    term52 = (devimagwrtfreq*devimagwrtphase)-((imag1[k] - Idesh[k]) *
    Ideshdfrqphas);
    hdevwfreq[k] = termpointarpk + term52;
    DevFuncH[2] = DevFuncH[2] + hdevwfreq[k];

    double
    Rdeshdphasphas=0.0,Ideshdphasphas=0.0,term53=0.0,term54=0.0;
    Rdeshdphasphas = -((Math.cos(phasp[i])) * R[k]) +
    ((Math.sin(phasp[i])) * I[k]);
    Ideshdphasphas = -((Math.sin(phasp[i])) * R[k]) -
    ((Math.cos(phasp[i])) * I[k]);
    term53 = (devrealwrtphase*devrealwrtphase)-((real1[k] - Rdesh[k]) *
    Rdeshdphasphas);
    term54 = (devimagwrtphase*devimagwrtphase)-((imag1[k] - Idesh[k]) *
    Ideshdphasphas);
    hdevwphase[k] = term53 + term54;
    DevFuncH[3] = DevFuncH[3] + hdevwphase[k];
    }

    Fdeshexp[0] = 100000000000000000000000D;
    Fdeshexp[i+1] = Fdesh[i];

    if(Fdeshexp[i+1]>= Fdeshexp[i])
    break;
    for(int m=0; m<1; m++)
    {
    for(int n=0; n<4; n++)
    {
    J[m][n] = DevFuncE[n];
    J[m+1][n] = DevFuncF[n];
    J[m+2][n] = DevFuncG[n];
    J[m+3][n] = DevFuncH[n];
    }
    }

    Func[0][0] = -FuncE[i];
    Func[1][0] = -FuncF[i];
    Func[2][0] = -FuncG[i];
    Func[3][0] = -FuncH[i];

    double[][] delta1 = new double[4][4];
    double[][] delta2 = new double[4][4];
    double[][] delta3 = new double[4][4];
    double[][] delta4 = new double[4][4];

    for(int m=0; m<4; m++)
    {
    for(int n=0; n<1; n++)
    {
    delta1[m][n] = Func[m][n];
    delta1[m][n+1] = J[m][n+1];
    delta1[m][n+2] = J[m][n+2];
    delta1[m][n+3] = J[m][n+3];
    }
    }

    for(int m=0; m<4; m++)
    {
    for(int n=0; n<1; n++)
    {
    delta2[m][n] = J[m][n];
    delta2[m][n+1] = Func[m][n];
    delta2[m][n+2] = J[m][n+2];
    delta2[m][n+3] = J[m][n+3];
    }
    }

    for(int m=0; m<4; m++)
    {
    for(int n=0; n<1; n++)
    {
    delta3[m][n] = J[m][n];
    delta3[m][n+1] = J[m][n+1];
    delta3[m][n+2] = Func[m][n];
    delta3[m][n+3] = J[m][n+3];
    }
    }

    for(int m=0; m<4; m++)
    {
    for(int n=0; n<1; n++)
    {
    delta4[m][n] = J[m][n];
    delta4[m][n+1] = J[m][n+1];
    delta4[m][n+2] = J[m][n+2];
    delta4[m][n+3] = Func[m][n];
    }
    }


    Determinant4 de1 = new Determinant4(J);
    double determinant1 = de1.returvalue();

    Determinant4 de2 = new Determinant4(delta1);
    double determinant2 = de2.returvalue();

    Determinant4 de3 = new Determinant4(delta2);
    double determinant3 = de3.returvalue();

    Determinant4 de4 = new Determinant4(delta3);
    double determinant4 = de4.returvalue();

    Determinant4 de5 = new Determinant4(delta4);
    double determinant5 = de5.returvalue();

    deltaamp[i] = determinant2/determinant1;
    deltadcp[i] = determinant3/determinant1;
    deltafrd[i] = determinant4/determinant1;
    deltaphas[i] = determinant5/determinant1;

    amplp[i+1] = amplp[i] + deltaamp[i];
    dcp[i+1] = dcp[i] + deltadcp[i];
    frdp[i+1] = frdp[i] + deltafrd[i];
    phasp[i+1] = phasp[i] + deltaphas[i];

    x1= amplp[i+1];
    x2 = dcp[i+1];
    x3 = frdp[i+1];
    x4 = phasp[i+1];
    countloop++;
    }

    for(int s=0; s<totalpoint; s++)
    {
    double term55 = 0.0, term56 = 0.0;
    //term55 = 2.0*(Math.PI)*(frdp[i+1] + freq[s]);
    term55 = 2.0*(Math.PI)*(x3 - freq[s]);
    term56 = term55 * term55;
    itRp[s] = (x1 * x2)/((x2 * x2) + term56);
    itIp[s] = (x1 * term55)/((x2 * x2) + term56);
    itratpeaks[s]= ((Math.cos(x4)) * itRp[s]) - ((Math.sin(x4)) *
    itIp[s]);
    itiatpeaks[s]= ((Math.sin(x4)) * itRp[s]) + ((Math.cos(x4)) *
    itIp[s]);
    iterreal[s] = (realdata[s] - itratpeaks[s]);
    iterimag[s] = (imagdata[s] - itiatpeaks[s]);
    }

    System.out.println("Loop Complete: " + countloop);

    output[0]= x1;
    output[1]= x2;
    output[2]= x3;
    output[3]= x4;


    fileHandling fw = new fileHandling();
    fw.filewrite(savepath, iterreal,"iterreal",foldername);
    fw.filewrite(savepath, iterimag,"iterimag",foldername);
    fw.filewrite(savepath, output,"Output",foldername);
    }

    public double[] getpsreal()
    {
    return iterreal;
    }

    public double[] getpsimag()
    {
    return iterimag;
    }

    }//package views;

    import java.awt.BorderLayout;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Color;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import java.util.Hashtable;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSlider;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import java.io.File;
    import javax.swing.text.NumberFormatter;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.beans.*;
    //import java.awt.*;
    //import java.awt.event.*;
    //import nmrui.mri.*;

    /**
    * @author Manoj Sarma
    *
    * @version 1.00
    */
    public class Apodizeview extends JInternalFrame
    {

    JSlider apodize;
    Hashtable table;
    JPanel panel;
    JLabel lapodize;
    JFormattedTextField textField;
    ChangeListener cl;
    PropertyChangeListener pl;
    PeakContainer pc;

    /**
    * @param title
    * @param pc
    */
    public Apodizeview(String title,PeakContainer pc)
    {
    super(title);
    this.pc = pc;
    panel = new JPanel(new GridBagLayout());
    GridBagConstraints gridbagconstraints = new GridBagConstraints();
    gridbagconstraints.fill = 2;
    lapodize = new JLabel("Apodize (Hz): ");
    //lapodize = new JLabel("Zero order apodize (deg): ", JLabel.CENTER);
    gridbagconstraints.gridx = 1;
    gridbagconstraints.gridy = 1;
    gridbagconstraints.gridwidth = 1;
    gridbagconstraints.gridheight = 1;
    gridbagconstraints.weightx = 1.0D;
    gridbagconstraints.weighty = 1.0D;
    panel.add(lapodize, gridbagconstraints);
    //panel.add(lapodize);
    panel.setBackground(Color.white);
    //apodize = new JSlider(JSlider.HORIZONTAL,0,400,0);
    apodize = new JSlider(0, 0, 500, 0);
    table = new Hashtable();
    table.put(new Integer(0),new JLabel("0"));
    table.put(new Integer(100),new JLabel("100"));
    table.put(new Integer(200),new JLabel("200"));
    table.put(new Integer(300),new JLabel("300"));
    table.put(new Integer(400),new JLabel("400"));
    apodize.setLabelTable(table);
    apodize.setPaintLabels(true);
    //apodize.setMinorTickSpacing(300);
    //apodize.setMajorTickSpacing(900);
    apodize.setMinorTickSpacing(1);
    apodize.setMajorTickSpacing(5);
    //apodize.setPaintTicks(false);
    apodize.setPaintTicks(true);
    apodize.setBackground(Color.white);
    apodize.addChangeListener(new ApodizeListener(this));
    //The components are created:
    java.text.NumberFormat numberFormat =
    java.text.NumberFormat.getIntegerInstance();
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setMinimum(new Integer(-180));
    formatter.setMaximum(new Integer(180));
    textField = new JFormattedTextField(formatter);
    textField.setValue(new Integer(0));
    textField.setColumns(10); //get some space
    textField.addPropertyChangeListener(new ApodizeListener(this));
    gridbagconstraints.gridx = 2; //1
    gridbagconstraints.gridy = 1; //2
    gridbagconstraints.gridwidth = 1; //2
    gridbagconstraints.gridheight = 1; //1
    gridbagconstraints.weightx = 2.0D; //1.0D
    gridbagconstraints.weighty = 0.0D; //1.0D
    gridbagconstraints.fill = 2;
    panel.add(textField, gridbagconstraints);
    gridbagconstraints.gridx = 1;
    gridbagconstraints.gridy = 2;
    gridbagconstraints.gridwidth = 2;
    gridbagconstraints.gridheight = 1;
    gridbagconstraints.weightx = 1.0D;
    gridbagconstraints.weighty = 1.0D;
    gridbagconstraints.fill = 2;
    panel.add(apodize, gridbagconstraints);
    getContentPane().add(panel,BorderLayout.CENTER);
    setSize(350,100);
    setLocation(300,40);
    setClosable(true);
    setIconifiable(true);
    setMaximizable(false);
    setResizable(false);
    setFrameIcon((Icon)new ImageIcon("./resources/images/apodize.gif"));
    setVisible(true);

    }
    }

    /**
    * @author Manoj Sarma
    *
    */



    class ApodizeListener implements ChangeListener, PropertyChangeListener
    {
    Apodizeview obj;
    GraphDataGE gd;
    GraphGE gr;
    private double apodizeValue = 0.0D;
    private double slid = 0.0D;
    int [] idx;
    /**
    * @param obj
    */
    ApodizeListener(Apodizeview obj)
    {
    this.obj = obj;
    }

    public void propertyChange(PropertyChangeEvent e)
    {
    if ("value".equals(e.getPropertyName()))
    {
    Number value = (Number)e.getNewValue();
    if (obj.apodize != null && value != null)
    {
    obj.apodize.setValue(value.intValue());
    //obj.apodize.setValue(obj.apodize.getValue());
    }
    }
    }

    public void stateChanged(ChangeEvent evt)
    {
    int d = obj.apodize.getValue();
    double d1 = obj.apodize.getValue();
    idx = new int[2];
    //double fps = ((double)obj.apodize.getValue())/10D;
    double fps = Math.exp((double)d / 10000D) - 1.0D; //### Its
    working
    //double fps = ((double)(int)(d1 * 100D) / 100D);
    //double fps = ((int)(0.5D + 100D * Math.log(d1 + 1.0D)));
    //double fps = ((double)obj.apodize.getValue());
    if (!obj.apodize.getValueIsAdjusting())
    {
    //done adjusting
    //obj.textField.setValue(new Integer(fps)); //update ftf value
    obj.textField.setText(String.valueOf(fps));
    }
    else
    {
    //value is adjusting; just set the text
    obj.textField.setText(String.valueOf(fps));
    }
    //double slid = (double)d;
    //double apodizeValue = Math.exp((double)d / 100D) -1.0D;
    double apodizeValue = Math.exp((double)d / 10000D) - 1.0D; //### Its
    working
    //double apodizeValue = (double)d/100;
    //double apodizeValue = ((int)(0.5D + 100D * Math.log(d1 + 1.0D)));;
    gd = obj.pc.getGraphDataGE();
    gr = obj.pc.getGraphGE();
    //gd.seta(slid);
    gd.seta(apodizeValue);
    //gd.doApodizeFID();
    gd.doApodize();
    idx = obj.pc.getSelectedMenu();
    if(idx[0] == 0)
    {
    int ch = idx[1];
    switch (ch)
    {

    case 0: // Real
    gr.clearValues();
    gr.setValues(gd.getRealFID());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 1: //Imag
    gr.clearValues();
    gr.setValues(gd.getImagFID());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 2: //Absolute
    gr.clearValues();
    gr.setValues(gd.getMagnitudeFID());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 3: //Real Square
    gr.clearValues();
    gr.setValues(gd.getRealFIDSq());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 4 : // Imag Square
    gr.clearValues();
    gr.setValues(gd.getImagFIDSq());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 5:
    gr.clearValues();
    gr.setValues(gd.getMagnitudeFIDSq());
    obj.pc.repaint();
    gr.reDraw();
    break;
    }
    }
    else if(idx[0] == 1)
    {
    int ch = idx[1];
    switch (ch)
    {

    case 0: // Real
    gr.clearValues();
    gr.setValues(gd.getReal());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 1: //Imag
    gr.clearValues();
    gr.setValues(gd.getImag());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 2: //Absolute
    gr.clearValues();
    gr.setValues(gd.getMagnitude());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 3: //Real Square
    gr.clearValues();
    gr.setValues(gd.getRealSq());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 4 : // Imag Square
    gr.clearValues();
    gr.setValues(gd.getImagSq());
    obj.pc.repaint();
    gr.reDraw();
    break;
    case 5:
    gr.clearValues();
    gr.setValues(gd.getMagnitudeSq());
    obj.pc.repaint();
    gr.reDraw();
    break;
    }
    }
    }
    }
    //package utils;

    public class BooleanLock extends Object {

    private boolean value;

    public BooleanLock(boolean initialValue) {

    value = initialValue;
    }

    public BooleanLock() {

    this(false);
    }

    public synchronized void setValue(boolean newValue) {

    if (newValue != value) {

    value = newValue;
    notifyAll();
    }
    }

    public synchronized boolean waitToSetTrue(long msTimeout)
    throws InterruptedException {

    boolean success = waitUntilFalse(msTimeout);

    if (success)
    setValue(true);

    return success;
    }

    public synchronized boolean waitToSetFalse(long msTimeout)
    throws InterruptedException {

    boolean success = waitUntilTrue(msTimeout);

    if (success)
    setValue(false);

    return success;
    }

    public synchronized boolean isTrue() {

    return value;
    }

    public synchronized boolean isFalse() {

    return !value;
    }

    public synchronized boolean waitUntilTrue(long msTimeout)
    throws InterruptedException {

    return waitUntilStateIs(true, msTimeout);
    }

    public synchronized boolean waitUntilFalse(long msTimeout)
    throws InterruptedException {

    return waitUntilStateIs(false, msTimeout);
    }

    public synchronized boolean waitUntilStateIs(boolean state, long
    msTimeout)
    throws InterruptedException {

    if (msTimeout == 0L) {

    while (value != state)
    wait();

    return true;
    }

    long endTime = System.currentTimeMillis() + msTimeout;

    long msRemaining = msTimeout;

    while ((value != state) && (msRemaining > 0L)) {

    wait(msRemaining);
    msRemaining = endTime - System.currentTimeMillis();
    }

    return (value == state);
    }

    }




    /*
    * Created on Aug 25, 2004
    *
    */
    //package nmrui.gui;

    /**
    * @author ANADI MISHRA
    *
    * @version 1.00
    */

    import java.io.File;
    import java.io.IOException;
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import javax.swing.JFileChooser;
    //import nmrui.readers.*;

    public class FileHandler {

    private File file;
    private File currentDir = new File("UNTITLED");
    private JFileChooser dialog;
    private NMRGui cot;

    public FileHandler(NMRGui cot) {
    this.cot = cot;
    }

    public void openFile() {
    dialog = new JFileChooser();
    int open = 0;
    open = dialog.showOpenDialog(cot);

    if (open == JFileChooser.APPROVE_OPTION) {
    File f = dialog.getSelectedFile();
    String s = f.getPath();
    String s1 = f.getPath();
    System.out.println("**********File Path " + s1);

    if (s.endsWith(".txt") || s.endsWith(".TXT")) {
    try {
    TXTFilesReader txtFile = new TXTFilesReader(s1);
    double ans[][] = txtFile.loadTxt();
    String title = f.getName();
    cot.addScreenGraph(title, 1, ans);
    } catch (IOException e) {
    System.err.println(e);
    e.printStackTrace();
    }
    } else {
    boolean flag = false;
    boolean flag1 = false;
    boolean flag2 = false;
    boolean flag3 = false;
    FileInputStream fileinputstream;
    DataInputStream datainputstream;
    byte abyte0[];
    String fileName = f.getName();

    try {
    fileinputstream = new FileInputStream(f);
    datainputstream = new DataInputStream(fileinputstream);

    String tp;
    int type;
    abyte0 = new byte[4];
    for (int j = 0; j != 4; j++)
    abyte0[j] = datainputstream.readByte();
    double[][] ans;

    GEFilesReader geFile = new GEFilesReader(f.getPath());

    type = geFile.findType();
    switch (type) {
    case 0 :
    geFile.loadGe(false, 4, true, true); //###Changed for Phantom
    data
    //geFile.loadGe(false, 4, true, false);
    tp = "4X";
    break;
    case 1 :
    geFile.loadGe(false, 4, true, true);
    tp = "5X";
    break;
    case 2 :
    geFile.loadGe(false, 5, true, true);
    tp = "P5";
    break;
    case 3 :
    default :
    geFile.loadGe(false, 8, true, true);
    tp = "LX";
    break;

    }
    ans = geFile.getResult();
    cot.addScreenGraph(
    "1D Mode " + f.getName() + " " + tp,
    2,
    ans);
    } catch (Exception e) {
    e.getMessage();
    }
    return;
    }
    } else if (open == JFileChooser.CANCEL_OPTION) {
    return;
    //do nothing
    }

    }
    public void callSave() {
    dialog = new JFileChooser();
    int save = dialog.showSaveDialog(cot);
    if (save == JFileChooser.APPROVE_OPTION) {
    saveFile(dialog.getSelectedFile());
    return;
    } else if (save == JFileChooser.CANCEL_OPTION) {
    return;
    //do nothing
    }
    }

    public void saveFile(File file) {
    }

    public void callSaveAs() {
    dialog = new JFileChooser();
    int saveas = dialog.showSaveDialog(cot);
    dialog.setSelectedFile(currentDir);
    if (saveas == JFileChooser.APPROVE_OPTION) {
    saveFile(dialog.getSelectedFile());
    return;
    } else if (saveas == JFileChooser.CANCEL_OPTION) {
    return;
    //do nothing
    }
    }

    }
    import java.io.*;
    public class fileHandling
    {
    //void filewrite(String path,double[] Arr,String name)
    void filewrite(String path,double[] Arr,String name, String folder)
    {
    try
    {
    //File file = new File(path+"/NMRResult");
    File file = new File(path+folder);
    file.mkdir();
    //FileOutputStream one = new
    FileOutputStream(path+"/NMRResult/"+name+".txt");
    FileOutputStream one = new
    FileOutputStream(path+folder+name+".txt");
    PrintStream p = new PrintStream(one);

    for(int i=0;i<Arr.length;i++)
    {
    p.println(Arr[i]);
    }
    }
    catch(Exception e)
    {}
    }
    }
    public class genppm_frq
    {
    double trans = 0D;
    double[] ppm;
    double[] frq;
    //public genppm_frq(int point, double a)

    public double gettrans()
    {
    return trans;
    }
    public void settrans(double trans)
    {
    this.trans = trans;
    }

    public genppm_frq(int point)
    {
    double frres = 2500D/2048D;
    double transfreq = 63.86;
    double ppmres = frres/transfreq;
    ppm = new double[point];
    frq = new double[point];

    for(int i = 0 ; i < point; i++)
    {
    //ppm[i] = (-ppmres * 1024) + (i * ppmres) + trans;
    ppm[i] = (-ppmres * 1024) + (i * ppmres);
    frq[i] = -1250 + (i * frres);
    }
    }
    double[] returnppm()
    {
    return ppm;
    }

    double[] returnfrq()
    {
    return frq;
    }
    }

    import javax.swing.*;
    import java.io.File;
    import java.awt.event.*;
    import java.io.*;
    import java.awt.image.*;
    import java.awt.*;
    import java.io.IOException;
    import java.awt.geom.Line2D;

    public class Frame_ParalleDisplay extends JInternalFrame
    {
    int point = 2048;
    int l =0;
    double maxX , minX, maxY, minY;

    double[] Yt, Ysupt, ppm, freq, ppmt, max, min, Ys, Yp, Ysups, Ysupp,
    Xs, Xp;

    public Frame_ParalleDisplay(double[] realdata)
    {

    mainfileread mfRs = new mainfileread("C:\\Documents and
    Settings\\manoj\\Desktop\\ApodizeMRS\\Result\\iterreal.txt");
    double[] realsupdata = mfRs.returnarray();

    ppm = new double[point];
    freq = new double[point];
    Yt = new double[point];
    Ysupt = new double[point];
    ppmt = new double[point];
    Ys = new double[point];
    Ysups = new double[point];
    Xs = new double[point];
    Yp = new double[point];
    Ysupp = new double[point];
    Xp = new double[point];
    double frres = 2500D/2048D;
    double transfreq = 63.86;
    double ppmres = frres/transfreq;
    for(int i = 0 ; i <point; i++)
    {
    Yt[i] = realdata[i+l];
    Ysupt[i] = realsupdata[i+l];
    ppm[i] = (-ppmres * 1024D) + (i*ppmres);
    freq[i] = -1250D + (i*frres);
    }
    max = new double[2];
    min = new double[2];
    max_min mm = new max_min();
    max[0] = mm.getMax(Yt);
    min[0] = mm.getMin(Yt);
    max[1] = mm.getMax(Ysupt);
    min[1] = mm.getMin(Ysupt);

    maxX = mm.getMax(ppm);
    minX = mm.getMin(ppm);
    System.out.println("XMaximum: "+ maxX + " " + "XMinimum: "+
    minX);
    maxY = mm.getMax(max);
    minY = mm.getMin(min);
    System.out.println("XMaximum: "+ maxY + " " + "XMinimum: "+
    minY);

    for(int k = 0 ; k < point; k++)
    {
    ppmt[k]= k;
    }

    for(int k = 0 ; k <point ; k++)
    {
    Ys[k] = (int)((((Yt[k]-minY)/(maxY-minY))*300));
    Ysups[k] = (int)((((Ysupt[k]-minY)/(maxY-minY))*300));
    //Xs[k] = (int)((((ppmt[k]-0)/((point-1)-0))*900));
    Xs[k] = (int)((((ppm[k]-minX)/(maxX-minX))*900));
    }

    /*addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    });*/

    setClosable(true);
    setIconifiable(true);
    setMaximizable(false);
    setResizable(false);
    setVisible(true);
    this.setBounds(0,0,1020,700);
    //setSize(1020, 700);
    setTitle("MRS");
    //setVisible(true);

    }


    public void paint(Graphics g)
    {
    Graphics2D ng = (Graphics2D) g;
    for(int j = 0 ; j<point ; j++)
    {
    Yp[j]=620 - Ys[j];
    Ysupp[j]=310 - Ysups[j];
    Xp[j]=80 + Xs[j];
    }
    ng.setColor(Color.black);
    ng.draw(new Line2D.Double(80,620,980,620));
    ng.draw(new Line2D.Double(80,110,80,620));
    ng.setColor(Color.blue);
    for(int p = 0; p< (point-1); p++)
    {
    ng.draw(new Line2D.Double(Xp[p],Yp[p],Xp[p+1],Yp[p+1]));
    ng.draw(new Line2D.Double(Xp[p],Ysupp[p],Xp[p+1],Ysupp[p+1]));
    }
    ng.setColor(Color.black);
    for(int i=0; i<17; i++)
    {
    g.drawString("|",(130+i*50),629);

    g.drawString(String.valueOf((float)((int)((minX+((850-i*50)*(maxX-minX)/900))*1000))/1000),(115+i*50),640);
    }
    ng.drawString("",980,625);
    ng.drawString(String.valueOf((float)((int)(minX*1000))/1000),70,640);
    ng.drawString(String.valueOf((float)((int)(maxX*1000))/1000),970,640);
    ng.drawString("Frequency ( ppm )",490,668);
    ng.drawString("",76,110);
    }
    }





    /*
    * Created on Aug 25, 2004
    *
    */

    /*
    * @author Manoj Sarma
    * @version 1.00
    */
    //package nmrui.readers;

    import java.io.DataInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;

    public class GEFilesReader {

    File dataFile, resultFile;
    FileInputStream dataStream;
    DataInputStream dataFilter;
    static int manufacturerIndex = -1;

    final int IMG_MAGIC = 0x494d4746;
    final int GE4X = 0;
    final int GE5X = 1;
    final int GEP5 = 2;
    final int GELX = 3;

    String fileName;

    byte smbuff[];
    byte fltbuff[];

    int length;
    int offset;
    int n;
    int image_magic;
    int fileType;
    int rawType;
    int sb;
    int ndp;
    int ndpmax;
    int sfrq;
    int ndim;
    int nfrm;
    int ptsz;

    double tempPh0;
    double B0;
    double tstep;
    double beginTime;
    double[][] result;

    public GEFilesReader(String s) {
    fileName = s;
    dataFile = new File(fileName);
    try
    {
    dataStream = new FileInputStream(dataFile);
    }
    catch (FileNotFoundException e)
    {
    e.printStackTrace();
    }
    dataFilter = new DataInputStream(dataStream);

    smbuff = new byte[8];
    fltbuff = new byte[4];
    }

    public int findType() throws IOException {
    boolean flag = false;
    boolean flag1 = false;
    boolean flag2 = false;
    boolean flag3 = false;
    int type = 0;

    FileInputStream fileinputstream;
    DataInputStream datainputstream;
    byte abyte0[];

    fileinputstream = new FileInputStream(dataFile);
    datainputstream = new DataInputStream(fileinputstream);

    abyte0 = new byte[4];
    for (int j = 0; j != 4; j++)
    abyte0[j] = datainputstream.readByte();

    flag2 =
    (dataFile.length() - 39940L) % 2048L == 0L
    && abyte0[0] == 64
    && abyte0[1] == -90
    && abyte0[2] == 102
    && abyte0[3] == 102;
    flag3 =
    (dataFile.length() - 39984L) % 2048L == 0L
    && abyte0[0] == 64
    && abyte0[1] == -32
    && abyte0[2] == 0
    && abyte0[3] == 0;

    if (fileName.indexOf("ge4x") != -1
    && !flag2
    && !flag3
    || fileName.indexOf("GE4X") != -1
    && !flag2
    && !flag3)
    type = GE4X;
    if (flag1 && !flag2 && !flag3)
    type = GE5X;
    if ((fileName.indexOf("geP5") != -1 || flag2)
    && !flag3
    || (fileName.indexOf("GEP5") != -1 || flag2)
    && !flag3)
    type = GEP5;
    if (!flag2 && flag3)
    type = GELX;

    return type;
    }

    public void loadGe(boolean flag, int i, boolean flag1, boolean flag2)
    throws IOException
    {

    int j = (int) (new File(fileName)).length();

    if (i == 4 || i == 5) {
    System.out.println("Loading GE Sigma 4.x or 5.x file");
    ndpmax = 4096;
    if (flag1)
    {
    if (flag2)
    {
    sb = 39940;
    ndp = 2048;
    sfrq = 0x3ce6d20;
    ndim = 2;
    nfrm = (j - sb) / ndp / 8;
    }
    else
    {
    sb = 1024;
    ndp = 2048;
    sfrq = 0x3ce6d20;
    ndim = 1;
    nfrm = 1;
    }
    }
    else
    {
    sb = 1024;
    ndp = 1024;
    sfrq = 0x18a7090;
    ndim = 1;
    nfrm = 1;
    }
    if (j == 16384)
    sb = 0;
    ptsz = 32;
    int l;
    if (ndim == 1)
    {
    int k = ndpmax;
    ndp = 0;
    }
    else
    {
    l = Math.min(ndpmax, ndp);
    }
    tstep = 0.40000000000000002D;
    beginTime = 0.0D;
    char c = '\u03E8';
    int j1;
    if (ndim == 1)
    j1 = nfrm;
    else
    j1 = 32;
    //dataFilter.skipBytes(sb);
    dataFilter.skipBytes(sb+4140);
    if (ndim == 1)
    {
    if (ndp == 0)
    {
    double[][] ad = new double[(j - sb) / 8][2];
    length = (int) (j - sb) / 8;
    for (int l1 = 0; l1 < (j - sb) / 8; l1++)
    {
    ad[l1][0] = ReadAFloat();
    ad[l1][1] = -ReadAFloat();
    }
    addResult(ad);

    }
    else
    {
    double[][] ad1 = new double[ndp][2];
    length = ndp;
    for (int i2 = 0; i2 < ndp; i2++)
    {
    ad1[i2][0] = ReadAFloat();
    ad1[i2][0] = -ReadAFloat();
    }
    addResult(ad1);

    }
    }
    if (ndim == 2)
    {
    double[][] ad = new double[ndp][2];
    length = nfrm * ndp;
    //double[][] res = new double[length][2];
    if (ptsz == 16)
    {
    double[][] res = new double[length][2];
    double ad1[] = new double[ndp];
    double ad2[] = new double[ndp];
    int ctr = 0;
    for (int j2 = 0; j2 < nfrm; j2++)
    {
    System.out.print(
    "Loading frame "
    + String.valueOf(j2 + 1)
    + " of "
    + String.valueOf(nfrm)
    + ".\r");
    for (int l2 = 0; l2 < ndp; l2++)
    {
    ad1[l2] = ReadAShort();
    ad2[l2] = -ReadAShort();
    //ad[l2][0] = ReadAShort();
    //ad[l2][1] = -ReadAShort();
    //res[ctr][0] = ad[l2][0];
    //res[ctr][1] = ad[l2][1];
    }
    for(int l2 = 0; l2 < ndp; l2++)
    {
    res[ctr][0] = ad1[l2];
    res[ctr][1] = ad2[l2];
    ctr++;
    }
    //System.out.println(ad);
    }
    addResult(res);
    }
    if (ptsz == 32)
    {
    double[][] res = new double[ndp * nfrm][2];
    int ctr = 0;
    for (int k2 = 0; k2 < nfrm; k2++)
    {
    double ad1[] = new double[ndp];
    double ad2[] = new double[ndp];
    System.out.print("Loading frame "+ (k2 + 1)+ " of " + nfrm +
    ".\r");
    for (int i3 = 0; i3 < ndp; i3++)
    {
    //ad[i3][0] = ReadAInt();
    //ad[i3][1] = - (double) ReadAInt();
    //res[ctr][0] = ad[i3][0];
    //res[ctr][1] = ad[i3][1];
    ad1[i3] = ReadAInt();
    ad2[i3] = -(double) ReadAInt();
    }
    for (int i3 = 0; i3 < ndp; i3++)
    {
    res[ctr][0] = ad1[i3];
    res[ctr][1] = ad2[i3];
    ctr++;
    }
    //System.out.println(ad);
    }
    addResult(res);
    }
    }
    System.out.println();
    tempPh0 = 0.0D;
    System.out.println("Step Time = " + tstep);
    System.out.println("Nucleus = " + -1D);
    System.out.println("Transmitter Freq = " + sfrq);
    B0 = (sfrq * 4.6974999999999998D) / 200000000D;
    System.out.println("B0 = " + B0);

    //data.areEchoes = true;
    }
    if (i == 8)
    {
    System.out.println("Loading GE Sigma LX file"); //Here we open
    this type of file

    sb = 39984;
    ndp = 2048;
    sfrq = 0x3ce6d20;
    if (j == 16384)
    sb = 0;
    nfrm = (j - sb) / ndp / 8;
    dataFilter.skipBytes(sb);
    length = nfrm * ndp;

    double[][] res = new double[ndp * nfrm][2];
    int ctr = 0;
    for (int i1 = 0; i1 < nfrm; i1++)
    {
    double ad1[] = new double[ndp];
    double ad2[] = new double[ndp];
    System.out.print("Loading frame " + (i1 + 1) + " of " + nfrm +
    ".\r");
    for (int k1 = 0; k1 < ndp; k1++)
    {
    ad1[k1] = ReadAInt();
    ad2[k1] = - (double) ReadAInt();
    }

    for (int k1 = 0; k1 < ndp; k1++)
    {
    res[ctr][0] = ad1[k1];
    res[ctr][1] = ad2[k1];
    ctr++;
    }
    }
    System.out.println();
    System.out.println("stepTime = " + 0.40000000000000002D);
    System.out.println("Transmitter Frequency ="+ sfrq);
    B0 = (sfrq * 4.6974999999999998D) / 200000000D;
    System.out.println("B0 = " + B0);
    //data.areEchoes = true;
    System.out.println("Begin Time = " + 0.0D);
    addResult(res);
    }
    if (dataFilter.available() != 0)
    System.out.println(
    "WARNING - Bytes not read:" + dataFilter.available());
    tempPh0 = 0.0D;
    B0 = 1.5D;
    //data.setPhases(tempPh0, beginTime);
    }

    public synchronized float ReadAFloat() throws IOException
    {
    return dataFilter.readFloat();
    }

    public synchronized short ReadAShort() throws IOException
    {
    return dataFilter.readShort();
    }

    public synchronized int ReadAInt() throws IOException
    {
    return dataFilter.readInt();
    }

    public int getLength()
    {
    return length;
    }

    public void addResult(double[][] ans)
    {
    result = ans;
    }

    public double[][] getResult()
    {
    return result;
    }
    //###///////////////////////////////////
    public int getnoframe()
    {
    return nfrm;
    }

    }//package nmrui.mri;

    import java.io.*;

    public class ppm_freq_save
    {
    private double[] nppmvalue, freq, ppm, nfreqvalue;
    private double numsubppm, numsubfrq, point;
    /**
    * Method XAxis
    *
    *
    */

    public ppm_freq_save(int point, double np, double nf)
    {
    numsubppm = np;
    numsubfrq = nf;
    point = point;
    nppmvalue = new double[point];
    nfreqvalue = new double[point];
    genppm_frq pmfr = new genppm_frq(point);
    ppm = pmfr.returnppm();
    freq = pmfr.returnfrq();
    for(int i=0; i<point; i++)
    {
    nppmvalue[i] = ppm[i] + numsubppm;
    nfreqvalue[i] = freq[i] + numsubfrq;
    }

    }
    public void writefrq()
    {
    try
    {
    File fp = new File(".");
    String savepath = fp.getAbsolutePath();
    String folder = "\\Result\\";
    File filet = new File(savepath+folder);
    filet.mkdir();
    fileHandling fw = new fileHandling();
    fw.filewrite(savepath,nppmvalue,"nppm",folder);
    fw.filewrite(savepath,nfreqvalue,"nfreq",folder);
    }
    catch(Exception e){}
    }
    }
    //Display Mouse.java
    import java.awt.image.*;
    import java.awt.*;
    import java.util.*;
    import java.io.*;
    import java.awt.event.*;


    public class DisplayMouse extends java.applet.Applet
    {
    handelmouse hm;
    int mouseX, mouseY;
    String msg;
    int point =2048;
    //int l=16445;
    int l=0;
    double max , min, max1, min1;

    double[] real51 = new double[point];
    int[] real1 = new int[point];
    int[] real2 = new int[point];
    double[] ppm1 = new double[point];
    int[] ppm2 = new int[point];
    int[] ppm3 = new int[point];
    double[] ppm51 = new double[point];


    public void init()
    {
    addMouseListener((hm=new handelmouse()));
    addMouseMotionListener(hm);

    mainfileread mfR = new mainfileread("C:\\Documents and
    Settings\\manoj\\Desktop\\InterfaceMRS\\Result\\pcreal.txt");
    double[] real = mfR.returnarray();

    //mainfileread mfp = new
    mainfileread("D:\\NMRDATAProg\\NMRProg\\AtWidthWP2\\sno78-h1\\ppm.txt");
    //double[] ppm = mfp.returnarray();

    for(int k = 0 ; k < point; k++)
    {
    real51[k]= real[k+l];
    //ppm51[k] = ppm[k+l];
    }
    max_min mm = new max_min();
    max = mm.getMax(real51);
    min = mm.getMin(real51);
    System.out.println(min);
    //max1 = mm.getMax(ppm51);
    //min1 = mm.getMin(ppm51);

    for(int k = 0 ; k < point; k++)
    {
    ppm1[k]= k;
    }

    for(int k = 0 ; k <point ; k++)
    {
    real1[k] = (int)((((real[k+l] - min)/(max-min))*600));
    ppm2[k] = (int)((((ppm1[k]-0)/((point-1)-0))*900));
    }
    }

    public void start()
    {
    }

    class handelmouse extends MouseAdapter implements
    MouseMotionListener
    {
    public void mouseMoved(MouseEvent me)
    {
    //mouseX = me.getX();
    mouseY = me.getY();
    //showStatus(mouseX + " , " + mouseY);
    repaint();
    }
    public void mouseDragged(MouseEvent me)
    {
    }
    public void mousePressed(MouseEvent me)
    {
    /*mouseX = me.getX();
    mouseY = me.getY();
    showStatus(mouseX + " , " + mouseY);
    repaint();*/
    }
    }
    //public void update(Graphics g){ paint(g);}

    public void paint(Graphics g)
    {

    for(int j = 0 ; j<point ; j++)
    {
    real2[j]=620-real1[j];
    ppm3[j]=80+ppm2[j];
    }

    for(int p = 0; p< (point-1); p++)
    {
    g.setColor(Color.black);
    g.drawLine(80,620,980,620);
    g.drawLine(80,0,80,620);
    g.setColor(Color.red);
    g.drawLine(ppm3[p],real2[p],ppm3[p+1],real2[p+1]);
    }
    g.setColor(Color.black);
    for(int i=0; i<17; i++)
    {
    g.drawString("|",(130+i*50),629);
    g.drawString(String.valueOf((float)((int)((min1+((850-i*50)*(max1-min1)/900))*1000))/1000),(115+i*50),640);
    }
    g.drawString("",980,625);

    g.drawString(String.valueOf((float)((int)(max1*1000))/1000),70,640);
    g.drawString(String.valueOf((float)((int)(min1*1000))/1000),970,640);
    g.drawString("Frequency ( ppm )",490,668);
    //String X =
    String.valueOf((float)((int)((min1+((900-(mouseX-80))*(max1-min1)/900))*1000))/1000);
    String Y =
    String.valueOf((float)((int)((min+((620-(mouseY))*(max-min)/600))*1000))/1000);
    //g.drawString("("+X + "," + Y+")",mouseX,mouseY);

    }
    /*
    * Created on Aug 26, 2004
    *
    */
    //package nmrui.mri;

    import java.util.Vector;
    //import java.io.*;
    import fft.*;
    /*
    * @author ANADI MISHRA
    *
    * @version 1.00
    */

    public class GraphDataGE_ch
    {
    double[] real;
    double[] imag;
    double[] real_pc;
    double[] imag_pc;
    double[] realTD;
    double[] imagTD;
    double [][] signal;
    double phi;
    int originalLength = 0;
    Vector setOfFIDs,setOFSpectra;

    public GraphDataGE_ch(int size)
    {
    originalLength = size/19;
    //originalLength = size;
    real = new double[size];
    imag = new double[size];
    real_pc = new double[size];
    imag_pc = new double[size];
    realTD = new double[size];
    imagTD = new double[size];
    signal = new double[size][2];
    phi=0.0D;
    setOfFIDs = new Vector();
    setOFSpectra = new Vector();
    }

    /**
    * @param s
    */
    /*public void addSignals(double[][] s)
    {
    for(int i=0;i<originalLength;i++)
    {
    signal[i][0] = s[i][0];
    signal[i][1] = s[i][1];
    }
    }*/

    public void addSignals(double[][] s)
    {
    int ctr = 2048;
    for(int k=1;k<19;k++)
    for (int l = 0; l < 2048; l++)
    {
    signal[l][0] += s[ctr][0];
    signal[l][1] += s[ctr][1];
    ctr++;
    }
    }


    public void doPhaseFID()
    {
    for(int i=0; i<originalLength; i++)
    {
    realTD[i]= (Math.cos(Math.toRadians(phi))) * signal[i][0] +
    (Math.sin(Math.toRadians(phi))) * signal[i][1];
    imagTD[i]= -(Math.sin(Math.toRadians(phi))) * signal[i][0] +
    (Math.cos(Math.toRadians(phi))) * signal[i][1];
    }
    }

    public void doFFT()
    {
    Fft fft = new Fft();
    double [][] input_fft = new double[2][originalLength];

    for(int i=0;i<input_fft[0].length;i++)
    {
    input_fft[0][i] = signal[i][0];
    input_fft[1][i] = signal[i][1];
    }

    double [][] estimate = fft.direct_1D_Estim_fft(input_fft);
    //double[][] output_fft = fft.calcFFTD(estimate,true);
    for (int i = 0; i < originalLength; i++)
    {
    real[i] = estimate[0][i];
    imag[i] = estimate[1][i];
    }
    }

    public int getPoint()
    {
    return originalLength;
    }

    public double getPhi()
    {
    return phi;
    }

    public void setPhi(double phi)
    {
    this.phi = phi;
    }

    public void doPhase()
    {
    for(int i=0; i<originalLength; i++)
    {
    real_pc[i]= (Math.cos(Math.toRadians(phi))) * real[i] +
    (Math.sin(Math.toRadians(phi))) * imag[i];
    imag_pc[i]= -(Math.sin(Math.toRadians(phi))) * real[i] +
    (Math.cos(Math.toRadians(phi))) * imag[i];
    }

    //File fp = new File(".");
    //System.out.println(fp.getAbsolutePath());
    //String savepath = fp.getAbsolutePath();
    //String foldername = "/LoadData/";
    //fileHandling fw = new fileHandling();
    //fw.filewrite(savepath, real,"Realphcorr",foldername);
    //fw.filewrite(savepath, imag,"Imagphcorr",foldername);
    }

    public double[][] getSignal()
    {
    return signal;
    }

    public double[] getReal()
    {
    return real;
    }

    public double[] getRealFID()
    {
    return realTD;
    }

    public double[] getpcReal()
    {
    return real_pc;
    }

    public double[] getImag()
    {
    return imag;
    }

    public double[] getImagFID()
    {
    return imagTD;
    }

    public double[] getpcImag()
    {
    return imag_pc;
    }

    public int getoriginalLength()
    {
    return originalLength;
    }

    public double[] getRealSq()
    {
    double[] sq = new double[real.length];

    for (int i = 0; i < real.length; i++)
    sq[i] = Math.pow(real[i], 2.0);

    return sq;
    }


    public double[] getpcRealSq()
    {
    double[] pcsq = new double[real_pc.length];

    for (int i = 0; i < real_pc.length; i++)
    pcsq[i] = Math.pow(real_pc[i], 2.0);

    return pcsq;
    }

    public double[] getRealFIDSq()
    {
    double[] sq = new double[realTD.length];

    for (int i = 0; i < realTD.length; i++)
    sq[i] = Math.pow(realTD[i], 2.0);

    return sq;
    }

    public double[] getImagSq()
    {
    double[] sq = new double[imag.length];

    for (int i = 0; i < imag.length; i++)
    sq[i] = Math.pow(imag[i], 2.0);

    return sq;
    }

    public double[] getpcImagSq()
    {
    double[] pcsq = new double[imag_pc.length];

    for (int i = 0; i < imag_pc.length; i++)
    pcsq[i] = Math.pow(imag_pc[i], 2.0);

    return pcsq;
    }

    public double[] getImagFIDSq()
    {
    double[] sq = new double[imagTD.length];

    for (int i = 0; i < imagTD.length; i++)
    sq[i] = Math.pow(imagTD[i], 2.0);

    return sq;
    }

    public double[] getMagnitude()
    {
    double[] mag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    mag[i] = Math.sqrt((Math.pow(real[i], 2.0) + Math.pow(imag[i],
    2.0)));

    return mag;
    }

    public double[] getpcMagnitude()
    {
    double[] pcmag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    pcmag[i] = Math.sqrt((Math.pow(real_pc[i], 2.0) +
    Math.pow(imag_pc[i], 2.0)));

    return pcmag;
    }

    public double[] getMagnitudeFID()
    {
    double[] mag = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    mag[i] = Math.sqrt((Math.pow(realTD[i], 2.0) + Math.pow(imagTD[i],
    2.0)));

    return mag;
    }

    public double[] getMagnitudeSq()
    {
    double[] mag = getMagnitude();
    double[] magsq = new double[originalLength];
    for (int i = 0; i < originalLength; i++) {
    magsq[i] = Math.pow(mag[i], 2.0);
    }

    return magsq;
    }

    public double[] getpcMagnitudeSq()
    {
    double[] pcmag = getMagnitude();
    double[] pcmagsq = new double[originalLength];
    for (int i = 0; i < originalLength; i++)
    {
    pcmagsq[i] = Math.pow(pcmag[i], 2.0);
    }

    return pcmagsq;
    }

    public double[] getMagnitudeFIDSq()
    {
    double[] mag = getMagnitudeFID();
    double[] magsq = new double[originalLength];
    for (int i = 0; i < originalLength; i++) {
    magsq[i] = Math.pow(mag[i], 2.0);
    }

    return magsq;
    }

    }

    }

    import java.awt.event.*;
    import java.awt.*;
    import java.applet.Applet;
    class handelmouse extends MouseAdapter implements MouseMotionListener
    {
    public void mouseMoved(MouseEvent me)
    {
    int mouseX = me.getX();
    int mouseY = me.getY();
    //showStatus(mouseX + " , " + mouseY);
    //repaint();
    }
    public void mouseDragged(MouseEvent me)
    {
    }
    public void mousePressed(MouseEvent me)
    {
    /*mouseX = me.getX();
    mouseY = me.getY();
    showStatus(mouseX + " , " + mouseY);
    repaint();*/
    }
    }[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
     
    sweta, May 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    22,687
    Bart Cremers
    Apr 12, 2006
  2. sweta
    Replies:
    2
    Views:
    723
    Roedy Green
    May 8, 2006
  3. sweta

    help in java swings

    sweta, Jun 2, 2006, in forum: Java
    Replies:
    0
    Views:
    421
    sweta
    Jun 2, 2006
  4. ashish
    Replies:
    3
    Views:
    726
    Andrew T.
    Jun 30, 2006
  5. Kumar
    Replies:
    1
    Views:
    354
Loading...

Share This Page