差分発生行の前後
無視リスト:
更新日時:
2010/05/11 20:15:55 (2 年 前)
更新者:
h
ログメッセージ:

refs #2 #8 #9 #7 #6
現状のソースをコミット。一部完了。一部未完了。
関連づいてない完了チケットのチェンジセットもまとめて。
パッケージ階層も大幅に変更。

パス:
trunk/src/org/rayflood/mikuvat/io/vsq
ファイル:
1 追加
1 移動

凡例:

変更なし
追加
削除
  • 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; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.io.vsq.VSQFile.COMMON; 
    54 
    65import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    78import java.util.ArrayList; 
    89import java.util.List; 
    910import java.util.Map; 
    1011 
    11 import javax.sound.midi.MetaMessage; 
    12 import javax.sound.midi.MidiEvent; 
    13  
    14 public class VSQTrack extends ImmutableObject{ 
     12import org.rayflood.mikuvat.io.BaseObject; 
     13import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     14 
     15public class VSQTrack extends BaseObject{ 
    1516        private static final long serialVersionUID = 6296614810415852578L; 
    16         private String trackName; 
    1717        private CommonSection common; 
    1818        private MixerSetting mixer; 
    1919        private TimeLine timeLine; 
    2020 
    21         public VSQTrack(MidiEvent trackName, MixerSetting mixer, Map<String, List<String>> sections){ 
     21        public VSQTrack(MixerSetting mixer, Map<String, List<String>> sections){ 
    2222                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); 
    2924        } 
    3025 
     
    3429        } 
    3530 
    36         public void setTrack(MidiEvent trackName, MixerSetting mixer, Map<String, List<String>> sections){ 
     31        public void setTrack(MixerSetting mixer, Map<String, List<String>> sections){ 
    3732                setMixer(mixer); 
    3833                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); 
    4634        } 
    4735 
     
    5341        public String toString(){ 
    5442                List<String> sl = new ArrayList<String>(); 
    55                 if(hasTrackName()){ 
    56                         sl.add("TrackName=" + getTrackName()); 
    57                 } 
    5843                if(hasCommon()){ 
    5944                        sl.add("Common={" + getCommon().toString() + "}"); 
     
    6651                } 
    6752 
    68                 StringBuffer sb = new StringBuffer(); 
     53                StringBuilder sb = new StringBuilder(); 
    6954                sb.append("VSQTrack={"); 
    7055                if(!sl.isEmpty()){ 
     
    7863        } 
    7964 
    80         public boolean isReadied(){ 
     65        public boolean validate() throws InvalidBaseObjectException{ 
    8166                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                } 
    8673                return ready; 
    8774        } 
    8875 
    89         public int compareTo(ImmutableObject obj){ 
     76        public int compareTo(BaseObject obj){ 
    9077                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){ 
    9582                VSQTrack vsqTrack = ((VSQTrack)obj).clone(); 
    9683                if(vsqTrack.hasCommon()){ 
     
    10592                        TimeLine timeLine = hasTimeLine() ? getTimeLine() : new TimeLine(); 
    10693                        setTimeLine(timeLine.over(vsqTrack.getTimeLine(), fill, has)); 
    107                 } 
    108                 if(vsqTrack.hasTrackName() && (fill || has == hasTrackName())){ 
    109                         setTrackName(vsqTrack.getTrackName()); 
    11094                } 
    11195                return this; 
     
    126110 
    127111        public VSQTrack delete(){ 
    128                 deleteTrackName(); 
    129112                deleteCommon(); 
    130113                deleteMixer(); 
     
    135118        public boolean isDeleted(){ 
    136119                boolean has = false; 
    137                 has |= hasTrackName(); 
    138120                has |= hasCommon(); 
    139121                has |= hasMixer(); 
     
    146128        } 
    147129 
    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  
    176130        public CommonSection getCommon(){ 
    177131                return common; 
     
    184138                } 
    185139                this.common = common; 
    186                 setTrackName(common.getName()); 
    187140        } 
    188141 
     
    239192        } 
    240193 
    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{ 
    250203                super.store(file); 
    251204        } 
    252205 
    253         public void store(File file) throws Exception{ 
     206        public void store(File file) throws FileNotFoundException, IOException{ 
    254207                super.store(file); 
    255208        } 
    256209 
    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{ 
    266219                super.zip(file); 
    267220        } 
    268221 
    269         public void zip(File file) throws Exception{ 
     222        public void zip(File file) throws IOException{ 
    270223                super.zip(file); 
    271224        }