package zdenekdrahos.App.View;
import zdenekdrahos.App.Controller.SourceDataController;
import zdenekdrahos.App.Controller.KohonenMapController;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import zdenekdrahos.AI.KohonenMap.KohonenMap;
import zdenekdrahos.App.Controller.BackPropagationController;
public class MainWindow extends javax.swing.JFrame {
public MainWindow() throws ClassNotFoundException, InstantiationException, UnsupportedLookAndFeelException, IllegalAccessException {
initComponents();
centerFrame();
setControllers();
switchCard("sourceData");
}
private void setControllers() {
KohonenMapController kohonenController = new KohonenMapController(new KohonenMap());
SourceDataController dataController = new SourceDataController();
BackPropagationController backController = new BackPropagationController();
dataController.addObserver(kohonenController);
dataController.addObserver(backController);
kohonenController.addObserver(backController);
kohonenMapView.setController(kohonenController);
sourceDataView.setController(dataController);
backPropagationView.setController(backController);
}
private void centerFrame() {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
}
/**
* 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() {
contentJPanel = new javax.swing.JPanel();
kohonenMapView = new zdenekdrahos.App.View.KohonenMapView();
sourceDataView = new zdenekdrahos.App.View.SourceDataView();
backPropagationView = new zdenekdrahos.App.View.BackPropagationView();
menuJMenuBar = new javax.swing.JMenuBar();
sourceDataJMenu = new javax.swing.JMenu();
kohoneneJMenu = new javax.swing.JMenu();
backPropagationJMenu = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Zdeněk Drahoš - INUI2");
setBackground(new java.awt.Color(255, 255, 255));
setPreferredSize(new java.awt.Dimension(520, 610));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
contentJPanel.setBackground(new java.awt.Color(255, 255, 255));
contentJPanel.setLayout(new java.awt.CardLayout());
contentJPanel.add(kohonenMapView, "kohonenMap");
contentJPanel.add(sourceDataView, "sourceData");
contentJPanel.add(backPropagationView, "backPropagation");
getContentPane().add(contentJPanel);
sourceDataJMenu.setText("Load data");
sourceDataJMenu.setDelay(0);
sourceDataJMenu.setMargin(new java.awt.Insets(5, 5, 5, 5));
sourceDataJMenu.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
sourceDataJMenuMouseClicked(evt);
}
});
menuJMenuBar.add(sourceDataJMenu);
kohoneneJMenu.setText("Classify data (SOM)");
kohoneneJMenu.setDelay(0);
kohoneneJMenu.setMargin(new java.awt.Insets(5, 5, 5, 5));
kohoneneJMenu.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
kohoneneJMenuMouseClicked(evt);
}
});
menuJMenuBar.add(kohoneneJMenu);
backPropagationJMenu.setText("Learn data (Back propagation)");
backPropagationJMenu.setDelay(0);
backPropagationJMenu.setMargin(new java.awt.Insets(5, 5, 5, 5));
backPropagationJMenu.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
backPropagationJMenuMouseClicked(evt);
}
});
menuJMenuBar.add(backPropagationJMenu);
setJMenuBar(menuJMenuBar);
pack();
}// </editor-fold>//GEN-END:initComponents
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
System.exit(0);
}//GEN-LAST:event_formWindowClosing
private void sourceDataJMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sourceDataJMenuMouseClicked
switchCard("sourceData");
}//GEN-LAST:event_sourceDataJMenuMouseClicked
private void kohoneneJMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_kohoneneJMenuMouseClicked
switchCard("kohonenMap");
}//GEN-LAST:event_kohoneneJMenuMouseClicked
private void backPropagationJMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_backPropagationJMenuMouseClicked
switchCard("backPropagation");
}//GEN-LAST:event_backPropagationJMenuMouseClicked
private void switchCard(String name) {
CardLayout cl = (CardLayout) contentJPanel.getLayout();
cl.show(contentJPanel, name);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Windows look and feel */
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
new MainWindow().setVisible(true);
} catch (Exception e) {}
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenu backPropagationJMenu;
private zdenekdrahos.App.View.BackPropagationView backPropagationView;
private javax.swing.JPanel contentJPanel;
private zdenekdrahos.App.View.KohonenMapView kohonenMapView;
private javax.swing.JMenu kohoneneJMenu;
private javax.swing.JMenuBar menuJMenuBar;
private javax.swing.JMenu sourceDataJMenu;
private zdenekdrahos.App.View.SourceDataView sourceDataView;
// End of variables declaration//GEN-END:variables
}