00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.meapsoft.gui;
00024
00025 import java.awt.*;
00026 import java.awt.event.*;
00027 import java.io.*;
00028 import java.util.*;
00029 import javax.swing.*;
00030
00031 import com.meapsoft.*;
00032
00040 public abstract class MEAPsoftGUIPanel extends JPanel implements ActionListener, MouseListener
00041 {
00042
00043 public Color color;
00044
00045
00046 protected static MEAPsoftGUI meapsoftGUI;
00047
00048
00049 protected static String audioPlayerName;
00050
00051
00052 public static FeatFile segmentFile = null;
00053 public static FeatFile featFile = null;
00054 public static EDLFile edlFile = null;
00055
00056
00057 protected static String dataDirectory;
00058 protected static String meapsoftDirectory;
00059 protected static String slash;
00060 protected static String dataBaseName = "mann";
00061
00062 protected static String inputSoundFileNameFull;
00063 protected static String inputSoundFileNameShort;
00064 protected static String outputSegmentsFileName = dataBaseName + ".seg";
00065
00066 protected static String inputSegmentsFileName = dataBaseName + ".seg";
00067 protected static String outputFeaturesFileName = dataBaseName + ".feat";
00068
00069 protected static String inputFeaturesFileName = dataBaseName + ".feat";
00070 protected static String outputEDLFileName = dataBaseName + ".edl";
00071
00072 protected static String inputEDLFileName = dataBaseName + ".edl";
00073 protected static String outputSoundFileNameFull;
00074 protected static String outputSoundFileNameShort;
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 protected JLabel helpButton;
00091 protected String helpURL;
00092
00093
00094 protected String title;
00095
00099 public MEAPsoftGUIPanel(MEAPsoftGUI msg)
00100 {
00101 meapsoftGUI = msg;
00102
00103 dataDirectory = msg.dataDirectory;
00104 meapsoftDirectory = msg.meapsoftDirectory;
00105 slash = MEAPUtil.slash;
00106
00107 if (System.getProperty("os.name").equals("Mac OS X"))
00108 audioPlayerName = "open";
00109 else if (System.getProperty("os.name").equals("Linux"))
00110 audioPlayerName = "play";
00111 else if (System.getProperty("os.name").startsWith("Windows"))
00112 audioPlayerName =
00113 "C:\\Program Files\\Windows Media Player\\wmplayer.exe";
00114 else
00115 audioPlayerName = null;
00116
00117 helpButton = new JLabel("(help)");
00118 helpButton.setForeground(Color.blue);
00119 helpButton.setAlignmentX(Component.CENTER_ALIGNMENT);
00120 helpButton.addMouseListener(this);
00121 helpURL = "file:///" + meapsoftDirectory + slash + "doc" + slash
00122 + "manual.html";
00123 }
00124
00129 public abstract int run();
00130
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 protected static void initSegmentFile()
00152 {
00153 String fn = dataDirectory + slash + outputSegmentsFileName;
00154
00155 if(segmentFile == null || segmentFile.filename != fn)
00156 segmentFile = new FeatFile(fn);
00157 }
00158
00159 protected static void initFeatFile()
00160 {
00161 String fn = dataDirectory + slash + outputFeaturesFileName;
00162
00163 if(featFile == null || featFile.filename != fn)
00164 featFile = new FeatFile(fn);
00165 }
00166
00167 protected static void initEDLFile()
00168 {
00169 String fn = dataDirectory + slash + outputEDLFileName;
00170
00171 if(edlFile == null || edlFile.filename != fn)
00172 edlFile = new EDLFile(fn);
00173 }
00174
00175 protected synchronized static void UpdateFileNames()
00176 {
00177
00178 outputSegmentsFileName = dataBaseName + ".seg";
00179
00180 inputSegmentsFileName = dataBaseName + ".seg";
00181 outputFeaturesFileName = dataBaseName + ".feat";
00182
00183 inputFeaturesFileName = dataBaseName + ".feat";
00184 outputEDLFileName = dataBaseName + ".edl";
00185
00186 inputEDLFileName = dataBaseName + ".edl";
00187 String[] outputName = new String[2];
00188 outputName[0] = dataDirectory + slash + dataBaseName + ".MEAPED.wav";
00189 outputName[1] = dataBaseName + ".MEAPED.wav";
00190 SetOutputFileName(outputName);
00191 }
00192
00193 protected synchronized static void SetInputFileName(String[] names)
00194 {
00195 inputSoundFileNameFull = names[0];
00196 inputSoundFileNameShort = names[1];
00197 dataBaseName = inputSoundFileNameShort;
00198 meapsoftGUI.segmenterPanel.inputSoundFileField.setText(inputSoundFileNameShort);
00199 UpdateFileNames();
00200 meapsoftGUI.UpdateInfoTexts();
00201 }
00202
00203 protected static void SetOutputFileName(String[] names)
00204 {
00205 outputSoundFileNameFull = names[0];
00206 outputSoundFileNameShort = names[1];
00207 meapsoftGUI.synthPanel.outputFileNameField.setText(outputSoundFileNameShort);
00208 }
00209
00210 protected static void RefreshGUI()
00211 {
00212 meapsoftGUI.RefreshGUI();
00213 }
00214
00215 protected static void PlaySoundFile(String soundFile)
00216 {
00217 try
00218 {
00219 Process p = null;
00220 if(audioPlayerName != null)
00221 {
00222 String[] args = {audioPlayerName, soundFile};
00223
00224
00225
00226 if(System.getProperty("os.name").equals("Mac OS X")
00227 && new File(audioPlayerName).isDirectory())
00228 {
00229 String[] tmp = {"open", "-a", audioPlayerName, soundFile};
00230 args = tmp;
00231 }
00232
00233 p = Runtime.getRuntime().exec(args);
00234 }
00235 else
00236 GUIUtils.ShowDialog(
00237 "I don't know what program to use to play audio on your platform. Please check your preferences.",
00238 GUIUtils.MESSAGE, null);
00239 }
00240 catch (IOException e)
00241 {
00242 GUIUtils.ShowDialog(e, "Problem opening soundfile.", GUIUtils.MESSAGE, null);
00243 }
00244 }
00245
00246
00247 public void actionPerformed(ActionEvent arg0)
00248 {
00249 }
00250
00251 public void mouseClicked(MouseEvent arg0)
00252 {
00253 HelpWindow help = new HelpWindow(helpURL, title+" Help", color);
00254 }
00255
00256 public void mousePressed(MouseEvent arg0)
00257 {
00258 }
00259
00260 public void mouseReleased(MouseEvent arg0)
00261 {
00262 }
00263
00264 public void mouseEntered(MouseEvent arg0)
00265 {
00266 }
00267
00268 public void mouseExited(MouseEvent arg0)
00269 {
00270 }
00271 }