チェンジセット 4
- 更新日時:
- 2010/05/11 20:15:55 (2 年 前)
- パス:
- trunk/src/org/rayflood/mikuvat
- ファイル:
-
- 4 追加
- 20 変更
- 24 移動
-
Mikuvat.java (変更) (4 diff)
-
Utilities.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/VSQDecoder.java) (3 diff)
-
gui/AnoteDialog.java (変更) (1 diff)
-
gui/AnotePanel.java (変更) (2 diff)
-
gui/BPLineDialog.java (変更) (1 diff)
-
gui/BPLinePanel.java (変更) (2 diff)
-
gui/MasterDialog.java (変更) (1 diff)
-
gui/MasterPanel.java (変更) (2 diff)
-
gui/MikuvatFrame.java (変更) (1 diff)
-
gui/ResoBPLineDialog.java (変更) (1 diff)
-
gui/ResoBPLinePanel.java (変更) (2 diff)
-
gui/TrackDialog.java (変更) (1 diff)
-
gui/TrackPanel.java (変更) (2 diff)
-
gui/VSQFileFilter.java (変更) (1 diff)
-
gui/VibratoBPTable.java (変更) (2 diff)
-
gui/VibratoDialog.java (変更) (1 diff)
-
gui/VibratoHandleButton.java (変更) (1 diff)
-
gui/VibratoHandleInput.java (変更) (1 diff)
-
gui/VibratoHandleLabel.java (変更) (1 diff)
-
gui/VibratoPanel.java (変更) (2 diff)
-
io/BaseObject.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/ImmutableObject.java) (7 diff)
-
io/InvalidBaseObjectException.java (追加)
-
io/midi (追加)
-
io/midi/MidiData.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MidiData.java) (4 diff)
-
io/midi/MidiFile.java (追加)
-
io/midi/MidiMeta.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MidiMeta.java) (7 diff)
-
io/midi/MidiShort.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MidiShort.java) (8 diff)
-
io/midi/MidiSysex.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MidiSysex.java) (7 diff)
-
io/midi/MidiTrack.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MidiTrack.java) (14 diff)
-
io/vsq (追加)
-
io/vsq/AnoteEvent.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/AnoteEvent.java) (6 diff)
-
io/vsq/CommonSection.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/CommonSection.java) (6 diff)
-
io/vsq/EOSEvent.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/EOSEvent.java) (4 diff)
-
io/vsq/Event.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/Event.java) (3 diff)
-
io/vsq/EventBPTime.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/EventBPTime.java) (5 diff)
-
io/vsq/IconHandle.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/IconHandle.java) (5 diff)
-
io/vsq/LyricHandle.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/LyricHandle.java) (4 diff)
-
io/vsq/LyricNote.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/LyricNote.java) (7 diff)
-
io/vsq/MasterSection.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MasterSection.java) (4 diff)
-
io/vsq/MixerSection.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MixerSection.java) (8 diff)
-
io/vsq/MixerSetting.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/MixerSetting.java) (6 diff)
-
io/vsq/SingerEvent.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/SingerEvent.java) (4 diff)
-
io/vsq/TimeLine.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/TimeLine.java) (6 diff)
-
io/vsq/VSQFile.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/VSQFile.java) (17 diff)
-
io/vsq/VSQTrack.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/VSQTrack.java) (11 diff)
-
io/vsq/VibratoBP.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/VibratoBP.java) (4 diff)
-
io/vsq/VibratoHandle.java (移動) (移動元: trunk/src/org/rayflood/mikuvat/io/VibratoHandle.java) (11 diff)
-
plugin/PluginLoader.java (変更) (3 diff)
凡例:
- 変更なし
- 追加
- 削除
-
trunk/src/org/rayflood/mikuvat/Mikuvat.java
r2 r4 12 12 import org.rayflood.mikuvat.plugin.PluginLoader; 13 13 14 /** 15 * ミクバット - VSQ Adjustment Tool 調整の難しいVSQパラメータを、ある程度オートで調整するツールです。 16 * 調整機能そのものはプラグインで実装されており、拡張可能です。 プラグインの機能については各プラグインのヘルプを参照してください。 17 * 18 * コマンド GUIツールを起動します。 java -jar mikuvat.jar このヘルプ画面を表示します。 java -jar mikuvat.jar 19 * --help プラグインのヘルプを表示します。 java -jar mikuvat.jar PLUGIN オプションを渡してプラグインを起動します。 20 * java -jar mikuvat.jar PLUGIN [OPTION]... 21 */ 14 22 public class Mikuvat{ 15 23 public static final String MIKUVAT_APPNAME = "ミクバット"; 16 public static final String MIKUVAT_VERSION = "0. 1";24 public static final String MIKUVAT_VERSION = "0.2"; 17 25 public static final String MIKUVAT_TITLE = MIKUVAT_APPNAME + " - ver " + MIKUVAT_VERSION; 18 26 … … 20 28 public static ImageIcon ICON; 21 29 30 /** 31 * @param args 32 * @throws Exception 33 */ 22 34 public static void main(String args[]) throws Exception{ 23 35 Mikuvat mikuvat = new Mikuvat(); … … 25 37 } 26 38 39 /** 40 * @param args 41 * @throws Exception 42 */ 27 43 public void start(String args[]) throws Exception{ 28 44 Map<String, PluginInstance> pluginInstance = PluginLoader.load(); … … 68 84 } 69 85 86 /** 87 * @param resource 88 */ 70 89 public static void printTextResource(String resource){ 71 90 System.out.println(getTextResource(resource)); 72 91 } 73 92 93 /** 94 * @param resource 95 * @return textResource 96 */ 74 97 public static String getTextResource(String resource){ 75 StringBu ffer sb = new StringBuffer();98 StringBuilder sb = new StringBuilder(); 76 99 try{ 77 100 BufferedReader br = new BufferedReader(new InputStreamReader( -
trunk/src/org/rayflood/mikuvat/Utilities.java
r2 r4 1 package org.rayflood.mikuvat .io;1 package org.rayflood.mikuvat; 2 2 3 import java.io.BufferedReader;4 import java.io.StringReader;5 3 import java.math.BigDecimal; 6 import java.nio.charset.Charset;7 4 import java.util.ArrayList; 8 import java.util.LinkedHashMap;9 5 import java.util.List; 10 import java.util.Map;11 6 import java.util.SortedMap; 12 7 import java.util.TreeMap; 13 8 import java.util.regex.Pattern; 14 9 15 import javax.sound.midi.MetaMessage; 16 import javax.sound.midi.MidiEvent; 17 import javax.sound.midi.MidiMessage; 18 import javax.sound.midi.Track; 10 import org.rayflood.mikuvat.io.vsq.VibratoBP; 19 11 20 public class VSQDecoder{12 public class Utilities{ 21 13 public static final Pattern SPLITEQUAL = Pattern.compile("="); 22 14 public static final Pattern SPLITCOMMA = Pattern.compile(","); 23 15 public static final Pattern SPLITDQUOTE = Pattern.compile("\\\""); 24 public static final Pattern MMHEADER = Pattern.compile("^DM:\\d+:$");25 public static final Pattern SECTIONLINE = Pattern.compile("^\\[.+\\]$");26 public static final Charset WIN31J = Charset.forName("Windows-31J");27 public static final int TEXTLENGTH = 119;28 16 29 17 public static String[] splitEqual(String s){ … … 86 74 87 75 public static String getByteArrayString(byte[] data){ 88 StringBu ffer sb = new StringBuffer();76 StringBuilder sb = new StringBuilder(); 89 77 if(data != null && data.length > 0){ 90 78 sb.append(String.format("%X", data[0])); … … 94 82 } 95 83 return sb.toString(); 96 }97 98 public static Map<String, List<String>> decode(Track tr) throws Exception{99 List<Byte> v = new ArrayList<Byte>();100 for(int i = 1; i < tr.size(); i++){101 MidiMessage m = tr.get(i).getMessage();102 if(m instanceof MetaMessage){103 byte b[] = ((MetaMessage)m).getData();104 if(b.length == 0){105 continue;106 }107 int h = 1;108 String mmheader;109 do{110 h++;111 mmheader = new String(b, 0, h * 4, WIN31J);112 }while(!MMHEADER.matcher(mmheader).matches());113 for(int k = h * 4; k < b.length; k++){114 if(b[k] != 0x00){115 v.add(new Byte(b[k]));116 }117 }118 }119 }120 byte b[] = new byte[v.size()];121 for(int i = 0; i < v.size(); i++){122 b[i] = v.get(i);123 }124 String textevent = new String(b, WIN31J);125 126 Map<String, List<String>> sections = new LinkedHashMap<String, List<String>>();127 BufferedReader br = new BufferedReader(new StringReader(textevent));128 String bf;129 String sn = "";130 List<String> sv = new ArrayList<String>();131 do{132 bf = br.readLine();133 if(bf == null || SECTIONLINE.matcher(bf).matches()){134 if(sn.length() > 0 && !sections.containsKey(sn)){135 sections.put(sn.substring(1, sn.length() - 1), sv);136 }137 sn = bf;138 sv = new ArrayList<String>();139 }140 else if(bf.length() > 0){141 sv.add(bf);142 }143 }while(bf != null);144 145 return sections;146 }147 148 public static List<MidiEvent> encode(List<String> trackSections) throws Exception{149 String te = "";150 for(int i = 0; i < trackSections.size(); i++){151 String vts = trackSections.get(i);152 te += vts + "\n";153 }154 155 List<MidiEvent> tme = new ArrayList<MidiEvent>();156 byte b[] = te.getBytes(WIN31J);157 for(int j = 0; j <= b.length / TEXTLENGTH; j++){158 int h = (int)StrictMath.ceil((double)Integer.toString(j).length() / 4.0);159 String mef = "DM:%0" + h * 4 + "d:";160 byte header[] = String.format(mef, j).getBytes(WIN31J);161 List<Byte> mbl = new ArrayList<Byte>();162 for(int k = 0; k < header.length; k++){163 mbl.add(header[k]);164 }165 for(int k = 0; k < TEXTLENGTH; k++){166 int bi = j * TEXTLENGTH + k;167 if(bi >= b.length){168 break;169 }170 mbl.add(b[bi]);171 }172 byte mb[] = new byte[mbl.size()];173 for(int k = 0; k < mbl.size(); k++){174 mb[k] = mbl.get(k);175 }176 MetaMessage mm = new MetaMessage();177 mm.setMessage(1, mb, mb.length);178 tme.add(new MidiEvent(mm, 0L));179 }180 181 return tme;182 84 } 183 85 -
trunk/src/org/rayflood/mikuvat/gui/AnoteDialog.java
r2 r4 5 5 import java.awt.Window; 6 6 7 import org.rayflood.mikuvat.io. AnoteEvent;8 import org.rayflood.mikuvat.io. LyricHandle;9 import org.rayflood.mikuvat.io. VibratoHandle;7 import org.rayflood.mikuvat.io.vsq.AnoteEvent; 8 import org.rayflood.mikuvat.io.vsq.LyricHandle; 9 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 10 10 11 11 public class AnoteDialog extends PropertyDialog{ -
trunk/src/org/rayflood/mikuvat/gui/AnotePanel.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat.io. AnoteEvent.ACCENT_MAX;4 import static org.rayflood.mikuvat.io. AnoteEvent.ACCENT_MIN;5 import static org.rayflood.mikuvat.io. AnoteEvent.BENDDEPTH_MAX;6 import static org.rayflood.mikuvat.io. AnoteEvent.BENDDEPTH_MIN;7 import static org.rayflood.mikuvat.io. AnoteEvent.BENDLENGTH_MAX;8 import static org.rayflood.mikuvat.io. AnoteEvent.BENDLENGTH_MIN;9 import static org.rayflood.mikuvat.io. AnoteEvent.DECAY_MAX;10 import static org.rayflood.mikuvat.io. AnoteEvent.DECAY_MIN;11 import static org.rayflood.mikuvat.io. AnoteEvent.NOTE_PARAMLIST;12 import static org.rayflood.mikuvat.io. AnoteEvent.PORTAMENTOUSE_PARAMLIST;13 import static org.rayflood.mikuvat.io. AnoteEvent.VELOCITY_MAX;14 import static org.rayflood.mikuvat.io. AnoteEvent.VELOCITY_MIN;3 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.ACCENT_MAX; 4 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.ACCENT_MIN; 5 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDDEPTH_MAX; 6 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDDEPTH_MIN; 7 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDLENGTH_MAX; 8 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDLENGTH_MIN; 9 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.DECAY_MAX; 10 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.DECAY_MIN; 11 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.NOTE_PARAMLIST; 12 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.PORTAMENTOUSE_PARAMLIST; 13 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.VELOCITY_MAX; 14 import static org.rayflood.mikuvat.io.vsq.AnoteEvent.VELOCITY_MIN; 15 15 16 16 import java.awt.BorderLayout; … … 26 26 import javax.swing.event.ChangeListener; 27 27 28 import org.rayflood.mikuvat.io. AnoteEvent;29 import org.rayflood.mikuvat.io. LyricHandle;30 import org.rayflood.mikuvat.io. LyricNote;31 import org.rayflood.mikuvat.io. VibratoHandle;28 import org.rayflood.mikuvat.io.vsq.AnoteEvent; 29 import org.rayflood.mikuvat.io.vsq.LyricHandle; 30 import org.rayflood.mikuvat.io.vsq.LyricNote; 31 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 32 32 33 33 public class AnotePanel extends PropertyPanel{ -
trunk/src/org/rayflood/mikuvat/gui/BPLineDialog.java
r2 r4 5 5 import java.awt.Window; 6 6 7 import org.rayflood.mikuvat.io. EventBPTime;7 import org.rayflood.mikuvat.io.vsq.EventBPTime; 8 8 9 9 public class BPLineDialog extends PropertyDialog{ -
trunk/src/org/rayflood/mikuvat/gui/BPLinePanel.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat.io. EventBPTime.BREATHINESS_MAX;4 import static org.rayflood.mikuvat.io. EventBPTime.BREATHINESS_MIN;5 import static org.rayflood.mikuvat.io. EventBPTime.BRIGHTNESS_MAX;6 import static org.rayflood.mikuvat.io. EventBPTime.BRIGHTNESS_MIN;7 import static org.rayflood.mikuvat.io. EventBPTime.CLEARNESS_MAX;8 import static org.rayflood.mikuvat.io. EventBPTime.CLEARNESS_MIN;9 import static org.rayflood.mikuvat.io. EventBPTime.DYNAMICS_MAX;10 import static org.rayflood.mikuvat.io. EventBPTime.DYNAMICS_MIN;11 import static org.rayflood.mikuvat.io. EventBPTime.GENDERFACTOR_MAX;12 import static org.rayflood.mikuvat.io. EventBPTime.GENDERFACTOR_MIN;13 import static org.rayflood.mikuvat.io. EventBPTime.OPENING_MAX;14 import static org.rayflood.mikuvat.io. EventBPTime.OPENING_MIN;15 import static org.rayflood.mikuvat.io. EventBPTime.PITCHBENDSENS_MAX;16 import static org.rayflood.mikuvat.io. EventBPTime.PITCHBENDSENS_MIN;17 import static org.rayflood.mikuvat.io. EventBPTime.PITCHBEND_MAX;18 import static org.rayflood.mikuvat.io. EventBPTime.PITCHBEND_MIN;19 import static org.rayflood.mikuvat.io. EventBPTime.PORTAMENTOTIMING_MAX;20 import static org.rayflood.mikuvat.io. EventBPTime.PORTAMENTOTIMING_MIN;3 import static org.rayflood.mikuvat.io.vsq.EventBPTime.BREATHINESS_MAX; 4 import static org.rayflood.mikuvat.io.vsq.EventBPTime.BREATHINESS_MIN; 5 import static org.rayflood.mikuvat.io.vsq.EventBPTime.BRIGHTNESS_MAX; 6 import static org.rayflood.mikuvat.io.vsq.EventBPTime.BRIGHTNESS_MIN; 7 import static org.rayflood.mikuvat.io.vsq.EventBPTime.CLEARNESS_MAX; 8 import static org.rayflood.mikuvat.io.vsq.EventBPTime.CLEARNESS_MIN; 9 import static org.rayflood.mikuvat.io.vsq.EventBPTime.DYNAMICS_MAX; 10 import static org.rayflood.mikuvat.io.vsq.EventBPTime.DYNAMICS_MIN; 11 import static org.rayflood.mikuvat.io.vsq.EventBPTime.GENDERFACTOR_MAX; 12 import static org.rayflood.mikuvat.io.vsq.EventBPTime.GENDERFACTOR_MIN; 13 import static org.rayflood.mikuvat.io.vsq.EventBPTime.OPENING_MAX; 14 import static org.rayflood.mikuvat.io.vsq.EventBPTime.OPENING_MIN; 15 import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBENDSENS_MAX; 16 import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBENDSENS_MIN; 17 import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBEND_MAX; 18 import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBEND_MIN; 19 import static org.rayflood.mikuvat.io.vsq.EventBPTime.PORTAMENTOTIMING_MAX; 20 import static org.rayflood.mikuvat.io.vsq.EventBPTime.PORTAMENTOTIMING_MIN; 21 21 22 22 import java.awt.BorderLayout; … … 26 26 import javax.swing.SpinnerNumberModel; 27 27 28 import org.rayflood.mikuvat.io. EventBPTime;28 import org.rayflood.mikuvat.io.vsq.EventBPTime; 29 29 30 30 public class BPLinePanel extends PropertyPanel{ -
trunk/src/org/rayflood/mikuvat/gui/MasterDialog.java
r2 r4 3 3 import java.awt.Window; 4 4 5 import org.rayflood.mikuvat.io. MasterSection;6 import org.rayflood.mikuvat.io. MixerSection;5 import org.rayflood.mikuvat.io.vsq.MasterSection; 6 import org.rayflood.mikuvat.io.vsq.MixerSection; 7 7 import static org.rayflood.mikuvat.gui.MasterPanel.*; 8 8 -
trunk/src/org/rayflood/mikuvat/gui/MasterPanel.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat.io. MasterSection.PREMEASURE_MAX;4 import static org.rayflood.mikuvat.io. MasterSection.PREMEASURE_MIN;5 import static org.rayflood.mikuvat.io. MixerSection.FEDER_MAX;6 import static org.rayflood.mikuvat.io. MixerSection.FEDER_MIN;7 import static org.rayflood.mikuvat.io. MixerSection.OUTPUTMODE_PARAMLIST;8 import static org.rayflood.mikuvat.io. MixerSection.PANPOT_MAX;9 import static org.rayflood.mikuvat.io. MixerSection.PANPOT_MIN;3 import static org.rayflood.mikuvat.io.vsq.MasterSection.PREMEASURE_MAX; 4 import static org.rayflood.mikuvat.io.vsq.MasterSection.PREMEASURE_MIN; 5 import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MAX; 6 import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MIN; 7 import static org.rayflood.mikuvat.io.vsq.MixerSection.OUTPUTMODE_PARAMLIST; 8 import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MAX; 9 import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MIN; 10 10 11 11 import java.awt.BorderLayout; … … 19 19 import javax.swing.SpinnerNumberModel; 20 20 21 import org.rayflood.mikuvat.io. MasterSection;22 import org.rayflood.mikuvat.io. MixerSection;23 import org.rayflood.mikuvat.io. MixerSetting;21 import org.rayflood.mikuvat.io.vsq.MasterSection; 22 import org.rayflood.mikuvat.io.vsq.MixerSection; 23 import org.rayflood.mikuvat.io.vsq.MixerSetting; 24 24 25 25 public class MasterPanel extends PropertyPanel{ -
trunk/src/org/rayflood/mikuvat/gui/MikuvatFrame.java
r2 r4 31 31 32 32 import org.rayflood.mikuvat.MikuvatProperties; 33 import org.rayflood.mikuvat.io. VSQFile;33 import org.rayflood.mikuvat.io.vsq.VSQFile; 34 34 import org.rayflood.mikuvat.plugin.PluginInstance; 35 35 import org.rayflood.mikuvat.plugin.PluginInterface; -
trunk/src/org/rayflood/mikuvat/gui/ResoBPLineDialog.java
r2 r4 5 5 import java.awt.Window; 6 6 7 import org.rayflood.mikuvat.io. EventBPTime;7 import org.rayflood.mikuvat.io.vsq.EventBPTime; 8 8 9 9 public class ResoBPLineDialog extends PropertyDialog{ -
trunk/src/org/rayflood/mikuvat/gui/ResoBPLinePanel.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat.io. EventBPTime.RESO1AMP_MAX;4 import static org.rayflood.mikuvat.io. EventBPTime.RESO1AMP_MIN;5 import static org.rayflood.mikuvat.io. EventBPTime.RESO1BW_MAX;6 import static org.rayflood.mikuvat.io. EventBPTime.RESO1BW_MIN;7 import static org.rayflood.mikuvat.io. EventBPTime.RESO1FREQ_MAX;8 import static org.rayflood.mikuvat.io. EventBPTime.RESO1FREQ_MIN;9 import static org.rayflood.mikuvat.io. EventBPTime.RESO2AMP_MAX;10 import static org.rayflood.mikuvat.io. EventBPTime.RESO2AMP_MIN;11 import static org.rayflood.mikuvat.io. EventBPTime.RESO2BW_MAX;12 import static org.rayflood.mikuvat.io. EventBPTime.RESO2BW_MIN;13 import static org.rayflood.mikuvat.io. EventBPTime.RESO2FREQ_MAX;14 import static org.rayflood.mikuvat.io. EventBPTime.RESO2FREQ_MIN;15 import static org.rayflood.mikuvat.io. EventBPTime.RESO3AMP_MAX;16 import static org.rayflood.mikuvat.io. EventBPTime.RESO3AMP_MIN;17 import static org.rayflood.mikuvat.io. EventBPTime.RESO3BW_MAX;18 import static org.rayflood.mikuvat.io. EventBPTime.RESO3BW_MIN;19 import static org.rayflood.mikuvat.io. EventBPTime.RESO3FREQ_MAX;20 import static org.rayflood.mikuvat.io. EventBPTime.RESO3FREQ_MIN;21 import static org.rayflood.mikuvat.io. EventBPTime.RESO4AMP_MAX;22 import static org.rayflood.mikuvat.io. EventBPTime.RESO4AMP_MIN;23 import static org.rayflood.mikuvat.io. EventBPTime.RESO4BW_MAX;24 import static org.rayflood.mikuvat.io. EventBPTime.RESO4BW_MIN;25 import static org.rayflood.mikuvat.io. EventBPTime.RESO4FREQ_MAX;26 import static org.rayflood.mikuvat.io. EventBPTime.RESO4FREQ_MIN;3 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1AMP_MAX; 4 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1AMP_MIN; 5 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1BW_MAX; 6 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1BW_MIN; 7 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1FREQ_MAX; 8 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1FREQ_MIN; 9 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2AMP_MAX; 10 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2AMP_MIN; 11 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2BW_MAX; 12 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2BW_MIN; 13 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2FREQ_MAX; 14 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2FREQ_MIN; 15 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3AMP_MAX; 16 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3AMP_MIN; 17 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3BW_MAX; 18 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3BW_MIN; 19 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3FREQ_MAX; 20 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3FREQ_MIN; 21 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4AMP_MAX; 22 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4AMP_MIN; 23 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4BW_MAX; 24 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4BW_MIN; 25 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4FREQ_MAX; 26 import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4FREQ_MIN; 27 27 28 28 import java.awt.BorderLayout; … … 32 32 import javax.swing.SpinnerNumberModel; 33 33 34 import org.rayflood.mikuvat.io. EventBPTime;34 import org.rayflood.mikuvat.io.vsq.EventBPTime; 35 35 36 36 public class ResoBPLinePanel extends PropertyPanel{ -
trunk/src/org/rayflood/mikuvat/gui/TrackDialog.java
r2 r4 6 6 import java.awt.Window; 7 7 8 import org.rayflood.mikuvat.io. CommonSection;9 import org.rayflood.mikuvat.io. MixerSetting;8 import org.rayflood.mikuvat.io.vsq.CommonSection; 9 import org.rayflood.mikuvat.io.vsq.MixerSetting; 10 10 11 11 public class TrackDialog extends PropertyDialog{ -
trunk/src/org/rayflood/mikuvat/gui/TrackPanel.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat.io. MixerSection.FEDER_MAX;4 import static org.rayflood.mikuvat.io. MixerSection.FEDER_MIN;5 import static org.rayflood.mikuvat.io. MixerSection.PANPOT_MAX;6 import static org.rayflood.mikuvat.io. MixerSection.PANPOT_MIN;3 import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MAX; 4 import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MIN; 5 import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MAX; 6 import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MIN; 7 7 8 8 import java.awt.BorderLayout; … … 16 16 import javax.swing.SpinnerNumberModel; 17 17 18 import org.rayflood.mikuvat.io. CommonSection;19 import org.rayflood.mikuvat.io. MixerSetting;18 import org.rayflood.mikuvat.io.vsq.CommonSection; 19 import org.rayflood.mikuvat.io.vsq.MixerSetting; 20 20 21 21 public class TrackPanel extends PropertyPanel{ -
trunk/src/org/rayflood/mikuvat/gui/VSQFileFilter.java
r2 r4 8 8 public boolean accept(File f){ 9 9 if(f != null){ 10 String name = f.getName(); 11 int per = name.lastIndexOf("."); 12 if(per > 0){ 13 String suffix = name.substring(per); 14 if(".vsq".equalsIgnoreCase(suffix)){ 15 return true; 16 } 17 if(".mid".equalsIgnoreCase(suffix)){ 18 return true; 10 if(f.isDirectory()){ 11 return true; 12 } 13 else if(f.isFile()){ 14 String name = f.getName(); 15 int per = name.lastIndexOf("."); 16 if(per > 0){ 17 String suffix = name.substring(per); 18 if(".vsq".equalsIgnoreCase(suffix)){ 19 return true; 20 } 21 if(".mid".equalsIgnoreCase(suffix)){ 22 return true; 23 } 19 24 } 20 25 } -
trunk/src/org/rayflood/mikuvat/gui/VibratoBPTable.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.getVibratoBPList;4 import static org.rayflood.mikuvat. io.VSQDecoder.getVibratoBPMap;5 import static org.rayflood.mikuvat.io. VibratoBP.Y_MAX;6 import static org.rayflood.mikuvat.io. VibratoBP.Y_MIN;3 import static org.rayflood.mikuvat.Utilities.getVibratoBPList; 4 import static org.rayflood.mikuvat.Utilities.getVibratoBPMap; 5 import static org.rayflood.mikuvat.io.vsq.VibratoBP.Y_MAX; 6 import static org.rayflood.mikuvat.io.vsq.VibratoBP.Y_MIN; 7 7 8 8 import java.awt.BorderLayout; … … 30 30 import javax.swing.table.DefaultTableModel; 31 31 32 import org.rayflood.mikuvat.io. VibratoBP;32 import org.rayflood.mikuvat.io.vsq.VibratoBP; 33 33 34 34 public class VibratoBPTable extends JPanel{ -
trunk/src/org/rayflood/mikuvat/gui/VibratoDialog.java
r2 r4 6 6 import java.util.List; 7 7 8 import org.rayflood.mikuvat.io. VibratoBP;9 import org.rayflood.mikuvat.io. VibratoHandle;8 import org.rayflood.mikuvat.io.vsq.VibratoBP; 9 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 10 10 11 11 public class VibratoDialog extends PropertyDialog{ -
trunk/src/org/rayflood/mikuvat/gui/VibratoHandleButton.java
r2 r4 8 8 import javax.swing.JOptionPane; 9 9 10 import org.rayflood.mikuvat.io. VibratoHandle;10 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 11 11 12 12 public class VibratoHandleButton extends JButton implements VibratoHandleInput{ -
trunk/src/org/rayflood/mikuvat/gui/VibratoHandleInput.java
r2 r4 3 3 import java.awt.Component; 4 4 5 import org.rayflood.mikuvat.io. VibratoHandle;5 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 6 6 7 7 public interface VibratoHandleInput{ -
trunk/src/org/rayflood/mikuvat/gui/VibratoHandleLabel.java
r2 r4 5 5 import javax.swing.JLabel; 6 6 7 import org.rayflood.mikuvat.io. VibratoHandle;7 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 8 8 9 9 public class VibratoHandleLabel extends JLabel implements VibratoHandleInput{ -
trunk/src/org/rayflood/mikuvat/gui/VibratoPanel.java
r2 r4 1 1 package org.rayflood.mikuvat.gui; 2 2 3 import static org.rayflood.mikuvat.io. VibratoHandle.CAPTION_PARAMLIST;4 import static org.rayflood.mikuvat.io. VibratoHandle.DEPTH_MAX;5 import static org.rayflood.mikuvat.io. VibratoHandle.DEPTH_MIN;6 import static org.rayflood.mikuvat.io. VibratoHandle.RATE_MAX;7 import static org.rayflood.mikuvat.io. VibratoHandle.RATE_MIN;3 import static org.rayflood.mikuvat.io.vsq.VibratoHandle.CAPTION_PARAMLIST; 4 import static org.rayflood.mikuvat.io.vsq.VibratoHandle.DEPTH_MAX; 5 import static org.rayflood.mikuvat.io.vsq.VibratoHandle.DEPTH_MIN; 6 import static org.rayflood.mikuvat.io.vsq.VibratoHandle.RATE_MAX; 7 import static org.rayflood.mikuvat.io.vsq.VibratoHandle.RATE_MIN; 8 8 9 9 import java.awt.BorderLayout; … … 18 18 import javax.swing.event.ChangeListener; 19 19 20 import org.rayflood.mikuvat.io. VibratoBP;21 import org.rayflood.mikuvat.io. VibratoHandle;20 import org.rayflood.mikuvat.io.vsq.VibratoBP; 21 import org.rayflood.mikuvat.io.vsq.VibratoHandle; 22 22 23 23 public class VibratoPanel extends PropertyPanel{ -
trunk/src/org/rayflood/mikuvat/io/BaseObject.java
r2 r4 9 9 import java.io.File; 10 10 import java.io.FileInputStream; 11 import java.io.FileNotFoundException; 11 12 import java.io.FileOutputStream; 13 import java.io.IOException; 12 14 import java.io.InputStream; 13 15 import java.io.ObjectInputStream; … … 21 23 import java.util.zip.ZipOutputStream; 22 24 23 public abstract class ImmutableObject implements Serializable, Cloneable, Comparable<ImmutableObject>{ 24 private static final long serialVersionUID = 768886758398033337L; 25 26 public abstract ImmutableObject setDefault(); 27 28 public abstract ImmutableObject delete(); 29 25 /** 26 * BaseObjectはデータを格納するオブジェクトのベースとなるクラスです。<br> 27 * 標準でSerializable, Cloneableを実装しており、派生クラスで定義しなくても使用可能です。<br> 28 * シリアライズによるインスタンスのファイル化もサポートしています。<br> 29 * <br> 30 * Serializableを実装するため、オブジェクト内のフィールドは全て直列化可能なオブジェクトを使ってください。<br> 31 * Comparableは派生クラスでオーバーライドしてください。<br> 32 * @see java.io.Serializable 33 * @see java.lang.Cloneable 34 * @see java.lang.Comparable 35 */ 36 public abstract class BaseObject implements Serializable, Cloneable, Comparable<BaseObject>{ 37 38 private static final long serialVersionUID = 5225438162616635387L; 39 40 /** 41 * このクラスのデフォルト値をセットします。<br> 42 * 通常は、デフォルト値がセットされたオブジェクトを返すgetDefault()メソッドも用意します。<br> 43 * <pre> 44 * public SomeObject extends BaseObject{ 45 * public static SomeObject getDefault(){ 46 * SomeObject someObject = new SomeObject(); 47 * someObject.setDefault(); 48 * return someObject; 49 * } 50 * } 51 * </pre> 52 * 派生クラスでそれぞれの内容にあったsetDefault()メソッドをオーバーライドしてください。<br> 53 * @return このクラスのデフォルト値がセットされたオブジェクト 54 */ 55 public abstract BaseObject setDefault(); 56 57 /** 58 * このオブジェクトの内容を完全に削除します。<br> 59 * <br> 60 * 派生クラスでそれぞれの内容にあったdelete()メソッドをオーバーライドしてください。<br> 61 * また、このメソッド実行後はisDeleted()メソッドがtrueになるようにしてください。<br> 62 * @see BaseObject#isDeleted() 63 * @return 内容が完全に削除されたこのオブジェクト 64 */ 65 public abstract BaseObject delete(); 66 67 /** 68 * オブジェクトの内容が論理的に正しいか調べます。<br> 69 * 通常は、オブジェクトをファイルに出力しても問題ないかのチェックに使います。<br> 70 * <br> 71 * 派生クラスでそれぞれの内容にあったvalidate()メソッドをオーバーライドしてください。<br> 72 * @return 内容が論理的に正しい場合はtrue、正しくない場合はfalse 73 */ 74 public abstract boolean validate() throws InvalidBaseObjectException; 75 76 /** 77 * オブジェクトの内容が完全に削除されているか調べます。<br> 78 * 通常は、オブジェクトをファイルに出力する際に、省いても良いかのチェックに使います。<br> 79 * <br> 80 * 派生クラスでそれぞれの内容にあったisDeleted()メソッドをオーバーライドしてください。<br> 81 * @see BaseObject#delete() 82 * @return 削除されている場合はtrue、されていない場合はfalse 83 */ 30 84 public abstract boolean isDeleted(); 31 85 32 public ImmutableObject cover(Object obj){ 86 /** 87 * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 88 * ただし、指定されたオブジェクトのうち、値が何も設定されていないフィールドは上書きしません。<br> 89 * <br> 90 * このメソッドは通常、over()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 91 * @param obj 上書きするオブジェクト 92 * @return 上書きされたこのオブジェクト 93 * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 94 */ 95 public BaseObject cover(BaseObject obj){ 33 96 return over(obj, true, false); 34 97 } 35 98 36 public ImmutableObject heap(Object obj){ 99 /** 100 * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 101 * 上書きする対象は、フィールドに<strong>何らかの値が設定されているもの</strong>のみです。値が設定されていないフィールドには上書きしません。<br> 102 * また、指定されたオブジェクトのうち、値が何も設定されていないフィールドは上書きしません。<br> 103 * <br> 104 * このメソッドは通常、over()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 105 * @param obj 上書きするオブジェクト 106 * @return 上書きされたこのオブジェクト 107 * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 108 */ 109 public BaseObject heap(BaseObject obj){ 37 110 return over(obj, false, true); 38 111 } 39 112 40 public ImmutableObject lay(Object obj){ 113 /** 114 * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 115 * 上書きする対象は、フィールドに<strong>何も値が設定されていないもの</strong>のみです。値が設定されているフィールドには上書きしません。<br> 116 * また、指定されたオブジェクトのうち、値が何も設定されていないフィールドは上書きしません。<br> 117 * <br> 118 * このメソッドは通常、over()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 119 * @param obj 上書きするオブジェクト 120 * @return 上書きされたこのオブジェクト 121 * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 122 */ 123 public BaseObject lay(BaseObject obj){ 41 124 return over(obj, false, false); 42 125 } 43 126 44 public abstract ImmutableObject over(Object obj, boolean fill, boolean has); 45 127 /** 128 * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 129 * ただし、指定されたオブジェクトのフィールドがnullの場合は上書きしません。<br> 130 * 派生クラスでそれぞれの内容にあったover()メソッドをオーバーライドしてください。<br> 131 * <pre> 132 * public SomeObject extends BaseObject{ 133 * String aString; 134 * public SomeObject over(Object obj, boolean fill, boolean has){ 135 * SomeObject someObject = ((SomeObject)obj).clone(); 136 * if(someObject.hasAString() && (fill || has == hasAString())){ 137 * setAString(someObject.getAString()); 138 * } 139 * return this; 140 * } 141 * } 142 * </pre> 143 * @see BaseObject#cover(BaseObject) 144 * @see BaseObject#heap(BaseObject) 145 * @see BaseObject#lay(BaseObject) 146 * @param obj 上書きするオブジェクト 147 * @param fill trueは、このオブジェクトのフィールドの状態に関係なく上書きする。 148 * @param has trueは、このオブジェクトのフィールドがnullではない場合に上書きする。falseはnullの場合に上書きする。 149 * @return 上書きされたこのオブジェクト 150 * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 151 */ 152 public abstract BaseObject over(BaseObject obj, boolean fill, boolean has); 153 154 /** 155 * オブジェクトの文字列表現を返します。<br> 156 * 通常、toString()メソッドはこのオブジェクトを「テキストで表現する」文字列を返します。<br> 157 * <br> 158 * 派生クラスでそれぞれの内容にあったtoString()メソッドをオーバーライドしてください。<br> 159 * @see java.lang.Object#toString() 160 */ 161 @Override 46 162 public abstract String toString(); 47 163 48 public abstract boolean isReadied(); 49 164 /** 165 * このオブジェクトと「等価」になるオブジェクトがあるかどうかを示します。<br> 166 * <br> 167 * このメソッドはお互いのオブジェクトをシリアライズしてバイト配列を取得し、そのバイト配列同士を比較します。<br> 168 * そのため、オブジェクト同士の、型を含めた完全一致チェックを行います。<br> 169 * @param obj 比較対象の参照オブジェクト 170 * @return 引数に指定されたオブジェクトとこのオブジェクトが等しい場合は true、そうでない場合は false 171 * @see java.lang.Object#equals(java.lang.Object) 172 * @see java.io.Serializable 173 */ 174 @Override 50 175 public boolean equals(Object obj){ 51 if(obj == null || ! (obj instanceof ImmutableObject) || !getClass().getName().equals(obj.getClass().getName())){176 if(obj == null || !getClass().getName().equals(obj.getClass().getName())){ 52 177 return false; 53 178 } 54 179 try{ 55 return Arrays.equals(encodeBytes(), (( ImmutableObject)obj).encodeBytes());180 return Arrays.equals(encodeBytes(), ((BaseObject)obj).encodeBytes()); 56 181 } 57 182 catch(Exception e){ … … 60 185 } 61 186 62 public abstract int compareTo(ImmutableObject obj); 63 187 /** 188 * このオブジェクトのコピーを作成して返します。<br> 189 * <br> 190 * 直列化してバイト配列を取得し、そのバイト配列から新たなインスタンスを作成するため、クラスに関係なく、常に「ディープコピー」が作成されます。<br> 191 * このメソッドの戻り値はObjectクラスになっており、アクセス権限もprotectedになっているため、使う場合は派生クラスでオーバーライドしてください。<br> 192 * <pre> 193 * public SomeObject extends BaseObject{ 194 * public SomeObject clone(){ 195 * return (SomeObject)super.clone(); 196 * } 197 * } 198 * </pre> 199 * @see BaseObject#encodeBytes() 200 * @see BaseObject#decodeBytes(byte[]) 201 * @return このインスタンスの複製 202 * @see java.lang.Object#clone() 203 * @see java.io.Serializable 204 */ 205 @Override 206 protected BaseObject clone(){ 207 try{ 208 return decodeBytes(encodeBytes()); 209 } 210 catch(Exception e){ 211 throw new RuntimeException(e); 212 } 213 } 214 215 /** 216 * このオブジェクトと指定されたオブジェクトの順序を比較します。<br> 217 * このオブジェクトが指定されたオブジェクトより小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数を返します。<br> 218 * <br> 219 * 派生クラスでそれぞれの内容にあったcompareTo()メソッドをオーバーライドしてください。<br> 220 * @see BaseObject#compare(Comparable, Comparable) 221 * @param obj 比較対象の Object 222 * @return このオブジェクトが指定されたオブジェクトより小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数 223 * @see java.lang.Comparable#compareTo(java.lang.Object) 224 */ 225 public abstract int compareTo(BaseObject obj); 226 227 /** 228 * 2つのオブジェクトの順序を比較します。<br> 229 * 一方のオブジェクトが他方のオブジェクトより小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数を返します。<br> 230 * <br> 231 * オブジェクトがnullだった場合は、nullの方が小さいと判定します。両方nullの場合は等しいと判定します。<br> 232 * 引数のオブジェクトはパラメータ化されていないため、オブジェクトの型が合わない場合はClassCastExceptionが発生します。<br> 233 * このメソッドは通常、compareTo()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 234 * @see BaseObject#compareTo(BaseObject) 235 * @param o1 一方のオブジェクト 236 * @param o2 他方のオブジェクト 237 * @return o1がo2より小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数 238 * @throws ClassCastException 指定されたオブジェクトの型が原因で、この Object と比較できない場合 239 */ 240 @SuppressWarnings("unchecked") 64 241 protected static int compare(Comparable o1, Comparable o2){ 65 242 if(o1 == null && o2 == null){ … … 75 252 } 76 253 77 public static Comparator<ImmutableObject> getComparator(){ 78 return new Comparator<ImmutableObject>(){ 79 public int compare(ImmutableObject o1, ImmutableObject o2){ 254 /** 255 * オブジェクトのコレクションで「全体順序付け」を行う比較関数です。<br> 256 * コンパレータ (Comparator) をソートメソッド (Collections.sort など) に渡すと、ソート順を正確に制御できます。<br> 257 * <br> 258 * このコンパレータはオブジェクトを「昇順」にソートします。比較はcompareTo()メソッドで行います。<br> 259 * compare()メソッドと同じく、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 260 * @see BaseObject#getComparatorR() 261 * @return 昇順コンパレータ 262 * @see java.util.Comparator 263 */ 264 public static Comparator<BaseObject> getComparator(){ 265 return new Comparator<BaseObject>(){ 266 public int compare(BaseObject o1, BaseObject o2){ 80 267 return o1.compareTo(o2); 81 268 } … … 83 270 } 84 271 85 public static Comparator<ImmutableObject> getComparatorR(){ 86 return new Comparator<ImmutableObject>(){ 87 public int compare(ImmutableObject o1, ImmutableObject o2){ 272 /** 273 * オブジェクトのコレクションで「全体順序付け」を行う比較関数です。<br> 274 * コンパレータ (Comparator) をソートメソッド (Collections.sort など) に渡すと、ソート順を正確に制御できます。<br> 275 * <br> 276 * このコンパレータはオブジェクトを「降順」にソートします。比較はcompareTo()メソッドの戻り値 * -1 です。<br> 277 * compare()メソッドと同じく、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 278 * @see BaseObject#getComparator() 279 * @return 降順コンパレータ 280 * @see java.util.Comparator 281 */ 282 public static Comparator<BaseObject> getComparatorR(){ 283 return new Comparator<BaseObject>(){ 284 public int compare(BaseObject o1, BaseObject o2){ 88 285 return o1.compareTo(o2) * -1; 89 286 } … … 91 288 } 92 289 93 protected Object clone(){ 94 try{ 95 return decodeBytes(encodeBytes()); 96 } 97 catch(Exception e){ 98 throw new RuntimeException(e); 99 } 100 } 101 102 private static Object decodeBytes(byte[] buf) throws Exception{ 103 return unserialize(new ByteArrayInputStream(buf)); 104 } 105 106 private static Object unserialize(InputStream in) throws Exception{ 107 ObjectInputStream ois = new ObjectInputStream(in); 108 return ois.readObject(); 109 } 110 111 private byte[] encodeBytes() throws Exception{ 290 /** 291 * このオブジェクトを直列化し、指定された出力ストリームに書き込みます。<br> 292 * 出力ストリームは自動的に閉じられるため、再利用できません。<br> 293 * @see BaseObject#unserialize(InputStream) 294 * @param out 出力ストリーム 295 * @throws IOException 296 */ 297 private void serialize(OutputStream out) throws IOException{ 298 ObjectOutputStream oos = null; 299 try{ 300 oos = new ObjectOutputStream(out); 301 oos.writeObject(this); 302 } 303 finally{ 304 if(oos != null){ 305 oos.close(); 306 } 307 else{ 308 out.close(); 309 } 310 } 311 } 312 313 /** 314 * 指定された入力ストリームからオブジェクトを読み込みます。<br> 315 * 入力ストリームは自動的に閉じられるため、再利用できません。<br> 316 * @see BaseObject#serialize(OutputStream) 317 * @param in 入力ストリーム 318 * @return 読み込まれたオブジェクト 319 * @throws IOException 320 * @throws ClassNotFoundException 321 */ 322 private static BaseObject unserialize(InputStream in) throws IOException, ClassNotFoundException{ 323 ObjectInputStream ois = null; 324 try{ 325 ois = new ObjectInputStream(in); 326 return (BaseObject)ois.readObject(); 327 } 328 finally{ 329 if(ois != null){ 330 ois.close(); 331 } 332 else{ 333 in.close(); 334 } 335 } 336 } 337 338 /** 339 * このオブジェクトを直列化し、バイト配列に変換します。<br> 340 * @see BaseObject#decodeBytes(byte[]) 341 * @return オブジェクトから直列化されたバイト配列 342 * @throws IOException 343 */ 344 protected byte[] encodeBytes() throws IOException{ 112 345 ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); 113 346 serialize(byteOut); … … 115 348 } 116 349 117 private void serialize(OutputStream out) throws Exception{ 118 ObjectOutputStream oos = new ObjectOutputStream(out); 119 oos.writeObject(this); 120 oos.close(); 121 } 122 123 protected static Object load(String file) throws Exception{ 350 /** 351 * オブジェクトを直列化したバイト配列を、元のオブジェクトに変換します。<br> 352 * @see BaseObject#encodeBytes() 353 * @param buf オブジェクトから変換されたバイト配列 354 * @return 読み込まれたオブジェクト 355 * @throws IOException 356 * @throws ClassNotFoundException 357 */ 358 protected static BaseObject decodeBytes(byte[] buf) throws IOException, ClassNotFoundException{ 359 return unserialize(new ByteArrayInputStream(buf)); 360 } 361 362 /** 363 * このオブジェクトを直列化し、指定された出力ファイルに書き込みます。<br> 364 * アクセス権限がprotectedになっているため、使う場合は派生クラスでオーバーライドしてください。<br> 365 * store(String)メソッド、zip(File)メソッド、zip(String)メソッドについても同様です。<br> 366 * <pre> 367 * public SomeObject extends BaseObject{ 368 * public void store(File file) throws FileNotFoundException, IOException{ 369 * super.store(File file); 370 * } 371 * } 372 * </pre> 373 * @see BaseObject#load(File) 374 * @param file 出力ファイル 375 * @throws FileNotFoundException 376 * @throws IOException 377 */ 378 protected void store(File file) throws FileNotFoundException, IOException{ 379 serialize(new BufferedOutputStream(new FileOutputStream(file))); 380 } 381 382 /** 383 * ファイル名をStringとして受ける以外はstore(File)と同じです。<br> 384 * @see BaseObject#store(File) 385 * @param file 出力ファイル 386 * @throws FileNotFoundException 387 * @throws IOException 388 */ 389 protected void store(String file) throws FileNotFoundException, IOException{ 390 store(new File(file)); 391 } 392 393 /** 394 * 入力ファイルからオブジェクトを読み込みます。<br> 395 * このメソッドの戻り値はObjectクラスになっており、アクセス権限もprotectedになっているため、使う場合は派生クラスでオーバーライドしてください。<br> 396 * load(String)メソッド、unzip(File)メソッド、unzip(String)メソッドについても同様です。<br> 397 * <pre> 398 * public SomeObject extends BaseObject{ 399 * public static SomeObject load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 400 * return (SomeObject)BaseObject.load(File file); 401 * } 402 * } 403 * </pre> 404 * @see BaseObject#store(File) 405 * @param file 入力ファイル 406 * @return 読み込まれたオブジェクト 407 * @throws FileNotFoundException 408 * @throws IOException 409 * @throws ClassNotFoundException 410 */ 411 protected static BaseObject load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 412 return unserialize(new BufferedInputStream(new FileInputStream(file))); 413 } 414 415 /** 416 * ファイル名をStringとして受ける以外はload(File)と同じです。<br> 417 * @see BaseObject#load(File) 418 * @throws FileNotFoundException 419 * @throws IOException 420 * @throws ClassNotFoundException 421 */ 422 protected static BaseObject load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 124 423 return load(new File(file)); 125 424 } 126 425 127 protected static Object load(File file) throws Exception{ 128 return unserialize(new BufferedInputStream(new FileInputStream(file))); 129 } 130 131 protected void store(String file) throws Exception{ 132 store(new File(file)); 133 } 134 135 protected void store(File file) throws Exception{ 136 serialize(new BufferedOutputStream(new FileOutputStream(file))); 137 } 138 139 protected static Object unzip(String file) throws Exception{ 140 return unzip(new File(file)); 141 } 142 143 protected static Object unzip(File file) throws Exception{ 144 ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file))); 145 zis.getNextEntry(); 146 return unserialize(zis); 147 } 148 149 protected void zip(String file) throws Exception{ 150 zip(new File(file)); 151 } 152 153 protected void zip(File file) throws Exception{ 154 ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file))); 155 zos.putNextEntry(new ZipEntry(getClass().getName())); 156 serialize(zos); 157 } 158 159 protected static Object decodeXML(String xml) throws Exception{ 426 /** 427 * このオブジェクトを直列化し、指定されたzipファイルに書き込みます。<br> 428 * zipエントリは1つだけで、クラス名がそのままエントリ名になります。<br> 429 * 派生クラスでの実装方法はstore(File)を参照してください。<br> 430 * @see BaseObject#store(File) 431 * @see BaseObject#unzip(File) 432 * @param zip zipファイル 433 * @throws IOException 434 */ 435 protected void zip(File zip) throws IOException{ 436 ZipOutputStream zos = null; 437 try{ 438 zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zip))); 439 zos.putNextEntry(new ZipEntry(getClass().getName())); 440 serialize(zos); 441 } 442 finally{ 443 if(zos != null){ 444 zos.close(); 445 } 446 } 447 } 448 449 /** 450 * ファイル名をStringとして受ける以外はzip(File)と同じです。<br> 451 * @see BaseObject#zip(File) 452 * @param zip zipファイル 453 * @throws IOException 454 */ 455 protected void zip(String zip) throws IOException{ 456 zip(new File(zip)); 457 } 458 459 /** 460 * zipファイルからオブジェクトを読み込みます。<br> 461 * 最初のエントリのみ読み込み、オブジェクトを返した後、zipファイルを閉じます。<br> 462 * エントリ名とクラス名が一致しているかはチェックしません。<br> 463 * 派生クラスでの実装方法はload(File)を参照してください。<br> 464 * @see BaseObject#load(File) 465 * @see BaseObject#zip(File) 466 * @param zip zipファイル 467 * @return 読み込まれたオブジェクト 468 * @throws IOException 469 * @throws ClassNotFoundException 470 */ 471 protected static BaseObject unzip(File zip) throws IOException, ClassNotFoundException{ 472 ZipInputStream zis = null; 473 try{ 474 zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zip))); 475 zis.getNextEntry(); 476 return unserialize(zis); 477 } 478 finally{ 479 if(zis != null){ 480 zis.close(); 481 } 482 } 483 } 484 485 /** 486 * ファイル名をStringとして受ける以外はunzip(File)と同じです。<br> 487 * @see BaseObject#unzip(File) 488 * @param zip zipファイル 489 * @return 読み込まれたオブジェクト 490 * @throws IOException 491 * @throws ClassNotFoundException 492 */ 493 protected static BaseObject unzip(String zip) throws IOException, ClassNotFoundException{ 494 return unzip(new File(zip)); 495 } 496 497 /** 498 * このオブジェクトのJavaBeanテキスト表現を生成し、指定された出力ストリームに書き込みます。<br> 499 * 出力ストリームは自動的に閉じられるため、再利用できません。<br> 500 * @see BaseObject#decodeXML(InputStream) 501 * @param out 出力ストリーム 502 * @throws IOException 503 * @see java.beans.XMLEncoder 504 */ 505 private void encodeXML(OutputStream out) throws IOException{ 506 XMLEncoder e = null; 507 try{ 508 e = new XMLEncoder(out); 509 e.writeObject(this); 510 } 511 finally{ 512 if(e != null){ 513 e.close(); 514 } 515 else{ 516 out.close(); 517 } 518 } 519 } 520 521 /** 522 * 指定された入力ストリームからJavaBeanテキスト表現を取得し、オブジェクトを読み込みます。<br> 523 * 入力ストリームは自動的に閉じられるため、再利用できません。<br> 524 * @see BaseObject#encodeXML(OutputStream) 525 * @param in 入力ストリーム 526 * @return 読み込まれたオブジェクト 527 * @throws IOException 528 * @see java.beans.XMLDecoder 529 */ 530 private static BaseObject decodeXML(InputStream in) throws IOException{ 531 XMLDecoder d = null; 532 try{ 533 d = new XMLDecoder(in); 534 BaseObject result = (BaseObject)d.readObject(); 535 return result; 536 } 537 finally{ 538 if(d != null){ 539 d.close(); 540 } 541 else{ 542 in.close(); 543 } 544 } 545 } 546 547 /** 548 * XMLEncoderを使って、オブジェクトをxmlファイルに書き込みます。<br> 549 * <br> 550 * ※注:このメソッドはオブジェクトがJavaBeanの仕様に準じる必要があるため、必ずしもstore(File)メソッド、zip(File)メソッドの代替にはなり得ません。<br> 551 * 例えばBigDecimalはXMLEncoderで保存することが出来ません。<br> 552 * 詳細については、『The Swing Connection』の記事「<a target="_blank" href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>」を参照してください。<br> 553 * @see BaseObject#decodeXML(File) 554 * @param xml xmlファイル 555 * @throws FileNotFoundException 556 * @throws IOException 557 * @see java.beans.XMLEncoder 558 */ 559 protected void encodeXML(File xml) throws FileNotFoundException, IOException{ 560 encodeXML(new BufferedOutputStream(new FileOutputStream(xml))); 561 } 562 563 /** 564 * ファイル名をStringとして受ける以外はencodeXML(File)と同じです。<br> 565 * @see BaseObject#encodeXML(File) 566 * @param xml xmlファイル 567 * @throws FileNotFoundException 568 * @throws IOException 569 */ 570 protected void encodeXML(String xml) throws FileNotFoundException, IOException{ 571 encodeXML(new File(xml)); 572 } 573 574 /** 575 * XMLDecoderを使って、xmlファイルからオブジェクトを読み込みます。<br> 576 * <br> 577 * ※注:このメソッドはオブジェクトがJavaBeanの仕様に準じる必要があるため、必ずしもload(File)メソッド、unzip(File)メソッドの代替にはなり得ません。<br> 578 * 例えばBigDecimalはXMLEncoderで保存することが出来ません。<br> 579 * 詳細については、『The Swing Connection』の記事「<a target="_blank" href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>」を参照してください。<br> 580 * @see BaseObject#encodeXML(File) 581 * @param xml xmlファイル 582 * @return 読み込まれたオブジェクト 583 * @throws FileNotFoundException 584 * @throws IOException 585 * @see java.beans.XMLDecoder 586 */ 587 protected static BaseObject decodeXML(File xml) throws FileNotFoundException, IOException{ 588 return decodeXML(new BufferedInputStream(new FileInputStream(xml))); 589 } 590 591 /** 592 * ファイル名をStringとして受ける以外はdecodeXML(File)と同じです。<br> 593 * @see BaseObject#decodeXML(File) 594 * @param xml xmlファイル 595 * @return 読み込まれたオブジェクト 596 * @throws FileNotFoundException 597 * @throws IOException 598 */ 599 protected static BaseObject decodeXML(String xml) throws FileNotFoundException, IOException{ 160 600 return decodeXML(new File(xml)); 161 601 } 162 163 protected static Object decodeXML(File xml) throws Exception{164 XMLDecoder d = new XMLDecoder(new BufferedInputStream(new FileInputStream(xml)));165 Object result = d.readObject();166 d.close();167 return result;168 }169 170 protected void encodeXML(String xml) throws Exception{171 encodeXML(new File(xml));172 }173 174 protected void encodeXML(File xml) throws Exception{175 XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(xml)));176 e.writeObject(this);177 e.close();178 }179 602 } -
trunk/src/org/rayflood/mikuvat/io/midi/MidiData.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.midi; 2 2 3 3 import java.io.File; 4 import java.io.FileNotFoundException; 5 import java.io.IOException; 4 6 7 import javax.sound.midi.InvalidMidiDataException; 5 8 import javax.sound.midi.MetaMessage; 6 9 import javax.sound.midi.MidiMessage; … … 8 11 import javax.sound.midi.SysexMessage; 9 12 10 public abstract class MidiData extends ImmutableObject{ 13 import org.rayflood.mikuvat.io.BaseObject; 14 15 public abstract class MidiData extends BaseObject{ 11 16 private static final long serialVersionUID = 2907770619042609302L; 12 17 13 public int compareTo( ImmutableObject obj){18 public int compareTo(BaseObject obj){ 14 19 MidiData midiData = (MidiData)obj; 15 20 return compare(getClass().getName(), midiData.getClass().getName()); … … 30 35 } 31 36 32 public abstract MidiMessage getMidiEvent() throws Exception;37 public abstract MidiMessage getMidiEvent() throws InvalidMidiDataException; 33 38 34 p ublicabstract void setMidiEvent(MidiMessage mm);39 protected abstract void setMidiEvent(MidiMessage mm); 35 40 36 41 public MidiData clone(){ … … 38 43 } 39 44 40 public static MidiData load(String file) throws Exception{41 return (MidiData) ImmutableObject.load(file);45 public static MidiData load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 46 return (MidiData)BaseObject.load(file); 42 47 } 43 48 44 public static MidiData load(File file) throws Exception{45 return (MidiData) ImmutableObject.load(file);49 public static MidiData load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 50 return (MidiData)BaseObject.load(file); 46 51 } 47 52 48 public void store(String file) throws Exception{53 public void store(String file) throws FileNotFoundException, IOException { 49 54 super.store(file); 50 55 } 51 56 52 public void store(File file) throws Exception{57 public void store(File file) throws FileNotFoundException, IOException{ 53 58 super.store(file); 54 59 } 55 60 56 public static MidiData unzip(String file) throws Exception{57 return (MidiData) ImmutableObject.unzip(file);61 public static MidiData unzip(String file) throws IOException, ClassNotFoundException{ 62 return (MidiData)BaseObject.unzip(file); 58 63 } 59 64 60 public static MidiData unzip(File file) throws Exception{61 return (MidiData) ImmutableObject.unzip(file);65 public static MidiData unzip(File file) throws IOException, ClassNotFoundException{ 66 return (MidiData)BaseObject.unzip(file); 62 67 } 63 68 64 public void zip(String file) throws Exception{69 public void zip(String file) throws IOException{ 65 70 super.zip(file); 66 71 } 67 72 68 public void zip(File file) throws Exception{73 public void zip(File file) throws IOException{ 69 74 super.zip(file); 70 75 } -
trunk/src/org/rayflood/mikuvat/io/midi/MidiMeta.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.midi; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.getByteArrayString;3 import static org.rayflood.mikuvat.Utilities.getByteArrayString; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 11 import javax.sound.midi.InvalidMidiDataException; 9 12 import javax.sound.midi.MetaMessage; 10 13 import javax.sound.midi.MidiMessage; 14 15 import org.rayflood.mikuvat.io.BaseObject; 11 16 12 17 public class MidiMeta extends MidiData{ … … 15 20 private byte[] data; 16 21 17 p ublicMidiMeta(MidiMessage mm){22 protected MidiMeta(MidiMessage mm){ 18 23 setMidiEvent(mm); 24 } 25 26 public MidiMeta(MetaMessage meta){ 27 setMidiEvent(meta); 19 28 } 20 29 … … 24 33 } 25 34 26 public MetaMessage getMidiEvent() throws Exception{35 public MetaMessage getMidiEvent() throws InvalidMidiDataException{ 27 36 MetaMessage meta = new MetaMessage(); 28 37 meta.setMessage(getType(), getData(), getData().length); … … 30 39 } 31 40 32 public void setMidiEvent(MidiMessage mm){ 33 MetaMessage meta = (MetaMessage)mm; 41 protected void setMidiEvent(MidiMessage mm){ 42 setMidiEvent((MetaMessage)mm); 43 } 44 45 public void setMidiEvent(MetaMessage meta){ 34 46 setType(meta.getType()); 35 47 setData(meta.getData()); … … 41 53 sl.add("Data=" + getByteArrayString(getData())); 42 54 43 StringBu ffer sb = new StringBuffer();55 StringBuilder sb = new StringBuilder(); 44 56 sb.append("MidiMeta={"); 45 57 if(!sl.isEmpty()){ … … 53 65 } 54 66 55 public boolean isReadied(){67 public boolean validate(){ 56 68 return true; 57 69 } 58 70 59 public int compareTo( ImmutableObject obj){71 public int compareTo(BaseObject obj){ 60 72 MidiMeta midiMeta = (MidiMeta)obj; 61 73 return compare(getType(), midiMeta.getType()); 62 74 } 63 75 64 public MidiMeta over( Object obj, boolean fill, boolean has){76 public MidiMeta over(BaseObject obj, boolean fill, boolean has){ 65 77 MidiMeta midiMeta = ((MidiMeta)obj).clone(); 66 78 setType(midiMeta.getType()); … … 112 124 } 113 125 114 public static MidiMeta load(String file) throws Exception{115 return (MidiMeta) ImmutableObject.load(file);126 public static MidiMeta load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 127 return (MidiMeta)BaseObject.load(file); 116 128 } 117 129 118 public static MidiMeta load(File file) throws Exception{119 return (MidiMeta) ImmutableObject.load(file);130 public static MidiMeta load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 131 return (MidiMeta)BaseObject.load(file); 120 132 } 121 133 122 public void store(String file) throws Exception{134 public void store(String file) throws FileNotFoundException, IOException{ 123 135 super.store(file); 124 136 } 125 137 126 public void store(File file) throws Exception{138 public void store(File file) throws FileNotFoundException, IOException{ 127 139 super.store(file); 128 140 } 129 141 130 public static MidiMeta unzip(String file) throws Exception{131 return (MidiMeta) ImmutableObject.unzip(file);142 public static MidiMeta unzip(String file) throws IOException, ClassNotFoundException{ 143 return (MidiMeta)BaseObject.unzip(file); 132 144 } 133 145 134 public static MidiMeta unzip(File file) throws Exception{135 return (MidiMeta) ImmutableObject.unzip(file);146 public static MidiMeta unzip(File file) throws IOException, ClassNotFoundException{ 147 return (MidiMeta)BaseObject.unzip(file); 136 148 } 137 149 138 public void zip(String file) throws Exception{150 public void zip(String file) throws IOException{ 139 151 super.zip(file); 140 152 } 141 153 142 public void zip(File file) throws Exception{154 public void zip(File file) throws IOException{ 143 155 super.zip(file); 144 156 } -
trunk/src/org/rayflood/mikuvat/io/midi/MidiShort.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.midi; 2 2 3 3 import java.io.File; 4 import java.io.FileNotFoundException; 5 import java.io.IOException; 4 6 import java.util.ArrayList; 5 7 import java.util.List; 6 8 9 import javax.sound.midi.InvalidMidiDataException; 7 10 import javax.sound.midi.MidiMessage; 8 11 import javax.sound.midi.ShortMessage; 12 13 import org.rayflood.mikuvat.io.BaseObject; 9 14 10 15 public class MidiShort extends MidiData{ … … 15 20 private int data2; 16 21 17 p ublicMidiShort(MidiMessage mm){22 protected MidiShort(MidiMessage mm){ 18 23 setMidiEvent(mm); 24 } 25 26 public MidiShort(ShortMessage shortm){ 27 setMidiEvent(shortm); 19 28 } 20 29 … … 26 35 } 27 36 28 public ShortMessage getMidiEvent() throws Exception{37 public ShortMessage getMidiEvent() throws InvalidMidiDataException{ 29 38 ShortMessage message = new ShortMessage(); 30 39 message.setMessage(getCommand(), getChannel(), getData1(), getData2()); … … 32 41 } 33 42 34 public void setMidiEvent(MidiMessage mm){ 35 ShortMessage message = (ShortMessage)mm; 36 setCommand(message.getCommand()); 37 setChannel(message.getChannel()); 38 setData1(message.getData1()); 39 setData2(message.getData2()); 43 protected void setMidiEvent(MidiMessage mm){ 44 setMidiEvent((ShortMessage)mm); 45 } 46 47 public void setMidiEvent(ShortMessage shortm){ 48 setCommand(shortm.getCommand()); 49 setChannel(shortm.getChannel()); 50 setData1(shortm.getData1()); 51 setData2(shortm.getData2()); 40 52 } 41 53 … … 47 59 sl.add("Data2=" + getData2()); 48 60 49 StringBu ffer sb = new StringBuffer();61 StringBuilder sb = new StringBuilder(); 50 62 sb.append("MidiShort={"); 51 63 if(!sl.isEmpty()){ … … 59 71 } 60 72 61 public boolean isReadied(){73 public boolean validate(){ 62 74 return true; 63 75 } 64 76 65 public int compareTo( ImmutableObject obj){77 public int compareTo(BaseObject obj){ 66 78 MidiShort midiShort = (MidiShort)obj; 67 79 int c = compare(this.getCommand(), midiShort.getCommand()); … … 72 84 } 73 85 74 public MidiShort over( Object obj, boolean fill, boolean has){86 public MidiShort over(BaseObject obj, boolean fill, boolean has){ 75 87 MidiShort midiShort = ((MidiShort)obj).clone(); 76 88 setCommand(midiShort.getCommand()); … … 142 154 } 143 155 144 public static MidiShort load(String file) throws Exception{145 return (MidiShort) ImmutableObject.load(file);156 public static MidiShort load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 157 return (MidiShort)BaseObject.load(file); 146 158 } 147 159 148 public static MidiShort load(File file) throws Exception{149 return (MidiShort) ImmutableObject.load(file);160 public static MidiShort load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 161 return (MidiShort)BaseObject.load(file); 150 162 } 151 163 152 public void store(String file) throws Exception{164 public void store(String file) throws FileNotFoundException, IOException{ 153 165 super.store(file); 154 166 } 155 167 156 public void store(File file) throws Exception{168 public void store(File file) throws FileNotFoundException, IOException{ 157 169 super.store(file); 158 170 } 159 171 160 public static MidiShort unzip(String file) throws Exception{161 return (MidiShort) ImmutableObject.unzip(file);172 public static MidiShort unzip(String file) throws IOException, ClassNotFoundException{ 173 return (MidiShort)BaseObject.unzip(file); 162 174 } 163 175 164 public static MidiShort unzip(File file) throws Exception{165 return (MidiShort) ImmutableObject.unzip(file);176 public static MidiShort unzip(File file) throws IOException, ClassNotFoundException{ 177 return (MidiShort)BaseObject.unzip(file); 166 178 } 167 179 168 public void zip(String file) throws Exception{180 public void zip(String file) throws IOException{ 169 181 super.zip(file); 170 182 } 171 183 172 public void zip(File file) throws Exception{184 public void zip(File file) throws IOException{ 173 185 super.zip(file); 174 186 } -
trunk/src/org/rayflood/mikuvat/io/midi/MidiSysex.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.midi; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.getByteArrayString;3 import static org.rayflood.mikuvat.Utilities.getByteArrayString; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 11 import javax.sound.midi.InvalidMidiDataException; 9 12 import javax.sound.midi.MidiMessage; 10 13 import javax.sound.midi.SysexMessage; 14 15 import org.rayflood.mikuvat.io.BaseObject; 11 16 12 17 public class MidiSysex extends MidiData{ … … 15 20 private byte[] data; 16 21 17 p ublicMidiSysex(MidiMessage mm){22 protected MidiSysex(MidiMessage mm){ 18 23 setMidiEvent(mm); 24 } 25 26 public MidiSysex(SysexMessage sysex){ 27 setMidiEvent(sysex); 19 28 } 20 29 … … 24 33 } 25 34 26 public SysexMessage getMidiEvent() throws Exception{35 public SysexMessage getMidiEvent() throws InvalidMidiDataException{ 27 36 SysexMessage sysex = new SysexMessage(); 28 37 sysex.setMessage(getStatus(), getData(), getData().length); … … 30 39 } 31 40 32 public void setMidiEvent(MidiMessage mm){ 33 SysexMessage sysex = (SysexMessage)mm; 41 protected void setMidiEvent(MidiMessage mm){ 42 setMidiEvent((SysexMessage)mm); 43 } 44 45 public void setMidiEvent(SysexMessage sysex){ 34 46 setStatus(sysex.getStatus()); 35 47 setData(sysex.getData()); … … 41 53 sl.add("Data=" + getByteArrayString(getData())); 42 54 43 StringBu ffer sb = new StringBuffer();55 StringBuilder sb = new StringBuilder(); 44 56 sb.append("MidiSysex={"); 45 57 if(!sl.isEmpty()){ … … 53 65 } 54 66 55 public boolean isReadied(){67 public boolean validate(){ 56 68 return true; 57 69 } 58 70 59 public int compareTo( ImmutableObject obj){71 public int compareTo(BaseObject obj){ 60 72 MidiSysex midiSysex = (MidiSysex)obj; 61 73 return compare(getStatus(), midiSysex.getStatus()); 62 74 } 63 75 64 public MidiSysex over( Object obj, boolean fill, boolean has){76 public MidiSysex over(BaseObject obj, boolean fill, boolean has){ 65 77 MidiSysex midiSysex = ((MidiSysex)obj).clone(); 66 78 setStatus(midiSysex.getStatus()); … … 112 124 } 113 125 114 public static MidiSysex load(String file) throws Exception{115 return (MidiSysex) ImmutableObject.load(file);126 public static MidiSysex load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 127 return (MidiSysex)BaseObject.load(file); 116 128 } 117 129 118 public static MidiSysex load(File file) throws Exception{119 return (MidiSysex) ImmutableObject.load(file);130 public static MidiSysex load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 131 return (MidiSysex)BaseObject.load(file); 120 132 } 121 133 122 public void store(String file) throws Exception{134 public void store(String file) throws FileNotFoundException, IOException{ 123 135 super.store(file); 124 136 } 125 137 126 public void store(File file) throws Exception{138 public void store(File file) throws FileNotFoundException, IOException{ 127 139 super.store(file); 128 140 } 129 141 130 public static MidiSysex unzip(String file) throws Exception{131 return (MidiSysex) ImmutableObject.unzip(file);142 public static MidiSysex unzip(String file) throws IOException, ClassNotFoundException{ 143 return (MidiSysex)BaseObject.unzip(file); 132 144 } 133 145 134 public static MidiSysex unzip(File file) throws Exception{135 return (MidiSysex) ImmutableObject.unzip(file);146 public static MidiSysex unzip(File file) throws IOException, ClassNotFoundException{ 147 return (MidiSysex)BaseObject.unzip(file); 136 148 } 137 149 138 public void zip(String file) throws Exception{150 public void zip(String file) throws IOException{ 139 151 super.zip(file); 140 152 } 141 153 142 public void zip(File file) throws Exception{154 public void zip(File file) throws IOException{ 143 155 super.zip(file); 144 156 } -
trunk/src/org/rayflood/mikuvat/io/midi/MidiTrack.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.midi; 2 2 3 3 import java.io.File; 4 import java.io.FileNotFoundException; 5 import java.io.IOException; 4 6 import java.util.ArrayList; 5 7 import java.util.List; 6 8 import java.util.TreeMap; 7 9 10 import javax.sound.midi.InvalidMidiDataException; 8 11 import javax.sound.midi.MidiEvent; 9 12 import javax.sound.midi.MidiMessage; 10 13 import javax.sound.midi.Track; 11 14 12 public class MidiTrack extends ImmutableObject{ 15 import org.rayflood.mikuvat.io.BaseObject; 16 17 public class MidiTrack extends BaseObject{ 13 18 private static final long serialVersionUID = -1866741348212885469L; 14 19 private TreeMap<Long, ArrayList<MidiData>> trackdata; … … 19 24 } 20 25 21 public ArrayList<MidiEvent> getMidiEvent(long tick) throws Exception{22 ArrayList<MidiData> list = getMidiData(tick);23 ArrayList<MidiEvent> mes = new ArrayList<MidiEvent>();26 public List<MidiEvent> getMidiEvent(long tick) throws InvalidMidiDataException { 27 List<MidiData> list = getMidiData(tick); 28 List<MidiEvent> mes = new ArrayList<MidiEvent>(); 24 29 for(int i = 0; i < list.size(); i++){ 25 30 mes.add(new MidiEvent(list.get(i).getMidiEvent(), tick)); … … 28 33 } 29 34 30 public ArrayList<MidiMessage> getMidiMessage(long tick) throwsException{31 ArrayList<MidiData> list = getMidiData(tick);32 ArrayList<MidiMessage> mms = new ArrayList<MidiMessage>();35 public List<MidiMessage> getMidiMessage(long tick) throws InvalidMidiDataException{ 36 List<MidiData> list = getMidiData(tick); 37 List<MidiMessage> mms = new ArrayList<MidiMessage>(); 33 38 for(int i = 0; i < list.size(); i++){ 34 39 mms.add(list.get(i).getMidiEvent()); … … 37 42 } 38 43 39 public ArrayList<MidiData> getMidiData(long tick){44 public List<MidiData> getMidiData(long tick){ 40 45 return hasMidiData(tick) ? trackdata.get(tick) : new ArrayList<MidiData>(); 41 46 } … … 50 55 51 56 public void addMidiData(long tick, MidiData midiData){ 52 ArrayList<MidiData> list = getMidiData(tick);57 ArrayList<MidiData> list = new ArrayList<MidiData>(getMidiData(tick)); 53 58 list.add(midiData); 54 59 trackdata.put(tick, list); 55 60 } 56 61 57 public void setMidiMessage(long tick, ArrayList<MidiMessage> messages){58 ArrayList<MidiData> list = new ArrayList<MidiData>();62 public void setMidiMessage(long tick, List<MidiMessage> messages){ 63 List<MidiData> list = new ArrayList<MidiData>(); 59 64 for(int i = 0; i < messages.size(); i++){ 60 65 list.add(MidiData.newMidiData(messages.get(i))); … … 63 68 } 64 69 65 public void setMidiData(long tick, ArrayList<MidiData> list){66 trackdata.put(tick, list);67 } 68 69 public void addMidiMessage(long tick, ArrayList<MidiMessage> messages){70 public void setMidiData(long tick, List<MidiData> list){ 71 trackdata.put(tick, new ArrayList<MidiData>(list)); 72 } 73 74 public void addMidiMessage(long tick, List<MidiMessage> messages){ 70 75 for(int i = 0; i < messages.size(); i++){ 71 76 addMidiData(tick, MidiData.newMidiData(messages.get(i))); … … 73 78 } 74 79 75 public void addMidiData(long tick, ArrayList<MidiData> list){80 public void addMidiData(long tick, List<MidiData> list){ 76 81 for(int i = 0; i < list.size(); i++){ 77 82 addMidiData(tick, list.get(i)); … … 91 96 } 92 97 93 public void getTrack(Track t) throws Exception{98 public void getTrack(Track t) throws InvalidMidiDataException{ 94 99 Long ticks[] = getTicks(); 95 100 for(int i = 0; i < ticks.length; i++){ 96 ArrayList<MidiEvent> mes = getMidiEvent(ticks[i]);101 List<MidiEvent> mes = getMidiEvent(ticks[i]); 97 102 for(int j = 0; j < mes.size(); j++){ 98 103 t.add(mes.get(j)); … … 112 117 if(ticks.length > 0){ 113 118 for(int i = 0; i < ticks.length; i++){ 114 ArrayList<MidiData> mes = getMidiData(ticks[i]);119 List<MidiData> mes = getMidiData(ticks[i]); 115 120 if(mes.size() > 0){ 116 StringBu ffer sb = new StringBuffer();121 StringBuilder sb = new StringBuilder(); 117 122 sb.append(mes.get(0).toString()); 118 123 for(int j = 1; j < mes.size(); j++){ … … 124 129 } 125 130 126 StringBu ffer sb = new StringBuffer();131 StringBuilder sb = new StringBuilder(); 127 132 sb.append("MidiTrack={"); 128 133 if(!sl.isEmpty()){ … … 136 141 } 137 142 138 public boolean isReadied(){143 public boolean validate(){ 139 144 return true; 140 145 } 141 146 142 public int compareTo( ImmutableObject obj){147 public int compareTo(BaseObject obj){ 143 148 if(!(obj instanceof MidiTrack)){ 144 149 throw new ClassCastException(); … … 147 152 } 148 153 149 public MidiTrack over( Object obj, boolean fill, boolean has){154 public MidiTrack over(BaseObject obj, boolean fill, boolean has){ 150 155 MidiTrack midiTrack = ((MidiTrack)obj).clone(); 151 156 Long ticks[] = midiTrack.getTicks(); … … 153 158 long tick = ticks[i]; 154 159 if(fill || has == hasMidiData(tick)){ 155 ArrayList<MidiData> list = midiTrack.getMidiData(tick);160 List<MidiData> list = midiTrack.getMidiData(tick); 156 161 for(int j = 0; j < list.size(); j++){ 157 162 addMidiData(tick, list.get(j)); … … 190 195 } 191 196 192 public static MidiTrack load(String file) throws Exception{193 return (MidiTrack) ImmutableObject.load(file);194 } 195 196 public static MidiTrack load(File file) throws Exception{197 return (MidiTrack) ImmutableObject.load(file);198 } 199 200 public void store(String file) throws Exception{197 public static MidiTrack load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 198 return (MidiTrack)BaseObject.load(file); 199 } 200 201 public static MidiTrack load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 202 return (MidiTrack)BaseObject.load(file); 203 } 204 205 public void store(String file) throws FileNotFoundException, IOException{ 201 206 super.store(file); 202 207 } 203 208 204 public void store(File file) throws Exception{209 public void store(File file) throws FileNotFoundException, IOException{ 205 210 super.store(file); 206 211 } 207 212 208 public static MidiTrack unzip(String file) throws Exception{209 return (MidiTrack) ImmutableObject.unzip(file);210 } 211 212 public static MidiTrack unzip(File file) throws Exception{213 return (MidiTrack) ImmutableObject.unzip(file);214 } 215 216 public void zip(String file) throws Exception{213 public static MidiTrack unzip(String file) throws IOException, ClassNotFoundException{ 214 return (MidiTrack)BaseObject.unzip(file); 215 } 216 217 public static MidiTrack unzip(File file) throws IOException, ClassNotFoundException{ 218 return (MidiTrack)BaseObject.unzip(file); 219 } 220 221 public void zip(String file) throws IOException{ 217 222 super.zip(file); 218 223 } 219 224 220 public void zip(File file) throws Exception{225 public void zip(File file) throws IOException{ 221 226 super.zip(file); 222 227 } -
trunk/src/org/rayflood/mikuvat/io/vsq/AnoteEvent.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;4 import static org.rayflood.mikuvat. io.VSQDecoder.setSectionBracket;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 4 import static org.rayflood.mikuvat.Utilities.setSectionBracket; 5 5 6 6 import java.io.File; 7 import java.io.FileNotFoundException; 8 import java.io.IOException; 7 9 import java.util.ArrayList; 8 10 import java.util.List; 9 11 import java.util.Map; 12 13 import org.rayflood.mikuvat.io.BaseObject; 14 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 10 15 11 16 public class AnoteEvent extends Event{ … … 292 297 } 293 298 294 StringBu ffer sb = new StringBuffer();299 StringBuilder sb = new StringBuilder(); 295 300 sb.append("AnoteEvent={"); 296 301 if(!sl.isEmpty()){ … … 304 309 } 305 310 306 public boolean isReadied(){311 public boolean validate() throws InvalidBaseObjectException{ 307 312 boolean ready = true; 308 313 ready &= hasLength(); … … 314 319 ready &= hasDecay(); 315 320 ready &= hasAccent(); 316 ready &= hasLyricHandle() && getLyricHandle().isReadied(); 317 ready &= !hasVibratoHandle() || getVibratoHandle().isReadied(); 321 ready &= hasLyricHandle() && getLyricHandle().validate(); 322 ready &= !hasVibratoHandle() || getVibratoHandle().validate(); 323 if(!ready){ 324 throw new InvalidBaseObjectException(this); 325 } 318 326 return ready; 319 327 } 320 328 321 public int compareTo( ImmutableObject obj){329 public int compareTo(BaseObject obj){ 322 330 AnoteEvent anoteEvent = (AnoteEvent)obj; 323 331 int c = compare(getLyricHandle(), anoteEvent.getLyricHandle()); … … 331 339 } 332 340 333 public AnoteEvent over( Object obj, boolean fill, boolean has){341 public AnoteEvent over(BaseObject obj, boolean fill, boolean has){ 334 342 AnoteEvent anoteEvent = ((AnoteEvent)obj).clone(); 335 343 if(anoteEvent.hasLength() && (fill || has == hasLength())){ … … 657 665 } 658 666 659 public static AnoteEvent load(String file) throws Exception{660 return (AnoteEvent) ImmutableObject.load(file);661 } 662 663 public static AnoteEvent load(File file) throws Exception{664 return (AnoteEvent) ImmutableObject.load(file);665 } 666 667 public void store(String file) throws Exception{667 public static AnoteEvent load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 668 return (AnoteEvent)BaseObject.load(file); 669 } 670 671 public static AnoteEvent load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 672 return (AnoteEvent)BaseObject.load(file); 673 } 674 675 public void store(String file) throws FileNotFoundException, IOException{ 668 676 super.store(file); 669 677 } 670 678 671 public void store(File file) throws Exception{679 public void store(File file) throws FileNotFoundException, IOException{ 672 680 super.store(file); 673 681 } 674 682 675 public static AnoteEvent unzip(String file) throws Exception{676 return (AnoteEvent) ImmutableObject.unzip(file);677 } 678 679 public static AnoteEvent unzip(File file) throws Exception{680 return (AnoteEvent) ImmutableObject.unzip(file);681 } 682 683 public void zip(String file) throws Exception{683 public static AnoteEvent unzip(String file) throws IOException, ClassNotFoundException{ 684 return (AnoteEvent)BaseObject.unzip(file); 685 } 686 687 public static AnoteEvent unzip(File file) throws IOException, ClassNotFoundException{ 688 return (AnoteEvent)BaseObject.unzip(file); 689 } 690 691 public void zip(String file) throws IOException{ 684 692 super.zip(file); 685 693 } 686 694 687 public void zip(File file) throws Exception{695 public void zip(File file) throws IOException{ 688 696 super.zip(file); 689 697 } -
trunk/src/org/rayflood/mikuvat/io/vsq/CommonSection.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.SPLITCOMMA;4 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.SPLITCOMMA; 4 import static org.rayflood.mikuvat.Utilities.splitEqual; 5 5 6 6 import java.awt.Color; 7 7 import java.io.File; 8 import java.io.FileNotFoundException; 9 import java.io.IOException; 8 10 import java.util.ArrayList; 9 11 import java.util.List; 10 12 11 public class CommonSection extends ImmutableObject{ 13 import org.rayflood.mikuvat.io.BaseObject; 14 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 15 16 public class CommonSection extends BaseObject{ 12 17 private static final long serialVersionUID = 8435457526013952633L; 13 18 public static final String VERSION = "Version"; … … 77 82 } 78 83 79 StringBu ffer sb = new StringBuffer();84 StringBuilder sb = new StringBuilder(); 80 85 sb.append("CommonSection={"); 81 86 if(!sl.isEmpty()){ … … 89 94 } 90 95 91 public boolean isReadied(){96 public boolean validate() throws InvalidBaseObjectException{ 92 97 boolean ready = true; 93 98 ready &= hasVersion(); … … 96 101 ready &= hasDynamicsMode(); 97 102 ready &= hasPlayMode(); 103 if(!ready){ 104 throw new InvalidBaseObjectException(this); 105 } 98 106 return ready; 99 107 } 100 108 101 public int compareTo( ImmutableObject obj){109 public int compareTo(BaseObject obj){ 102 110 CommonSection commonSection = (CommonSection)obj; 103 111 int c = compare(getName(), commonSection.getName()); … … 108 116 } 109 117 110 public CommonSection over( Object obj, boolean fill, boolean has){118 public CommonSection over(BaseObject obj, boolean fill, boolean has){ 111 119 CommonSection commonSection = ((CommonSection)obj).clone(); 112 120 if(commonSection.hasVersion() && (fill || has == hasVersion())){ … … 276 284 } 277 285 278 public static CommonSection load(String file) throws Exception{279 return (CommonSection) ImmutableObject.load(file);280 } 281 282 public static CommonSection load(File file) throws Exception{283 return (CommonSection) ImmutableObject.load(file);284 } 285 286 public void store(String file) throws Exception{286 public static CommonSection load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 287 return (CommonSection)BaseObject.load(file); 288 } 289 290 public static CommonSection load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 291 return (CommonSection)BaseObject.load(file); 292 } 293 294 public void store(String file) throws FileNotFoundException, IOException{ 287 295 super.store(file); 288 296 } 289 297 290 public void store(File file) throws Exception{298 public void store(File file) throws FileNotFoundException, IOException{ 291 299 super.store(file); 292 300 } 293 301 294 public static CommonSection unzip(String file) throws Exception{295 return (CommonSection) ImmutableObject.unzip(file);296 } 297 298 public static CommonSection unzip(File file) throws Exception{299 return (CommonSection) ImmutableObject.unzip(file);300 } 301 302 public void zip(String file) throws Exception{302 public static CommonSection unzip(String file) throws IOException, ClassNotFoundException{ 303 return (CommonSection)BaseObject.unzip(file); 304 } 305 306 public static CommonSection unzip(File file) throws IOException, ClassNotFoundException{ 307 return (CommonSection)BaseObject.unzip(file); 308 } 309 310 public void zip(String file) throws IOException{ 303 311 super.zip(file); 304 312 } 305 313 306 public void zip(File file) throws Exception{314 public void zip(File file) throws IOException{ 307 315 super.zip(file); 308 316 } -
trunk/src/org/rayflood/mikuvat/io/vsq/EOSEvent.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.vsq; 2 2 3 3 import java.io.File; 4 import java.io.FileNotFoundException; 5 import java.io.IOException; 4 6 import java.util.List; 5 7 import java.util.Map; 8 9 import org.rayflood.mikuvat.io.BaseObject; 6 10 7 11 public class EOSEvent extends Event{ … … 20 24 } 21 25 22 public boolean isReadied(){26 public boolean validate(){ 23 27 return true; 24 28 } 25 29 26 public int compareTo( ImmutableObject obj){30 public int compareTo(BaseObject obj){ 27 31 if(!(obj instanceof EOSEvent)){ 28 32 throw new ClassCastException(); … … 31 35 } 32 36 33 public EOSEvent over( Object obj, boolean fill, boolean has){37 public EOSEvent over(BaseObject obj, boolean fill, boolean has){ 34 38 if(!(obj instanceof EOSEvent)){ 35 39 throw new ClassCastException(); … … 54 58 } 55 59 56 public static EOSEvent load(String file) throws Exception{57 return (EOSEvent) ImmutableObject.load(file);60 public static EOSEvent load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 61 return (EOSEvent)BaseObject.load(file); 58 62 } 59 63 60 public static EOSEvent load(File file) throws Exception{61 return (EOSEvent) ImmutableObject.load(file);64 public static EOSEvent load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 65 return (EOSEvent)BaseObject.load(file); 62 66 } 63 67 64 public void store(String file) throws Exception{68 public void store(String file) throws FileNotFoundException, IOException{ 65 69 super.store(file); 66 70 } 67 71 68 public void store(File file) throws Exception{72 public void store(File file) throws FileNotFoundException, IOException{ 69 73 super.store(file); 70 74 } 71 75 72 public static EOSEvent unzip(String file) throws Exception{73 return (EOSEvent) ImmutableObject.unzip(file);76 public static EOSEvent unzip(String file) throws IOException, ClassNotFoundException{ 77 return (EOSEvent)BaseObject.unzip(file); 74 78 } 75 79 76 public static EOSEvent unzip(File file) throws Exception{77 return (EOSEvent) ImmutableObject.unzip(file);80 public static EOSEvent unzip(File file) throws IOException, ClassNotFoundException{ 81 return (EOSEvent)BaseObject.unzip(file); 78 82 } 79 83 80 public void zip(String file) throws Exception{84 public void zip(String file) throws IOException{ 81 85 super.zip(file); 82 86 } 83 87 84 public void zip(File file) throws Exception{88 public void zip(File file) throws IOException{ 85 89 super.zip(file); 86 90 } -
trunk/src/org/rayflood/mikuvat/io/vsq/Event.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.vsq; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;3 import static org.rayflood.mikuvat.Utilities.splitEqual; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.HashMap; 7 9 import java.util.List; 8 10 import java.util.Map; 9 11 10 public abstract class Event extends ImmutableObject{ 12 import org.rayflood.mikuvat.io.BaseObject; 13 14 public abstract class Event extends BaseObject{ 11 15 private static final long serialVersionUID = 3144497610281730738L; 12 16 public static final String TYPE = "Type"; … … 15 19 public static final String EOS = "EOS"; 16 20 17 public int compareTo( ImmutableObject obj){21 public int compareTo(BaseObject obj){ 18 22 Event event = (Event)obj; 19 23 return compare(getClass().getName(), event.getClass().getName()); … … 58 62 } 59 63 60 public static Event load(String file) throws Exception{61 return (Event) ImmutableObject.load(file);64 public static Event load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 65 return (Event)BaseObject.load(file); 62 66 } 63 67 64 public static Event load(File file) throws Exception{65 return (Event) ImmutableObject.load(file);68 public static Event load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 69 return (Event)BaseObject.load(file); 66 70 } 67 71 68 public void store(String file) throws Exception{72 public void store(String file) throws FileNotFoundException, IOException{ 69 73 super.store(file); 70 74 } 71 75 72 public void store(File file) throws Exception{76 public void store(File file) throws FileNotFoundException, IOException{ 73 77 super.store(file); 74 78 } 75 79 76 public static Event unzip(String file) throws Exception{77 return (Event) ImmutableObject.unzip(file);80 public static Event unzip(String file) throws IOException, ClassNotFoundException{ 81 return (Event)BaseObject.unzip(file); 78 82 } 79 83 80 public static Event unzip(File file) throws Exception{81 return (Event) ImmutableObject.unzip(file);84 public static Event unzip(File file) throws IOException, ClassNotFoundException{ 85 return (Event)BaseObject.unzip(file); 82 86 } 83 87 84 public void zip(String file) throws Exception{88 public void zip(String file) throws IOException{ 85 89 super.zip(file); 86 90 } 87 91 88 public void zip(File file) throws Exception{92 public void zip(File file) throws IOException{ 89 93 super.zip(file); 90 94 } -
trunk/src/org/rayflood/mikuvat/io/vsq/EventBPTime.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 9 public class EventBPTime extends ImmutableObject{ 11 import org.rayflood.mikuvat.io.BaseObject; 12 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 13 14 public class EventBPTime extends BaseObject{ 10 15 private static final long serialVersionUID = 817431318781476681L; 11 16 public static final int PITCHBEND_MAX = 8191; … … 144 149 } 145 150 146 StringBu ffer sb = new StringBuffer();151 StringBuilder sb = new StringBuilder(); 147 152 sb.append("EventBPTime={"); 148 153 if(!sl.isEmpty()){ … … 156 161 } 157 162 158 public boolean isReadied(){ 159 return !hasEvent() || getEvent().isReadied(); 160 } 161 162 public int compareTo(ImmutableObject obj){ 163 public boolean validate() throws InvalidBaseObjectException{ 164 boolean ready = true; 165 ready &= !hasEvent() || getEvent().validate(); 166 if(!ready){ 167 throw new InvalidBaseObjectException(this); 168 } 169 return ready; 170 } 171 172 public int compareTo(BaseObject obj){ 163 173 EventBPTime eventBPTime = (EventBPTime)obj; 164 174 int c = compare(getDynamics(), eventBPTime.getDynamics()); … … 201 211 } 202 212 203 public EventBPTime over( Object obj, boolean fill, boolean has){213 public EventBPTime over(BaseObject obj, boolean fill, boolean has){ 204 214 EventBPTime eventBPTime = ((EventBPTime)obj).clone(); 205 215 if(eventBPTime.hasEvent()){ … … 889 899 } 890 900 891 public static EventBPTime load(String file) throws Exception{892 return (EventBPTime) ImmutableObject.load(file);893 } 894 895 public static EventBPTime load(File file) throws Exception{896 return (EventBPTime) ImmutableObject.load(file);897 } 898 899 public void store(String file) throws Exception{901 public static EventBPTime load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 902 return (EventBPTime)BaseObject.load(file); 903 } 904 905 public static EventBPTime load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 906 return (EventBPTime)BaseObject.load(file); 907 } 908 909 public void store(String file) throws FileNotFoundException, IOException{ 900 910 super.store(file); 901 911 } 902 912 903 public void store(File file) throws Exception{913 public void store(File file) throws FileNotFoundException, IOException{ 904 914 super.store(file); 905 915 } 906 916 907 public static EventBPTime unzip(String file) throws Exception{908 return (EventBPTime) ImmutableObject.unzip(file);909 } 910 911 public static EventBPTime unzip(File file) throws Exception{912 return (EventBPTime) ImmutableObject.unzip(file);913 } 914 915 public void zip(String file) throws Exception{917 public static EventBPTime unzip(String file) throws IOException, ClassNotFoundException{ 918 return (EventBPTime)BaseObject.unzip(file); 919 } 920 921 public static EventBPTime unzip(File file) throws IOException, ClassNotFoundException{ 922 return (EventBPTime)BaseObject.unzip(file); 923 } 924 925 public void zip(String file) throws IOException{ 916 926 super.zip(file); 917 927 } 918 928 919 public void zip(File file) throws Exception{929 public void zip(File file) throws IOException{ 920 930 super.zip(file); 921 931 } -
trunk/src/org/rayflood/mikuvat/io/vsq/IconHandle.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.splitEqual; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 9 public class IconHandle extends ImmutableObject{ 11 import org.rayflood.mikuvat.io.BaseObject; 12 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 13 14 public class IconHandle extends BaseObject{ 10 15 private static final long serialVersionUID = 6787028875195143543L; 11 16 public static final String ICONID = "IconID"; … … 93 98 } 94 99 95 StringBu ffer sb = new StringBuffer();100 StringBuilder sb = new StringBuilder(); 96 101 sb.append("IconHandle={"); 97 102 if(!sl.isEmpty()){ … … 105 110 } 106 111 107 public boolean isReadied(){112 public boolean validate() throws InvalidBaseObjectException{ 108 113 boolean ready = true; 109 114 ready &= hasIconID(); … … 114 119 ready &= hasLanguage(); 115 120 ready &= hasProgram(); 121 if(!ready){ 122 throw new InvalidBaseObjectException(this); 123 } 116 124 return ready; 117 125 } 118 126 119 public int compareTo( ImmutableObject obj){127 public int compareTo(BaseObject obj){ 120 128 IconHandle iconHandle = (IconHandle)obj; 121 129 return compare(getIconID(), iconHandle.getIconID()); 122 130 } 123 131 124 public IconHandle over( Object obj, boolean fill, boolean has){132 public IconHandle over(BaseObject obj, boolean fill, boolean has){ 125 133 IconHandle iconHandle = ((IconHandle)obj).clone(); 126 134 if(iconHandle.hasIconID() && (fill || has == hasIconID())){ … … 340 348 } 341 349 342 public static IconHandle load(String file) throws Exception{343 return (IconHandle) ImmutableObject.load(file);344 } 345 346 public static IconHandle load(File file) throws Exception{347 return (IconHandle) ImmutableObject.load(file);348 } 349 350 public void store(String file) throws Exception{350 public static IconHandle load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 351 return (IconHandle)BaseObject.load(file); 352 } 353 354 public static IconHandle load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 355 return (IconHandle)BaseObject.load(file); 356 } 357 358 public void store(String file) throws FileNotFoundException, IOException{ 351 359 super.store(file); 352 360 } 353 361 354 public void store(File file) throws Exception{362 public void store(File file) throws FileNotFoundException, IOException{ 355 363 super.store(file); 356 364 } 357 365 358 public static IconHandle unzip(String file) throws Exception{359 return (IconHandle) ImmutableObject.unzip(file);360 } 361 362 public static IconHandle unzip(File file) throws Exception{363 return (IconHandle) ImmutableObject.unzip(file);364 } 365 366 public void zip(String file) throws Exception{366 public static IconHandle unzip(String file) throws IOException, ClassNotFoundException{ 367 return (IconHandle)BaseObject.unzip(file); 368 } 369 370 public static IconHandle unzip(File file) throws IOException, ClassNotFoundException{ 371 return (IconHandle)BaseObject.unzip(file); 372 } 373 374 public void zip(String file) throws IOException{ 367 375 super.zip(file); 368 376 } 369 377 370 public void zip(File file) throws Exception{378 public void zip(File file) throws IOException{ 371 379 super.zip(file); 372 380 } -
trunk/src/org/rayflood/mikuvat/io/vsq/LyricHandle.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.vsq; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;3 import static org.rayflood.mikuvat.Utilities.splitEqual; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 9 public class LyricHandle extends ImmutableObject{ 11 import org.rayflood.mikuvat.io.BaseObject; 12 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 13 14 public class LyricHandle extends BaseObject{ 10 15 private static final long serialVersionUID = 3044157326865723314L; 11 16 private ArrayList<LyricNote> lyricNotes; … … 47 52 } 48 53 49 StringBu ffer sb = new StringBuffer();54 StringBuilder sb = new StringBuilder(); 50 55 sb.append("LyricHandle={"); 51 56 if(!sl.isEmpty()){ … … 59 64 } 60 65 61 public boolean isReadied(){66 public boolean validate() throws InvalidBaseObjectException{ 62 67 boolean ready = true; 63 ready &= hasLyricNotes() && getLyricNote().isReadied(); 68 ready &= hasLyricNotes() && getLyricNote().validate(); 69 if(!ready){ 70 throw new InvalidBaseObjectException(this); 71 } 64 72 return ready; 65 73 } 66 74 67 public int compareTo( ImmutableObject obj){75 public int compareTo(BaseObject obj){ 68 76 LyricHandle lyricHandle = (LyricHandle)obj; 69 77 return compare(getLyricNote(), lyricHandle.getLyricNote()); 70 78 } 71 79 72 public LyricHandle over( Object obj, boolean fill, boolean has){80 public LyricHandle over(BaseObject obj, boolean fill, boolean has){ 73 81 LyricHandle lyricHandle = ((LyricHandle)obj).clone(); 74 82 if(lyricHandle.hasLyricNotes()){ … … 150 158 } 151 159 152 public static LyricHandle load(String file) throws Exception{153 return (LyricHandle) ImmutableObject.load(file);160 public static LyricHandle load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 161 return (LyricHandle)BaseObject.load(file); 154 162 } 155 163 156 public static LyricHandle load(File file) throws Exception{157 return (LyricHandle) ImmutableObject.load(file);164 public static LyricHandle load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 165 return (LyricHandle)BaseObject.load(file); 158 166 } 159 167 160 public void store(String file) throws Exception{168 public void store(String file) throws FileNotFoundException, IOException{ 161 169 super.store(file); 162 170 } 163 171 164 public void store(File file) throws Exception{172 public void store(File file) throws FileNotFoundException, IOException{ 165 173 super.store(file); 166 174 } 167 175 168 public static LyricHandle unzip(String file) throws Exception{169 return (LyricHandle) ImmutableObject.unzip(file);176 public static LyricHandle unzip(String file) throws IOException, ClassNotFoundException{ 177 return (LyricHandle)BaseObject.unzip(file); 170 178 } 171 179 172 public static LyricHandle unzip(File file) throws Exception{173 return (LyricHandle) ImmutableObject.unzip(file);180 public static LyricHandle unzip(File file) throws IOException, ClassNotFoundException{ 181 return (LyricHandle)BaseObject.unzip(file); 174 182 } 175 183 176 public void zip(String file) throws Exception{184 public void zip(String file) throws IOException{ 177 185 super.zip(file); 178 186 } 179 187 180 public void zip(File file) throws Exception{188 public void zip(File file) throws IOException{ 181 189 super.zip(file); 182 190 } -
trunk/src/org/rayflood/mikuvat/io/vsq/LyricNote.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.SPLITCOMMA;4 import static org.rayflood.mikuvat. io.VSQDecoder.SPLITDQUOTE;5 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;6 import static org.rayflood.mikuvat. io.VSQDecoder.getBigDecimalString;7 import static org.rayflood.mikuvat. io.VSQDecoder.getBooleanValue;8 import static org.rayflood.mikuvat. io.VSQDecoder.getStringValue;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.SPLITCOMMA; 4 import static org.rayflood.mikuvat.Utilities.SPLITDQUOTE; 5 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 6 import static org.rayflood.mikuvat.Utilities.getBigDecimalString; 7 import static org.rayflood.mikuvat.Utilities.getBooleanValue; 8 import static org.rayflood.mikuvat.Utilities.getStringValue; 9 9 10 10 import java.io.File; 11 import java.io.FileNotFoundException; 12 import java.io.IOException; 11 13 import java.math.BigDecimal; 12 14 import java.util.ArrayList; 13 15 import java.util.List; 14 16 15 public class LyricNote extends ImmutableObject{ 17 import org.rayflood.mikuvat.io.BaseObject; 18 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 19 20 public class LyricNote extends BaseObject{ 16 21 private static final long serialVersionUID = -119405351990339359L; 17 22 public static final BigDecimal A_MAX = new BigDecimal("1.0"); … … 78 83 } 79 84 if(hasB()){ 80 StringBu ffer sb = new StringBuffer();85 StringBuilder sb = new StringBuilder(); 81 86 sb.append(b[0]); 82 87 for(int i = 1; i < b.length; i++){ … … 89 94 } 90 95 91 StringBu ffer sb = new StringBuffer();96 StringBuilder sb = new StringBuilder(); 92 97 sb.append("LyricNote={"); 93 98 if(!sl.isEmpty()){ … … 101 106 } 102 107 103 public boolean isReadied(){108 public boolean validate() throws InvalidBaseObjectException{ 104 109 boolean ready = true; 105 110 ready &= hasCaption(); … … 108 113 ready &= hasB(); 109 114 ready &= hasProtect(); 115 if(!ready){ 116 throw new InvalidBaseObjectException(this); 117 } 110 118 return ready; 111 119 } 112 120 113 public int compareTo( ImmutableObject obj){121 public int compareTo(BaseObject obj){ 114 122 LyricNote lyricNote = (LyricNote)obj; 115 123 int c = compare(getCaption(), lyricNote.getCaption()); … … 123 131 } 124 132 125 public LyricNote over( Object obj, boolean fill, boolean has){133 public LyricNote over(BaseObject obj, boolean fill, boolean has){ 126 134 LyricNote lyricNote = ((LyricNote)obj).clone(); 127 135 if(lyricNote.hasCaption() && (fill || has == hasCaption())){ … … 281 289 } 282 290 283 public static LyricNote load(String file) throws Exception{284 return (LyricNote) ImmutableObject.load(file);285 } 286 287 public static LyricNote load(File file) throws Exception{288 return (LyricNote) ImmutableObject.load(file);289 } 290 291 public void store(String file) throws Exception{291 public static LyricNote load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 292 return (LyricNote)BaseObject.load(file); 293 } 294 295 public static LyricNote load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 296 return (LyricNote)BaseObject.load(file); 297 } 298 299 public void store(String file) throws FileNotFoundException, IOException{ 292 300 super.store(file); 293 301 } 294 302 295 public void store(File file) throws Exception{303 public void store(File file) throws FileNotFoundException, IOException{ 296 304 super.store(file); 297 305 } 298 306 299 public static LyricNote unzip(String file) throws Exception{300 return (LyricNote) ImmutableObject.unzip(file);301 } 302 303 public static LyricNote unzip(File file) throws Exception{304 return (LyricNote) ImmutableObject.unzip(file);305 } 306 307 public void zip(String file) throws Exception{307 public static LyricNote unzip(String file) throws IOException, ClassNotFoundException{ 308 return (LyricNote)BaseObject.unzip(file); 309 } 310 311 public static LyricNote unzip(File file) throws IOException, ClassNotFoundException{ 312 return (LyricNote)BaseObject.unzip(file); 313 } 314 315 public void zip(String file) throws IOException{ 308 316 super.zip(file); 309 317 } 310 318 311 public void zip(File file) throws Exception{319 public void zip(File file) throws IOException{ 312 320 super.zip(file); 313 321 } -
trunk/src/org/rayflood/mikuvat/io/vsq/MasterSection.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.vsq; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;4 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;3 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 4 import static org.rayflood.mikuvat.Utilities.splitEqual; 5 5 6 6 import java.io.File; 7 import java.io.FileNotFoundException; 8 import java.io.IOException; 7 9 import java.util.ArrayList; 8 10 import java.util.List; 9 11 10 public class MasterSection extends ImmutableObject{ 12 import org.rayflood.mikuvat.io.BaseObject; 13 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 14 15 public class MasterSection extends BaseObject{ 11 16 private static final long serialVersionUID = 3680414369532973128L; 12 17 … … 44 49 } 45 50 46 StringBu ffer sb = new StringBuffer();51 StringBuilder sb = new StringBuilder(); 47 52 sb.append("MasterSection={"); 48 53 if(!sl.isEmpty()){ … … 56 61 } 57 62 58 public boolean isReadied(){63 public boolean validate() throws InvalidBaseObjectException{ 59 64 boolean ready = true; 60 65 ready &= hasPreMeasure(); 66 if(!ready){ 67 throw new InvalidBaseObjectException(this); 68 } 61 69 return ready; 62 70 } 63 71 64 public int compareTo( ImmutableObject obj){72 public int compareTo(BaseObject obj){ 65 73 MasterSection masterSection = (MasterSection)obj; 66 74 return compare(this.getPreMeasure(), masterSection.getPreMeasure()); 67 75 } 68 76 69 public MasterSection over( Object obj, boolean fill, boolean has){77 public MasterSection over(BaseObject obj, boolean fill, boolean has){ 70 78 MasterSection masterSection = ((MasterSection)obj).clone(); 71 79 if(masterSection.hasPreMeasure() && (fill || has == hasPreMeasure())){ … … 129 137 } 130 138 131 public static MasterSection load(String file) throws Exception{132 return (MasterSection) ImmutableObject.load(file);139 public static MasterSection load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 140 return (MasterSection)BaseObject.load(file); 133 141 } 134 142 135 public static MasterSection load(File file) throws Exception{136 return (MasterSection) ImmutableObject.load(file);143 public static MasterSection load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 144 return (MasterSection)BaseObject.load(file); 137 145 } 138 146 139 public void store(String file) throws Exception{147 public void store(String file) throws FileNotFoundException, IOException{ 140 148 super.store(file); 141 149 } 142 150 143 public void store(File file) throws Exception{151 public void store(File file) throws FileNotFoundException, IOException{ 144 152 super.store(file); 145 153 } 146 154 147 public static MasterSection unzip(String file) throws Exception{148 return (MasterSection) ImmutableObject.unzip(file);155 public static MasterSection unzip(String file) throws IOException, ClassNotFoundException{ 156 return (MasterSection)BaseObject.unzip(file); 149 157 } 150 158 151 public static MasterSection unzip(File file) throws Exception{152 return (MasterSection) ImmutableObject.unzip(file);159 public static MasterSection unzip(File file) throws IOException, ClassNotFoundException{ 160 return (MasterSection)BaseObject.unzip(file); 153 161 } 154 162 155 public void zip(String file) throws Exception{163 public void zip(String file) throws IOException{ 156 164 super.zip(file); 157 165 } 158 166 159 public void zip(File file) throws Exception{167 public void zip(File file) throws IOException{ 160 168 super.zip(file); 161 169 } -
trunk/src/org/rayflood/mikuvat/io/vsq/MixerSection.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;4 import static org.rayflood.mikuvat. io.VSQDecoder.getBooleanValue;5 import static org.rayflood.mikuvat. io.VSQDecoder.getStringValue;6 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 4 import static org.rayflood.mikuvat.Utilities.getBooleanValue; 5 import static org.rayflood.mikuvat.Utilities.getStringValue; 6 import static org.rayflood.mikuvat.Utilities.splitEqual; 7 7 8 8 import java.io.File; 9 import java.io.FileNotFoundException; 10 import java.io.IOException; 9 11 import java.util.ArrayList; 10 12 import java.util.HashMap; … … 12 14 import java.util.TreeMap; 13 15 14 public class MixerSection extends ImmutableObject{ 16 import org.rayflood.mikuvat.io.BaseObject; 17 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 18 19 public class MixerSection extends BaseObject{ 15 20 private static final long serialVersionUID = 1038661919778326460L; 16 21 public static final String MASTERFEDER = "MasterFeder"; … … 175 180 } 176 181 if(hasMixerSettings()){ 177 StringBu ffer sb = new StringBuffer();182 StringBuilder sb = new StringBuilder(); 178 183 Integer indexes[] = getIndexes(); 179 184 sb.append(indexes[0] + "={" + getMixerSetting(indexes[0]).toString() + "}"); … … 184 189 } 185 190 186 StringBu ffer sb = new StringBuffer();191 StringBuilder sb = new StringBuilder(); 187 192 sb.append("MixerSection={"); 188 193 if(!sl.isEmpty()){ … … 196 201 } 197 202 198 public boolean isReadied(){203 public boolean validate() throws InvalidBaseObjectException{ 199 204 boolean ready = true; 200 205 ready &= hasMasterFeder(); … … 205 210 Integer indexes[] = getIndexes(); 206 211 for(int i = 0; i < indexes.length; i++){ 207 ready &= getMixerSetting(indexes[i]). isReadied();212 ready &= getMixerSetting(indexes[i]).validate(); 208 213 } 209 214 ready &= (getTracks() == indexes.length); 215 if(!ready){ 216 throw new InvalidBaseObjectException(this); 217 } 210 218 return ready; 211 219 } 212 220 213 public int compareTo( ImmutableObject obj){221 public int compareTo(BaseObject obj){ 214 222 MixerSection mixerSection = (MixerSection)obj; 215 223 int c = compare(getMasterFeder(), mixerSection.getMasterFeder()); … … 226 234 } 227 235 228 public MixerSection over( Object obj, boolean fill, boolean has){236 public MixerSection over(BaseObject obj, boolean fill, boolean has){ 229 237 MixerSection mixerSection = ((MixerSection)obj).clone(); 230 238 if(mixerSection.hasMasterFeder() && (fill || has == hasMasterFeder())){ … … 439 447 } 440 448 441 public static MixerSection load(String file) throws Exception{442 return (MixerSection) ImmutableObject.load(file);443 } 444 445 public static MixerSection load(File file) throws Exception{446 return (MixerSection) ImmutableObject.load(file);447 } 448 449 public void store(String file) throws Exception{449 public static MixerSection load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 450 return (MixerSection)BaseObject.load(file); 451 } 452 453 public static MixerSection load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 454 return (MixerSection)BaseObject.load(file); 455 } 456 457 public void store(String file) throws FileNotFoundException, IOException{ 450 458 super.store(file); 451 459 } 452 460 453 public void store(File file) throws Exception{461 public void store(File file) throws FileNotFoundException, IOException{ 454 462 super.store(file); 455 463 } 456 464 457 public static MixerSection unzip(String file) throws Exception{458 return (MixerSection) ImmutableObject.unzip(file);459 } 460 461 public static MixerSection unzip(File file) throws Exception{462 return (MixerSection) ImmutableObject.unzip(file);463 } 464 465 public void zip(String file) throws Exception{465 public static MixerSection unzip(String file) throws IOException, ClassNotFoundException{ 466 return (MixerSection)BaseObject.unzip(file); 467 } 468 469 public static MixerSection unzip(File file) throws IOException, ClassNotFoundException{ 470 return (MixerSection)BaseObject.unzip(file); 471 } 472 473 public void zip(String file) throws IOException{ 466 474 super.zip(file); 467 475 } 468 476 469 public void zip(File file) throws Exception{477 public void zip(File file) throws IOException{ 470 478 super.zip(file); 471 479 } -
trunk/src/org/rayflood/mikuvat/io/vsq/MixerSetting.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;4 import static org.rayflood.mikuvat. io.VSQDecoder.getBooleanValue;5 import static org.rayflood.mikuvat. io.VSQDecoder.getStringValue;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 4 import static org.rayflood.mikuvat.Utilities.getBooleanValue; 5 import static org.rayflood.mikuvat.Utilities.getStringValue; 6 6 7 7 import java.io.File; 8 import java.io.FileNotFoundException; 9 import java.io.IOException; 8 10 import java.util.ArrayList; 9 11 import java.util.List; 10 12 11 public class MixerSetting extends ImmutableObject{ 13 import org.rayflood.mikuvat.io.BaseObject; 14 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 15 16 public class MixerSetting extends BaseObject{ 12 17 private static final long serialVersionUID = -4879364127354448647L; 13 18 private Integer feder; … … 47 52 } 48 53 49 StringBu ffer sb = new StringBuffer();54 StringBuilder sb = new StringBuilder(); 50 55 sb.append("MixerSetting={"); 51 56 if(!sl.isEmpty()){ … … 59 64 } 60 65 61 public boolean isReadied(){66 public boolean validate() throws InvalidBaseObjectException{ 62 67 boolean ready = true; 63 68 ready &= hasFeder(); … … 65 70 ready &= hasMute(); 66 71 ready &= hasSolo(); 72 if(!ready){ 73 throw new InvalidBaseObjectException(this); 74 } 67 75 return ready; 68 76 } 69 77 70 public int compareTo( ImmutableObject obj){78 public int compareTo(BaseObject obj){ 71 79 MixerSetting mixerSetting = (MixerSetting)obj; 72 80 int c = compare(getFeder(), mixerSetting.getFeder()); … … 83 91 } 84 92 85 public MixerSetting over( Object obj, boolean fill, boolean has){93 public MixerSetting over(BaseObject obj, boolean fill, boolean has){ 86 94 MixerSetting mixerSetting = ((MixerSetting)obj).clone(); 87 95 if(mixerSetting.hasFeder() && (fill || has == hasFeder())){ … … 235 243 } 236 244 237 public static MixerSetting load(String file) throws Exception{238 return (MixerSetting) ImmutableObject.load(file);239 } 240 241 public static MixerSetting load(File file) throws Exception{242 return (MixerSetting) ImmutableObject.load(file);243 } 244 245 public void store(String file) throws Exception{245 public static MixerSetting load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 246 return (MixerSetting)BaseObject.load(file); 247 } 248 249 public static MixerSetting load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 250 return (MixerSetting)BaseObject.load(file); 251 } 252 253 public void store(String file) throws FileNotFoundException, IOException{ 246 254 super.store(file); 247 255 } 248 256 249 public void store(File file) throws Exception{257 public void store(File file) throws FileNotFoundException, IOException{ 250 258 super.store(file); 251 259 } 252 260 253 public static MixerSetting unzip(String file) throws Exception{254 return (MixerSetting) ImmutableObject.unzip(file);255 } 256 257 public static MixerSetting unzip(File file) throws Exception{258 return (MixerSetting) ImmutableObject.unzip(file);259 } 260 261 public void zip(String file) throws Exception{261 public static MixerSetting unzip(String file) throws IOException, ClassNotFoundException{ 262 return (MixerSetting)BaseObject.unzip(file); 263 } 264 265 public static MixerSetting unzip(File file) throws IOException, ClassNotFoundException{ 266 return (MixerSetting)BaseObject.unzip(file); 267 } 268 269 public void zip(String file) throws IOException{ 262 270 super.zip(file); 263 271 } 264 272 265 public void zip(File file) throws Exception{273 public void zip(File file) throws IOException{ 266 274 super.zip(file); 267 275 } -
trunk/src/org/rayflood/mikuvat/io/vsq/SingerEvent.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.vsq; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.setSectionBracket;3 import static org.rayflood.mikuvat.Utilities.setSectionBracket; 4 4 5 5 import java.io.File; 6 import java.io.FileNotFoundException; 7 import java.io.IOException; 6 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 import java.util.Map; 11 12 import org.rayflood.mikuvat.io.BaseObject; 13 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 9 14 10 15 public class SingerEvent extends Event{ … … 47 52 } 48 53 49 StringBu ffer sb = new StringBuffer();54 StringBuilder sb = new StringBuilder(); 50 55 sb.append("SingerEvent={"); 51 56 if(!sl.isEmpty()){ … … 59 64 } 60 65 61 public boolean isReadied(){66 public boolean validate() throws InvalidBaseObjectException{ 62 67 boolean ready = true; 63 ready &= hasIconHandle() && getIconHandle().isReadied(); 68 ready &= hasIconHandle() && getIconHandle().validate(); 69 if(!ready){ 70 throw new InvalidBaseObjectException(this); 71 } 64 72 return ready; 65 73 } 66 74 67 public int compareTo( ImmutableObject obj){75 public int compareTo(BaseObject obj){ 68 76 SingerEvent singerEvent = (SingerEvent)obj; 69 77 return compare(getIconHandle(), singerEvent.getIconHandle()); 70 78 } 71 79 72 public SingerEvent over( Object obj, boolean fill, boolean has){80 public SingerEvent over(BaseObject obj, boolean fill, boolean has){ 73 81 SingerEvent singerEvent = ((SingerEvent)obj).clone(); 74 82 if(singerEvent.hasIconHandle()){ … … 129 137 } 130 138 131 public static SingerEvent load(String file) throws Exception{132 return (SingerEvent) ImmutableObject.load(file);139 public static SingerEvent load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 140 return (SingerEvent)BaseObject.load(file); 133 141 } 134 142 135 public static SingerEvent load(File file) throws Exception{136 return (SingerEvent) ImmutableObject.load(file);143 public static SingerEvent load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 144 return (SingerEvent)BaseObject.load(file); 137 145 } 138 146 139 public void store(String file) throws Exception{147 public void store(String file) throws FileNotFoundException, IOException{ 140 148 super.store(file); 141 149 } 142 150 143 public void store(File file) throws Exception{151 public void store(File file) throws FileNotFoundException, IOException{ 144 152 super.store(file); 145 153 } 146 154 147 public static SingerEvent unzip(String file) throws Exception{148 return (SingerEvent) ImmutableObject.unzip(file);155 public static SingerEvent unzip(String file) throws IOException, ClassNotFoundException{ 156 return (SingerEvent)BaseObject.unzip(file); 149 157 } 150 158 151 public static SingerEvent unzip(File file) throws Exception{152 return (SingerEvent) ImmutableObject.unzip(file);159 public static SingerEvent unzip(File file) throws IOException, ClassNotFoundException{ 160 return (SingerEvent)BaseObject.unzip(file); 153 161 } 154 162 155 public void zip(String file) throws Exception{163 public void zip(String file) throws IOException{ 156 164 super.zip(file); 157 165 } 158 166 159 public void zip(File file) throws Exception{167 public void zip(File file) throws IOException{ 160 168 super.zip(file); 161 169 } -
trunk/src/org/rayflood/mikuvat/io/vsq/TimeLine.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.setSectionBracket;4 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.setSectionBracket; 4 import static org.rayflood.mikuvat.Utilities.splitEqual; 5 5 6 6 import java.io.File; 7 import java.io.FileNotFoundException; 8 import java.io.IOException; 7 9 import java.util.ArrayList; 8 10 import java.util.List; … … 10 12 import java.util.TreeMap; 11 13 12 public class TimeLine extends ImmutableObject{ 14 import org.rayflood.mikuvat.io.BaseObject; 15 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 16 17 public class TimeLine extends BaseObject{ 13 18 private static final long serialVersionUID = -3486238291169847310L; 14 19 public static final String PITCHBEND = "PitchBendBPList"; … … 580 585 } 581 586 if(hasEventTimes()){ 582 StringBu ffer sb = new StringBuffer();587 StringBuilder sb = new StringBuilder(); 583 588 Long ticks[] = getTicks(); 584 589 sb.append(ticks[0] + "={" + getEventBPTime(ticks[0]).toString() + "}"); … … 589 594 } 590 595 591 StringBu ffer sb = new StringBuffer();596 StringBuilder sb = new StringBuilder(); 592 597 sb.append("TimeLine={"); 593 598 if(!sl.isEmpty()){ … … 601 606 } 602 607 603 public boolean isReadied(){608 public boolean validate() throws InvalidBaseObjectException{ 604 609 boolean ready = true; 605 ready &= hasInitialSinger() && getInitialSinger(). isReadied();610 ready &= hasInitialSinger() && getInitialSinger().validate(); 606 611 Long ticks[] = getTicks(); 607 612 for(int i = 0; i < ticks.length; i++){ 608 ready &= getEventBPTime(ticks[i]).isReadied(); 613 ready &= getEventBPTime(ticks[i]).validate(); 614 } 615 if(!ready){ 616 throw new InvalidBaseObjectException(this); 609 617 } 610 618 return ready; 611 619 } 612 620 613 public int compareTo( ImmutableObject obj){621 public int compareTo(BaseObject obj){ 614 622 TimeLine timeLine = (TimeLine)obj; 615 623 return compare(getInitialSinger(), timeLine.getInitialSinger()); 616 624 } 617 625 618 public TimeLine over( Object obj, boolean fill, boolean has){626 public TimeLine over(BaseObject obj, boolean fill, boolean has){ 619 627 TimeLine timeLine = ((TimeLine)obj).clone(); 620 628 if(timeLine.hasInitialSinger()){ … … 872 880 } 873 881 874 public static TimeLine load(String file) throws Exception{875 return (TimeLine) ImmutableObject.load(file);876 } 877 878 public static TimeLine load(File file) throws Exception{879 return (TimeLine) ImmutableObject.load(file);880 } 881 882 public void store(String file) throws Exception{882 public static TimeLine load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 883 return (TimeLine)BaseObject.load(file); 884 } 885 886 public static TimeLine load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 887 return (TimeLine)BaseObject.load(file); 888 } 889 890 public void store(String file) throws FileNotFoundException, IOException{ 883 891 super.store(file); 884 892 } 885 893 886 public void store(File file) throws Exception{894 public void store(File file) throws FileNotFoundException, IOException{ 887 895 super.store(file); 888 896 } 889 897 890 public static TimeLine unzip(String file) throws Exception{891 return (TimeLine) ImmutableObject.unzip(file);892 } 893 894 public static TimeLine unzip(File file) throws Exception{895 return (TimeLine) ImmutableObject.unzip(file);896 } 897 898 public void zip(String file) throws Exception{898 public static TimeLine unzip(String file) throws IOException, ClassNotFoundException{ 899 return (TimeLine)BaseObject.unzip(file); 900 } 901 902 public static TimeLine unzip(File file) throws IOException, ClassNotFoundException{ 903 return (TimeLine)BaseObject.unzip(file); 904 } 905 906 public void zip(String file) throws IOException{ 899 907 super.zip(file); 900 908 } 901 909 902 public void zip(File file) throws Exception{910 public void zip(File file) throws IOException{ 903 911 super.zip(file); 904 912 } -
trunk/src/org/rayflood/mikuvat/io/vsq/VSQFile.java
r2 r4 1 package org.rayflood.mikuvat.io; 2 3 import static org.rayflood.mikuvat.io.VSQDecoder.decode; 4 import static org.rayflood.mikuvat.io.VSQDecoder.encode; 5 import static org.rayflood.mikuvat.io.VSQDecoder.setSectionBracket; 6 1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.setSectionBracket; 4 5 import java.io.BufferedReader; 7 6 import java.io.File; 7 import java.io.FileNotFoundException; 8 import java.io.IOException; 9 import java.io.StringReader; 10 import java.nio.charset.Charset; 8 11 import java.util.ArrayList; 12 import java.util.LinkedHashMap; 9 13 import java.util.List; 10 14 import java.util.Map; 11 12 import javax.sound.midi.MidiEvent; 13 import javax.sound.midi. MidiSystem;15 import java.util.regex.Pattern; 16 17 import javax.sound.midi.InvalidMidiDataException; 14 18 import javax.sound.midi.Sequence; 15 import javax.sound.midi.Track; 16 17 public class VSQFile extends ImmutableObject{ 19 20 import org.rayflood.mikuvat.io.BaseObject; 21 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 22 import org.rayflood.mikuvat.io.midi.MidiData; 23 import org.rayflood.mikuvat.io.midi.MidiFile; 24 import org.rayflood.mikuvat.io.midi.MidiMeta; 25 import org.rayflood.mikuvat.io.midi.MidiTrack; 26 27 public class VSQFile extends MidiFile{ 18 28 private static final long serialVersionUID = -6314152290164983853L; 29 public static final Pattern MMHEADER = Pattern.compile("^DM:\\d+:"); 30 public static final Charset WIN31J = Charset.forName("Windows-31J"); 31 public static final Pattern SECTIONLINE = Pattern.compile("^\\[.+\\]$"); 32 public static final int TEXTLENGTH = 119; 19 33 public static final String COMMON = "Common"; 20 34 public static final String MASTER = "Master"; … … 22 36 public static final String EVENTLIST = "EventList"; 23 37 24 private File vsqFile;25 private Integer fileType;26 private Float divisionType;27 private Integer resolution;28 private MidiTrack conductor;29 38 private MasterSection master; 30 39 private MixerSection mixer; 31 40 private ArrayList<VSQTrack> tracks; 32 41 33 public VSQFile(String vsq) throws Exception{42 public VSQFile(String vsq) throws IOException, InvalidMidiDataException{ 34 43 this(); 35 readVSQFile(vsq); 36 } 37 38 public VSQFile(File vsq) throws Exception{ 44 readMidiFile(vsq); 45 setVSQSequence(getMidiTracks()); 46 } 47 48 public VSQFile(File vsq) throws IOException, InvalidMidiDataException{ 39 49 this(); 40 readVSQFile(vsq); 41 } 42 43 public VSQFile(Sequence sq) throws Exception{ 50 readMidiFile(vsq); 51 setVSQSequence(getMidiTracks()); 52 } 53 54 public VSQFile(Sequence sq) throws IOException{ 44 55 this(); 45 setVSQSequence(sq); 46 } 47 48 public void readVSQFile(String vsq) throws Exception{ 56 setMidiSequence(sq); 57 setVSQSequence(getMidiTracks()); 58 } 59 60 public void readVSQFile(String vsq) throws IOException, InvalidMidiDataException{ 49 61 readVSQFile(new File(vsq)); 50 62 } 51 63 52 public void readVSQFile(File vsq) throws Exception{53 s etVsqFile(vsq);54 setVSQSequence( MidiSystem.getSequence(getVsqFile()));55 } 56 57 public void writeVSQFile() throws Exception{64 public void readVSQFile(File vsq) throws IOException, InvalidMidiDataException{ 65 super.readMidiFile(vsq); 66 setVSQSequence(getMidiTracks()); 67 } 68 69 public void writeVSQFile() throws IOException, InvalidMidiDataException, InvalidBaseObjectException{ 58 70 writeVSQFile(getVsqFile()); 59 71 } 60 72 61 public void writeVSQFile(String vsq) throws Exception{73 public void writeVSQFile(String vsq) throws IOException, InvalidMidiDataException, InvalidBaseObjectException{ 62 74 writeVSQFile(new File(vsq)); 63 75 } 64 76 65 public void writeVSQFile(File vsq) throws Exception{ 66 MidiSystem.write(getVSQSequence(), getFileType(), vsq); 67 } 68 69 public void setVSQSequence(Sequence sq) throws Exception{ 70 setFileType(MidiSystem.getMidiFileTypes(sq)[0]); 71 setDivisionType(sq.getDivisionType()); 72 setResolution(sq.getResolution()); 73 Track t[] = sq.getTracks(); 74 setConductor(t[0]); 75 76 Map<String, List<String>> sections = decode(t[1]); 77 public void writeVSQFile(File vsq) throws IOException, InvalidMidiDataException, InvalidBaseObjectException{ 78 setMidiTracks(getVSQSequence()); 79 super.writeMidiFile(vsq); 80 } 81 82 public Map<String, List<String>> decode(List<MidiData> md) throws IOException{ 83 List<Byte> v = new ArrayList<Byte>(); 84 for(int i = 0; i < md.size(); i++){ 85 MidiData m = md.get(i); 86 if(m instanceof MidiMeta){ 87 byte b[] = ((MidiMeta)m).getData(); 88 if(b.length == 0){ 89 continue; 90 } 91 String mmheader = new String(b); 92 String[] ss = MMHEADER.split(mmheader, 2); 93 if(ss.length > 1){ 94 for(int k = mmheader.indexOf(ss[1]); k < b.length; k++){ 95 if(b[k] != 0x00){ 96 v.add(b[k]); 97 } 98 } 99 } 100 } 101 } 102 byte b[] = new byte[v.size()]; 103 for(int i = 0; i < v.size(); i++){ 104 b[i] = v.get(i); 105 } 106 String textevent = new String(b, WIN31J); 107 System.out.println(textevent); 108 109 Map<String, List<String>> sections = new LinkedHashMap<String, List<String>>(); 110 BufferedReader br = new BufferedReader(new StringReader(textevent)); 111 String bf; 112 String sn = ""; 113 List<String> sv = new ArrayList<String>(); 114 do{ 115 bf = br.readLine(); 116 if(bf == null || SECTIONLINE.matcher(bf).matches()){ 117 if(sn.length() > 0 && !sections.containsKey(sn)){ 118 sections.put(sn.substring(1, sn.length() - 1), sv); 119 } 120 sn = bf; 121 sv = new ArrayList<String>(); 122 } 123 else if(bf.length() > 0){ 124 sv.add(bf); 125 } 126 }while(bf != null); 127 128 return sections; 129 } 130 131 public List<MidiData> encode(List<String> trackSections){ 132 String te = ""; 133 for(int i = 0; i < trackSections.size(); i++){ 134 String vts = trackSections.get(i); 135 te += vts + "\n"; 136 } 137 138 List<MidiData> tme = new ArrayList<MidiData>(); 139 byte b[] = te.getBytes(WIN31J); 140 for(int j = 0; j <= b.length / TEXTLENGTH; j++){ 141 int h = (int)StrictMath.ceil((double)Integer.toString(j).length() / 4.0); 142 String mef = "DM:%0" + h * 4 + "d:"; 143 byte header[] = String.format(mef, j).getBytes(WIN31J); 144 List<Byte> mbl = new ArrayList<Byte>(); 145 for(int k = 0; k < header.length; k++){ 146 mbl.add(header[k]); 147 } 148 for(int k = 0; k < TEXTLENGTH; k++){ 149 int bi = j * TEXTLENGTH + k; 150 if(bi >= b.length){ 151 break; 152 } 153 mbl.add(b[bi]); 154 } 155 byte mb[] = new byte[mbl.size()]; 156 for(int k = 0; k < mbl.size(); k++){ 157 mb[k] = mbl.get(k); 158 } 159 tme.add(new MidiMeta(1, mb)); 160 } 161 162 return tme; 163 } 164 165 public void setVSQSequence(ArrayList<MidiTrack> t) throws IOException{ 166 Map<String, List<String>> sections = decode(t.get(0).getMidiData(0L)); 77 167 setMaster(new MasterSection(sections.get(MASTER))); 78 168 setMixer(new MixerSection(sections.get(MIXER))); 79 addTrack(new VSQTrack(t[1].get(0), getMixerSetting(0), sections)); 80 for(int i = 2; i < t.length; i++){ 81 addTrack(new VSQTrack(t[i].get(0), getMixerSetting(i - 1), decode(t[i]))); 82 } 83 } 84 85 public Sequence getVSQSequence() throws Exception{ 86 Sequence sq = new Sequence(getDivisionType(), getResolution()); 87 Track mt = sq.createTrack(); 88 getConductor(mt); 169 addVSQTrack(new VSQTrack(getMixerSetting(0), sections)); 170 for(int i = 1; i < t.size(); i++){ 171 addVSQTrack(new VSQTrack(getMixerSetting(i), decode(t.get(i).getMidiData(0L)))); 172 } 173 } 174 175 public ArrayList<MidiTrack> getVSQSequence() throws InvalidBaseObjectException{ 176 ArrayList<MidiTrack> t = new ArrayList<MidiTrack>(); 89 177 90 178 List<List<String>> tsections = getVSQText(); 91 for(int i = 0; i < getTrackSize(); i++){ 92 VSQTrack vt = getTrack(i); 93 Track t = sq.createTrack(); 94 t.add(vt.getTrackNameME()); 95 List<MidiEvent> me = encode(tsections.get(i)); 96 for(int j = 0; j < me.size(); j++){ 97 t.add(me.get(j)); 98 } 99 } 100 101 return sq; 102 } 103 104 public List<List<String>> getVSQText() throws Exception{ 105 if(!isReadied()){ 106 throw new Exception(); 107 } 179 for(int i = 0; i < getVSQTrackSize(); i++){ 180 MidiTrack mt = new MidiTrack(); 181 mt.setMidiData(0L, encode(tsections.get(i))); 182 t.add(mt); 183 } 184 185 return t; 186 } 187 188 public List<List<String>> getVSQText() throws InvalidBaseObjectException{ 189 validate(); 108 190 109 191 List<List<String>> tcommons = new ArrayList<List<String>>(); 110 192 List<List<String>> ttimelines = new ArrayList<List<String>>(); 111 for(int i = 0; i < get TrackSize(); i++){112 VSQTrack vt = get Track(i);193 for(int i = 0; i < getVSQTrackSize(); i++){ 194 VSQTrack vt = getVSQTrack(i); 113 195 tcommons.add(vt.getCommon().getSection()); 114 196 ttimelines.add(vt.getTimeLine().getSectionFast()); … … 128 210 vsqtext.add(sections); 129 211 130 for(int i = 1; i < get TrackSize(); i++){212 for(int i = 1; i < getVSQTrackSize(); i++){ 131 213 sections = new ArrayList<String>(); 132 214 sections.add(setSectionBracket(COMMON)); … … 164 246 } 165 247 166 public int get TrackSize(){248 public int getVSQTrackSize(){ 167 249 return tracks.size(); 168 250 } 169 251 170 public void add Track(VSQTrack vt){252 public void addVSQTrack(VSQTrack vt){ 171 253 if(vt == null || vt.isDeleted()){ 172 254 return; … … 175 257 } 176 258 177 public void add Track(int index, VSQTrack vt){259 public void addVSQTrack(int index, VSQTrack vt){ 178 260 if(vt == null || vt.isDeleted()){ 179 261 return; 180 262 } 181 if(index < get TrackSize()){263 if(index < getVSQTrackSize()){ 182 264 tracks.add(index, vt); 183 265 } 184 266 else{ 185 add Track(vt);186 } 187 } 188 189 public void set Track(int index, VSQTrack vt){267 addVSQTrack(vt); 268 } 269 } 270 271 public void setVSQTrack(int index, VSQTrack vt){ 190 272 if(vt == null || vt.isDeleted()){ 191 remove Track(index);192 return; 193 } 194 if(index < get TrackSize()){273 removeVSQTrack(index); 274 return; 275 } 276 if(index < getVSQTrackSize()){ 195 277 tracks.set(index, vt); 196 278 } 197 279 else{ 198 add Track(vt);199 } 200 } 201 202 public VSQTrack get Track(int index){203 if(index < get TrackSize()){280 addVSQTrack(vt); 281 } 282 } 283 284 public VSQTrack getVSQTrack(int index){ 285 if(index < getVSQTrackSize()){ 204 286 return tracks.get(index); 205 287 } … … 209 291 } 210 292 211 public VSQTrack remove Track(int index){212 if(index < get TrackSize()){293 public VSQTrack removeVSQTrack(int index){ 294 if(index < getVSQTrackSize()){ 213 295 return tracks.remove(index); 214 296 } … … 223 305 sl.add("VsqFile=" + getVsqFileS()); 224 306 } 225 if(hasFileType()){226 sl.add("FileType=" + getFileType());227 }228 if(hasDivisionType()){229 sl.add("DivisionType=" + getDivisionType());230 }231 if(hasResolution()){232 sl.add("Resolution=" + getResolution());233 }234 if(hasConductor()){235 sl.add("Conductor={" + getConductor().toString() + "}");236 }237 307 if(hasMaster()){ 238 308 sl.add("Master={" + getMaster().toString() + "}"); … … 241 311 sl.add("Mixer={" + getMixer().toString() + "}"); 242 312 } 243 if(has Tracks()){244 StringBu ffer sb = new StringBuffer();245 sb.append(get Track(0).toString());246 for(int i = 1; i < get TrackSize(); i++){247 sb.append("," + get Track(i).toString());313 if(hasVSQTracks()){ 314 StringBuilder sb = new StringBuilder(); 315 sb.append(getVSQTrack(0).toString()); 316 for(int i = 1; i < getVSQTrackSize(); i++){ 317 sb.append("," + getVSQTrack(i).toString()); 248 318 } 249 319 sl.add("Tracks=[" + sb.toString() + "]"); 250 320 } 251 321 252 StringBuffer sb = new StringBuffer(); 322 StringBuilder sb = new StringBuilder(); 323 sb.append(super.toString()); 324 253 325 sb.append("VSQFile={"); 254 326 if(!sl.isEmpty()){ … … 262 334 } 263 335 264 public boolean isReadied(){ 265 boolean ready = true; 266 ready &= hasFileType(); 267 ready &= hasDivisionType(); 268 ready &= hasResolution(); 269 ready &= hasConductor() && getConductor().isReadied(); 270 ready &= hasMaster() && getMaster().isReadied(); 271 ready &= hasMixer() && getMixer().isReadied(); 272 for(int i = 0; i < getTrackSize(); i++){ 273 ready &= getTrack(i).isReadied(); 336 public boolean validate() throws InvalidBaseObjectException{ 337 boolean ready = super.validate(); 338 ready &= hasMaster() && getMaster().validate(); 339 ready &= hasMixer() && getMixer().validate(); 340 for(int i = 0; i < getVSQTrackSize(); i++){ 341 ready &= getVSQTrack(i).validate(); 342 } 343 if(!ready){ 344 throw new InvalidBaseObjectException(this); 274 345 } 275 346 return ready; 276 347 } 277 348 278 public int compareTo(ImmutableObject obj){ 279 VSQFile vsqFile = (VSQFile)obj; 280 return compare(getVsqFile().getPath(), vsqFile.getVsqFile().getPath()); 281 } 282 283 public VSQFile over(Object obj, boolean fill, boolean has){ 349 public VSQFile over(BaseObject obj, boolean fill, boolean has){ 350 super.over(obj, fill, has); 284 351 VSQFile vsqFile = ((VSQFile)obj).clone(); 285 if(vsqFile.hasFileType() && (fill || has == hasFileType())){286 setFileType(vsqFile.getFileType());287 }288 if(vsqFile.hasDivisionType() && (fill || has == hasDivisionType())){289 setDivisionType(vsqFile.getDivisionType());290 }291 if(vsqFile.hasResolution() && (fill || has == hasResolution())){292 setResolution(vsqFile.getResolution());293 }294 if(vsqFile.hasConductor()){295 MidiTrack conductor = hasConductor() ? getConductor() : new MidiTrack();296 setConductor(conductor.over(vsqFile.getConductor(), fill, has));297 }298 352 if(vsqFile.hasMaster()){ 299 353 MasterSection master = hasMaster() ? getMaster() : new MasterSection(); … … 304 358 setMixer(mixer.over(vsqFile.getMixer(), fill, has)); 305 359 } 306 for(int i = 0; i < vsqFile.getTracks().size(); i++){ 307 VSQTrack vt = getTrack(i); 308 setTrack(i, vt.over(vsqFile.getTrack(i), fill, has)); 309 } 310 if(vsqFile.hasVsqFile() && (fill || has == hasVsqFile())){ 311 setVsqFile(vsqFile.getVsqFile()); 360 for(int i = 0; i < vsqFile.getVSQTracks().size(); i++){ 361 VSQTrack vt = getVSQTrack(i); 362 setVSQTrack(i, vt.over(vsqFile.getVSQTrack(i), fill, has)); 312 363 } 313 364 return this; … … 315 366 316 367 public VSQFile setDefault(){ 317 setFileType(1); 318 setDivisionType(0.0f); 319 setResolution(480); 320 setConductor(new MidiTrack()); 368 super.setDefault(); 321 369 setMaster(MasterSection.getDefault()); 322 370 setMixer(MixerSection.getDefault()); 323 deleteTracks(); 324 addTrack(VSQTrack.getDefault()); 325 deleteVsqFile(); 371 deleteVSQTracks(); 372 addVSQTrack(VSQTrack.getDefault()); 326 373 return this; 327 374 } … … 334 381 335 382 public VSQFile delete(){ 336 deleteFileType(); 337 deleteDivisionType(); 338 deleteResolution(); 339 deleteConductor(); 383 super.delete(); 340 384 deleteMaster(); 341 385 deleteMixer(); 342 deleteTracks(); 343 deleteVsqFile(); 386 deleteVSQTracks(); 344 387 return this; 345 388 } 346 389 347 390 public boolean isDeleted(){ 348 boolean has = false; 349 has |= hasFileType(); 350 has |= hasDivisionType(); 351 has |= hasResolution(); 352 has |= hasConductor(); 391 boolean has = super.isDeleted(); 353 392 has |= hasMaster(); 354 393 has |= hasMixer(); 355 has |= hasTracks(); 356 has |= hasVsqFile(); 394 has |= hasVSQTracks(); 357 395 return !has; 358 396 } 359 397 360 398 public VSQFile(){ 399 super(); 361 400 delete(); 362 401 } 363 402 364 403 public File getVsqFile(){ 365 return vsqFile;404 return getMidiFile(); 366 405 } 367 406 … … 371 410 372 411 public void setVsqFile(File vsqFile){ 373 this.vsqFile = vsqFile;412 setMidiFile(vsqFile); 374 413 } 375 414 … … 379 418 380 419 public void deleteVsqFile(){ 381 vsqFile = null;420 deleteMidiFile(); 382 421 } 383 422 384 423 public boolean hasVsqFile(){ 385 return vsqFile != null; 386 } 387 388 public Integer getFileType(){ 389 return fileType; 390 } 391 392 public void setFileType(Integer fileType){ 393 this.fileType = fileType; 394 } 395 396 public void deleteFileType(){ 397 fileType = null; 398 } 399 400 public boolean hasFileType(){ 401 return fileType != null; 402 } 403 404 public Float getDivisionType(){ 405 return divisionType; 406 } 407 408 public void setDivisionType(Float divisionType){ 409 this.divisionType = divisionType; 410 } 411 412 public void deleteDivisionType(){ 413 divisionType = null; 414 } 415 416 public boolean hasDivisionType(){ 417 return divisionType != null; 418 } 419 420 public Integer getResolution(){ 421 return resolution; 422 } 423 424 public void setResolution(Integer resolution){ 425 this.resolution = resolution; 426 } 427 428 public void deleteResolution(){ 429 resolution = null; 430 } 431 432 public boolean hasResolution(){ 433 return resolution != null; 434 } 435 436 public MidiTrack getConductor(){ 437 return conductor; 438 } 439 440 public void getConductor(Track t) throws Exception{ 441 conductor.getTrack(t); 442 } 443 444 public void setConductor(MidiTrack conductor){ 445 if(conductor == null || conductor.isDeleted()){ 446 deleteConductor(); 447 return; 448 } 449 this.conductor = conductor; 450 } 451 452 public void setConductor(Track t){ 453 this.conductor = new MidiTrack(t); 454 } 455 456 public void deleteConductor(){ 457 conductor = null; 458 } 459 460 public boolean hasConductor(){ 461 return conductor != null; 424 return hasMidiFile(); 462 425 } 463 426 … … 502 465 } 503 466 504 public ArrayList<VSQTrack> get Tracks(){467 public ArrayList<VSQTrack> getVSQTracks(){ 505 468 return tracks; 506 469 } 507 470 508 public void set Tracks(ArrayList<VSQTrack> tracks){471 public void setVSQTracks(ArrayList<VSQTrack> tracks){ 509 472 if(tracks == null){ 510 delete Tracks();473 deleteVSQTracks(); 511 474 return; 512 475 } … … 514 477 } 515 478 516 public void delete Tracks(){517 set Tracks(new ArrayList<VSQTrack>());518 } 519 520 public boolean has Tracks(){479 public void deleteVSQTracks(){ 480 setVSQTracks(new ArrayList<VSQTrack>()); 481 } 482 483 public boolean hasVSQTracks(){ 521 484 return !tracks.isEmpty(); 522 485 } … … 526 489 } 527 490 528 public static VSQFile load(String file) throws Exception{529 return (VSQFile) ImmutableObject.load(file);530 } 531 532 public static VSQFile load(File file) throws Exception{533 return (VSQFile) ImmutableObject.load(file);534 } 535 536 public void store(String file) throws Exception{491 public static VSQFile load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 492 return (VSQFile)BaseObject.load(file); 493 } 494 495 public static VSQFile load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 496 return (VSQFile)BaseObject.load(file); 497 } 498 499 public void store(String file) throws FileNotFoundException, IOException{ 537 500 super.store(file); 538 501 } 539 502 540 public void store(File file) throws Exception{503 public void store(File file) throws FileNotFoundException, IOException{ 541 504 super.store(file); 542 505 } 543 506 544 public static VSQFile unzip(String file) throws Exception{545 return (VSQFile) ImmutableObject.unzip(file);546 } 547 548 public static VSQFile unzip(File file) throws Exception{549 return (VSQFile) ImmutableObject.unzip(file);550 } 551 552 public void zip(String file) throws Exception{507 public static VSQFile unzip(String file) throws IOException, ClassNotFoundException{ 508 return (VSQFile)BaseObject.unzip(file); 509 } 510 511 public static VSQFile unzip(File file) throws IOException, ClassNotFoundException{ 512 return (VSQFile)BaseObject.unzip(file); 513 } 514 515 public void zip(String file) throws IOException{ 553 516 super.zip(file); 554 517 } 555 518 556 public void zip(File file) throws Exception{519 public void zip(File file) throws IOException{ 557 520 super.zip(file); 558 521 } -
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 } -
trunk/src/org/rayflood/mikuvat/io/vsq/VibratoBP.java
r2 r4 1 package org.rayflood.mikuvat.io ;1 package org.rayflood.mikuvat.io.vsq; 2 2 3 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;4 import static org.rayflood.mikuvat. io.VSQDecoder.getBigDecimalString;3 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 4 import static org.rayflood.mikuvat.Utilities.getBigDecimalString; 5 5 6 6 import java.io.File; 7 import java.io.FileNotFoundException; 8 import java.io.IOException; 7 9 import java.math.BigDecimal; 8 10 9 public class VibratoBP extends ImmutableObject{ 11 import org.rayflood.mikuvat.io.BaseObject; 12 13 public class VibratoBP extends BaseObject{ 10 14 private static final long serialVersionUID = -1542047841867886356L; 11 15 public static final BigDecimal X_MAX = new BigDecimal("1.0"); … … 33 37 } 34 38 35 public boolean isReadied(){39 public boolean validate(){ 36 40 return true; 37 41 } 38 42 39 public int compareTo( ImmutableObject obj){43 public int compareTo(BaseObject obj){ 40 44 VibratoBP bp = (VibratoBP)obj; 41 45 int c = compare(getX(), bp.getX()); … … 46 50 } 47 51 48 public VibratoBP over( Object obj, boolean fill, boolean has){52 public VibratoBP over(BaseObject obj, boolean fill, boolean has){ 49 53 VibratoBP vibratoBP = ((VibratoBP)obj).clone(); 50 54 setX(vibratoBP.getX()); … … 112 116 } 113 117 114 public static VibratoBP load(String file) throws Exception{115 return (VibratoBP) ImmutableObject.load(file);118 public static VibratoBP load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 119 return (VibratoBP)BaseObject.load(file); 116 120 } 117 121 118 public static VibratoBP load(File file) throws Exception{119 return (VibratoBP) ImmutableObject.load(file);122 public static VibratoBP load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 123 return (VibratoBP)BaseObject.load(file); 120 124 } 121 125 122 public void store(String file) throws Exception{126 public void store(String file) throws FileNotFoundException, IOException{ 123 127 super.store(file); 124 128 } 125 129 126 public void store(File file) throws Exception{130 public void store(File file) throws FileNotFoundException, IOException{ 127 131 super.store(file); 128 132 } 129 133 130 public static VibratoBP unzip(String file) throws Exception{131 return (VibratoBP) ImmutableObject.unzip(file);134 public static VibratoBP unzip(String file) throws IOException, ClassNotFoundException{ 135 return (VibratoBP)BaseObject.unzip(file); 132 136 } 133 137 134 public static VibratoBP unzip(File file) throws Exception{135 return (VibratoBP) ImmutableObject.unzip(file);138 public static VibratoBP unzip(File file) throws IOException, ClassNotFoundException{ 139 return (VibratoBP)BaseObject.unzip(file); 136 140 } 137 141 138 public void zip(String file) throws Exception{142 public void zip(String file) throws IOException{ 139 143 super.zip(file); 140 144 } 141 145 142 public void zip(File file) throws Exception{146 public void zip(File file) throws IOException{ 143 147 super.zip(file); 144 148 } -
trunk/src/org/rayflood/mikuvat/io/vsq/VibratoHandle.java
r2 r4 1 package org.rayflood.mikuvat.io ;2 3 import static org.rayflood.mikuvat. io.VSQDecoder.SPLITCOMMA;4 import static org.rayflood.mikuvat. io.VSQDecoder.adjustMaxMin;5 import static org.rayflood.mikuvat. io.VSQDecoder.getBigDecimalString;6 import static org.rayflood.mikuvat. io.VSQDecoder.getVibratoBPList;7 import static org.rayflood.mikuvat. io.VSQDecoder.getVibratoBPMap;8 import static org.rayflood.mikuvat. io.VSQDecoder.splitEqual;1 package org.rayflood.mikuvat.io.vsq; 2 3 import static org.rayflood.mikuvat.Utilities.SPLITCOMMA; 4 import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 5 import static org.rayflood.mikuvat.Utilities.getBigDecimalString; 6 import static org.rayflood.mikuvat.Utilities.getVibratoBPList; 7 import static org.rayflood.mikuvat.Utilities.getVibratoBPMap; 8 import static org.rayflood.mikuvat.Utilities.splitEqual; 9 9 10 10 import java.io.File; 11 import java.io.FileNotFoundException; 12 import java.io.IOException; 11 13 import java.math.BigDecimal; 12 14 import java.util.ArrayList; … … 14 16 import java.util.TreeMap; 15 17 16 public class VibratoHandle extends ImmutableObject{ 18 import org.rayflood.mikuvat.io.BaseObject; 19 import org.rayflood.mikuvat.io.InvalidBaseObjectException; 20 21 public class VibratoHandle extends BaseObject{ 17 22 private static final long serialVersionUID = 7575294004927556748L; 18 23 public static final String ICONID = "IconID"; … … 208 213 TreeMap<BigDecimal, Integer> bps = getDepthBP(); 209 214 BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 210 StringBu ffer xsb = new StringBuffer();211 StringBu ffer ysb = new StringBuffer();215 StringBuilder xsb = new StringBuilder(); 216 StringBuilder ysb = new StringBuilder(); 212 217 xsb.append(getBigDecimalString(xs[0])); 213 218 ysb.append(bps.get(xs[0])); … … 224 229 TreeMap<BigDecimal, Integer> bps = getRateBP(); 225 230 BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 226 StringBu ffer xsb = new StringBuffer();227 StringBu ffer ysb = new StringBuffer();231 StringBuilder xsb = new StringBuilder(); 232 StringBuilder ysb = new StringBuilder(); 228 233 xsb.append(getBigDecimalString(xs[0])); 229 234 ysb.append(bps.get(xs[0])); … … 284 289 TreeMap<BigDecimal, Integer> bps = getDepthBP(); 285 290 BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 286 StringBu ffer xsb = new StringBuffer();287 StringBu ffer ysb = new StringBuffer();291 StringBuilder xsb = new StringBuilder(); 292 StringBuilder ysb = new StringBuilder(); 288 293 xsb.append(getBigDecimalString(xs[0])); 289 294 ysb.append(bps.get(xs[0])); … … 304 309 TreeMap<BigDecimal, Integer> bps = getRateBP(); 305 310 BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 306 StringBu ffer xsb = new StringBuffer();307 StringBu ffer ysb = new StringBuffer();311 StringBuilder xsb = new StringBuilder(); 312 StringBuilder ysb = new StringBuilder(); 308 313 xsb.append(getBigDecimalString(xs[0])); 309 314 ysb.append(bps.get(xs[0])); … … 316 321 } 317 322 318 StringBu ffer sb = new StringBuffer();323 StringBuilder sb = new StringBuilder(); 319 324 sb.append("VibratoHandle={"); 320 325 if(!sl.isEmpty()){ … … 328 333 } 329 334 330 public boolean isReadied(){335 public boolean validate() throws InvalidBaseObjectException{ 331 336 boolean ready = true; 332 337 ready &= hasIconID(); … … 342 347 ready &= hasRateBPNum(); 343 348 ready &= (getRateBPNum() == getRateBP().size()); 349 if(!ready){ 350 throw new InvalidBaseObjectException(this); 351 } 344 352 return ready; 345 353 } 346 354 347 public int compareTo( ImmutableObject obj){355 public int compareTo(BaseObject obj){ 348 356 VibratoHandle vibratoHandle = (VibratoHandle)obj; 349 357 int c = compare(getIconID(), vibratoHandle.getIconID()); … … 354 362 } 355 363 356 public VibratoHandle over( Object obj, boolean fill, boolean has){364 public VibratoHandle over(BaseObject obj, boolean fill, boolean has){ 357 365 VibratoHandle vibratoHandle = ((VibratoHandle)obj).clone(); 358 366 if(vibratoHandle.hasIconID() && (fill || has == hasIconID())){ … … 717 725 } 718 726 719 public static VibratoHandle load(String file) throws Exception{720 return (VibratoHandle) ImmutableObject.load(file);721 } 722 723 public static VibratoHandle load(File file) throws Exception{724 return (VibratoHandle) ImmutableObject.load(file);725 } 726 727 public void store(String file) throws Exception{727 public static VibratoHandle load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 728 return (VibratoHandle)BaseObject.load(file); 729 } 730 731 public static VibratoHandle load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 732 return (VibratoHandle)BaseObject.load(file); 733 } 734 735 public void store(String file) throws FileNotFoundException, IOException{ 728 736 super.store(file); 729 737 } 730 738 731 public void store(File file) throws Exception{739 public void store(File file) throws FileNotFoundException, IOException{ 732 740 super.store(file); 733 741 } 734 742 735 public static VibratoHandle unzip(String file) throws Exception{736 return (VibratoHandle) ImmutableObject.unzip(file);737 } 738 739 public static VibratoHandle unzip(File file) throws Exception{740 return (VibratoHandle) ImmutableObject.unzip(file);741 } 742 743 public void zip(String file) throws Exception{743 public static VibratoHandle unzip(String file) throws IOException, ClassNotFoundException{ 744 return (VibratoHandle)BaseObject.unzip(file); 745 } 746 747 public static VibratoHandle unzip(File file) throws IOException, ClassNotFoundException{ 748 return (VibratoHandle)BaseObject.unzip(file); 749 } 750 751 public void zip(String file) throws IOException{ 744 752 super.zip(file); 745 753 } 746 754 747 public void zip(File file) throws Exception{755 public void zip(File file) throws IOException{ 748 756 super.zip(file); 749 757 } -
trunk/src/org/rayflood/mikuvat/plugin/PluginLoader.java
r2 r4 31 31 String plugin = man.getMainAttributes().getValue("Mikuvat-Plugin"); 32 32 float version = new Float(MIKUVAT_VERSION); 33 float reqver = new Float(man.getMainAttributes().getValue("Mikuvat-Require-Version")); 34 if(plugin != null && !plugin.isEmpty() && version >= reqver){ 33 String mins = man.getMainAttributes().getValue("Mikuvat-Min-Version"); 34 float min = (mins == null) ? Float.MIN_VALUE: new Float(mins); 35 String maxs = man.getMainAttributes().getValue("Mikuvat-Max-Version"); 36 float max = (maxs == null) ? Float.MAX_VALUE: new Float(maxs); 37 if(plugin != null && !plugin.isEmpty() && version >= min && version <= max){ 35 38 pluginclasses.add(plugin); 36 39 urls.add(pluginfiles[i].toURI().toURL()); … … 38 41 } 39 42 catch(Exception e){ 43 System.out.println("プラグイン読み込み失敗! 無視します。" + pluginfiles[i].getPath()); 40 44 e.printStackTrace(); 41 45 } … … 56 60 } 57 61 catch(Exception e){ 62 System.out.println("ライブラリ読み込み失敗! 無視します。" + libfiles[i].getPath()); 58 63 e.printStackTrace(); 59 64 }
