/* For License see bottom */
/*
* SoundIOPanel.java
*
* Created on 22. Juli 2007, 09:21
*/
package jrackattack.gui;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import jonkoshare.util.VersionInformation;
import jrackattack.midi.FXParameter;
/**
*
* @author methke01
*/
@VersionInformation (
lastChanged="$LastChangedDate: 2009-09-15 14:15:46 -0500 (Tue, 15 Sep 2009) $",
authors={"Alexander Methke"},
revision="$LastChangedRevision: 15 $",
lastEditor="$LastChangedBy: onkobu $",
id="$Id"
)
public class FXIOPanel extends JPanel {
/** Creates new form SoundIOPanel */
public FXIOPanel() {
initComponents();
initValues();
}
protected void initValues() {
bufferCheckBox.setSelected(true);
ButtonGroup buttonGroup1=new ButtonGroup();
buttonGroup1.add(loadButton);
buttonGroup1.add(storeButton);
buttonGroup1.add(resetButton);
buttonGroup1.add(messageButton);
loadButton.setSelected(true);
((SpinnerNumberModel)fxSpinner.getModel()).setMinimum(1);
((SpinnerNumberModel)fxSpinner.getModel()).setMaximum(4);
fxSpinner.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 ">
private void initComponents() {
GridBagConstraints gridBagConstraints;
fxSpinner = new JSpinner();
loadButton = new JRadioButton();
storeButton = new JRadioButton();
resetButton = new JRadioButton();
messageButton = new JRadioButton();
allCheckBox = new JCheckBox();
bufferCheckBox = new JCheckBox();
execButton = new JButton();
setLayout(new GridBagLayout());
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
add(fxSpinner, gridBagConstraints);
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jrackattack/gui"); // NOI18N
loadButton.setText(bundle.getString("radio.sound.load")); // NOI18N
loadButton.setToolTipText(bundle.getString("tooltip.sound.load")); // NOI18N
loadButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
loadButton.setMargin(new Insets(0, 0, 0, 0));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(loadButton, gridBagConstraints);
storeButton.setText(bundle.getString("radio.sound.store")); // NOI18N
storeButton.setToolTipText(bundle.getString("tooltip.sound.store")); // NOI18N
storeButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
storeButton.setMargin(new Insets(0, 0, 0, 0));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(storeButton, gridBagConstraints);
resetButton.setText(bundle.getString("radio.sound.reset")); // NOI18N
resetButton.setToolTipText(bundle.getString("tooltip.sound.reset")); // NOI18N
resetButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
resetButton.setMargin(new Insets(0, 0, 0, 0));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(resetButton, gridBagConstraints);
messageButton.setText(bundle.getString("button.midi_message")); // NOI18N
messageButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
messageButton.setMargin(new Insets(0, 0, 0, 0));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(messageButton, gridBagConstraints);
allCheckBox.setText(bundle.getString("checkbox.fx.all")); // NOI18N
allCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
allCheckBox.setMargin(new Insets(0, 0, 0, 0));
allCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
allCheckBoxItemStateChanged(evt);
}
});
allCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
allCheckBoxActionPerformed(evt);
}
});
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(allCheckBox, gridBagConstraints);
bufferCheckBox.setText(bundle.getString("checkbox.sound.buffer")); // NOI18N
bufferCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
bufferCheckBox.setMargin(new Insets(0, 0, 0, 0));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 6;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(bufferCheckBox, gridBagConstraints);
execButton.setText(bundle.getString("button.exec")); // NOI18N
execButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
execButtonActionPerformed(evt);
}
});
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 7;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
add(execButton, gridBagConstraints);
}
private void allCheckBoxActionPerformed(ActionEvent evt) {
fxSpinner.setEnabled(!allCheckBox.isSelected());
}
private void execButtonActionPerformed(ActionEvent evt) {
if (allCheckBox.isSelected()) {
for(FXParameter fp:getFxBuffer().getAllFXParameter()) {
execute(fp);
}
} else {
FXParameter fp=getFxBuffer().getAllFXParameter()[((Integer)fxSpinner.getValue()).intValue()];
execute(fp);
}
}
protected void execute(FXParameter sp) {
/*
if (loadButton.isSelected()) {
MidiThread.getInstance().loadSoundParameter(sp.getSoundNumber(),
bufferCheckBox.isSelected());
} else if (storeButton.isSelected()) {
MidiThread.getInstance().storeSoundParameter(sp, bufferCheckBox.isSelected());
} else if (resetButton.isSelected()) {
MidiThread.getInstance().loadSoundParameter(sp.getSoundNumber(),
false);
} else if (messageButton.isSelected()) {
String msg=MidiReader.formatMidiMessage(sp.createMessage(bufferCheckBox.isSelected()));
JRackAttackFrame.getInstance().appendMessage("# sound parameter "+sp.getSoundNumber());
JRackAttackFrame.getInstance().appendMessage(msg);
}
*/
}
private void allCheckBoxItemStateChanged(ItemEvent evt) {
}
private JCheckBox allCheckBox;
private JCheckBox bufferCheckBox;
private JButton execButton;
private JSpinner fxSpinner;
private JRadioButton loadButton;
private JRadioButton messageButton;
private JRadioButton resetButton;
private JRadioButton storeButton;
/**
* Holds value of property fxBuffer.
*/
private FXBuffer fxBuffer;
/**
* Getter for property fxBuffer.
* @return Value of property fxBuffer.
*/
public FXBuffer getFxBuffer() {
return this.fxBuffer;
}
/**
* Setter for property fxBuffer.
* @param fxBuffer New value of property fxBuffer.
*/
public void setFxBuffer(FXBuffer fxBuffer) {
this.fxBuffer = fxBuffer;
}
}
/*
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).
*/