aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src/PunchingBagGUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'PunchingBag/src/PunchingBagGUI.java')
-rw-r--r--PunchingBag/src/PunchingBagGUI.java115
1 files changed, 111 insertions, 4 deletions
diff --git a/PunchingBag/src/PunchingBagGUI.java b/PunchingBag/src/PunchingBagGUI.java
index 5f1b571..91d223a 100644
--- a/PunchingBag/src/PunchingBagGUI.java
+++ b/PunchingBag/src/PunchingBagGUI.java
@@ -6,6 +6,7 @@ import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@@ -20,6 +21,10 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
import javax.swing.ListCellRenderer;
public class PunchingBagGUI implements MouseListener, MouseMotionListener, ButtonListener, LEDListener {
@@ -62,10 +67,109 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener, Butto
bag.addButtonListener(this);
bag.addLEDChangeListener(this);
- frame.add(new PunchingBagSim(), BorderLayout.WEST);
+ JSplitPane bottomTopSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
- frame.add(new LEDControlPanel(), BorderLayout.CENTER);
+ JSplitPane centerTopSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ JTabbedPane tabbedPane = new JTabbedPane();
+ tabbedPane.addTab("LED Control Panel", null, new LEDControlPanel(), "Allows control of individual LED's");
+
+ centerTopSplitPane.setLeftComponent(new PunchingBagSim());
+ centerTopSplitPane.setRightComponent(tabbedPane);
+
+ bottomTopSplitPane.setTopComponent(centerTopSplitPane);
+ bottomTopSplitPane.setBottomComponent(new SerialPanel());
+
+ frame.add(bottomTopSplitPane, BorderLayout.CENTER);
+ }
+
+ class SerialPanel extends JPanel implements ActionListener {
+ JTextArea buttonIn = new JTextArea();
+ JTextArea buttonOut = new JTextArea();
+ JTextArea ledIn = new JTextArea();
+ JTextArea ledOut = new JTextArea();
+
+ public SerialPanel() {
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ JSplitPane buttonSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ JSplitPane ledSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ /*
+ * splitPane.setOneTouchExpandable(true);
+ * buttonSplitPane.setOneTouchExpandable(true);
+ * ledSplitPane.setOneTouchExpandable(true);
+ */
+
+ splitPane.setMinimumSize(new Dimension(200, 50));
+ buttonSplitPane.setMinimumSize(new Dimension(100, 50));
+ ledSplitPane.setMinimumSize(new Dimension(100, 50));
+
+ JButton clear = new JButton("Clear");
+ clear.addActionListener(this);
+
+ // buttonIn.setColumns(20);
+ // buttonIn.setRows(5);
+ buttonIn.setBorder(BorderFactory.createTitledBorder("Serial In - Button Arduino"));
+ // buttonOut.setColumns(20);
+ // buttonOut.setRows(5);
+ buttonOut.setBorder(BorderFactory.createTitledBorder("Serial Out - Button Arduino"));
+ // ledIn.setColumns(20);
+ // ledIn.setRows(5);
+ ledIn.setBorder(BorderFactory.createTitledBorder("Serial In - LED Arduino"));
+ // ledOut.setColumns(20);
+ // ledOut.setRows(5);
+ ledOut.setBorder(BorderFactory.createTitledBorder("Serial Out - LED Arduino"));
+
+ JPanel buttonInPanel = new JPanel();
+ JScrollPane areaScrollPane = new JScrollPane(buttonIn);
+ areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ areaScrollPane.setPreferredSize(new Dimension(250, 100));
+ buttonInPanel.add(areaScrollPane, BorderLayout.CENTER);
+ clear.setActionCommand("BI");
+ buttonInPanel.add(clear, BorderLayout.SOUTH);
+ buttonSplitPane.setLeftComponent(buttonInPanel);
+
+ JPanel buttonOutPanel = new JPanel();
+ areaScrollPane = new JScrollPane(buttonOut);
+ areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ areaScrollPane.setPreferredSize(new Dimension(250, 100));
+ buttonOutPanel.add(areaScrollPane, BorderLayout.CENTER);
+ clear = new JButton("Clear");
+ clear.setActionCommand("BO");
+ buttonOutPanel.add(clear, BorderLayout.SOUTH);
+ buttonSplitPane.setRightComponent(buttonOutPanel);
+
+ JPanel ledInPanel = new JPanel();
+ areaScrollPane = new JScrollPane(ledIn);
+ areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ areaScrollPane.setPreferredSize(new Dimension(250, 100));
+ ledInPanel.add(areaScrollPane, BorderLayout.CENTER);
+ clear = new JButton("Clear");
+ clear.setActionCommand("LI");
+ ledInPanel.add(clear, BorderLayout.SOUTH);
+ ledSplitPane.setLeftComponent(ledInPanel);
+
+ JPanel ledOutPanel = new JPanel();
+ areaScrollPane = new JScrollPane(ledOut);
+ areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ areaScrollPane.setPreferredSize(new Dimension(250, 100));
+ ledOutPanel.add(areaScrollPane, BorderLayout.CENTER);
+ clear = new JButton("Clear");
+ clear.setActionCommand("LO");
+ ledOutPanel.add(clear, BorderLayout.SOUTH);
+ ledSplitPane.setRightComponent(ledOutPanel);
+
+ splitPane.setLeftComponent(buttonSplitPane);
+ splitPane.setRightComponent(ledSplitPane);
+
+ this.add(splitPane);
+
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
}
class LEDControlPanel extends JPanel implements ActionListener {
@@ -278,7 +382,9 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener, Butto
super.paintComponent(g);
g.setColor(Color.black);
- g.fill3DRect(0, 0, this.getWidth(), this.getHeight(), true);
+ g.fillRect(0, 0, this.getWidth(), this.getHeight());
+ g.setColor(new Color(220,220,220));
+ g.fillRect(4, 4, this.getWidth()-8, this.getHeight()-8);
}
@@ -394,7 +500,8 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener, Butto
@Override
public void buttonPressed(int x, int y) {
System.out.println("Button Pressed: " + x + " " + y);
- bag.circleExpand(x, y, 16);
+ // bag.circleExpand(x, y, 16);
+ bag.noise(new Rectangle(0, 0, 9, 20), 5000);
}