import java.awt.Dimension;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Brian
*/
public class DataMinerInterface extends javax.swing.JFrame {
/**
* Creates new form DataMinerInterface
*/
public DataMinerInterface() {
initComponents();
}
/**
* 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")
// //GEN-BEGIN:initComponents
private void initComponents() {
jFileChooser1 = new javax.swing.JFileChooser();
PopUp = new javax.swing.JDialog();
NADP = new javax.swing.JButton();
NAD = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
PopUp2 = new javax.swing.JDialog();
MineECs = new javax.swing.JButton();
ScanExceptions = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jProgressBar1 = new javax.swing.JProgressBar();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jFileChooser1.setDialogTitle("Select an input file (.txt or .pdf)");
jFileChooser1.setFocusCycleRoot(true);
jFileChooser1.setName("Select an input file (.txt or .pdf)"); // NOI18N
PopUp.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
PopUp.setSize(new java.awt.Dimension(200, 220));
PopUp.setType(java.awt.Window.Type.POPUP);
NADP.setText("NADP");
NADP.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NADPActionPerformed(evt);
}
});
NAD.setText("NAD");
NAD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NADActionPerformed(evt);
}
});
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Mine for NAD or NADP?");
javax.swing.GroupLayout PopUpLayout = new javax.swing.GroupLayout(PopUp.getContentPane());
PopUp.getContentPane().setLayout(PopUpLayout);
PopUpLayout.setHorizontalGroup(
PopUpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addGroup(PopUpLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PopUpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(NAD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(NADP, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
PopUpLayout.setVerticalGroup(
PopUpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PopUpLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(NAD, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(NADP, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(53, 53, 53))
);
PopUp2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
PopUp2.setSize(new java.awt.Dimension(200, 220));
PopUp2.setType(java.awt.Window.Type.POPUP);
MineECs.setText("Mine ECs");
MineECs.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MineECsActionPerformed(evt);
}
});
ScanExceptions.setText("Scan for Exceptions");
ScanExceptions.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ScanExceptionsActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("Mine for NAD or NADP?");
javax.swing.GroupLayout PopUp2Layout = new javax.swing.GroupLayout(PopUp2.getContentPane());
PopUp2.getContentPane().setLayout(PopUp2Layout);
PopUp2Layout.setHorizontalGroup(
PopUp2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addGroup(PopUp2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(PopUp2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(MineECs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ScanExceptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
PopUp2Layout.setVerticalGroup(
PopUp2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PopUp2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(MineECs, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(ScanExceptions, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(78, 78, 78))
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(153, 153, 153));
setResizable(false);
setSize(new java.awt.Dimension(640, 500));
jProgressBar1.setForeground(new java.awt.Color(0, 255, 0));
jProgressBar1.setToolTipText("");
jProgressBar1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jProgressBar1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jProgressBar1.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
jProgressBar1.setRequestFocusEnabled(false);
jProgressBar1.setStringPainted(true);
jLabel1.setFont(new java.awt.Font("Impact", 0, 24)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Data Miner");
jTextArea1.setEditable(false);
jTextArea1.setColumns(20);
jTextArea1.setLineWrap(true);
jTextArea1.setRows(5);
jTextArea1.setText("Welcome to Data Miner!\n");
jTextArea1.setWrapStyleWord(true);
jTextArea1.setDisabledTextColor(new java.awt.Color(0, 0, 0));
jScrollPane1.setViewportView(jTextArea1);
jButton1.setAutoscrolls(true);
jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton1.setLabel("Select File(s)");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Start");
jButton2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jProgressBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(13, 13, 13)
.addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// //GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here: Select Files button
this.jFileChooser1.setPreferredSize(new Dimension(640,480));
this.jFileChooser1.setMultiSelectionEnabled(true);
this.jFileChooser1.showOpenDialog(this);
this.files = jFileChooser1.getSelectedFiles();
for (File f : files){
this.addText(f+"\n");
}
this.addText("\n");
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here: Start Button
//System.out.println(DM);
if(files == null || files.length == 0){
this.addText("No File(s) Selected!\n");
this.addText("\n");
}
else if (files[0].toString().contains(".txt"))
{
Thread thread = new Thread(){
public void run(){
try {
addText("Mining KEGG...\n");
addText("\n");
DM.mineKegg(files);
} catch (Exception ex) {
Logger.getLogger(DataMinerInterface.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
thread.start();
jButton2.setEnabled(false);
}
else if (files[0].toString().contains(".pdf"))
{
//Pop-up prompts for NAD or NADP Criterion
PopUp.setVisible(true);
//jButton2.setEnabled(false);
}
}//GEN-LAST:event_jButton2ActionPerformed
private void NADActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NADActionPerformed
// TODO add your handling code here:
this.isNAD = true;
PopUp.setVisible(false);
PopUp2.setVisible(true);
}//GEN-LAST:event_NADActionPerformed
private void NADPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NADPActionPerformed
// TODO add your handling code here:
this.isNAD = false;
PopUp.setVisible(false);
PopUp2.setVisible(true);
}//GEN-LAST:event_NADPActionPerformed
private void MineECsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MineECsActionPerformed
//Starts PDF Mining
jButton2.setEnabled(false);
PopUp2.setVisible(false);
Thread thread = new Thread(){
public void run(){
try {
addText("Mining PDFs...\n");
addText("\n");
DM.minePDF(files,isNAD);
jProgressBar1.setValue(100);
addText("Complete...\n");
addText("\n");
} catch (Exception ex) {
Logger.getLogger(DataMinerInterface.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
thread.start();
}//GEN-LAST:event_MineECsActionPerformed
private void ScanExceptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ScanExceptionsActionPerformed
//Starts Exceptions Scanning
jButton2.setEnabled(false);
PopUp2.setVisible(false);
Thread thread = new Thread(){
public void run(){
try {
addText("Mining PDFs...\n");
addText("\n");
DM.scanSpecialCases(files,isNAD);
jProgressBar1.setValue(100);
addText("Complete...\n");
addText("\n");
} catch (Exception ex) {
Logger.getLogger(DataMinerInterface.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
thread.start();
}//GEN-LAST:event_ScanExceptionsActionPerformed
/**
* @param args the command line arguments
* @throws java.lang.Exception
*/
public static void main(String args[]) throws Exception{
//Instantiates DMI Object
DataMinerInterface DMI = new DataMinerInterface();
DMI.addDM(DMI);
/* Set the Nimbus look and feel */
//
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see https://urldefense.proofpoint.com/v2/url?u=http-3A__download.oracle.com_javase_tutorial_uiswing_lookandfeel_plaf.html&d=AwIGAg&c=1QsCMERiq7JOmEnKpsSyjg&r=j9BjNmxXIwCVhVOItuh4qA&m=DKh9xIxhDhnzC8qOe7BJ_a7V6hroczkaCz_-G2-e5e0&s=d7CY-zAW4RwxU3HCxLImF6BYVIdXZSNsvwmaOoV9Bbs&e=
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//System.out.println(info.getName());
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DataMinerInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DataMinerInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DataMinerInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DataMinerInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
DMI.setVisible(true);
}
});
}
//Utility Methods
public void addText(String s)
{
s = jTextArea1.getText() + s;
jTextArea1.setText(s);
}
//Getter Methods
public JProgressBar getProgressBar(){
return this.jProgressBar1;
}
public JTextArea getTextArea(){
return this.jTextArea1;
}
public DataMiner getDM(){
return this.DM;
}
public JButton getStartButton(){
return this.jButton2;
}
public void addDM(DataMinerInterface DMI){
this.DM = new DataMiner(DMI);
}
//DMI Variables
private File[] files;
private DataMiner DM;
private boolean isNAD;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton MineECs;
private javax.swing.JButton NAD;
private javax.swing.JButton NADP;
private javax.swing.JDialog PopUp;
private javax.swing.JDialog PopUp2;
private javax.swing.JButton ScanExceptions;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration//GEN-END:variables
}