Package com.meapsoft.gui.composers

Source Code of com.meapsoft.gui.composers.VQComposerPanel

/*
* VQComposerPanel.java
*
* Created on November 18, 2007, 10:54 PM
*/

package com.meapsoft.gui.composers;

import java.io.File;

import com.meapsoft.FeatFile;
import com.meapsoft.composers.Composer;
import com.meapsoft.composers.VQComposer;
import com.meapsoft.disgraced.GUIUtils;

/**
*
* @author  Mike
*/
public class VQComposerPanel extends ComposerSettingsPanel
{
    private String vqFeaturesNameFull = "";
    private String vqFeaturesNameShort = "";
 
 
    /** Creates new form VQComposerPanel */
    public VQComposerPanel()
    {
        initComponents();
    }
   
    public int initComposer()
    {
    mComposer = new VQComposer(mParentTab.featFile, mParentTab.edlFile);

        VQComposer vqc = (VQComposer)mComposer;
        vqc.setCodebookSize(mNumSlider.getValue());
        vqc.setBeatsPerCodeword(mBeatsSlider.getValue());

        if(vqFeaturesNameFull != null)
        {
            if (!(new File(vqFeaturesNameFull).exists()))
            {
                GUIUtils.ShowDialog("VQComposer: Please select a valid feature file!",
                                    GUIUtils.MESSAGE, mParentTab.mMainScreen);
                return -1;
            }
            else
                vqc.setFeatsToQuantize(new FeatFile(vqFeaturesNameFull));
        }

        if(mQuantizeChk.isSelected())
            vqc.setFeatsToQuantize(mParentTab.featFile);
     
      return 0;
    }
   
    /** 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() {

        mNumSlider = new javax.swing.JSlider();
        mBeatsSlider = new javax.swing.JSlider();
        mQuantizeChk = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        mFeatFileTxt = new javax.swing.JTextField();
        mBrowseBtn = new javax.swing.JButton();

        mNumSlider.setMajorTickSpacing(25);
        mNumSlider.setPaintLabels(true);

        mBeatsSlider.setMajorTickSpacing(2);
        mBeatsSlider.setMaximum(16);
        mBeatsSlider.setPaintLabels(true);
        mBeatsSlider.setValue(1);

        mQuantizeChk.setText("Quantize training file");
        mQuantizeChk.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        mQuantizeChk.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jLabel1.setText("Number of codewords:");

        jLabel2.setText("Beats per codeword:");

        jLabel3.setText("Feature file:");

        mFeatFileTxt.setText("feat file");

        mBrowseBtn.setText("Browse");
        mBrowseBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mBrowseBtnActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(layout.createSequentialGroup()
                        .add(10, 10, 10)
                        .add(mBeatsSlider, 0, 0, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .add(9, 9, 9)
                        .add(mNumSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 157, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 95, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createSequentialGroup()
                        .add(10, 10, 10)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(mFeatFileTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(mQuantizeChk))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mBrowseBtn)))
                .addContainerGap(46, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(5, 5, 5)
                        .add(jLabel1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mNumSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel2)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mBeatsSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(mFeatFileTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(mBrowseBtn))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mQuantizeChk)))
                .addContainerGap(161, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void mBrowseBtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_mBrowseBtnActionPerformed
    {//GEN-HEADEREND:event_mBrowseBtnActionPerformed

    String names[] = browseFile("feat");
    vqFeaturesNameFull = names[0];
    vqFeaturesNameShort = names[1];
       
        mFeatFileTxt.setText(vqFeaturesNameShort);
     
    }//GEN-LAST:event_mBrowseBtnActionPerformed
   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JSlider mBeatsSlider;
    private javax.swing.JButton mBrowseBtn;
    private javax.swing.JTextField mFeatFileTxt;
    private javax.swing.JSlider mNumSlider;
    private javax.swing.JCheckBox mQuantizeChk;
    // End of variables declaration//GEN-END:variables
   
}
TOP

Related Classes of com.meapsoft.gui.composers.VQComposerPanel

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.