// file: $ISIP_IFC/util/demo/isip_comm_client_speech_analysis/ConfigTabPanel.java
// version: $Id: ConfigTabPanel.java 10227 2005-09-09 19:07:49Z stanley $ 
//

// import necessary java libraries
//
import java.net.*;
import java.io.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import javax.swing.border.*;

/**
 * This class is used to organize configuration tabs.
 */
public class ConfigTabPanel extends JTabbedPane {

    //-------------------------------------------------------------------------
    //
    // public constants
    //
    //-------------------------------------------------------------------------
    
    /**
     * AUDIO tab index.
     */
    public static final int AUDIO = 0;

    /**
     * ENERGY tab index.
     */
    public static final int ENERGY = 1;

    /**
     *  WAVEFORM index.
     */
    public static final int WAVEFORM = 2;

    /**
     * SPECTROGRAM tab index.
     */
    public static final int SPECTROGRAM = 3;

    /**
     * DISPLAY tab index.
     */
    public static final int DISPLAY = 4;

    /**
     * DETECTOR tab index.
     */
    public static final int DETECTOR = 5;

    //------------------------------------------------------------------------
    //
    // protected data
    //
    //-----------------------------------------------------------------------

    /**
     * Audio configuration panel.
     */
    protected PanelAudio panel_audio_d;
    
    /**
     * Energy configuration panel.
     */
    protected PanelEnergy panel_energy_d;
    
    /**
     * Spectrogram configuration panel.
     */
    protected PanelSpectrogram panel_spectrogram_d;
    
    /**
     * Waveform configuration panel.
     */
    protected PanelWaveform panel_waveform_d;
    
    /**
     * Display configuration panel.
     */
    protected PanelDisplay panel_display_d;

     /**
     * Display configuration panel.
     */
    protected PanelDetector panel_detector_d;

    /**
     * Constructor.
     */
    public ConfigTabPanel() {

	// call the super class's constructor
	//
	super();

	// Initialize variables
	//
	panel_audio_d = new PanelAudio();

	panel_energy_d = new PanelEnergy();

	panel_waveform_d = new PanelWaveform();

	panel_spectrogram_d = new PanelSpectrogram();

	panel_display_d = new PanelDisplay();
	
	panel_detector_d = new PanelDetector();

	// initialize layout manager
	//
	ImageIcon myicon = new ImageIcon("images/love.gif");

	this.addTab("Audio", myicon, panel_audio_d);

	this.addTab("Energy", myicon, panel_energy_d);

	this.addTab("Waveform", myicon, panel_waveform_d);

	this.addTab("Spectrogram", myicon, panel_spectrogram_d);

	this.addTab("Display", myicon, panel_display_d);
	
	this.addTab("Detector", myicon, panel_detector_d);

	// set all value to default
	//
        reset(); 
    }

    /**
     * Set all the parameter values to their default values.
     *
     * @return a boolean value indicating status.
     */
    public boolean reset() {

	panel_audio_d.defaultSetting();
	panel_energy_d.defaultSetting();
	panel_waveform_d.defaultSetting();
	panel_spectrogram_d.defaultSetting();
	panel_display_d.defaultSetting();
	panel_detector_d.defaultSetting();

	return true;

    }

    /**
     * apply all the parameter values and verify them.
     *
     * @return a boolean value indicating status.
     */
    public boolean apply() {

	boolean success = true;

	success &= panel_audio_d.apply();
	success &= panel_energy_d.apply();
	success &= panel_waveform_d.apply();
	success &= panel_spectrogram_d.apply();
	success &= panel_display_d.apply();
	success &= panel_detector_d.apply();

	return success;

    }

    /**
     * Get audio configuration data.
     *
     * @return a ConfigData for Audio configuration.
     */
    public ConfigData getAudioData() {
	return panel_audio_d.getData();
    }

    /**
     * Get energy configuration data.
     *
     * @return a ConfigData for Energy configuration.
     */
    public ConfigData getEnergyData() {
	return panel_energy_d.getData();
    }

    /**
     * Get spectrogram configuration data.
     *
     * @return a ConfigData for Spectrogram configuration.
     */
    public ConfigData getSpectrogramData() {
	return panel_spectrogram_d.getData();
    }

    /**
     * Get waveform configuration data.
     *
     * @return a ConfigData for Waveform configuration.
     */
    public ConfigData getWaveformData() {
	return panel_waveform_d.getData();
    }

    /**
     * Get display configuration data.
     *
     * @return a ConfigData for Display configuration.
     */
    public ConfigData getDisplayData() {
	return panel_display_d.getData();
    }

    /**
     * Get detector configuration data.
     *
     * @return a ConfigData for end point Detector configuration.
     */
    public ConfigData getDetectorData() {
	return panel_detector_d.getData();
    }


    public String getDemoName() {
	return panel_audio_d.getDemoName();
    }
    
    /**
     * Set the name of the demo.
     *
     * @param demo_name_a name of the demo
     *
     * @return a boolean value
     */
    public boolean setDemoName(String demo_name_a) {
	
	panel_audio_d.setDemoName(demo_name_a);
	
	return true;
    }
}
