//==============================================
// Numerical WorkSheet Input Panel for Bisection Approximation
//==============================================
// This class is used to set up the Bisection approximation
// method layout for the applet Numerical Worksheet. Data is
// collected from this panel when the WorkSheet is called to
// the process the input equation.
//
//
<< BisectionPanel.java >>
//
//==============================================
// Copyright (C) 1999-2004 Dana M. Proctor
// Version 2.4 5/11/2005
//
// 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 PURPOSE. See the GNU General Public
// License for more details. You should have received 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
// (http://opensource.org)
//
//================================================
// Revision History
// Changes to the code should be documented here and reflected
// in the present version number. Author information should
// also be included with the original copyright author.
//================================================
// Version 1.0 Original Stand Alone Applet.
// 1.1 Sub-Division into Numerical WorkSheet.
//
1.2 Implementation of Intermediate Output.
// 1.3 Renamed BisectionPanel.
// 1.4 Package Creation/Inclusion.
// 1.5 SubClassed to MethodPanel
//
1.6 Removed Gridbag Method. Common to WorkSheet.
// 2.0 Upgrade with WorkSheet to Swing.
// 2.1 GPL Inclusion and JavaDoc Addition.
//
2.2 buildConst Changed to NA_Utils Class.
// 2.3 Privatized All Class Instance Variables.
// 2.4 Misc. Comment Changes.
//-------------------------------------------------------------
//
danap_n_mt@users.sourceforge.net
//==================================================
package net.danap.numericalworksheet;
import java.awt.*;
import javax.swing.*;
/**
* The BisectionPanel used for collecting input data
* required to execute the Bisection approximation.
*
* @author Dana M. Proctor
* @version 2.4 05/11/2005
*/
class BisectionPanel extends JPanel
{
//=============================================
// Required class fields creation.
//=============================================
private static JTextField txtFieldEndpointA, txtFieldEndpointB;
private static JTextField txtFieldTolerance, txtFieldIterations;
private static JCheckBox checkboxIntermediateData;
private JLabel labelHeading, labelEndpointA, labelEndpointB;
private JLabel labelTolerance, labelIterations;
//=============================================
// Bisection Panels Constructor
//=============================================
protected BisectionPanel()
{
//==================================================
// Creation of Labels and Setting up the Panel GUI.
//==================================================
String Heading = ("Bisection Method Approximation");
labelHeading = new JLabel(Heading, JLabel.CENTER);
labelHeading.setFont(labelHeading.getFont().deriveFont(Font.BOLD));
labelEndpointA = new JLabel("Interval Endpoint A");
txtFieldEndpointA = new JTextField(10);
labelEndpointB = new JLabel("Interval Endpoint B", JLabel.CENTER);
txtFieldEndpointB = new JTextField(10);
labelTolerance = new JLabel("Approximation Tolerance", JLabel.CENTER);
txtFieldTolerance = new JTextField(16);
labelIterations = new JLabel("Number of Iterations", JLabel.CENTER);
txtFieldIterations = new JTextField(6);
checkboxIntermediateData = new JCheckBox("Intermediate Output Data");
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints inputMain = new GridBagConstraints();
setLayout(gridbag);
//===================================================
// Adding Labels, TextFields, and Checkbox to the panel.
//===================================================
NA_Utils.buildConst(inputMain, 0,0,2,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.CENTER;
gridbag.setConstraints(labelHeading, inputMain);
add(labelHeading);
NA_Utils.buildConst(inputMain, 0,1,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(labelEndpointA, inputMain);
add(labelEndpointA);
NA_Utils.buildConst(inputMain, 1,1,2,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(txtFieldEndpointA, inputMain);
add(txtFieldEndpointA);
NA_Utils.buildConst(inputMain, 0,2,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(labelEndpointB, inputMain);
add(labelEndpointB);
NA_Utils.buildConst(inputMain, 1,2,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(txtFieldEndpointB, inputMain);
add(txtFieldEndpointB);
NA_Utils.buildConst(inputMain, 0,3,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(labelTolerance, inputMain);
add(labelTolerance);
NA_Utils.buildConst(inputMain, 1,3,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(txtFieldTolerance, inputMain);
add(txtFieldTolerance);
NA_Utils.buildConst(inputMain, 0,4,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(labelIterations, inputMain);
add(labelIterations);
NA_Utils.buildConst(inputMain, 1,4,1,1,10,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(txtFieldIterations, inputMain);
add(txtFieldIterations);
NA_Utils.buildConst(inputMain, 1,5,1,1,100,100);
inputMain.fill = GridBagConstraints.NONE;
inputMain.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(checkboxIntermediateData, inputMain);
add(checkboxIntermediateData);
}
//==================================================
// Class method for outside classes to obtain the
// TextField Strings from this panel.
//==================================================
protected static String getData(String getData)
{
if (getData == "endPointA")
return txtFieldEndpointA.getText();
if (getData == "endPointB")
return txtFieldEndpointB.getText();
if (getData == "tolerance")
return txtFieldTolerance.getText();
else
return txtFieldIterations.getText();
}
//==================================================
// Class method for outside classes to clear the
// TextField Strings in the panel.
//==================================================
protected static void clearTextFields()
{
txtFieldEndpointA.setText("");
txtFieldEndpointB.setText("");
txtFieldTolerance.setText("");
txtFieldIterations.setText("");
}
//==================================================
// Class method for outside classes to obtain the
// Checkbox State from this panel.
//==================================================
protected static boolean getStateCheckbox()
{
return checkboxIntermediateData.isSelected();
}
}