/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOUSE. See the GNU
 * General Public License for more details.
 *
 * You should have recieved a copy of the GNU General Public License
 * along with this program; if not write to the Free Software
 * Foundation, inc., 59 Temple Place, Suite 330, Boston MA 02111-1307
 * USA
 */

package gui;

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

public class PreProcessor_Node extends JPanel {
  Canvas3D J3D;
  BorderLayout borderLayout1 = new BorderLayout();//("",JLabel.CENTER);
  JPanel jPanel1 = new JPanel();
  GridLayout gridLayout1 = new GridLayout();
  JTextField x1 = new JTextField();
  JPanel jPanel2 = new JPanel();
  JButton jButton1 = new JButton();
  JTextField y1 = new JTextField();
  JTextField z1 = new JTextField();
  JLabel jLabel5 = new JLabel("",JLabel.CENTER);
  JLabel jLabel6 = new JLabel("",JLabel.CENTER);
  JLabel jLabel7 = new JLabel("",JLabel.CENTER);
  private JLabel jLabel1 = new JLabel();


  public PreProcessor_Node(Canvas3D j3d) {
    try {
      J3D=j3d;
      jbInit();
    }catch(Exception e) { e.printStackTrace();}
  }
  private void jbInit() throws Exception {
    this.setLayout(borderLayout1);
    jPanel1.setLayout(gridLayout1);
    gridLayout1.setRows(2);
    gridLayout1.setColumns(3);
    jButton1.setText("Add");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    jLabel5.setText("X");
    jLabel6.setText("Y");
    jLabel7.setText("Z");
    jLabel1.setForeground(Color.blue);
    jLabel1.setText("Node");
    x1.setColumns(3);
    y1.setColumns(3);
    z1.setColumns(3);
    this.add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jLabel5, null);
    jPanel1.add(jLabel6, null);
    jPanel1.add(jLabel7, null);
    jPanel1.add(x1, null);
    jPanel1.add(y1, null);
    jPanel1.add(z1, null);
    this.add(jPanel2, BorderLayout.SOUTH);
    jPanel2.add(jButton1, null);
    this.add(jLabel1, BorderLayout.NORTH);
  }

  void jButton1_actionPerformed(ActionEvent e) {
    try{
      J3D.add3D(new _Node(Float.parseFloat(x1.getText()),Float.parseFloat(y1.getText()),Float.parseFloat(z1.getText())));
      J3D.repaint();
    }catch(Exception e1){error(e1);}
  }
  public void error(Object st){
    JOptionPane.showMessageDialog(this,"Error: "+st,"Error!",JOptionPane.ERROR_MESSAGE);
    System.out.println("Error: "+st);
    if(st instanceof Exception) ((Exception)st).printStackTrace();
  }

}


