Java tutorial
package yadrone; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import ImageProcessing.CircleDetection; import ImageProcessing.ProcessedImagePanel; import de.yadrone.base.IARDrone; import java.awt.Color; import java.io.File; import java.io.IOException; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.TimerTask; import javax.imageio.ImageIO; import javax.swing.UIManager; import org.apache.commons.io.FileUtils; /** * * @author Martin */ public class DroneGUI extends javax.swing.JFrame implements Runnable { private VideoListener v1; private NavDataListener navData; private DroneControl cont; private IARDrone drone; private Regulator regulator; private final ProcessedImagePanel pil; private final CircleDetection cd; private final double HSV_INCR = 0.05; DecimalFormat df = new DecimalFormat("#.###"); /** * Constructor * * @param drone Drone object * @param pil Image panel with processed image stream * @param cont DroneControl object for receiving navigation data * @param regulator Object for reading and setting PID parameters * @param cd Object for reading and setting thresholding parameters */ public DroneGUI(IARDrone drone, DroneControl cont, ProcessedImagePanel pil, TimerTask regulator, CircleDetection cd, int[] resolution) { this.drone = drone; this.cont = cont; this.pil = pil; this.regulator = (Regulator) regulator; this.cd = cd; v1 = new VideoListener(drone, resolution); navData = new NavDataListener(drone); try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { } } df.setRoundingMode(RoundingMode.CEILING); initComponents(); updateTextFields(); this.setVisible(true); } /** * 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() { jPanel1 = new javax.swing.JPanel(); VideoStreamViewer = v1; ImageProcessViewer = pil; ButtonPanel1 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); yawTextLabel = new javax.swing.JLabel(); PitchTextLabel = new javax.swing.JLabel(); RollTextLabel = new javax.swing.JLabel(); altidudeTextLabel = new javax.swing.JLabel(); batteryTextLabel = new javax.swing.JLabel(); jPanel4 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); yawProportionalTextField = new javax.swing.JTextField(); yawProportionalTextField.setText("Propotional: " + regulator.getKpYaw()); jLabel1 = new javax.swing.JLabel(); yawIntegralTextField = new javax.swing.JTextField(); yawIntegralTextField.setText("Integral: " + regulator.getKiYaw()); yawDerivateTextField = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); pitchProportionalTextField = new javax.swing.JTextField(); pitchIntegralTextField = new javax.swing.JTextField(); pitchDerivateTextField = new javax.swing.JTextField(); zProportionalTextField = new javax.swing.JTextField(); jLabel7 = new javax.swing.JLabel(); zIntegralTextField = new javax.swing.JTextField(); zDerivateTextField = new javax.swing.JTextField(); jButtonSaveParametersPID = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); snapshotButton = new javax.swing.JButton(); valueUpperTF = new javax.swing.JTextField(); saturationUpperTF = new javax.swing.JTextField(); hueUpperTF = new javax.swing.JTextField(); valueLowerTF = new javax.swing.JTextField(); SaturationLowerTF = new javax.swing.JTextField(); hueLowerTF = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); gaussFilterSigmaTextField = new javax.swing.JTextField(); jButtonhlm = new javax.swing.JButton(); jButtonhlp = new javax.swing.JButton(); jButtonhup = new javax.swing.JButton(); jButtonhum = new javax.swing.JButton(); jButtonslm = new javax.swing.JButton(); jButtonslp = new javax.swing.JButton(); jButtonsum = new javax.swing.JButton(); jButtonsup = new javax.swing.JButton(); jButtonvlm = new javax.swing.JButton(); jButtonvlp = new javax.swing.JButton(); jButtonvum = new javax.swing.JButton(); jButtonvup = new javax.swing.JButton(); jButtonGFSM = new javax.swing.JButton(); jButtonGFSP = new javax.swing.JButton(); jButtonSaveParametersHSV = new javax.swing.JButton(); gaussFilterDimTextField = new javax.swing.JTextField(); jButtonvlp1 = new javax.swing.JButton(); jButtonvlp2 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); landButton = new javax.swing.JButton(); autoButton = new javax.swing.JButton(); manButton = new javax.swing.JButton(); jLabel5 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); VideoStreamViewer.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); javax.swing.GroupLayout VideoStreamViewerLayout = new javax.swing.GroupLayout(VideoStreamViewer); VideoStreamViewer.setLayout(VideoStreamViewerLayout); VideoStreamViewerLayout.setHorizontalGroup(VideoStreamViewerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); VideoStreamViewerLayout.setVerticalGroup(VideoStreamViewerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 358, Short.MAX_VALUE)); ImageProcessViewer.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); javax.swing.GroupLayout ImageProcessViewerLayout = new javax.swing.GroupLayout(ImageProcessViewer); ImageProcessViewer.setLayout(ImageProcessViewerLayout); ImageProcessViewerLayout.setHorizontalGroup(ImageProcessViewerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 638, Short.MAX_VALUE)); ImageProcessViewerLayout.setVerticalGroup(ImageProcessViewerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); ButtonPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel4.setText("Navigation data"); jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder()); yawTextLabel.setText("Yaw:"); PitchTextLabel.setText("Pitch:"); RollTextLabel.setText("Roll:"); altidudeTextLabel.setText("Altidude:"); batteryTextLabel.setText("Battery:"); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout .setHorizontalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(altidudeTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE) .addComponent(yawTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(PitchTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(batteryTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE) .addComponent(RollTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(yawTextLabel).addComponent(PitchTextLabel) .addComponent(RollTextLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(altidudeTextLabel).addComponent(batteryTextLabel)) .addContainerGap())); javax.swing.GroupLayout ButtonPanel1Layout = new javax.swing.GroupLayout(ButtonPanel1); ButtonPanel1.setLayout(ButtonPanel1Layout); ButtonPanel1Layout.setHorizontalGroup(ButtonPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ButtonPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(ButtonPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); ButtonPanel1Layout.setVerticalGroup(ButtonPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ButtonPanel1Layout.createSequentialGroup() .addContainerGap().addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(6, 6, 6))); jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("PID gains"); yawProportionalTextField.setText("Proportional"); yawProportionalTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { yawProportionalTextFieldFocusLost(evt); } }); yawProportionalTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { yawProportionalTextFieldActionPerformed(evt); } }); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("Yaw"); yawIntegralTextField.setText("Integral "); yawIntegralTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { yawIntegralTextFieldFocusLost(evt); } }); yawIntegralTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { yawIntegralTextFieldActionPerformed(evt); } }); yawDerivateTextField.setText("Derivate "); yawDerivateTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { yawDerivateTextFieldFocusLost(evt); } }); yawDerivateTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { yawDerivateTextFieldActionPerformed(evt); } }); jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel6.setText("Pitch"); pitchProportionalTextField.setText("Proportional"); pitchProportionalTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { pitchProportionalTextFieldFocusLost(evt); } }); pitchProportionalTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pitchProportionalTextFieldActionPerformed(evt); } }); pitchIntegralTextField.setText("Integral"); pitchIntegralTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { pitchIntegralTextFieldFocusLost(evt); } }); pitchIntegralTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pitchIntegralTextFieldActionPerformed(evt); } }); pitchDerivateTextField.setText("Derivate"); pitchDerivateTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { pitchDerivateTextFieldFocusLost(evt); } }); pitchDerivateTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pitchDerivateTextFieldActionPerformed(evt); } }); zProportionalTextField.setText("Proportional"); zProportionalTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { zProportionalTextFieldFocusLost(evt); } }); zProportionalTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { zProportionalTextFieldActionPerformed(evt); } }); jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel7.setText("Z"); zIntegralTextField.setText("Integral"); zIntegralTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { zIntegralTextFieldFocusLost(evt); } }); zIntegralTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { zIntegralTextFieldActionPerformed(evt); } }); zDerivateTextField.setText("Derivate"); zDerivateTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { zDerivateTextFieldFocusLost(evt); } }); zDerivateTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { zDerivateTextFieldActionPerformed(evt); } }); jButtonSaveParametersPID.setText("Save Parameters"); jButtonSaveParametersPID.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSaveParametersPIDActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup().addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(yawIntegralTextField, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(yawDerivateTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE) .addComponent(yawProportionalTextField, javax.swing.GroupLayout.Alignment.LEADING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(zProportionalTextField) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(zIntegralTextField).addComponent(zDerivateTextField)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pitchProportionalTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE) .addComponent(pitchIntegralTextField) .addComponent(pitchDerivateTextField))) .addComponent(jButtonSaveParametersPID, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addComponent(jLabel2) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(jLabel6).addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(yawProportionalTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pitchProportionalTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(zProportionalTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(yawIntegralTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pitchIntegralTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(zIntegralTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(yawDerivateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pitchDerivateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(zDerivateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18).addComponent(jButtonSaveParametersPID) .addContainerGap(15, Short.MAX_VALUE))); jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); snapshotButton.setText("Snapshot"); snapshotButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { snapshotButtonActionPerformed(evt); } }); valueUpperTF.setText("V upper threshold:"); valueUpperTF.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { valueUpperTFFocusLost(evt); } }); valueUpperTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { valueUpperTFActionPerformed(evt); } }); saturationUpperTF.setText("S upper threshold:"); saturationUpperTF.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { saturationUpperTFFocusLost(evt); } }); saturationUpperTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saturationUpperTFActionPerformed(evt); } }); hueUpperTF.setText("H upper threshold:"); hueUpperTF.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { hueUpperTFFocusLost(evt); } }); hueUpperTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { hueUpperTFActionPerformed(evt); } }); valueLowerTF.setText("V lower threshold:"); valueLowerTF.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { valueLowerTFFocusLost(evt); } }); valueLowerTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { valueLowerTFActionPerformed(evt); } }); SaturationLowerTF.setText("S lower threshold:"); SaturationLowerTF.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { SaturationLowerTFFocusLost(evt); } }); SaturationLowerTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SaturationLowerTFActionPerformed(evt); } }); hueLowerTF.setText("H lower threshold:"); hueLowerTF.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { hueLowerTFFocusLost(evt); } }); hueLowerTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { hueLowerTFActionPerformed(evt); } }); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("Image Processing"); gaussFilterSigmaTextField.setText("Gauss filter sigma:"); gaussFilterSigmaTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { gaussFilterSigmaTextFieldFocusLost(evt); } }); gaussFilterSigmaTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { gaussFilterSigmaTextFieldActionPerformed(evt); } }); jButtonhlm.setText("-"); jButtonhlm.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonhlm.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonhlmActionPerformed(evt); } }); jButtonhlp.setText("+"); jButtonhlp.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonhlp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonhlpActionPerformed(evt); } }); jButtonhup.setText("+"); jButtonhup.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonhup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonhupActionPerformed(evt); } }); jButtonhum.setText("-"); jButtonhum.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonhum.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonhumActionPerformed(evt); } }); jButtonslm.setText("-"); jButtonslm.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonslm.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonslmActionPerformed(evt); } }); jButtonslp.setText("+"); jButtonslp.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonslp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonslpActionPerformed(evt); } }); jButtonsum.setText("-"); jButtonsum.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonsum.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonsumActionPerformed(evt); } }); jButtonsup.setText("+"); jButtonsup.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonsup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonsupActionPerformed(evt); } }); jButtonvlm.setText("-"); jButtonvlm.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonvlm.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonvlmActionPerformed(evt); } }); jButtonvlp.setText("+"); jButtonvlp.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonvlp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonvlpActionPerformed(evt); } }); jButtonvum.setText("-"); jButtonvum.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonvum.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonvumActionPerformed(evt); } }); jButtonvup.setText("+"); jButtonvup.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonvup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonvupActionPerformed(evt); } }); jButtonGFSM.setText("-"); jButtonGFSM.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonGFSM.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonGFSMactionPerformed(evt); } }); jButtonGFSP.setText("+"); jButtonGFSP.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonGFSP.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonGFSPactionPerformed(evt); } }); jButtonSaveParametersHSV.setText("Save Parameters"); jButtonSaveParametersHSV.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSaveParametersHSVActionPerformed(evt); } }); gaussFilterDimTextField.setText("Gauss filter dimensions:"); gaussFilterDimTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { gaussFilterDimTextFieldFocusLost(evt); } }); gaussFilterDimTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { gaussFilterDimTextFieldActionPerformed(evt); } }); jButtonvlp1.setText("+"); jButtonvlp1.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonvlp1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonGFDPactionPerformed(evt); } }); jButtonvlp2.setText("-"); jButtonvlp2.setPreferredSize(new java.awt.Dimension(67, 19)); jButtonvlp2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonGFDMactionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(snapshotButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jButtonvlm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonvlp, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addComponent(jButtonslm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonslp, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)) .addComponent(valueLowerTF) .addComponent(SaturationLowerTF, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addComponent(jButtonhlm, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonhlp, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(hueLowerTF, javax.swing.GroupLayout.Alignment.TRAILING)) .addGap(18, 18, 18) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jButtonGFSM, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jButtonGFSP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(gaussFilterSigmaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(gaussFilterDimTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jButtonvlp2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jButtonvlp1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGap(18, 18, 18) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addComponent(jButtonvum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonvup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addComponent(jButtonhum, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonhup, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addComponent(jButtonsum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonsup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(saturationUpperTF, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(valueUpperTF, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(hueUpperTF, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jButtonSaveParametersHSV, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap().addComponent(jLabel3).addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(hueLowerTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(hueUpperTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(gaussFilterSigmaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonhlm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonhlp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonhup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonhum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonGFSM, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonGFSP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(SaturationLowerTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(saturationUpperTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(gaussFilterDimTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonslm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonslp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonsum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonsup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonvlp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonvlp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valueUpperTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(valueLowerTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonvlm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonvlp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonvum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonvup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE) .addComponent(jButtonSaveParametersHSV) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(snapshotButton).addContainerGap())); jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); landButton.setText("Land"); landButton.setFocusPainted(false); landButton.setFocusable(false); landButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { landButtonActionPerformed(evt); } }); autoButton.setText("Autonomous mode"); autoButton.setFocusPainted(false); autoButton.setFocusable(false); autoButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { autoButtonActionPerformed(evt); } }); manButton.setText("Manual mode"); manButton.setFocusPainted(false); manButton.setFocusable(false); manButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { manButtonActionPerformed(evt); } }); jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel5.setText("Mode selection"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout .setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(manButton, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(landButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18).addComponent(autoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(manButton).addComponent(autoButton).addComponent(landButton)) .addContainerGap())); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(ButtonPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(ImageProcessViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(VideoStreamViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(VideoStreamViewer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ImageProcessViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(ButtonPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap())); VideoStreamViewer.getAccessibleContext().setAccessibleName(""); ImageProcessViewer.getAccessibleContext().setAccessibleName("ImageProcessViewer"); ImageProcessViewer.getAccessibleContext().setAccessibleDescription("The Processed Images"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); pack(); }// </editor-fold>//GEN-END:initComponents //============================================================================== // Mode buttons //============================================================================== private void manButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manButtonActionPerformed cont.setMode(DroneControl.DroneMode.MAN_MODE); manButton.setForeground(Color.GREEN); autoButton.setForeground(Color.BLACK); landButton.setForeground(Color.BLACK); }//GEN-LAST:event_manButtonActionPerformed private void autoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoButtonActionPerformed cont.setMode(DroneControl.DroneMode.AUTO_MODE); manButton.setForeground(Color.BLACK); autoButton.setForeground(Color.GREEN); landButton.setForeground(Color.BLACK); }//GEN-LAST:event_autoButtonActionPerformed private void landButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_landButtonActionPerformed cont.setMode(DroneControl.DroneMode.LANDING); manButton.setForeground(Color.BLACK); autoButton.setForeground(Color.BLACK); landButton.setForeground(Color.GREEN); }//GEN-LAST:event_landButtonActionPerformed //============================================================================== // Snapshot button //============================================================================== private void snapshotButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_snapshotButtonActionPerformed {//GEN-HEADEREND:event_snapshotButtonActionPerformed try { String name = "" + System.currentTimeMillis(); File outputfile = new File(name + ".png"); ImageIO.write(v1.getImage(), "png", outputfile); } catch (IOException ex) { } }//GEN-LAST:event_snapshotButtonActionPerformed //============================================================================== // HSV threshold parameter input fields //============================================================================== private void hueLowerTFActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_hueLowerTFActionPerformed {//GEN-HEADEREND:event_hueLowerTFActionPerformed try { cd.setHl(Double.valueOf(getValueFromTextInput(hueLowerTF.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_hueLowerTFActionPerformed private void hueUpperTFActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_hueUpperTFActionPerformed {//GEN-HEADEREND:event_hueUpperTFActionPerformed try { cd.setHu(Double.valueOf(getValueFromTextInput(hueUpperTF.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_hueUpperTFActionPerformed private void SaturationLowerTFActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_SaturationLowerTFActionPerformed {//GEN-HEADEREND:event_SaturationLowerTFActionPerformed try { cd.setSl(Double.valueOf(getValueFromTextInput(SaturationLowerTF.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_SaturationLowerTFActionPerformed private void saturationUpperTFActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saturationUpperTFActionPerformed {//GEN-HEADEREND:event_saturationUpperTFActionPerformed try { cd.setSu(Double.valueOf(getValueFromTextInput(saturationUpperTF.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_saturationUpperTFActionPerformed private void valueLowerTFActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_valueLowerTFActionPerformed {//GEN-HEADEREND:event_valueLowerTFActionPerformed try { cd.setVl(Double.valueOf(getValueFromTextInput(valueLowerTF.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_valueLowerTFActionPerformed private void valueUpperTFActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_valueUpperTFActionPerformed {//GEN-HEADEREND:event_valueUpperTFActionPerformed try { cd.setVu(Double.valueOf(getValueFromTextInput(valueUpperTF.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_valueUpperTFActionPerformed private void hueLowerTFFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_hueLowerTFFocusLost {//GEN-HEADEREND:event_hueLowerTFFocusLost updateTextFields(); }//GEN-LAST:event_hueLowerTFFocusLost private void hueUpperTFFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_hueUpperTFFocusLost {//GEN-HEADEREND:event_hueUpperTFFocusLost updateTextFields(); }//GEN-LAST:event_hueUpperTFFocusLost private void SaturationLowerTFFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_SaturationLowerTFFocusLost {//GEN-HEADEREND:event_SaturationLowerTFFocusLost updateTextFields(); }//GEN-LAST:event_SaturationLowerTFFocusLost private void saturationUpperTFFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_saturationUpperTFFocusLost {//GEN-HEADEREND:event_saturationUpperTFFocusLost updateTextFields(); }//GEN-LAST:event_saturationUpperTFFocusLost private void valueLowerTFFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_valueLowerTFFocusLost {//GEN-HEADEREND:event_valueLowerTFFocusLost updateTextFields(); }//GEN-LAST:event_valueLowerTFFocusLost private void valueUpperTFFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_valueUpperTFFocusLost {//GEN-HEADEREND:event_valueUpperTFFocusLost updateTextFields(); }//GEN-LAST:event_valueUpperTFFocusLost //============================================================================== // PID Yaw parameter input fields //============================================================================== private void yawProportionalTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_yawProportionalTextFieldActionPerformed {//GEN-HEADEREND:event_yawProportionalTextFieldActionPerformed try { regulator.setKpYaw(Float.valueOf(getValueFromTextInput(yawProportionalTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_yawProportionalTextFieldActionPerformed private void yawIntegralTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_yawIntegralTextFieldActionPerformed {//GEN-HEADEREND:event_yawIntegralTextFieldActionPerformed try { regulator.setKiYaw(Float.valueOf(getValueFromTextInput(yawIntegralTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_yawIntegralTextFieldActionPerformed private void yawDerivateTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_yawDerivateTextFieldActionPerformed {//GEN-HEADEREND:event_yawDerivateTextFieldActionPerformed try { regulator.setKdYaw(Float.valueOf(getValueFromTextInput(yawDerivateTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_yawDerivateTextFieldActionPerformed private void yawProportionalTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_yawProportionalTextFieldFocusLost {//GEN-HEADEREND:event_yawProportionalTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_yawProportionalTextFieldFocusLost private void yawIntegralTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_yawIntegralTextFieldFocusLost {//GEN-HEADEREND:event_yawIntegralTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_yawIntegralTextFieldFocusLost private void yawDerivateTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_yawDerivateTextFieldFocusLost {//GEN-HEADEREND:event_yawDerivateTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_yawDerivateTextFieldFocusLost //============================================================================== // PID Z parameter input fields //============================================================================== private void zProportionalTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_zProportionalTextFieldActionPerformed {//GEN-HEADEREND:event_zProportionalTextFieldActionPerformed try { regulator.setKpZ(Float.valueOf(getValueFromTextInput(zProportionalTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_zProportionalTextFieldActionPerformed private void zIntegralTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_zIntegralTextFieldActionPerformed {//GEN-HEADEREND:event_zIntegralTextFieldActionPerformed try { regulator.setKiZ(Float.valueOf(getValueFromTextInput(zIntegralTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_zIntegralTextFieldActionPerformed private void zDerivateTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_zDerivateTextFieldActionPerformed {//GEN-HEADEREND:event_zDerivateTextFieldActionPerformed try { regulator.setKdZ(Float.valueOf(getValueFromTextInput(zDerivateTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_zDerivateTextFieldActionPerformed private void zProportionalTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_zProportionalTextFieldFocusLost {//GEN-HEADEREND:event_zProportionalTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_zProportionalTextFieldFocusLost private void zIntegralTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_zIntegralTextFieldFocusLost {//GEN-HEADEREND:event_zIntegralTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_zIntegralTextFieldFocusLost private void zDerivateTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_zDerivateTextFieldFocusLost {//GEN-HEADEREND:event_zDerivateTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_zDerivateTextFieldFocusLost //============================================================================== // PID Pitch parameter input fields //============================================================================== private void pitchProportionalTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_pitchProportionalTextFieldActionPerformed {//GEN-HEADEREND:event_pitchProportionalTextFieldActionPerformed try { regulator.setKpPitch(Float.valueOf(getValueFromTextInput(pitchProportionalTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_pitchProportionalTextFieldActionPerformed private void pitchIntegralTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_pitchIntegralTextFieldActionPerformed {//GEN-HEADEREND:event_pitchIntegralTextFieldActionPerformed try { regulator.setKiPitch(Float.valueOf(getValueFromTextInput(pitchIntegralTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_pitchIntegralTextFieldActionPerformed private void pitchDerivateTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_pitchDerivateTextFieldActionPerformed {//GEN-HEADEREND:event_pitchDerivateTextFieldActionPerformed try { regulator.setKdPitch(Float.valueOf(getValueFromTextInput(pitchDerivateTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_pitchDerivateTextFieldActionPerformed private void pitchProportionalTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_pitchProportionalTextFieldFocusLost {//GEN-HEADEREND:event_pitchProportionalTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_pitchProportionalTextFieldFocusLost private void pitchIntegralTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_pitchIntegralTextFieldFocusLost {//GEN-HEADEREND:event_pitchIntegralTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_pitchIntegralTextFieldFocusLost private void pitchDerivateTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_pitchDerivateTextFieldFocusLost {//GEN-HEADEREND:event_pitchDerivateTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_pitchDerivateTextFieldFocusLost //============================================================================== // HSV parameter buttons //============================================================================== private void jButtonhlmActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonhlmActionPerformed {//GEN-HEADEREND:event_jButtonhlmActionPerformed cd.setHl(cd.getHl() - HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonhlmActionPerformed private void jButtonhupActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonhupActionPerformed {//GEN-HEADEREND:event_jButtonhupActionPerformed cd.setHu(cd.getHu() + HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonhupActionPerformed private void jButtonhumActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonhumActionPerformed {//GEN-HEADEREND:event_jButtonhumActionPerformed cd.setHu(cd.getHu() - HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonhumActionPerformed private void jButtonsumActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonsumActionPerformed {//GEN-HEADEREND:event_jButtonsumActionPerformed cd.setSu(cd.getSu() - HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonsumActionPerformed private void jButtonhlpActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonhlpActionPerformed {//GEN-HEADEREND:event_jButtonhlpActionPerformed cd.setHl(cd.getHl() + HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonhlpActionPerformed private void jButtonslmActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonslmActionPerformed {//GEN-HEADEREND:event_jButtonslmActionPerformed cd.setSl(cd.getSl() - HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonslmActionPerformed private void jButtonslpActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonslpActionPerformed {//GEN-HEADEREND:event_jButtonslpActionPerformed cd.setSl(cd.getSl() + HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonslpActionPerformed private void jButtonsupActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonsupActionPerformed {//GEN-HEADEREND:event_jButtonsupActionPerformed cd.setSu(cd.getSu() + HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonsupActionPerformed private void jButtonvumActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonvumActionPerformed {//GEN-HEADEREND:event_jButtonvumActionPerformed cd.setVu(cd.getVu() - HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonvumActionPerformed private void jButtonvupActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonvupActionPerformed {//GEN-HEADEREND:event_jButtonvupActionPerformed cd.setVu(cd.getVu() + HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonvupActionPerformed private void jButtonvlmActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonvlmActionPerformed {//GEN-HEADEREND:event_jButtonvlmActionPerformed cd.setVl(cd.getVl() - HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonvlmActionPerformed private void jButtonvlpActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonvlpActionPerformed {//GEN-HEADEREND:event_jButtonvlpActionPerformed cd.setVl(cd.getVl() + HSV_INCR); updateTextFields(); }//GEN-LAST:event_jButtonvlpActionPerformed //============================================================================== // HSV + Sigma save parameters button //============================================================================== private void jButtonSaveParametersHSVActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSaveParametersHSVActionPerformed {//GEN-HEADEREND:event_jButtonSaveParametersHSVActionPerformed try { String s = "" + cd.getHl() + " " + cd.getHu() + " " + cd.getSl() + " " + cd.getSu() + " " + cd.getVl() + " " + cd.getVu() + " " + cd.getSigmaX() + " " + cd.getGaussKernelDim(); FileUtils.writeStringToFile(new File("imProParameters.txt"), s); } catch (Exception ex) { System.out.println(ex); } }//GEN-LAST:event_jButtonSaveParametersHSVActionPerformed //============================================================================== // PID save parameters button //============================================================================== private void jButtonSaveParametersPIDActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSaveParametersPIDActionPerformed {//GEN-HEADEREND:event_jButtonSaveParametersPIDActionPerformed try { String s = "" + regulator.getKpYaw() + " " + regulator.getKiYaw() + " " + regulator.getKdYaw() + " " + regulator.getKpZ() + " " + regulator.getKiZ() + " " + regulator.getKdZ() + " " + regulator.getKpPitch() + " " + regulator.getKiPitch() + " " + regulator.getKdPitch(); FileUtils.writeStringToFile(new File("PIDparameters.txt"), s); } catch (Exception ex) { System.out.println(ex); } }//GEN-LAST:event_jButtonSaveParametersPIDActionPerformed //============================================================================== // Gauss filter sigma text field //============================================================================== private void gaussFilterSigmaTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_gaussFilterSigmaTextFieldActionPerformed {//GEN-HEADEREND:event_gaussFilterSigmaTextFieldActionPerformed try { cd.setSigmaX(Double.valueOf(getValueFromTextInput(gaussFilterSigmaTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_gaussFilterSigmaTextFieldActionPerformed private void gaussFilterSigmaTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_gaussFilterSigmaTextFieldFocusLost {//GEN-HEADEREND:event_gaussFilterSigmaTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_gaussFilterSigmaTextFieldFocusLost //============================================================================== // Gauss filter sigma parameter buttons //============================================================================== private void jButtonGFSMactionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonGFSMactionPerformed {//GEN-HEADEREND:event_jButtonGFSMactionPerformed cd.setSigmaX(cd.getSigmaX() - 1); updateTextFields(); }//GEN-LAST:event_jButtonGFSMactionPerformed private void jButtonGFSPactionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonGFSPactionPerformed {//GEN-HEADEREND:event_jButtonGFSPactionPerformed cd.setSigmaX(cd.getSigmaX() + 1); updateTextFields(); }//GEN-LAST:event_jButtonGFSPactionPerformed //============================================================================== // Gauss filter dimensions text field //============================================================================== private void gaussFilterDimTextFieldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_gaussFilterDimTextFieldActionPerformed {//GEN-HEADEREND:event_gaussFilterDimTextFieldActionPerformed try { cd.setGaussKernelDim(Double.valueOf(getValueFromTextInput(gaussFilterDimTextField.getText()))); } catch (Exception e) { } updateTextFields(); }//GEN-LAST:event_gaussFilterDimTextFieldActionPerformed private void gaussFilterDimTextFieldFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_gaussFilterDimTextFieldFocusLost {//GEN-HEADEREND:event_gaussFilterDimTextFieldFocusLost updateTextFields(); }//GEN-LAST:event_gaussFilterDimTextFieldFocusLost //============================================================================== // Gauss filter dimensions parameter buttons //============================================================================== private void jButtonGFDPactionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonGFDPactionPerformed {//GEN-HEADEREND:event_jButtonGFDPactionPerformed cd.setGaussKernelDim(cd.getGaussKernelDim() + 2); updateTextFields(); }//GEN-LAST:event_jButtonGFDPactionPerformed private void jButtonGFDMactionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonGFDMactionPerformed {//GEN-HEADEREND:event_jButtonGFDMactionPerformed cd.setGaussKernelDim(cd.getGaussKernelDim() - 2); updateTextFields(); }//GEN-LAST:event_jButtonGFDMactionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel ButtonPanel1; private javax.swing.JPanel ImageProcessViewer; private javax.swing.JLabel PitchTextLabel; private javax.swing.JLabel RollTextLabel; private javax.swing.JTextField SaturationLowerTF; private javax.swing.JPanel VideoStreamViewer; private javax.swing.JLabel altidudeTextLabel; private javax.swing.JButton autoButton; private javax.swing.JLabel batteryTextLabel; private javax.swing.JTextField gaussFilterDimTextField; private javax.swing.JTextField gaussFilterSigmaTextField; private javax.swing.JTextField hueLowerTF; private javax.swing.JTextField hueUpperTF; private javax.swing.JButton jButtonGFSM; private javax.swing.JButton jButtonGFSP; private javax.swing.JButton jButtonSaveParametersHSV; private javax.swing.JButton jButtonSaveParametersPID; private javax.swing.JButton jButtonhlm; private javax.swing.JButton jButtonhlp; private javax.swing.JButton jButtonhum; private javax.swing.JButton jButtonhup; private javax.swing.JButton jButtonslm; private javax.swing.JButton jButtonslp; private javax.swing.JButton jButtonsum; private javax.swing.JButton jButtonsup; private javax.swing.JButton jButtonvlm; private javax.swing.JButton jButtonvlp; private javax.swing.JButton jButtonvlp1; private javax.swing.JButton jButtonvlp2; private javax.swing.JButton jButtonvum; private javax.swing.JButton jButtonvup; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JButton landButton; private javax.swing.JButton manButton; private javax.swing.JTextField pitchDerivateTextField; private javax.swing.JTextField pitchIntegralTextField; private javax.swing.JTextField pitchProportionalTextField; private javax.swing.JTextField saturationUpperTF; private javax.swing.JButton snapshotButton; private javax.swing.JTextField valueLowerTF; private javax.swing.JTextField valueUpperTF; private javax.swing.JTextField yawDerivateTextField; private javax.swing.JTextField yawIntegralTextField; private javax.swing.JTextField yawProportionalTextField; private javax.swing.JLabel yawTextLabel; private javax.swing.JTextField zDerivateTextField; private javax.swing.JTextField zIntegralTextField; private javax.swing.JTextField zProportionalTextField; // End of variables declaration//GEN-END:variables //============================================================================== //============================================================================== // Not autogenerated methods //============================================================================== //============================================================================== public void run() { while (true) { try { updateNavDataText(); } catch (Exception e) { } } } private void updateTextFields() { // HSV // --------------------------------------------------------------------- // Hue hueLowerTF.setText("H lower thresh: " + df.format(cd.getHl()).replace(",", ".")); hueUpperTF.setText("H upper thresh: " + df.format(cd.getHu()).replace(",", ".")); // Saturation SaturationLowerTF.setText("S lower thresh: " + df.format(cd.getSl()).replace(",", ".")); saturationUpperTF.setText("S upper thresh: " + df.format(cd.getSu()).replace(",", ".")); // Value valueLowerTF.setText("V lower thresh: " + df.format(cd.getVl()).replace(",", ".")); valueUpperTF.setText("V upper thresh: " + df.format(cd.getVu()).replace(",", ".")); // Gauss filter // --------------------------------------------------------------------- // sigma gaussFilterSigmaTextField.setText("Gauss filter sigma: " + df.format(cd.getSigmaX()).replace(",", ".")); // Mask gaussFilterDimTextField.setText("Gauss filter dimensions: " + (int) cd.getGaussKernelDim()); // PID // --------------------------------------------------------------------- // Yaw yawProportionalTextField.setText("Propotional: " + regulator.getKpYaw()); yawIntegralTextField.setText("Integral: " + regulator.getKiYaw()); yawDerivateTextField.setText("Derivate: " + regulator.getKdYaw()); // Z zProportionalTextField.setText("Propotional: " + regulator.getKpZ()); zIntegralTextField.setText("Integral: " + regulator.getKiZ()); zDerivateTextField.setText("Derivate: " + regulator.getKdZ()); // Pitch pitchProportionalTextField.setText("Propotional: " + regulator.getKpPitch()); pitchIntegralTextField.setText("Integral: " + regulator.getKiPitch()); pitchDerivateTextField.setText("Derivate: " + regulator.getKdPitch()); } private String getValueFromTextInput(String text) { String[] s = text.split(":"); return s[s.length - 1].trim(); } private void updateNavDataText() { RollTextLabel.setText("Roll: " + navData.getRoll()); PitchTextLabel.setText("Pitch: " + navData.getPitch()); yawTextLabel.setText("Yaw: " + navData.getYaw()); altidudeTextLabel.setText("Altitude: " + navData.getExtAltitude().getRaw() / 1000f); // Battery status with color coding int percentage = navData.getPercentage(); if (percentage > 75) { batteryTextLabel.setText("<html><font color='green'>Battery status: " + "<font color='black'>" + percentage + "%</html>"); } else if (percentage > 25) { batteryTextLabel.setText("<html><font color='yellow'>Battery status: " + "<font color='black'>" + percentage + "%</html>"); } else { batteryTextLabel.setText( "<html><font color='red'>Battery status: " + "<font color='black'>" + percentage + "%</html>"); } } }