Package jrackattack.gui

Source Code of jrackattack.gui.SoundIOPanel

/* For License see bottom */
/*
* SoundIOPanel.java
*
* Created on 22. Juli 2007, 09:21
*/

package jrackattack.gui;

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 jonkoshare.util.VersionInformation;
import jrackattack.midi.MidiReader;
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 SoundIOPanel extends JPanel {
 
  /** Creates new form SoundIOPanel */
  public SoundIOPanel() {
    initComponents();
    initValues();
  }
 
  public void soundParameterChanged(SoundParameter p) {
  }
 
  protected void initValues() {
    bufferCheckBox.setSelected(true);
    ButtonGroup buttonGroup1=new ButtonGroup();
    buttonGroup1.add(loadButton);
    buttonGroup1.add(storeButton);
    buttonGroup1.add(randomButton);
    buttonGroup1.add(resetButton);
    buttonGroup1.add(messageButton);
    loadButton.setSelected(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.
   */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        loadButton = new JRadioButton();
        storeButton = new JRadioButton();
        randomButton = new JRadioButton();
        resetButton = new JRadioButton();
        execButton = new JButton();
        allCheckBox = new JCheckBox();
        bufferCheckBox = new JCheckBox();
        messageButton = new JRadioButton();

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

        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 java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.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 java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(storeButton, gridBagConstraints);

        randomButton.setText(bundle.getString("radio.sound.random")); // NOI18N
        randomButton.setToolTipText(bundle.getString("tooltip.sound.random")); // NOI18N
        randomButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        randomButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(randomButton, 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 java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(resetButton, gridBagConstraints);

        execButton.setText(bundle.getString("button.exec")); // NOI18N
        execButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                execButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(execButton, gridBagConstraints);

        allCheckBox.setText(bundle.getString("checkbox.sound.all")); // NOI18N
        allCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        allCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        allCheckBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                allCheckBoxItemStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.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 java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(bufferCheckBox, gridBagConstraints);

        messageButton.setText(bundle.getString("button.midi_message")); // NOI18N
        messageButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        messageButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        add(messageButton, gridBagConstraints);

    }// </editor-fold>

  private void execButtonActionPerformed(java.awt.event.ActionEvent evt) {

    if (allCheckBox.isSelected()) {
      for(SoundParameter sp:getSoundBuffer().getAllSoundParameter()) {
        execute(sp);
      }
    } else {
      SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
      execute(sp);
    }
  }

  protected void execute(SoundParameter 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().loadSoundFromProgramToEdit(sp.getSoundNumber());
    } else if (randomButton.isSelected()) {
      sp.randomize();
      MidiThread.getInstance().storeSoundParameter(sp, bufferCheckBox.isSelected());
      JRackAttackFrame.getInstance().setSoundParameter(sp);
    } else if (messageButton.isSelected()) {
      String msg=MidiReader.formatMidiMessage(sp.createMessage(bufferCheckBox.isSelected()));
      JRackAttackFrame.getInstance().appendMessage("# sound parameter "+sp.getSoundNumber());
      JRackAttackFrame.getInstance().appendMessage(msg);
    }
  }

  /**
   * Getter for property soundBuffer.
   * @return Value of property soundBuffer.
   */
  public SoundBuffer getSoundBuffer() {
    return this.soundBuffer;
  }

  /**
   * Setter for property soundBuffer.
   * @param soundBuffer New value of property soundBuffer.
   */
  public void setSoundBuffer(SoundBuffer soundBuffer) {
    this.soundBuffer = soundBuffer;
  }
 
  private void allCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {

  }
 
 
    // Variables declaration - do not modify
    private JCheckBox allCheckBox;
    private JCheckBox bufferCheckBox;
    private JButton execButton;
    private JRadioButton loadButton;
    private JRadioButton messageButton;
    private JRadioButton randomButton;
    private JRadioButton resetButton;
    private JRadioButton storeButton;
    // End of variables declaration

  /**
   * Holds value of property soundBuffer.
   */
  private SoundBuffer soundBuffer;

 
}
/*
    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.SoundIOPanel

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.