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.composers;
00024
00025 import gnu.getopt.Getopt;
00026
00027 import java.io.IOException;
00028 import java.util.Iterator;
00029 import java.util.Vector;
00030
00031 import com.meapsoft.EDLChunk;
00032 import com.meapsoft.EDLFile;
00033 import com.meapsoft.MEAPUtil;
00034 import com.meapsoft.ParserException;
00035
00042 public abstract class Composer extends MEAPUtil
00043 {
00044 public static String description = "I am a generic Composer.";
00045
00046 EDLFile outFile;
00047
00048 Vector commands = null;
00049
00056 public void setup() throws IOException, ParserException
00057 {
00058
00059 outFile.clearChunks();
00060 }
00061
00065 public abstract EDLFile compose();
00066
00067
00068
00069
00070 public void go()
00071 {
00072 try
00073 {
00074 setup();
00075 compose();
00076 addCommandsToAllEDLChunks();
00077 outFile.writeFile();
00078 }
00079 catch(Exception e)
00080 {
00081 e.printStackTrace();
00082 System.exit(1);
00083 }
00084 }
00085
00086
00090 public void addCommandToAllEDLChunks(String cmd)
00091 {
00092 if(outFile != null)
00093 {
00094 Iterator i = outFile.chunks.iterator();
00095 while(i.hasNext())
00096 {
00097 EDLChunk chunk = (EDLChunk)i.next();
00098
00099 if(chunk.commands != null)
00100 chunk.commands.add(cmd);
00101 }
00102 }
00103 }
00104
00108 public void addCommandsToAllEDLChunks(Vector cmds)
00109 {
00110 Iterator i = cmds.iterator();
00111 while(i.hasNext())
00112 addCommandToAllEDLChunks((String)i.next());
00113 }
00114
00115 public void addCommandsToAllEDLChunks()
00116 {
00117 if(commands != null)
00118 addCommandsToAllEDLChunks(commands);
00119 }
00120
00124 public void addCommand(String cmd)
00125 {
00126 if(commands == null)
00127 commands = new Vector();
00128
00129 commands.add(cmd);
00130 }
00131
00132 public static void printCommandLineOptions(char arg)
00133 {
00134 if(arg == 'c')
00135 {
00136 System.out.println(
00137 " -c command apply command to all chunks in the EDL output file\n" +
00138 " Supported commands include: reverse, crossfade(time), overlap(time) (time in seconds)" +
00139 "");
00140 }
00141 else
00142 MEAPUtil.printCommandLineOptions(arg);
00143 }
00144
00148 public void parseCommands(String[] args, String argString)
00149 {
00150 Getopt opt = new Getopt("Composer", args, argString);
00151 opt.setOpterr(false);
00152
00153 int c = -1;
00154 while ((c = opt.getopt()) != -1)
00155 {
00156 if(c == 'c')
00157 {
00158 if(commands == null)
00159 commands = new Vector();
00160
00161 commands.add(opt.getOptarg());
00162 }
00163 }
00164 }
00165 }