/* -------------------------------------------------------------------------- */
/* */
/* BATCH MODE INPUT WINDOW */
/* Frans Coenen */
/* Tuesday 6 February 2007 */
/* */
/* -------------------------------------------------------------------------- */
/* Window to input batch mode parameters. */
//package lucsKDD_ARM;
// Java packages
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BatchModeParams extends JFrame implements ActionListener {
/* ------------------------------------------------- */
/* */
/* FIELDS */
/* */
/* ------------------------------------------------- */
// Constants
/** Array of prinary batch mode parameter labels (also dictates ordering of
defualt values). */
private final static String[] PRIME_BM_LABELS = {"Num. Cols","Num. Rows",
"Density"};
/** Array of secondary batch mode labels (includes empty first label). */
private final static String[] SEC_BM_LABELS = {" ","Start","End","Step"};
/** Minimum batch mode parameter value. */
private final static int MIN_VALUE = 0;
/** Maximum batch mode parameter value. */
private final static int MAX_VALUE = 100;
// Other fields
/** Instance of generator model. */
private GeneratorModel genModel = null;
/** Array of batch mode default values. */
private int[][] batchValues = null;
/** 1-D Array of instances of class JTextField. */
private JTextField[][] batchFields =
new JTextField[PRIME_BM_LABELS.length][SEC_BM_LABELS.length];
/** Panel to hold text fields. */
private JPanel panel = null;
/* ------------------------------------------------- */
/* */
/* CONSTRUCTORS */
/* */
/* ------------------------------------------------- */
/** One argument constructor.
@param newGenModel new isntance of TextMiningModel class. */
public BatchModeParams(GeneratorModel newGenModel) {
super("LUCS-KDD DATA GENERATOR: Batch mode input");
// Set fields
genModel = newGenModel;
batchValues = genModel.getBatchValues();
// Content pane
getContentPane().setBackground(Color.pink);
getContentPane().setLayout(new BorderLayout(5,5));
// Heading
JLabel heading = new JLabel("BATCH MODE INPUT");
getContentPane().add(heading,BorderLayout.NORTH);
JPanel instructPanel = new JPanel();
instructPanel.setBackground(Color.pink);
instructPanel.setLayout(new GridLayout(3,1));
Label label1 = new Label("BATCH MODE INPUT");
Label label2 = new Label("Instructions: Press enter to confirm " +
"a changed value,");
Label label3 = new Label(" and \"Set batch mode parameters\" to " +
"implement change.");
instructPanel.add(label1);
instructPanel.add(label2);
instructPanel.add(label3);
getContentPane().add(instructPanel,BorderLayout.NORTH);
// Panel
createPanel();
getContentPane().add(panel,BorderLayout.CENTER);
// Set Button
JButton setButton = new JButton("Set batch mode parameters");
setButton.addActionListener(this);
getContentPane().add(setButton,BorderLayout.SOUTH);
}
/** Creates panel for text fields. */
private void createPanel() {
// Creat panel and set layout
panel = new JPanel();
panel.setLayout(new GridLayout(4,4,5,5));
// Add top row of labels
JLabel[] bmLables2 = new JLabel[SEC_BM_LABELS.length];
for (int index=0;indexActionEvent class. */
public void actionPerformed(ActionEvent event) {
String textString;
// Check for set button
if (event.getActionCommand().equals("Set batch mode parameters"))
setInputBmode();
// Else ID source field index
else {
int index1 = 0;
int index2 = 0;
boolean foundField = false;
for ( ;index10) {
if (batchValues[index1][0] > batchValues[index1][1]) {
String s = "\"Start\" value for " + PRIME_BM_LABELS[index1] +
" batch mode parameters\nmust be less than or equal " +
"to \"End\" value,\n" + batchValues[index1][0] + ">=" +
batchValues[index1][1] + "!";
JOptionPane.showMessageDialog(this,s,
"Batch mode Input Error: ",
JOptionPane.ERROR_MESSAGE);
return(!okToProceed);
}
}
// Check step value is not 0
else {
String s = "\"Step\" value for " + PRIME_BM_LABELS[index1] +
" batch mode parameters\ncannot be 0 otherwise batch " +
" will not terminate!";
JOptionPane.showMessageDialog(this,s,"Batch mode Input Error: ",
JOptionPane.ERROR_MESSAGE);
return(!okToProceed);
}
// Return
return(okToProceed);
}
/* --------------------------------------------------- */
/* */
/* CONSTRUCTORS */
/* */
/* --------------------------------------------------- */
/** Outputs the batch mode parameters for the given instance of the
generator model class.
@param textArea the given instance of the class JTextArea. */
public void outputBMparams(JTextArea textArea) {
textArea.append("Batch mode parameters:\n");
// Loop
for(int index1=0;index1