Package jrackattack.gui

Source Code of jrackattack.gui.ProgramEditPanel

/* For License see bottom */
/*
* ProgramEditPanel.java
*
* Created on 5. August 2007, 21:10
*/

package jrackattack.gui;

import javax.swing.ButtonGroup;
import javax.swing.SpinnerNumberModel;

import jonkoshare.util.VersionInformation;

import jrackattack.event.ProgramParameterEvent;
import jrackattack.event.ProgramParameterListener;

import jrackattack.midi.MidiThread;
import jrackattack.midi.ParameterChange;
import jrackattack.midi.ProgramParameter;
import jrackattack.midi.RackAttack;

/**
* Panel to edit program parameter.
*
* @since 0.9.1
* @author  methke01
*/
@VersionInformation (
  lastChanged="$LastChangedDate: 2009-07-25 04:59:33 -0500 (Sat, 25 Jul 2009) $",
  authors={"Alexander Methke"},
  revision="$LastChangedRevision: 11 $",
  lastEditor="$LastChangedBy: onkobu $",
  id="$Id"
)
public class ProgramEditPanel extends javax.swing.JPanel
              implements ProgramParameterListener {
 
  /** Creates new form ProgramEditPanel */
  public ProgramEditPanel() {
    initComponents();
    initValues();
  }
 
  protected void initValues() {
    initiating=true;
    pluginCompatibleBox.setEnabled(false);
    nameField.setText("");
    ((SpinnerNumberModel)velocitySSpinner.getModel()).setMinimum(0);
    ((SpinnerNumberModel)velocitySSpinner.getModel()).setMaximum(127);
    velocitySSpinner.setValue(0);
    ((SpinnerNumberModel)velocityASpinner.getModel()).setMinimum(0);
    ((SpinnerNumberModel)velocityASpinner.getModel()).setMaximum(127);
    velocityASpinner.setValue(0);
    ((SpinnerNumberModel)velocityBSpinner.getModel()).setMinimum(0);
    ((SpinnerNumberModel)velocityBSpinner.getModel()).setMaximum(127);
    velocityBSpinner.setValue(0);
    ((SpinnerNumberModel)velocityCSpinner.getModel()).setMinimum(0);
    ((SpinnerNumberModel)velocityCSpinner.getModel()).setMaximum(127);
    velocityCSpinner.setValue(0);
   
    ((SpinnerNumberModel)soundSSpinner.getModel()).setMinimum(1);
    ((SpinnerNumberModel)soundSSpinner.getModel()).setMaximum(24);
    soundSSpinner.setValue(1);
    ((SpinnerNumberModel)soundCSpinner.getModel()).setMinimum(1);
    ((SpinnerNumberModel)soundCSpinner.getModel()).setMaximum(24);
    soundCSpinner.setValue(1);
    ((SpinnerNumberModel)soundBSpinner.getModel()).setMinimum(1);
    ((SpinnerNumberModel)soundBSpinner.getModel()).setMaximum(24);
    soundBSpinner.setValue(1);
    ((SpinnerNumberModel)soundASpinner.getModel()).setMinimum(1);
    ((SpinnerNumberModel)soundASpinner.getModel()).setMaximum(24);
    soundASpinner.setValue(1);
   
    SpinnerNumberModel smn=new SpinnerNumberModel(0.2, 0.2, 319.9, 0.1);
    smn.setValue(new Double(0.2));
    tempoSpinner.setModel(smn);

    signatureBox.removeAllItems();
    for(String t:RackAttack.TIME_SIGNATURES) {
      signatureBox.addItem(t);
    }
   
    tempoSpinner.setEnabled(false);
    ButtonGroup bg=new ButtonGroup();
    bg.add(freeRadioButton);
    bg.add(globalRadioButton);
    bg.add(externRadioButton);
    externRadioButton.setSelected(true);

    initiating=false;
  }
 
  /** 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() {
        java.awt.GridBagConstraints gridBagConstraints;

        nameLabel = new javax.swing.JLabel();
        nameField = new javax.swing.JTextField();
        pluginCompatibleBox = new javax.swing.JCheckBox();
        soundALabel = new javax.swing.JLabel();
        soundASpinner = new javax.swing.JSpinner();
        velocityALabel = new javax.swing.JLabel();
        velocityASpinner = new javax.swing.JSpinner();
        soundBLabel = new javax.swing.JLabel();
        soundBSpinner = new javax.swing.JSpinner();
        velocityBLabel = new javax.swing.JLabel();
        velocityBSpinner = new javax.swing.JSpinner();
        soundCLabel = new javax.swing.JLabel();
        soundCSpinner = new javax.swing.JSpinner();
        velocityCLabel = new javax.swing.JLabel();
        velocityCSpinner = new javax.swing.JSpinner();
        soundSLabel = new javax.swing.JLabel();
        soundSSpinner = new javax.swing.JSpinner();
        velocitySLabel = new javax.swing.JLabel();
        velocitySSpinner = new javax.swing.JSpinner();
        signatureBox = new javax.swing.JComboBox();
        signatureLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        tempoSpinner = new javax.swing.JSpinner();
        freeRadioButton = new javax.swing.JRadioButton();
        globalRadioButton = new javax.swing.JRadioButton();
        externRadioButton = new javax.swing.JRadioButton();

        setLayout(new java.awt.GridBagLayout());

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jrackattack/gui"); // NOI18N
        nameLabel.setText(bundle.getString("label.name")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(nameLabel, gridBagConstraints);

        nameField.setText("jTextField1");
        nameField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                nameFieldKeyPressed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(nameField, gridBagConstraints);

        pluginCompatibleBox.setText(bundle.getString("box.plugin_compatible")); // NOI18N
        pluginCompatibleBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        pluginCompatibleBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        pluginCompatibleBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pluginCompatibleBoxActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(pluginCompatibleBox, gridBagConstraints);

        soundALabel.setText(bundle.getString("label.soundA")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundALabel, gridBagConstraints);

        soundASpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        soundASpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                soundASpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundASpinner, gridBagConstraints);

        velocityALabel.setText(bundle.getString("label.velocityA")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocityALabel, gridBagConstraints);

        velocityASpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        velocityASpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                velocityASpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocityASpinner, gridBagConstraints);

        soundBLabel.setText(bundle.getString("label.soundB")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundBLabel, gridBagConstraints);

        soundBSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        soundBSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                soundBSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundBSpinner, gridBagConstraints);

        velocityBLabel.setText(bundle.getString("label.velocityB")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocityBLabel, gridBagConstraints);

        velocityBSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        velocityBSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                velocityBSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocityBSpinner, gridBagConstraints);

        soundCLabel.setText(bundle.getString("label.soundC")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundCLabel, gridBagConstraints);

        soundCSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        soundCSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                soundCSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundCSpinner, gridBagConstraints);

        velocityCLabel.setText(bundle.getString("label.velocityC")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocityCLabel, gridBagConstraints);

        velocityCSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        velocityCSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                velocityCSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocityCSpinner, gridBagConstraints);

        soundSLabel.setText(bundle.getString("label.soundS")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundSLabel, gridBagConstraints);

        soundSSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        soundSSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                soundSSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(soundSSpinner, gridBagConstraints);

        velocitySLabel.setText(bundle.getString("label.velocityS")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocitySLabel, gridBagConstraints);

        velocitySSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        velocitySSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                velocitySSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(velocitySSpinner, gridBagConstraints);

        signatureBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        signatureBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                signatureBoxItemStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(signatureBox, gridBagConstraints);

        signatureLabel.setText(bundle.getString("label.signature")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(signatureLabel, gridBagConstraints);

        jLabel1.setText(bundle.getString("label.tempo")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(jLabel1, gridBagConstraints);

        tempoSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
        tempoSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tempoSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 7;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(tempoSpinner, gridBagConstraints);

        freeRadioButton.setText(bundle.getString("checkbox.free")); // NOI18N
        freeRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        freeRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        freeRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                freeRadioButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(freeRadioButton, gridBagConstraints);

        globalRadioButton.setText(bundle.getString("checkbox.global_clock")); // NOI18N
        globalRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        globalRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        globalRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                globalRadioButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(globalRadioButton, gridBagConstraints);

        externRadioButton.setText(bundle.getString("checkbox.extern")); // NOI18N
        externRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        externRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        externRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                externRadioButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(externRadioButton, gridBagConstraints);

    }// </editor-fold>//GEN-END:initComponents

  private void externRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_externRadioButtonActionPerformed
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    tempoSpinner.setEnabled(false);
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.PROGRAM_TEMPO_HI,
      0);
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.PROGRAM_TEMPO_LO,
      1);
  }//GEN-LAST:event_externRadioButtonActionPerformed

  private void globalRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_globalRadioButtonActionPerformed
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    tempoSpinner.setEnabled(false);
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.PROGRAM_TEMPO_HI,
      0);
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.PROGRAM_TEMPO_LO,
      0);
  }//GEN-LAST:event_globalRadioButtonActionPerformed

  private void freeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freeRadioButtonActionPerformed
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    tempoSpinner.setEnabled(true);
    tempoSpinnerStateChanged(null);
  }//GEN-LAST:event_freeRadioButtonActionPerformed

  private void tempoSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tempoSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    Number n=((SpinnerNumberModel)tempoSpinner.getModel()).getNumber();
    if (! (n instanceof Double)) {
      throw new IllegalStateException("Tempo spinner's number may not be of any other type than Double, wrong type: "+n.getClass().getName());
    }
    int[] tempo=ProgramParameter.calculateTempo(((Double)n).floatValue());
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.PROGRAM_TEMPO_HI,
      tempo[0]);
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.PROGRAM_TEMPO_LO,
      tempo[1]);
  }//GEN-LAST:event_tempoSpinnerStateChanged

  private void signatureBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_signatureBoxItemStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.TIME_SIGNATURE,
      signatureBox.getSelectedIndex());
  }//GEN-LAST:event_signatureBoxItemStateChanged

  private void velocitySSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_velocitySSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.VELOCITY_S,
      ((Integer)velocitySSpinner.getValue()).intValue());
  }//GEN-LAST:event_velocitySSpinnerStateChanged

  private void soundSSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_soundSSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.INSTRUMENT_S,
      ((Integer)soundSSpinner.getValue()).intValue());
  }//GEN-LAST:event_soundSSpinnerStateChanged

  private void velocityCSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_velocityCSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.VELOCITY_C,
      ((Integer)velocityCSpinner.getValue()).intValue());
  }//GEN-LAST:event_velocityCSpinnerStateChanged

  private void soundCSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_soundCSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.INSTRUMENT_C,
      ((Integer)soundCSpinner.getValue()).intValue());
  }//GEN-LAST:event_soundCSpinnerStateChanged

  private void velocityBSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_velocityBSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.VELOCITY_B,
      ((Integer)velocityBSpinner.getValue()).intValue());
  }//GEN-LAST:event_velocityBSpinnerStateChanged

  private void soundBSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_soundBSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.INSTRUMENT_B,
      ((Integer)soundBSpinner.getValue()).intValue());
  }//GEN-LAST:event_soundBSpinnerStateChanged

  private void velocityASpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_velocityASpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.VELOCITY_A,
      ((Integer)velocityASpinner.getValue()).intValue());
  }//GEN-LAST:event_velocityASpinnerStateChanged

  private void soundASpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_soundASpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    MidiThread.getInstance().emitProgramChange(this,
      getProgramBuffer().getActiveProgramNumber(),
      RackAttack.INSTRUMENT_A,
      ((Integer)soundASpinner.getValue()).intValue());
  }//GEN-LAST:event_soundASpinnerStateChanged

  private void pluginCompatibleBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pluginCompatibleBoxActionPerformed
// TODO add your handling code here:
   
  }//GEN-LAST:event_pluginCompatibleBoxActionPerformed

  private void nameFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nameFieldKeyPressed
// TODO add your handling code here:
    MidiThread mt=MidiThread.getInstance();
    String name=nameField.getText();
    for (int i=0;i<16&&i<name.length();i++) {
      mt.emitProgramChange(this,
        getProgramBuffer().getActiveProgramNumber(),
        RackAttack.PARAM_NAME_AH_AL[i],
        (byte)name.charAt(i));
    }
  }//GEN-LAST:event_nameFieldKeyPressed

//ProgramParameterListener
  public void parameterChanged(ParameterChange pc) {
    System.out.println("*** change ***");
    programParameterChanged(getProgramBuffer().getActiveProgramParameter());
  }
 
  public void programParameterChanged(ProgramParameter pp) {
    initiating=true;
    nameField.setText(pp.getName());
    soundASpinner.setValue(pp.getInstrumentA());
    soundBSpinner.setValue(pp.getInstrumentB());
    soundCSpinner.setValue(pp.getInstrumentC());
    soundSSpinner.setValue(pp.getInstrumentS());
    velocityASpinner.setValue(pp.getVelocityA());
    velocityBSpinner.setValue(pp.getVelocityB());
    velocityCSpinner.setValue(pp.getVelocityC());
    velocitySSpinner.setValue(pp.getVelocityS());
    if (pp.getTempo()==0) {
      globalRadioButton.setSelected(true);
      tempoSpinner.setEnabled(false);
    } else if (pp.getTempo()==0.1) {
      externRadioButton.setSelected(true);
      tempoSpinner.setEnabled(false);
    } else {
      tempoSpinner.setValue(new Double(pp.getTempo()));
      tempoSpinner.setEnabled(true);
      freeRadioButton.setSelected(true);
    }
    initiating=false;
  }
 
  public void parameterChanged(ProgramParameterEvent ppe) {
    // should be the only source of program parameter
    // changes...
    if (ppe.getSource()==this) {
      return;
    }
  }
 
  public void programNumberChanged(ProgramParameterEvent ppe) {
   
  }

  /**
   * Getter for property programBuffer.
   * @return Value of property programBuffer.
   */
  public ProgramBuffer getProgramBuffer() {
    return this.programBuffer;
  }

  /**
   * Setter for property programBuffer.
   * @param programBuffer New value of property programBuffer.
   */
  public void setProgramBuffer(ProgramBuffer programBuffer) {
    this.programBuffer = programBuffer;
  }
 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton externRadioButton;
    private javax.swing.JRadioButton freeRadioButton;
    private javax.swing.JRadioButton globalRadioButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField nameField;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JCheckBox pluginCompatibleBox;
    private javax.swing.JComboBox signatureBox;
    private javax.swing.JLabel signatureLabel;
    private javax.swing.JLabel soundALabel;
    private javax.swing.JSpinner soundASpinner;
    private javax.swing.JLabel soundBLabel;
    private javax.swing.JSpinner soundBSpinner;
    private javax.swing.JLabel soundCLabel;
    private javax.swing.JSpinner soundCSpinner;
    private javax.swing.JLabel soundSLabel;
    private javax.swing.JSpinner soundSSpinner;
    private javax.swing.JSpinner tempoSpinner;
    private javax.swing.JLabel velocityALabel;
    private javax.swing.JSpinner velocityASpinner;
    private javax.swing.JLabel velocityBLabel;
    private javax.swing.JSpinner velocityBSpinner;
    private javax.swing.JLabel velocityCLabel;
    private javax.swing.JSpinner velocityCSpinner;
    private javax.swing.JLabel velocitySLabel;
    private javax.swing.JSpinner velocitySSpinner;
    // End of variables declaration//GEN-END:variables

  private boolean initiating;
 
  /**
   * Holds value of property programBuffer.
   */
  private ProgramBuffer programBuffer;
}
/*
    Copyright (C) 2008  Alexander Methke

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program (gplv3.txt).
*/
TOP

Related Classes of jrackattack.gui.ProgramEditPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.