summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app/App.java12
-rw-r--r--src/args/ArgsManager.java3
-rw-r--r--src/client/DriverJPanel.java30
-rw-r--r--src/client/GUI.java22
-rw-r--r--src/client/JPanelTypeA.java (renamed from src/client/GUITypeA.java)4
-rw-r--r--src/client/MainWindow.java72
6 files changed, 89 insertions, 54 deletions
diff --git a/src/app/App.java b/src/app/App.java
index 34c91ff..f652d66 100644
--- a/src/app/App.java
+++ b/src/app/App.java
@@ -4,12 +4,20 @@ import org.manzerbredes.open_klm.args.ArgsManager;
import org.manzerbredes.open_klm.client.MainWindow;
import org.manzerbredes.open_klm.drivers.*;
+
+
/**
- * Hello world!
+ * Open KLM Application
*
*/
public class App
{
+
+ /**
+ * Entry point
+ *
+ * @param args
+ */
public static void main( String[] args )
{
// Get driver
@@ -25,7 +33,7 @@ public class App
// Else run GUI
try {
- MainWindow mw = new MainWindow(aDriver);
+ new MainWindow(aDriver);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/src/args/ArgsManager.java b/src/args/ArgsManager.java
index 332553c..f43edde 100644
--- a/src/args/ArgsManager.java
+++ b/src/args/ArgsManager.java
@@ -1,8 +1,7 @@
package org.manzerbredes.open_klm.args;
import org.manzerbredes.open_klm.drivers.Driver;
-import org.manzerbredes.open_klm.drivers.DriverTypeA;
-import org.manzerbredes.open_klm.drivers.Driver_1770_ff00;
+
/**
*
diff --git a/src/client/DriverJPanel.java b/src/client/DriverJPanel.java
new file mode 100644
index 0000000..a88af43
--- /dev/null
+++ b/src/client/DriverJPanel.java
@@ -0,0 +1,30 @@
+package org.manzerbredes.open_klm.client;
+
+import org.manzerbredes.open_klm.drivers.Driver;
+
+/**
+ * JPanel for a specific driver. Each panel who manage
+ * a driver must implement this interface.
+ *
+ * @author Manzerbredes
+ *
+ */
+public interface DriverJPanel{
+
+
+ /**
+ * Get the type of driver handled by the JPanel
+ *
+ * @return class Class that represent the type of the driver the JPanel handle
+ */
+ public Class<?> getType();
+
+ /**
+ *
+ * Init the JPanel with a driver (driver must have the correct type)
+ *
+ * @param driver The driver to manage
+ * @return True if success to init, False else
+ */
+ public boolean initUI(Driver driver);
+} \ No newline at end of file
diff --git a/src/client/GUI.java b/src/client/GUI.java
deleted file mode 100644
index 8c561ee..0000000
--- a/src/client/GUI.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.manzerbredes.open_klm.client;
-
-import org.manzerbredes.open_klm.drivers.Driver;
-
-public interface GUI{
-
- /**
- * Get the type of driver the GUI handle
- *
- * @return class that represent the type of the driver the GUI handle
- */
- public Class<?> getType();
-
- /**
- *
- * Init the GUI with driver
- *
- * @param driver
- * @return
- */
- public boolean initGUI(Driver driver);
-} \ No newline at end of file
diff --git a/src/client/GUITypeA.java b/src/client/JPanelTypeA.java
index dcca028..15c9800 100644
--- a/src/client/GUITypeA.java
+++ b/src/client/JPanelTypeA.java
@@ -15,7 +15,7 @@ import org.manzerbredes.open_klm.drivers.DriverTypeA.Color;
import org.manzerbredes.open_klm.drivers.DriverTypeA.Intensity;
import org.manzerbredes.open_klm.drivers.DriverTypeA.Region;
-public class GUITypeA extends JPanel implements GUI{
+public class JPanelTypeA extends JPanel implements DriverJPanel{
private JComboBox<Color> left;
@@ -25,7 +25,7 @@ public class GUITypeA extends JPanel implements GUI{
private DriverTypeA keyboardTypeA;
@Override
- public boolean initGUI(Driver driver){
+ public boolean initUI(Driver driver){
if(driver.getType().equals(DriverTypeA.class)){
diff --git a/src/client/MainWindow.java b/src/client/MainWindow.java
index f42ecef..f3fbf63 100644
--- a/src/client/MainWindow.java
+++ b/src/client/MainWindow.java
@@ -1,43 +1,51 @@
package org.manzerbredes.open_klm.client;
-import java.awt.EventQueue;
-import java.awt.GridLayout;
-import java.awt.Label;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
+import javax.swing.*;
import org.manzerbredes.open_klm.drivers.*;
-import org.manzerbredes.open_klm.drivers.DriverTypeA.*;
+/**
+ * Main Window
+ *
+ * @author Manzerbredes
+ *
+ */
public class MainWindow extends JFrame {
+ /**
+ * Define serial Version UID
+ */
+ private static final long serialVersionUID = 8058826286308946977L;
+
- private Class<?>[] availableGUI={
- GUITypeA.class
+ /**
+ * Contain all JPanel corresponding to each driver type
+ */
+ private Class<?>[] driverJPanels={
+ JPanelTypeA.class
};
+
+ /**
+ * Build a main window
+ * @param aDriver
+ */
public MainWindow(Driver aDriver){
- // Configure MainWindow
- this.setTitle("Open KLM");
- this.setSize(700, 500);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
+ // Configure main window
+ this.initUI();
-
- for(int i=0;i<this.availableGUI.length;i++){
+ // Add driver panel
+ for(int i=0;i<this.driverJPanels.length;i++){
try {
- GUI gui=(GUI) availableGUI[i].newInstance();
- if(gui.getType().equals(aDriver.getType())){
- if(gui.initGUI(aDriver)){
- this.add((JPanel) gui);
+ // Build a panel
+ DriverJPanel driverJPanel=(DriverJPanel) driverJPanels[i].newInstance();
+ // If the panel have the same type of the driver try to init it
+ if(driverJPanel.getType().equals(aDriver.getType())){
+ // If init success add it to the main window
+ if(driverJPanel.initUI(aDriver)){
+ this.add((JPanel) driverJPanel);
}
}
@@ -46,9 +54,21 @@ public class MainWindow extends JFrame {
}
}
-
+ // Display the main window
this.setVisible(true);
}
+
+
+ /**
+ * Configure main window
+ */
+ private void initUI(){
+ // Configure MainWindow
+ this.setTitle("Open KLM");
+ this.setSize(700, 500);
+ setLocationRelativeTo(null);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ }
} \ No newline at end of file