/***********************************************************************
This file is part of KEEL-software, the Data Mining tool for regression,
classification, clustering, pattern mining and so on.
Copyright (C) 2004-2010
F. Herrera (herrera@decsai.ugr.es)
L. Sánchez (luciano@uniovi.es)
J. Alcalá-Fdez (jalcala@decsai.ugr.es)
S. García (sglopez@ujaen.es)
A. Fernández (alberto.fernandez@ujaen.es)
J. Luengo (julianlm@decsai.ugr.es)
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 3 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, see http://www.gnu.org/licenses/
**********************************************************************/
/**
* <p>
* @author Written by Francisco Fernández Navarro (University of Córdoba)
* @author Modified by Juan Carlos Fernandez Caballerero (University of Cordoba)
* @author Modified by Pedro Antonio Gutierrez Peña (University of Cordoba)
* @version 1.0
* @since JDK 1.5
* </p>
*/
package keel.GraphInterKeel.experiments;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import keel.RunKeelTxtDocente.EducationalRunKeelTxt;
import org.jdom.Element;
public class EducationalRun extends javax.swing.JFrame implements WindowListener, IEducationalRunkeelListener<EducationalRunKeelTxt>
{
/**
* <p>
* Visual Class for running on-line experiments
* </p>
*/
/**
* <p>
* Constructor
* Creates new form EducationalRun
* </p>
*/
public EducationalRun() {
initComponents();
this.setTitle("Educational");
this.setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/keel/GraphInterKeel/resources/ico/logo/logo.gif")));
}
/**
* <p>
* Constructor
* Interaction with Experiments.java
* </p>
* @param listener
*/
public EducationalRun(IEducationalRunListener<EducationalRun> listener)
{
super();
this.listener = listener;
this.experiment = (Experiments)listener;
initComponents();
this.setTitle("Educational");
this.setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/keel/GraphInterKeel/resources/ico/logo/logo.gif")));
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
experimentManagementPanel = new javax.swing.JPanel();
labelInitialTime = new javax.swing.JLabel();
startButton = new javax.swing.JButton();
suspendResumenButton = new javax.swing.JButton();
stopButton = new javax.swing.JButton();
finalTimeLabel = new javax.swing.JLabel();
initialTimeTextField = new javax.swing.JTextField();
finalTimeTextField = new javax.swing.JTextField();
runTimeLabel = new javax.swing.JLabel();
progressLabel = new javax.swing.JLabel();
runTimeTextField = new javax.swing.JTextField();
runProgressBar = new javax.swing.JProgressBar();
staticStateLabel = new javax.swing.JLabel();
stateLabel = new javax.swing.JLabel();
partitionAreaPanel = new javax.swing.JPanel();
partitionAreaScrollPane = new javax.swing.JScrollPane();
partitionAreaTextArea = new javax.swing.JTextArea();
reportAreaPanel = new javax.swing.JPanel();
selectorTabbedPane = new javax.swing.JTabbedPane();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(750, 525));
setName("Educational"); // NOI18N
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
getContentPane().setLayout(new java.awt.GridBagLayout());
experimentManagementPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Experiment Management"));
experimentManagementPanel.setMinimumSize(new java.awt.Dimension(350, 280));
experimentManagementPanel.setName("experimentManagementPanel"); // NOI18N
experimentManagementPanel.setPreferredSize(new java.awt.Dimension(350, 280));
experimentManagementPanel.setLayout(new java.awt.GridBagLayout());
labelInitialTime.setText("Initial Time:");
labelInitialTime.setName("labelInitialTime"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0);
experimentManagementPanel.add(labelInitialTime, gridBagConstraints);
startButton.setText("Start");
startButton.setMaximumSize(new java.awt.Dimension(121, 23));
startButton.setMinimumSize(new java.awt.Dimension(121, 23));
startButton.setName("startButton"); // NOI18N
startButton.setPreferredSize(new java.awt.Dimension(121, 23));
startButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
startButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 6;
gridBagConstraints.ipady = 5;
experimentManagementPanel.add(startButton, gridBagConstraints);
suspendResumenButton.setText("Suspend/Resume");
suspendResumenButton.setName("suspendResumenButton"); // NOI18N
suspendResumenButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
suspendResumenButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
experimentManagementPanel.add(suspendResumenButton, gridBagConstraints);
stopButton.setText("Stop");
stopButton.setMaximumSize(new java.awt.Dimension(121, 23));
stopButton.setMinimumSize(new java.awt.Dimension(121, 23));
stopButton.setName("stopButton"); // NOI18N
stopButton.setPreferredSize(new java.awt.Dimension(121, 23));
stopButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
stopButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.ipadx = 39;
gridBagConstraints.ipady = 4;
gridBagConstraints.insets = new java.awt.Insets(13, 65, 0, 65);
experimentManagementPanel.add(stopButton, gridBagConstraints);
finalTimeLabel.setText("Final Time:");
finalTimeLabel.setName("finalTimeLabel"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
experimentManagementPanel.add(finalTimeLabel, gridBagConstraints);
initialTimeTextField.setName("initialTimeTextField"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0);
experimentManagementPanel.add(initialTimeTextField, gridBagConstraints);
finalTimeTextField.setName("finalTimeTextField"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
experimentManagementPanel.add(finalTimeTextField, gridBagConstraints);
runTimeLabel.setText("Run Time (s):");
runTimeLabel.setName("runTimeLabel"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
experimentManagementPanel.add(runTimeLabel, gridBagConstraints);
progressLabel.setText("Progress:");
progressLabel.setName("progressLabel"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 6;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(23, 0, 3, 0);
experimentManagementPanel.add(progressLabel, gridBagConstraints);
runTimeTextField.setName("runTimeTextField"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
experimentManagementPanel.add(runTimeTextField, gridBagConstraints);
runProgressBar.setName("runProgressBar"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 6;
gridBagConstraints.insets = new java.awt.Insets(22, 0, 4, 0);
experimentManagementPanel.add(runProgressBar, gridBagConstraints);
staticStateLabel.setText("State:");
staticStateLabel.setName("State:"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(22, 0, 0, 0);
experimentManagementPanel.add(staticStateLabel, gridBagConstraints);
stateLabel.setName("stateLabel"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(22, 0, 0, 0);
experimentManagementPanel.add(stateLabel, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.ipadx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
getContentPane().add(experimentManagementPanel, gridBagConstraints);
partitionAreaPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("PartitionArea"));
partitionAreaPanel.setMinimumSize(new java.awt.Dimension(287, 240));
partitionAreaPanel.setName("partitionAreaPanel"); // NOI18N
partitionAreaPanel.setPreferredSize(new java.awt.Dimension(287, 240));
partitionAreaPanel.setLayout(new java.awt.GridBagLayout());
partitionAreaScrollPane.setMinimumSize(new java.awt.Dimension(50, 75));
partitionAreaScrollPane.setName(""); // NOI18N
partitionAreaTextArea.setColumns(20);
partitionAreaTextArea.setEditable(false);
partitionAreaTextArea.setRows(5);
partitionAreaTextArea.setMinimumSize(new java.awt.Dimension(60, 17));
partitionAreaTextArea.setName("partitionAreaTextArea"); // NOI18N
partitionAreaScrollPane.setViewportView(partitionAreaTextArea);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
partitionAreaPanel.add(partitionAreaScrollPane, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.ipadx = 1;
gridBagConstraints.ipady = 18;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints.weighty = 1.0;
getContentPane().add(partitionAreaPanel, gridBagConstraints);
reportAreaPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Report Area"));
reportAreaPanel.setAutoscrolls(true);
reportAreaPanel.setMinimumSize(new java.awt.Dimension(400, 340));
reportAreaPanel.setName("reportAreaPanel"); // NOI18N
reportAreaPanel.setPreferredSize(new java.awt.Dimension(400, 340));
reportAreaPanel.setLayout(new java.awt.GridBagLayout());
selectorTabbedPane.setBackground(new java.awt.Color(148, 148, 148));
selectorTabbedPane.setAutoscrolls(true);
selectorTabbedPane.setMinimumSize(new java.awt.Dimension(400, 300));
selectorTabbedPane.setName("selectorTabbedPane"); // NOI18N
selectorTabbedPane.setPreferredSize(new java.awt.Dimension(400, 300));
selectorTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
selectorTabbedPaneStateChanged(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
reportAreaPanel.add(selectorTabbedPane, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
getContentPane().add(reportAreaPanel, gridBagConstraints);
pack();
}// </editor-fold>//GEN-END:initComponents
private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
//Clean Report Area (right panel
this.selectorTabbedPane.removeAll();
//Start button isn´t already pressed
if(ejp==null)
{
this.stateLabel.setText("Running");
this.initialTimeTextField.setText("");
this.finalTimeTextField.setText("");
this.runTimeTextField.setText("");
this.initialTimeTextField.setText((Calendar.getInstance().getTime()).toString());
this.totalTimeComputational = 0.0;
this.progressionValue = 0;
this.partitionCounter = 0; //for progressbar
this.runProgressBar.setValue(progressionValue);
this.partitionAreaTextArea.setText("");
this.partitionAreaTextArea.setBackground(Color.WHITE);
/************* Threads out of control:
start->suspend->start->suspend.
*************************/
this.stop = false;
this.kill = false;
this.naturalFinish = false;
// CLASSIFICATION = 0, REGRESSION = 1 or UNSUPERVISED = 2
this.runkeel = new EducationalRunKeelTxt(this.experiment.experimentType());
/*runkeel.setTipoExperimento(experiment.experimentType());*/
//Partition type: 5x2, kfold
/*runkeel.setTipoParticion(experiment.partitionType());*/
//Number of partitions
this.partitionNumberValue = this.runkeel.getTotalPartitions();
//Thread for RunKeelTxtDocente.java
this.ejp = new EducationalPartitionsRun(this.runkeel,this);
this.ejp.start();
}
startButton.setEnabled(false);
stopButton.setEnabled(true);
}//GEN-LAST:event_startButtonActionPerformed
private void suspendResumenButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_suspendResumenButtonActionPerformed
//Experiment finalized in no natural way
if(this.naturalFinish == false && this.kill == false)
{
//suspend
if (this.stop == false && this.kill == false)
{
this.stateLabel.setText("Pause");
this.stop = true;
//experiment suspend
runkeel.stopProcess();
}
//reanude
else if(stop == true && kill == false)
{
//reanude experiment
this.stateLabel.setText("Runing");
this.stop = false;
this.runkeel.reanudeProcess();
}
}
}//GEN-LAST:event_suspendResumenButtonActionPerformed
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
startButton.setEnabled(true);
stopButton.setEnabled(false);
// Partitions have finished. Kill experiment
if(this.naturalFinish==false)
{
this.stateLabel.setText("Stop");
this.kill = true;
//null pointer exception if stop button is pressed in two occassions
//and experiment has finished already
if(this.runkeel!=null)
{
List<Element> sentencias;
sentencias = runkeel.getActualJobSentences();
if(this.actualProblemType.equals("Method"))
{
EducationalMethodReport inf = new EducationalMethodReport((ArrayList<Element>) sentencias, experiment.experimentType());
inf.running();
}
else if(this.actualProblemType.equals("Preprocess-D"))
{
EducationalDiscretizerReport inf = new EducationalDiscretizerReport((ArrayList<Element>) sentencias, experiment.experimentType());
inf.running();
}
else if (this.actualProblemType.equals("Preprocess-TSS") == true)
{
EducationalISReport inf = new EducationalISReport((ArrayList<Element>) sentencias, experiment.experimentType());
inf.running();
}
else if (this.actualProblemType.equals("Preprocess-FS") == true)
{
EducationalFSReport inf = new EducationalFSReport((ArrayList<Element>) sentencias, experiment.experimentType());
inf.running();
}
try {
showReport(runkeel.getNumberofJobFinished() + 1);
} catch (IOException ex) {
Logger.getLogger(EducationalRun.class.getName()).log(Level.SEVERE, null, ex);
}
runkeel.killProcess();
}
}
}//GEN-LAST:event_stopButtonActionPerformed
private void selectorTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_selectorTabbedPaneStateChanged
}//GEN-LAST:event_selectorTabbedPaneStateChanged
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
//kill window of partitions
if(runkeel!=null)
runkeel.killProcess();
ejp = null;
runkeel = null;
keel.GraphInterKeel.datacf.util.FileUtils.deletePath(new File("./experiment"));
//Close window event
EducationalRunEvent<EducationalRun> event = new EducationalRunEvent<EducationalRun>(this);
this.listener.closedEducationalExec(event);
}//GEN-LAST:event_formWindowClosing
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new EducationalRun().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel experimentManagementPanel;
private javax.swing.JLabel finalTimeLabel;
private javax.swing.JTextField finalTimeTextField;
private javax.swing.JTextField initialTimeTextField;
private javax.swing.JLabel labelInitialTime;
private javax.swing.JPanel partitionAreaPanel;
private javax.swing.JScrollPane partitionAreaScrollPane;
private javax.swing.JTextArea partitionAreaTextArea;
private javax.swing.JLabel progressLabel;
private javax.swing.JPanel reportAreaPanel;
private javax.swing.JProgressBar runProgressBar;
private javax.swing.JLabel runTimeLabel;
private javax.swing.JTextField runTimeTextField;
private javax.swing.JTabbedPane selectorTabbedPane;
private javax.swing.JButton startButton;
private javax.swing.JLabel stateLabel;
private javax.swing.JLabel staticStateLabel;
private javax.swing.JButton stopButton;
private javax.swing.JButton suspendResumenButton;
// End of variables declaration//GEN-END:variables
protected IEducationalRunListener<EducationalRun> listener;
private Experiments experiment;
private EducationalPartitionsRun ejp = null;
private double totalTimeComputational = 0.0;
private int progressionValue = 0;
private int partitionCounter = 0;
private boolean stop = false;
private boolean kill = false;
private boolean naturalFinish = true;
private EducationalRunKeelTxt runkeel = null;
private int partitionNumberValue = 0;
private String actualProblemType = "";
/**
* <p>
* This method is invoqued when a partition is finished.
*</p>
* @param event Event in EducationalRunKeelTxt
*
*/
public void runKeelIterationCompleted(EducationalRunkeelEvent<EducationalRunKeelTxt> event)
{
EducationalRunKeelTxt aux = event.getRunkeel();
//If a partition is interrupted.
if (aux.isInterrumpted()==false || (aux.isInterrumpted()==true && aux.getexecExternoFinalizado()==true) )
{
this.partitionCounter++;
if (this.partitionCounter==this.partitionNumberValue)
this.progressionValue = 100;
else
this.progressionValue = this.progressionValue + (100/this.partitionNumberValue);
this.runProgressBar.setValue(this.progressionValue);
this.actualProblemType = aux.getProblemType();
if(this.actualProblemType.equals("Method"))
{
String nameExp = runkeel.getActualNameExperiment();
this.partitionAreaTextArea.append("\"" + "Method : " + nameExp + "\"" + ", partition "
+ aux.calculatePartitionDatNameFile(this.partitionCounter-1)+ ", seed " + aux.calculateActualSeed() + "\n");
this.partitionAreaTextArea.append("Compute time: "+ EducationalRun.round(aux.getPartitionTime(),3)
+ " seconds" + "\n");
this.totalTimeComputational = EducationalRun.round((this.totalTimeComputational + aux.getPartitionTime()),3);
}
else if(aux.getProblemType().equals("Preprocess-D") == true || aux.getProblemType().equals("Preprocess-TSS") == true
|| aux.getProblemType().equals("Preprocess-FS") == true)
{
String nameExp = this.runkeel.getActualNameExperiment();
this.partitionAreaTextArea.append("\"" + "Preprocess method : " + nameExp + "\"" + ", partition "
+ aux.calculatePartitionDatNameFile(this.partitionCounter-1)+ ", seed " + aux.calculateActualSeed() + "\n");
this.partitionAreaTextArea.append("Compute time: "+ EducationalRun.round(aux.getPartitionTime(),3)
+ " seconds" + "\n");
this.totalTimeComputational = EducationalRun.round((this.totalTimeComputational + aux.getPartitionTime()),3);
}
else{
this.partitionAreaTextArea.append("\"" + aux.getProblemType() + "\n");
}
}
if(aux.nJobFinished()==true)
try {
showReport(aux.getNumberofJobFinished());
} catch (IOException ex) {
Logger.getLogger(EducationalRun.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* <p>
* This method is invoqued when the partitions
* have finished in natural way or not
*</p>
*
*/
public void runKeelFinished(EducationalRunkeelEvent<EducationalRunKeelTxt> event)
{
if (this.kill == true)
{
//experiment finished early
this.stateLabel.setText("Stop");
this.finalTimeTextField.setText((Calendar.getInstance().getTime()).toString());
this.runTimeTextField.setText(Double.toString(this.totalTimeComputational));
this.totalTimeComputational = 0.0;
}
else if(this.kill == false && this.stop == false)
{
//experiment finished in natural way
this.stateLabel.setText("Finished");
this.finalTimeTextField.setText((Calendar.getInstance().getTime()).toString());
this.runTimeTextField.setText(Double.toString(this.totalTimeComputational));
this.naturalFinish = true;
this.totalTimeComputational = 0.0;
}
this.runkeel = null;
this.ejp = null;
}
/**
* <p>
* This method show the report in screen.
* Report.txt file is readed and shown
*</p>
* @return void
*/
private void showReport(int NumberofJob) throws IOException
{
FileReader fr = null;
BufferedReader br = null;
String cad = "";
String filePath = "";
JPanel jp1 = null;
JScrollPane jsp = null;
// Only the first time is removed
if(NumberofJob==0)
{
//Remove report area
this.selectorTabbedPane.removeAll();
}
filePath = runkeel.obtainReportFilePath();
String cadenaAuxExp = runkeel.getActualNameExperiment();
this.selectorTabbedPane.insertTab(cadenaAuxExp, null, getReportPane(), null, NumberofJob);
this.repaint();
try
{
fr = new FileReader(filePath);
br = new BufferedReader(fr);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
try
{
cad = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
while (cad!=null)
{
jp1 = (JPanel) this.selectorTabbedPane.getComponentAt(NumberofJob);
jsp = (JScrollPane) jp1.getComponent(0);
((JTextArea)jsp.getViewport().getView()).setBackground(Color.WHITE);
((JTextArea)jsp.getViewport().getView()).append(cad + "\n");
//((JTextArea)this.selectorTabbedPane.getComponentAt(NumberofJob)).setBackground(Color.WHITE);
//((JTextArea)this.selectorTabbedPane.getComponentAt(NumberofJob)).append(cadena + "\n");
try
{
cad = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
}
try
{
fr.close();
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
/**
* <p>
* When the user close the window of
* partitions. Then the experiment finished
*</p>
* @param arg0 Window event
*
*/
public void windowClosing(WindowEvent arg0)
{
this.formWindowClosing(arg0);
}
public void windowOpened(WindowEvent arg0)
{
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
this.formWindowClosing(arg0);
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
/**
* <p>
* Round a double with a decimal precision determined
* </p>
* @return double
*/
public static double round(double num,int ndecimal)
{
double aux0 = Math.pow(10,ndecimal);
double aux = num * aux0;
int tmp = (int) aux;
return (double) (tmp / aux0) ;
}
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* <p>
* This method initializes panelInforme
* </p>
* @return javax.swing.JPanel
*/
private JPanel getReportPane()
{
JPanel reportPane = new JPanel();
reportPane.setBorder(javax.swing.BorderFactory.createTitledBorder("Report Area"));
reportPane.setLayout(new BorderLayout());
reportPane.add(getPanelScrollInforme(), java.awt.BorderLayout.CENTER);
reportPane.setVisible(true);
return reportPane;
}
/**
* <p>
* This method initializes panelScrollInforme
*</p>
* @return javax.swing.JScrollPane
*/
private JScrollPane getPanelScrollInforme()
{
JScrollPane panelScrollInforme = new JScrollPane();
panelScrollInforme.setViewportView(getReportTextArea());
return panelScrollInforme;
}
/**
* <p>
* This method initializes areaTextoInforme
*</p>
* @return javax.swing.JTextArea
*/
private JTextArea getReportTextArea()
{
JTextArea reportTextArea = new JTextArea();
reportTextArea.setEditable(false);
reportTextArea.setBackground(new Color(119,119,119));
return reportTextArea;
}
}