/* For License see bottom */
/*
* SoundMMUPanel.java
*
* Created on 4. August 2007, 08:49
*/
package jrackattack.gui;
import javax.swing.SpinnerNumberModel;
import jonkoshare.util.VersionInformation;
import jrackattack.midi.MidiThread;
import jrackattack.midi.SoundParameter;
/**
*
* @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 SoundMMUPanel extends javax.swing.JPanel {
/** Creates new form SoundMMUPanel */
public SoundMMUPanel() {
initComponents();
initValues();
}
protected void initValues() {
((SpinnerNumberModel)copyFromSpinner.getModel()).setMinimum(1);
((SpinnerNumberModel)copyFromSpinner.getModel()).setMaximum(24);
copyFromSpinner.setValue(1);
((SpinnerNumberModel)copyToSpinner.getModel()).setMinimum(1);
((SpinnerNumberModel)copyToSpinner.getModel()).setMaximum(24);
copyToSpinner.setValue(1);
((SpinnerNumberModel)switchSpinner1.getModel()).setMinimum(1);
((SpinnerNumberModel)switchSpinner1.getModel()).setMaximum(24);
switchSpinner1.setValue(1);
((SpinnerNumberModel)switchSpinner2.getModel()).setMinimum(1);
((SpinnerNumberModel)switchSpinner2.getModel()).setMaximum(24);
switchSpinner2.setValue(1);
}
/** 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;
jLabel1 = new javax.swing.JLabel();
copyFromSpinner = new javax.swing.JSpinner();
copyButton = new javax.swing.JButton();
copyToSpinner = new javax.swing.JSpinner();
jLabel2 = new javax.swing.JLabel();
switchSpinner1 = new javax.swing.JSpinner();
switchButton = new javax.swing.JButton();
switchSpinner2 = new javax.swing.JSpinner();
setLayout(new java.awt.GridBagLayout());
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jrackattack/gui"); // NOI18N
jLabel1.setText(bundle.getString("label.copy")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jLabel1, gridBagConstraints);
copyFromSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(copyFromSpinner, gridBagConstraints);
copyButton.setText(bundle.getString("button.to")); // NOI18N
copyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
copyButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(copyButton, gridBagConstraints);
copyToSpinner.setPreferredSize(new java.awt.Dimension(50, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(copyToSpinner, gridBagConstraints);
jLabel2.setText(bundle.getString("label.switch")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jLabel2, gridBagConstraints);
switchSpinner1.setPreferredSize(new java.awt.Dimension(50, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(switchSpinner1, gridBagConstraints);
switchButton.setText(bundle.getString("button.and")); // NOI18N
switchButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
switchButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(switchButton, gridBagConstraints);
switchSpinner2.setPreferredSize(new java.awt.Dimension(50, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(switchSpinner2, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
private void switchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_switchButtonActionPerformed
// TODO add your handling code here:
JRackAttackFrame jrf=JRackAttackFrame.getInstance();
SoundParameter sp1=jrf.getAllSoundParameter()[((Integer)switchSpinner1.getValue()).intValue()-1];
SoundParameter sp2=jrf.getAllSoundParameter()[((Integer)switchSpinner2.getValue()).intValue()-1];
int sn=sp1.getSoundNumber();
sp1.setSoundNumber(sp2.getSoundNumber());
sp2.setSoundNumber(sn);
MidiThread.getInstance().storeSoundParameter(sp1, true);
MidiThread.getInstance().storeSoundParameter(sp2, true);
jrf.setSoundParameter(sp1);
jrf.setSoundParameter(sp2);
}//GEN-LAST:event_switchButtonActionPerformed
private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyButtonActionPerformed
// TODO add your handling code here:
JRackAttackFrame jrf=JRackAttackFrame.getInstance();
SoundParameter sp=jrf.getAllSoundParameter()[((Integer)copyFromSpinner.getValue()).intValue()-1];
SoundParameter sp2=sp.copy();
sp2.setSoundNumber(((Integer)copyToSpinner.getValue()).intValue()-1);
// store parameter in edith buffer too
MidiThread.getInstance().storeSoundParameter(sp2, true);
jrf.setSoundParameter(sp2);
}//GEN-LAST:event_copyButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton copyButton;
private javax.swing.JSpinner copyFromSpinner;
private javax.swing.JSpinner copyToSpinner;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton switchButton;
private javax.swing.JSpinner switchSpinner1;
private javax.swing.JSpinner switchSpinner2;
// End of variables declaration//GEN-END:variables
}
/*
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).
*/