/* -------------------------------------------------------------------------- */
/* */
/* TEXT MINING THRESHOLDS INPUT WINDOW */
/* Frans Coenen */
/* Tuesday 28 February 2006 */
/* */
/* -------------------------------------------------------------------------- */
/** Window to input threshold parmeters. */
//package lucsKDD_ARM;
// Java packages
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Thresholds extends JFrame implements ActionListener {
/* ------------------------------------------------- */
/* */
/* FIELDS */
/* */
/* ------------------------------------------------- */
// Constants
/** array of threshold labels (also dictates ordering of defualt values). */
private final static String[] THOLD_LABELS = {"Support (%)",
"Confidence (%)", "Signifcance",
"Upper Noise (%)","Lower Noise (%)"};
/** Minimum thresholds value. */
private final static double MIN_VALUE = 0.0;
/** Maximum thresholds value. */
private final static double MAX_VALUE = 100.0;
// Other fields
/** Instance of text mining model. */
private TextMiningModel tmModel = null;
/** Array of threshold default values. */
private double[] tHoldValues = null;
/** Array of instances of class JTextField. */
private JTextField[] tHoldFields = new JTextField[THOLD_LABELS.length];
/* ------------------------------------------------- */
/* */
/* CONSTRUCTORS */
/* */
/* ------------------------------------------------- */
/** One argument constructor.
@param newTMmodel new isntance of TextMiningModel class. */
public Thresholds(TextMiningModel newTMmodel) {
super("LUCS-KDD TEXT MINING GUI: Threshold input");
// Set fields
tmModel = newTMmodel;
tHoldValues = tmModel.getTholdValues();
// Content pane
getContentPane().setBackground(Color.pink);
getContentPane().setLayout(new BorderLayout(5,5));
// Set Layout
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(5,5,2,THOLD_LABELS.length));
// Heading and instruction instructions
JPanel instructPanel = new JPanel();
instructPanel.setBackground(Color.pink);
instructPanel.setLayout(new GridLayout(3,1));
Label label1 = new Label("THRESHOLD INPUT");
Label label2 = new Label("Instructions: Press enter to confirm " +
"a changed value,");
Label label3 = new Label(" and \"Set Thresholds\" to implement " +
"change.");
instructPanel.add(label1);
instructPanel.add(label2);
instructPanel.add(label3);
getContentPane().add(instructPanel,BorderLayout.NORTH);
// Create fields
JLabel[] lables = new JLabel[THOLD_LABELS.length];
for (int index=0;indexActionEvent class. */
public void actionPerformed(ActionEvent event) {
String textString;
// Check for set button
if (event.getActionCommand().equals("Set Thresholds")) setInputTholds();
// Else ID source field index
else {
int index = 0;
for ( ;index=MAX_VALUE) {
String s = "Input value for " + THOLD_LABELS[index] +
" threshold, " + value + ",\nnot between limits of " +
MIN_VALUE + " and " + MAX_VALUE + "!";
JOptionPane.showMessageDialog(this,s,
"Threshold Input Error: ",
JOptionPane.ERROR_MESSAGE);
}
else tHoldValues[index] =
Double.parseDouble(event.getActionCommand());
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(this,"Number format exception",
"Threshold Input Error: ",
JOptionPane.ERROR_MESSAGE);
}
}
}
/* ----------------------------------------------------- */
/* */
/* SET METHODS */
/* */
/* ----------------------------------------------------- */
/** Sets the file input thresholds for the given instance of the text
mining model class. */
public void setInputTholds() {
tmModel.setTholdValues(tHoldValues);
// Test output
/*tHoldValues = tmModel.getTholdValues();
System.out.println("Thresholds: ");
for(int index=0;index