wiiusej 0.12 clean1 before release
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@158 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -37,324 +37,387 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author guiguito
|
||||
* This frame is used to display events from a nunchuk.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListener {
|
||||
public class NunchukGuiTest extends javax.swing.JFrame implements
|
||||
WiimoteListener {
|
||||
|
||||
private Wiimote wiimote;
|
||||
private boolean isThresholdsRequested = true;
|
||||
private Wiimote wiimote;
|
||||
private boolean isThresholdsRequested = true;
|
||||
|
||||
/** Creates new form NunchukGuiTest */
|
||||
public NunchukGuiTest(Wiimote wiimote) {
|
||||
initComponents();
|
||||
this.wiimote = wiimote;
|
||||
registerListeners();
|
||||
}
|
||||
/** Creates new form NunchukGuiTest */
|
||||
public NunchukGuiTest(Wiimote wiimote) {
|
||||
initComponents();
|
||||
this.wiimote = wiimote;
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote.addWiiMoteEventListeners((NunchukJoystickEventPanel)joystickEventsPanel);
|
||||
}
|
||||
private void registerListeners() {
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote
|
||||
.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote
|
||||
.addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
|
||||
}
|
||||
|
||||
public void unRegisterListeners() {
|
||||
wiimote.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote.removeWiiMoteEventListeners((NunchukJoystickEventPanel)joystickEventsPanel);
|
||||
wiimote.removeWiiMoteEventListeners(this);
|
||||
}
|
||||
|
||||
public void requestThresholdsUpdate(){
|
||||
isThresholdsRequested = true;
|
||||
}
|
||||
public void unRegisterListeners() {
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
|
||||
wiimote.removeWiiMoteEventListeners(this);
|
||||
}
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
public void requestThresholdsUpdate() {
|
||||
isThresholdsRequested = true;
|
||||
}
|
||||
|
||||
topPanels = new javax.swing.JPanel();
|
||||
joystickEventsPanel = joystickEventsPanel = new NunchukJoystickEventPanel();
|
||||
motionSensingEventsPanel = new javax.swing.JPanel();
|
||||
motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
|
||||
rawAccelerationPanel = new AccelerationExpansionEventPanel();
|
||||
orientationPanel = new OrientationExpansionEventPanel();
|
||||
gForcePanel = new GForceExpansionEventPanel();
|
||||
setNunchukValuesPanel = new javax.swing.JPanel();
|
||||
nunchukButtonsEventPanel = new javax.swing.JPanel();
|
||||
cButton = new javax.swing.JButton();
|
||||
zButton = new javax.swing.JButton();
|
||||
nunchukOrientationPanel = new javax.swing.JPanel();
|
||||
nunchukOrientationTextField = new javax.swing.JTextField();
|
||||
nunchukOrientationButton = new javax.swing.JButton();
|
||||
nunchukAccelerationPanel = new javax.swing.JPanel();
|
||||
nunchukAccelerationTextField = new javax.swing.JTextField();
|
||||
nunchukAccelerationButton = new javax.swing.JButton();
|
||||
messagePanel = new javax.swing.JPanel();
|
||||
messageText = new javax.swing.JLabel();
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(400, 400));
|
||||
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
||||
topPanels = new javax.swing.JPanel();
|
||||
joystickEventsPanel = new NunchukJoystickEventPanel();
|
||||
motionSensingEventsPanel = new javax.swing.JPanel();
|
||||
motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
|
||||
rawAccelerationPanel = new AccelerationExpansionEventPanel();
|
||||
orientationPanel = new OrientationExpansionEventPanel();
|
||||
gForcePanel = new GForceExpansionEventPanel();
|
||||
setNunchukValuesPanel = new javax.swing.JPanel();
|
||||
nunchukButtonsEventPanel = new javax.swing.JPanel();
|
||||
cButton = new javax.swing.JButton();
|
||||
zButton = new javax.swing.JButton();
|
||||
nunchukOrientationPanel = new javax.swing.JPanel();
|
||||
nunchukOrientationTextField = new javax.swing.JTextField();
|
||||
nunchukOrientationButton = new javax.swing.JButton();
|
||||
nunchukAccelerationPanel = new javax.swing.JPanel();
|
||||
nunchukAccelerationTextField = new javax.swing.JTextField();
|
||||
nunchukAccelerationButton = new javax.swing.JButton();
|
||||
messagePanel = new javax.swing.JPanel();
|
||||
messageText = new javax.swing.JLabel();
|
||||
|
||||
topPanels.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setLayout(new javax.swing.BoxLayout(topPanels, javax.swing.BoxLayout.LINE_AXIS));
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(400, 400));
|
||||
getContentPane().setLayout(
|
||||
new javax.swing.BoxLayout(getContentPane(),
|
||||
javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
joystickEventsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 153, 0), 2, true), "Joystick View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(204, 102, 0)));
|
||||
joystickEventsPanel.setToolTipText("JoystickEvent");
|
||||
joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
topPanels.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setLayout(new javax.swing.BoxLayout(topPanels,
|
||||
javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(joystickEventsPanel);
|
||||
joystickEventsPanel.setLayout(joystickEventsPanelLayout);
|
||||
joystickEventsPanelLayout.setHorizontalGroup(
|
||||
joystickEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 601, Short.MAX_VALUE)
|
||||
);
|
||||
joystickEventsPanelLayout.setVerticalGroup(
|
||||
joystickEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 174, Short.MAX_VALUE)
|
||||
);
|
||||
joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
joystickEventsPanel.setBorder(javax.swing.BorderFactory
|
||||
.createTitledBorder(new javax.swing.border.LineBorder(
|
||||
new java.awt.Color(51, 153, 0), 2, true),
|
||||
"Joystick View",
|
||||
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
javax.swing.border.TitledBorder.DEFAULT_POSITION,
|
||||
new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(
|
||||
204, 102, 0)));
|
||||
joystickEventsPanel.setToolTipText("JoystickEvent");
|
||||
joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
|
||||
topPanels.add(joystickEventsPanel);
|
||||
joystickEventsPanel.getAccessibleContext().setAccessibleName("Joystick");
|
||||
javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(
|
||||
joystickEventsPanel);
|
||||
joystickEventsPanel.setLayout(joystickEventsPanelLayout);
|
||||
joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 601, Short.MAX_VALUE));
|
||||
joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 174, Short.MAX_VALUE));
|
||||
|
||||
motionSensingEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
topPanels.add(joystickEventsPanel);
|
||||
joystickEventsPanel.getAccessibleContext()
|
||||
.setAccessibleName("Joystick");
|
||||
|
||||
rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent");
|
||||
motionSensingEventsPanel
|
||||
.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
|
||||
javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(rawAccelerationPanel);
|
||||
rawAccelerationPanel.setLayout(rawAccelerationPanelLayout);
|
||||
rawAccelerationPanelLayout.setHorizontalGroup(
|
||||
rawAccelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE)
|
||||
);
|
||||
rawAccelerationPanelLayout.setVerticalGroup(
|
||||
rawAccelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE)
|
||||
);
|
||||
rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent");
|
||||
|
||||
motionSensingEventsTabbedPanels.addTab("RawAcceleration", rawAccelerationPanel);
|
||||
javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(
|
||||
rawAccelerationPanel);
|
||||
rawAccelerationPanel.setLayout(rawAccelerationPanelLayout);
|
||||
rawAccelerationPanelLayout
|
||||
.setHorizontalGroup(rawAccelerationPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
|
||||
javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(orientationPanel);
|
||||
orientationPanel.setLayout(orientationPanelLayout);
|
||||
orientationPanelLayout.setHorizontalGroup(
|
||||
orientationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE)
|
||||
);
|
||||
orientationPanelLayout.setVerticalGroup(
|
||||
orientationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE)
|
||||
);
|
||||
motionSensingEventsTabbedPanels.addTab("RawAcceleration",
|
||||
rawAccelerationPanel);
|
||||
|
||||
motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel);
|
||||
javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(
|
||||
orientationPanel);
|
||||
orientationPanel.setLayout(orientationPanelLayout);
|
||||
orientationPanelLayout.setHorizontalGroup(orientationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
orientationPanelLayout.setVerticalGroup(orientationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
|
||||
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel);
|
||||
gForcePanel.setLayout(gForcePanelLayout);
|
||||
gForcePanelLayout.setHorizontalGroup(
|
||||
gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE)
|
||||
);
|
||||
gForcePanelLayout.setVerticalGroup(
|
||||
gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE)
|
||||
);
|
||||
motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel);
|
||||
|
||||
motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel);
|
||||
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(
|
||||
gForcePanel);
|
||||
gForcePanel.setLayout(gForcePanelLayout);
|
||||
gForcePanelLayout.setHorizontalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
gForcePanelLayout.setVerticalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
|
||||
javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(motionSensingEventsPanel);
|
||||
motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout);
|
||||
motionSensingEventsPanelLayout.setHorizontalGroup(
|
||||
motionSensingEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels, javax.swing.GroupLayout.DEFAULT_SIZE, 602, Short.MAX_VALUE)
|
||||
);
|
||||
motionSensingEventsPanelLayout.setVerticalGroup(
|
||||
motionSensingEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||
);
|
||||
motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel);
|
||||
|
||||
topPanels.add(motionSensingEventsPanel);
|
||||
javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(
|
||||
motionSensingEventsPanel);
|
||||
motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout);
|
||||
motionSensingEventsPanelLayout
|
||||
.setHorizontalGroup(motionSensingEventsPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 602,
|
||||
Short.MAX_VALUE));
|
||||
motionSensingEventsPanelLayout
|
||||
.setVerticalGroup(motionSensingEventsPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 200,
|
||||
Short.MAX_VALUE));
|
||||
|
||||
getContentPane().add(topPanels);
|
||||
topPanels.add(motionSensingEventsPanel);
|
||||
|
||||
setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS));
|
||||
getContentPane().add(topPanels);
|
||||
|
||||
nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent");
|
||||
nunchukButtonsEventPanel.setMinimumSize(new java.awt.Dimension(100, 100));
|
||||
nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100, 100));
|
||||
nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||
setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel
|
||||
.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(
|
||||
setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
cButton.setText("C");
|
||||
cButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(cButton);
|
||||
nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent");
|
||||
nunchukButtonsEventPanel
|
||||
.setMinimumSize(new java.awt.Dimension(100, 100));
|
||||
nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100,
|
||||
100));
|
||||
nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(
|
||||
nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
zButton.setText("Z");
|
||||
zButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(zButton);
|
||||
cButton.setText("C");
|
||||
cButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(cButton);
|
||||
|
||||
setNunchukValuesPanel.add(nunchukButtonsEventPanel);
|
||||
zButton.setText("Z");
|
||||
zButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(zButton);
|
||||
|
||||
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60, 20));
|
||||
nunchukOrientationPanel.add(nunchukOrientationTextField);
|
||||
setNunchukValuesPanel.add(nunchukButtonsEventPanel);
|
||||
|
||||
nunchukOrientationButton.setText("Set Orientation Threshold");
|
||||
nunchukOrientationButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukOrientationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukOrientationPanel.add(nunchukOrientationButton);
|
||||
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60,
|
||||
20));
|
||||
nunchukOrientationPanel.add(nunchukOrientationTextField);
|
||||
|
||||
setNunchukValuesPanel.add(nunchukOrientationPanel);
|
||||
nunchukOrientationButton.setText("Set Orientation Threshold");
|
||||
nunchukOrientationButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukOrientationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukOrientationPanel.add(nunchukOrientationButton);
|
||||
|
||||
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(60, 20));
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationTextField);
|
||||
setNunchukValuesPanel.add(nunchukOrientationPanel);
|
||||
|
||||
nunchukAccelerationButton.setText("Set Acceleration Threshold");
|
||||
nunchukAccelerationButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukAccelerationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationButton);
|
||||
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(
|
||||
60, 20));
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationTextField);
|
||||
|
||||
setNunchukValuesPanel.add(nunchukAccelerationPanel);
|
||||
nunchukAccelerationButton.setText("Set Acceleration Threshold");
|
||||
nunchukAccelerationButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukAccelerationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationButton);
|
||||
|
||||
messageText.setText("Message:");
|
||||
setNunchukValuesPanel.add(nunchukAccelerationPanel);
|
||||
|
||||
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(messagePanel);
|
||||
messagePanel.setLayout(messagePanelLayout);
|
||||
messagePanelLayout.setHorizontalGroup(
|
||||
messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 1216, Short.MAX_VALUE)
|
||||
.addGroup(messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(messagePanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(messageText)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
);
|
||||
messagePanelLayout.setVerticalGroup(
|
||||
messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 34, Short.MAX_VALUE)
|
||||
.addGroup(messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(messagePanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(messageText)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
);
|
||||
messageText.setText("Message:");
|
||||
|
||||
setNunchukValuesPanel.add(messagePanel);
|
||||
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
|
||||
messagePanel);
|
||||
messagePanel.setLayout(messagePanelLayout);
|
||||
messagePanelLayout
|
||||
.setHorizontalGroup(messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 1216, Short.MAX_VALUE)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createSequentialGroup()
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE)
|
||||
.addComponent(
|
||||
messageText)
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE))));
|
||||
messagePanelLayout
|
||||
.setVerticalGroup(messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 34, Short.MAX_VALUE)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createSequentialGroup()
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE)
|
||||
.addComponent(
|
||||
messageText)
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE))));
|
||||
|
||||
getContentPane().add(setNunchukValuesPanel);
|
||||
setNunchukValuesPanel.add(messagePanel);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
private void nunchukOrientationButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nunchukOrientationButtonMousePressed
|
||||
try {
|
||||
float nb = Float.parseFloat(nunchukOrientationTextField.getText());
|
||||
wiimote.setNunchukOrientationThreshold(nb);
|
||||
messageText.setText("Nunchuk orientation threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText.setText("Number is not an integer, nunchuk orientation threshold not set !");
|
||||
}
|
||||
}//GEN-LAST:event_nunchukOrientationButtonMousePressed
|
||||
getContentPane().add(setNunchukValuesPanel);
|
||||
|
||||
private void nunchukAccelerationButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nunchukAccelerationButtonMousePressed
|
||||
try {
|
||||
int nb = Integer.parseInt(nunchukAccelerationTextField.getText());
|
||||
wiimote.setNunchukAccelerationThreshold(nb);
|
||||
messageText.setText("Nunchuk acceleration threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText.setText("Number is not an integer, nunchuk acceleration threshold not set !");
|
||||
}
|
||||
}//GEN-LAST:event_nunchukAccelerationButtonMousePressed
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
//nothing to do
|
||||
}
|
||||
private void nunchukOrientationButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed
|
||||
try {
|
||||
float nb = Float.parseFloat(nunchukOrientationTextField.getText());
|
||||
wiimote.setNunchukOrientationThreshold(nb);
|
||||
messageText.setText("Nunchuk orientation threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText
|
||||
.setText("Number is not an integer, nunchuk orientation threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_nunchukOrientationButtonMousePressed
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
//nothing to do
|
||||
}
|
||||
private void nunchukAccelerationButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed
|
||||
try {
|
||||
int nb = Integer.parseInt(nunchukAccelerationTextField.getText());
|
||||
wiimote.setNunchukAccelerationThreshold(nb);
|
||||
messageText.setText("Nunchuk acceleration threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText
|
||||
.setText("Number is not an integer, nunchuk acceleration threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_nunchukAccelerationButtonMousePressed
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
//nothing to do
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
if (arg0 instanceof NunchukEvent) {
|
||||
NunchukEvent nunchuk = (NunchukEvent) arg0;
|
||||
NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
|
||||
if (buttons.isButtonCJustPressed()) {
|
||||
cButton.setEnabled(false);
|
||||
}
|
||||
if (buttons.isButtonCJustReleased()) {
|
||||
cButton.setEnabled(true);
|
||||
}
|
||||
if (buttons.isButtonZJustPressed()) {
|
||||
zButton.setEnabled(false);
|
||||
}
|
||||
if (buttons.isButtonZJustReleased()) {
|
||||
zButton.setEnabled(true);
|
||||
}
|
||||
if (isThresholdsRequested){
|
||||
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
|
||||
nunchukAccelerationTextField.setText(evt.getAccelerationThreshold()+"");
|
||||
nunchukOrientationTextField.setText(evt.getOrientationThreshold()+"");
|
||||
isThresholdsRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
//nothing to do
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
//nothing
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
if (arg0 instanceof NunchukEvent) {
|
||||
NunchukEvent nunchuk = (NunchukEvent) arg0;
|
||||
NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
|
||||
if (buttons.isButtonCJustPressed()) {
|
||||
cButton.setEnabled(false);
|
||||
}
|
||||
if (buttons.isButtonCJustReleased()) {
|
||||
cButton.setEnabled(true);
|
||||
}
|
||||
if (buttons.isButtonZJustPressed()) {
|
||||
zButton.setEnabled(false);
|
||||
}
|
||||
if (buttons.isButtonZJustReleased()) {
|
||||
zButton.setEnabled(true);
|
||||
}
|
||||
if (isThresholdsRequested) {
|
||||
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
|
||||
nunchukAccelerationTextField.setText(evt
|
||||
.getAccelerationThreshold()
|
||||
+ "");
|
||||
nunchukOrientationTextField.setText(evt
|
||||
.getOrientationThreshold()
|
||||
+ "");
|
||||
isThresholdsRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
//nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
//nothing
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cButton;
|
||||
private javax.swing.JPanel gForcePanel;
|
||||
private javax.swing.JPanel joystickEventsPanel;
|
||||
private javax.swing.JPanel messagePanel;
|
||||
private javax.swing.JLabel messageText;
|
||||
private javax.swing.JPanel motionSensingEventsPanel;
|
||||
private javax.swing.JTabbedPane motionSensingEventsTabbedPanels;
|
||||
private javax.swing.JButton nunchukAccelerationButton;
|
||||
private javax.swing.JPanel nunchukAccelerationPanel;
|
||||
private javax.swing.JTextField nunchukAccelerationTextField;
|
||||
private javax.swing.JPanel nunchukButtonsEventPanel;
|
||||
private javax.swing.JButton nunchukOrientationButton;
|
||||
private javax.swing.JPanel nunchukOrientationPanel;
|
||||
private javax.swing.JTextField nunchukOrientationTextField;
|
||||
private javax.swing.JPanel orientationPanel;
|
||||
private javax.swing.JPanel rawAccelerationPanel;
|
||||
private javax.swing.JPanel setNunchukValuesPanel;
|
||||
private javax.swing.JPanel topPanels;
|
||||
private javax.swing.JButton zButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cButton;
|
||||
private javax.swing.JPanel gForcePanel;
|
||||
private javax.swing.JPanel joystickEventsPanel;
|
||||
private javax.swing.JPanel messagePanel;
|
||||
private javax.swing.JLabel messageText;
|
||||
private javax.swing.JPanel motionSensingEventsPanel;
|
||||
private javax.swing.JTabbedPane motionSensingEventsTabbedPanels;
|
||||
private javax.swing.JButton nunchukAccelerationButton;
|
||||
private javax.swing.JPanel nunchukAccelerationPanel;
|
||||
private javax.swing.JTextField nunchukAccelerationTextField;
|
||||
private javax.swing.JPanel nunchukButtonsEventPanel;
|
||||
private javax.swing.JButton nunchukOrientationButton;
|
||||
private javax.swing.JPanel nunchukOrientationPanel;
|
||||
private javax.swing.JTextField nunchukOrientationTextField;
|
||||
private javax.swing.JPanel orientationPanel;
|
||||
private javax.swing.JPanel rawAccelerationPanel;
|
||||
private javax.swing.JPanel setNunchukValuesPanel;
|
||||
private javax.swing.JPanel topPanels;
|
||||
private javax.swing.JButton zButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user