		   /*
 *      @(#)Vrml97Viewer.java 1.26 98/09/24 12:36:47
 *
 * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
 * modify and redistribute this software in source and binary code form,
 * provided that i) this copyright notice and license appear on all copies of
 * the software; and ii) Licensee does not utilize the software in a manner
 * which is disparaging to Sun.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 *
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 *
 * @Author: Doug Gehringer
 * @Author: Rick Goldberg
 */


// A Frame which creates a Canvas3D and a VrmlLoader and passes a URL to 
// the loader

// TODO: make into an applet

import java.io.File;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
import java.util.Enumeration;
import java.net.URL;

/*import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.loaders.vrml97.VrmlLoader;
import com.sun.j3d.loaders.vrml97.VrmlScene;
import com.sun.j3d.loaders.vrml97.BaseNode;
import com.sun.j3d.loaders.vrml97.node.Viewpoint;*/
// import com.sun.j3d.utils.dev_tools.TreePrinter;
import java.applet.*;

public class P_Frame extends Applet
{
  // Canvas3D 	canvas;
  Button panel;
  Panel m_buttonPanel;

// Vrml97Viewer	v97;

  //Not Sure yet
  private int m_pruneValue;
  private double m_radiusValue;

  // Buttons
  private Button m_showDeletedButton;
  private Button m_showSymmetriesButton;

  private Button m_deleteFragmentButton;
  private Button m_unDeleteFragmentButton;
  private Button m_lockFragmentButton;
  private Button m_deleteAtomButton;
  private Button m_undoButton;

  private Button m_pruneButton;
  private Button m_radiusButton;

  private Button m_idButton;
  private Button m_showAllIdsButton;
  private Button m_clearIdButton;

  private Button m_distanceButton;
  private Button m_angleButton;
  private Button m_torsionButton;

  private Button m_showDistancesButton;
  private Button m_showAnglesButton;
  private Button m_showTorsionsButton;

  private Button m_centerAllButton;
  private Button m_unitCellButton;

  private Button m_restoreButton;
  private Button m_saveButton;

    // Text Fields
  private TextField m_pruneField;
  private TextField m_radiusField;

  // Status Label
 Label m_statusLabel;

  // Result Label
  private Label m_resultLabel;


/////////////////////////////////////////////////////////////

	public  void init()
{

 	  add(new Button("hopeful"));
	}
		/////////////////////////////////////////////////////////////



public  void main( )
{

Frame myFrame = new Frame("the Frame");
Applet myApplet = new P_Frame();
myApplet.init();
myApplet.start();
myFrame.setLayout (new FlowLayout());
myFrame.add(myApplet);
myFrame.resize(640,480);
	     // Create a gridbag layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(0, 0, 0, 0);
    myFrame.setLayout(gridbag);

	myFrame.setLayout(new BorderLayout ());

    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.weighty = 0;

    // Status Label
    m_statusLabel = new Label("");
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(m_statusLabel, c);
    add(m_statusLabel);
    
    // Result Label
    m_resultLabel = new Label("");
    c.gridx = 0;
   c.gridy = 1;
    gridbag.setConstraints(m_resultLabel, c);
    add(m_resultLabel);


	    // Create a button panel
    m_buttonPanel = new Panel();
	m_buttonPanel.setLayout(gridbag);
	myFrame.add(m_buttonPanel);

	//add("West", m_buttonControlPanel);


    // Show Deleted button
    m_showDeletedButton = new Button("Show Deleted");
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(m_showDeletedButton, c);
    m_buttonPanel.add(m_showDeletedButton);

    // Show Symmetries button
    m_showSymmetriesButton = new Button("Show Symmetries");
    c.gridx = 1;
    c.gridy = 0;
    gridbag.setConstraints(m_showSymmetriesButton, c);
    m_buttonPanel.add(m_showSymmetriesButton);

    // Delete Fragment button
    m_deleteFragmentButton = new Button("Delete Frag");
    c.gridx = 0;
    c.gridy = 1;
    gridbag.setConstraints(m_deleteFragmentButton, c);
    m_buttonPanel.add(m_deleteFragmentButton);

    // undelete Fragment button
    m_unDeleteFragmentButton = new Button("Undelete Frag");
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(m_unDeleteFragmentButton, c);
    m_buttonPanel.add(m_unDeleteFragmentButton);

    // Delete Atom button
    m_deleteAtomButton = new Button("Delete Atom");
    c.gridx = 0;
    c.gridy = 2;
    gridbag.setConstraints(m_deleteAtomButton, c);
    m_buttonPanel.add(m_deleteAtomButton);

    // Lock Fragment button
    m_lockFragmentButton = new Button("Lock Frag");
    c.gridx = 1;
    c.gridy = 2;
    gridbag.setConstraints(m_lockFragmentButton, c);
    m_buttonPanel.add(m_lockFragmentButton);

    c.insets = new Insets(20, 0, 0, 0);

    // Prune button
    m_pruneButton = new Button("Prune <=");
    c.gridx = 0;
    c.gridy = 3;
    gridbag.setConstraints(m_pruneButton, c);
    m_buttonPanel.add(m_pruneButton);

    // Prune text field
    m_pruneField = new TextField(new Integer(m_pruneValue).toString(), 5);
    c.gridx = 1;
    c.gridy = 3;
    gridbag.setConstraints(m_pruneField, c);
    m_buttonPanel.add(m_pruneField);

    c.insets = new Insets(0, 0, 0, 0);

    // Radius button
    m_radiusButton = new Button("Radius On");
    c.gridx = 0;
    c.gridy = 4;
    gridbag.setConstraints(m_radiusButton, c);
    m_buttonPanel.add(m_radiusButton);

    // Radius text field
    m_radiusField = new TextField(new Double(m_radiusValue).toString(), 5);
    c.gridx = 1;
    c.gridy = 4;
    gridbag.setConstraints(m_radiusField, c);
    m_buttonPanel.add(m_radiusField);

    c.insets = new Insets(20, 0, 0, 0);

    // ID button
    m_idButton = new Button("ID");
    c.gridx = 0;
    c.gridy = 5;
    gridbag.setConstraints(m_idButton, c);
    m_buttonPanel.add(m_idButton);

    // Show all IDs button
    m_showAllIdsButton = new Button("Show All IDs");
    c.gridx = 1;
    c.gridy = 5;
    gridbag.setConstraints(m_showAllIdsButton, c);
    m_buttonPanel.add(m_showAllIdsButton);

    c.insets = new Insets(0, 0, 0, 0);

    // clear ID button
    m_clearIdButton = new Button("Clear IDs");
    c.gridx = 0;
    c.gridy = 6;
    gridbag.setConstraints(m_clearIdButton, c);
    m_buttonPanel.add(m_clearIdButton);

    c.insets = new Insets(20, 0, 0, 0);

    // Distance button
    m_distanceButton = new Button("Distance");
    c.gridx = 0;
    c.gridy = 7;
    gridbag.setConstraints(m_distanceButton, c);
    m_buttonPanel.add(m_distanceButton);

    // Show Distances button
    m_showDistancesButton = new Button("Show Distances");
    c.gridx = 1;
    c.gridy = 7;
    gridbag.setConstraints(m_showDistancesButton, c);
    m_buttonPanel.add(m_showDistancesButton);

    c.insets = new Insets(0, 0, 0, 0);

    // Angle button
    m_angleButton = new Button("Angle");
    c.gridx = 0;
    c.gridy = 8;
    gridbag.setConstraints(m_angleButton, c);
    m_buttonPanel.add(m_angleButton);

    // Show Angles button
    m_showAnglesButton = new Button("Show Angles");
    c.gridx = 1;
    c.gridy = 8;
    gridbag.setConstraints(m_showAnglesButton, c);
    m_buttonPanel.add(m_showAnglesButton);

    // Torsion button
    m_torsionButton = new Button("Torsion");
    c.gridx = 0;
    c.gridy = 9;
    gridbag.setConstraints(m_torsionButton, c);
    m_buttonPanel.add(m_torsionButton);

    // Show Torsions button
    m_showTorsionsButton = new Button("Show Torsions");
    c.gridx = 1;
    c.gridy = 9;
    gridbag.setConstraints(m_showTorsionsButton, c);
    m_buttonPanel.add(m_showTorsionsButton);

    c.insets = new Insets(20, 0, 0, 0);
    
    // Center all button
    m_centerAllButton = new Button("Center All");
    c.gridx = 0;
    c.gridy = 10;
    gridbag.setConstraints(m_centerAllButton, c);
    m_buttonPanel.add(m_centerAllButton);

    // Unit cell button
    m_unitCellButton = new Button("Unit Cell On");
    c.gridx = 1;
    c.gridy = 10;
    gridbag.setConstraints(m_unitCellButton, c);
    m_buttonPanel.add(m_unitCellButton);

    // Undo Button
    m_undoButton = new Button("Undo");
    c.gridx = 0;
    c.gridy = 11;
    gridbag.setConstraints(m_undoButton, c);
    m_buttonPanel.add(m_undoButton);

    c.insets = new Insets(0, 0, 0, 0);

    // Restore button
    m_restoreButton = new Button("Restore");
    c.gridx = 0;
    c.gridy = 12;
    gridbag.setConstraints(m_restoreButton, c);
    m_buttonPanel.add(m_restoreButton);

    // Save button
    m_saveButton = new Button("Save");
    c.gridx = 0;
    c.gridy = 13;
    gridbag.setConstraints(m_saveButton, c);
    m_buttonPanel.add(m_saveButton);

    // add the button panel
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(m_buttonPanel, c);
    myApplet.add(m_buttonPanel);



    m_buttonPanel.disable();
   myFrame.show();


  }

}


