/* * This file is part of the Remote Sensor Actuator Interface (ReSAI). * * Copyright(c) Andreas Kipp, Frederic Siepmann * http://opensource.cit-ec.de/projects/resai * * This file may be licensed under the terms of of the * GNU Lesser General Public License Version 3 (the ``LGPL''), * or (at your option) any later version. * * Software distributed under the License is distributed * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the LGPL for the specific language * governing rights and limitations. * * You should have received a copy of the LGPL along with this * program. If not, go to http://www.gnu.org/licenses/lgpl.html * or write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The development of this software was supported by the * Excellence Cluster EXC 277 Cognitive Interaction Technology. * The Excellence Cluster EXC 277 is a grant of the Deutsche * Forschungsgemeinschaft (DFG) in the context of the German * Excellence Initiative. * */ /** * Panel for the navigation actuator. * * @author akipp */ package de.unibi.airobots.resaijavaclient.gui.panels.components; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Observable; import javax.swing.JButton; import de.unibi.airobots.resaijavaclient.gui.panels.components.template.PanelTemplate; public class NavigationPanel extends PanelTemplate implements ActionListener { private static final long serialVersionUID = 1L; private JButton btnForward = new JButton("Forward"); private JButton btnLeft = new JButton("Left"); private JButton btnRight = new JButton("Right"); private JButton btnStop = new JButton("Stop"); private JButton btnBackward = new JButton("Backward"); public NavigationPanel() { setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; add(btnForward, c); btnForward.addActionListener(this); c.gridx = 0; c.gridy = 1; add(btnLeft, c); btnLeft.addActionListener(this); c.gridx = 1; c.gridy = 1; add(btnStop, c); btnStop.addActionListener(this); c.gridx = 2; c.gridy = 1; add(btnRight, c); btnRight.addActionListener(this); c.gridx = 1; c.gridy = 2; add(btnBackward, c); btnBackward.addActionListener(this); } @Override public void update(Observable arg0, Object arg1) { } @Override public void actionPerformed(ActionEvent e) { if(e.getSource().equals(btnLeft)) { sendCommand("LEFT"); } if(e.getSource().equals(btnRight)) { sendCommand("RIGHT"); } if(e.getSource().equals(btnForward)) { sendCommand("FORWARD"); } if(e.getSource().equals(btnStop)) { sendCommand("MANUALSTOP"); } if(e.getSource().equals(btnBackward)) { sendCommand("BACKWARD"); } } private void sendCommand(String command) { HashMap propertiesToSend = new HashMap(); propertiesToSend.put("TAG", "NavigationActuatorThread"); propertiesToSend.put(command, "true"); overviewController.sendMessage(propertiesToSend); } }