- 更新日時:
- 2010/05/11 20:15:55 (2 年 前)
- パス:
- trunk/src/org/rayflood/mikuvat/io/vsq
- ファイル:
-
- 1 追加
- 1 移動
-
. (追加)
-
VSQTrack.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/VSQTrack.java) (11 diff)
凡例:
- 変更なし
- 追加
- 削除
-
trunk/src/org/rayflood/mikuvat/io/vsq/VSQTrack.java
r2 r4 1 package org.rayflood.mikuvat.io; 2 3 import static org.rayflood.mikuvat.io.VSQDecoder.WIN31J; 4 import static org.rayflood.mikuvat.io.VSQFile.COMMON; 1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.io.vsq.VSQFile.COMMON; 5 4 6 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 7 8 import java.util.ArrayList; 8 9 import java.util.List; 9 10 import java.util.Map; 10 11 11 import javax.sound.midi.MetaMessage;12 import javax.sound.midi.MidiEvent;13 14 public class VSQTrack extends ImmutableObject{12 import org.rayflood.mikuvat.io.BaseObject; 13 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 14 15 public class VSQTrack extends BaseObject{ 15 16 private static final long serialVersionUID = 6296614810415852578L; 16 private String trackName;17 17 private CommonSection common; 18 18 private MixerSetting mixer; 19 19 private TimeLine timeLine; 20 20 21 public VSQTrack(Mi diEvent trackName, MixerSetting mixer, Map<String, List<String>> sections){21 public VSQTrack(MixerSetting mixer, Map<String, List<String>> sections){ 22 22 this(); 23 setTrack(trackName, mixer, sections); 24 } 25 26 public VSQTrack(String trackName, MixerSetting mixer, Map<String, List<String>> sections){ 27 this(); 28 setTrack(trackName, mixer, sections); 23 setTrack(mixer, sections); 29 24 } 30 25 … … 34 29 } 35 30 36 public void setTrack(Mi diEvent trackName, MixerSetting mixer, Map<String, List<String>> sections){31 public void setTrack(MixerSetting mixer, Map<String, List<String>> sections){ 37 32 setMixer(mixer); 38 33 setTrack(sections); 39 setTrackName(trackName);40 }41 42 public void setTrack(String trackName, MixerSetting mixer, Map<String, List<String>> sections){43 setMixer(mixer);44 setTrack(sections);45 setTrackName(trackName);46 34 } 47 35 … … 53 41 public String toString(){ 54 42 List<String> sl = new ArrayList<String>(); 55 if(hasTrackName()){56 sl.add("TrackName=" + getTrackName());57 }58 43 if(hasCommon()){ 59 44 sl.add("Common={" + getCommon().toString() + "}"); … … 66 51 } 67 52 68 StringBu ffer sb = new StringBuffer();53 StringBuilder sb = new StringBuilder(); 69 54 sb.append("VSQTrack={"); 70 55 if(!sl.isEmpty()){ … … 78 63 } 79 64 80 public boolean isReadied(){65 public boolean validate() throws InvalidBaseObjectException{ 81 66 boolean ready = true; 82 ready &= hasTrackName(); 83 ready &= hasCommon() && getCommon().isReadied(); 84 ready &= hasMixer() && getMixer().isReadied(); 85 ready &= hasTimeLine() && getTimeLine().isReadied(); 67 ready &= hasCommon() && getCommon().validate(); 68 ready &= hasMixer() && getMixer().validate(); 69 ready &= hasTimeLine() && getTimeLine().validate(); 70 if(!ready){ 71 throw new InvalidBaseObjectException(this); 72 } 86 73 return ready; 87 74 } 88 75 89 public int compareTo( ImmutableObject obj){76 public int compareTo(BaseObject obj){ 90 77 VSQTrack vsqTrack = (VSQTrack)obj; 91 return compare( this.getTrackName(), vsqTrack.getTrackName());92 } 93 94 public VSQTrack over( Object obj, boolean fill, boolean has){78 return compare(getCommon().getName(), vsqTrack.getCommon().getName()); 79 } 80 81 public VSQTrack over(BaseObject obj, boolean fill, boolean has){ 95 82 VSQTrack vsqTrack = ((VSQTrack)obj).clone(); 96 83 if(vsqTrack.hasCommon()){ … … 105 92 TimeLine timeLine = hasTimeLine() ? getTimeLine() : new TimeLine(); 106 93 setTimeLine(timeLine.over(vsqTrack.getTimeLine(), fill, has)); 107 }108 if(vsqTrack.hasTrackName() && (fill || has == hasTrackName())){109 setTrackName(vsqTrack.getTrackName());110 94 } 111 95 return this; … … 126 110 127 111 public VSQTrack delete(){ 128 deleteTrackName();129 112 deleteCommon(); 130 113 deleteMixer(); … … 135 118 public boolean isDeleted(){ 136 119 boolean has = false; 137 has |= hasTrackName();138 120 has |= hasCommon(); 139 121 has |= hasMixer(); … … 146 128 } 147 129 148 public String getTrackName(){149 return trackName;150 }151 152 public MidiEvent getTrackNameME() throws Exception{153 byte mb[] = getTrackName().getBytes(WIN31J);154 MetaMessage mm = new MetaMessage();155 mm.setMessage(1, mb, mb.length);156 return new MidiEvent(mm, 0);157 }158 159 public void setTrackName(String trackName){160 this.trackName = trackName;161 }162 163 public void setTrackName(MidiEvent trackName){164 MetaMessage mm = (MetaMessage)trackName.getMessage();165 setTrackName(new String(mm.getData(), WIN31J));166 }167 168 public void deleteTrackName(){169 trackName = null;170 }171 172 public boolean hasTrackName(){173 return trackName != null;174 }175 176 130 public CommonSection getCommon(){ 177 131 return common; … … 184 138 } 185 139 this.common = common; 186 setTrackName(common.getName());187 140 } 188 141 … … 239 192 } 240 193 241 public static VSQTrack load(String file) throws Exception{242 return (VSQTrack) ImmutableObject.load(file);243 } 244 245 public static VSQTrack load(File file) throws Exception{246 return (VSQTrack) ImmutableObject.load(file);247 } 248 249 public void store(String file) throws Exception{194 public static VSQTrack load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 195 return (VSQTrack)BaseObject.load(file); 196 } 197 198 public static VSQTrack load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 199 return (VSQTrack)BaseObject.load(file); 200 } 201 202 public void store(String file) throws FileNotFoundException, IOException{ 250 203 super.store(file); 251 204 } 252 205 253 public void store(File file) throws Exception{206 public void store(File file) throws FileNotFoundException, IOException{ 254 207 super.store(file); 255 208 } 256 209 257 public static VSQTrack unzip(String file) throws Exception{258 return (VSQTrack) ImmutableObject.unzip(file);259 } 260 261 public static VSQTrack unzip(File file) throws Exception{262 return (VSQTrack) ImmutableObject.unzip(file);263 } 264 265 public void zip(String file) throws Exception{210 public static VSQTrack unzip(String file) throws IOException, ClassNotFoundException{ 211 return (VSQTrack)BaseObject.unzip(file); 212 } 213 214 public static VSQTrack unzip(File file) throws IOException, ClassNotFoundException{ 215 return (VSQTrack)BaseObject.unzip(file); 216 } 217 218 public void zip(String file) throws IOException{ 266 219 super.zip(file); 267 220 } 268 221 269 public void zip(File file) throws Exception{222 public void zip(File file) throws IOException{ 270 223 super.zip(file); 271 224 }
