import javax.swing.filechooser.FileNameExtensionFilter;\r
import javax.swing.table.AbstractTableModel;\r
import javax.swing.table.TableCellEditor;\r
+import javax.swing.table.TableColumn;\r
import javax.swing.table.TableColumnModel;\r
import javax.swing.table.TableModel;\r
\r
public void actionPerformed(ActionEvent e) {\r
if( midiFileChooser != null ) {\r
// ファイルに保存できる場合(Javaアプレットではなく、Javaアプリとして動作している場合)\r
- MidiSequenceTableModel seqModel = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
+ SequenceTrackListTableModel seqModel = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
if( seqModel.isModified() ) {\r
// ファイル未保存の変更がある場合\r
String confirmMessage =\r
/**\r
* ファイル選択ダイアログ(アプレットでは使用不可)\r
*/\r
+ private MidiFileChooser midiFileChooser;\r
+ /**\r
+ * ファイル選択ダイアログ(アプレットでは使用不可)\r
+ */\r
private class MidiFileChooser extends JFileChooser {\r
{\r
setFileFilter(\r
public Action saveMidiFileAction = new AbstractAction("Save") {\r
@Override\r
public void actionPerformed(ActionEvent e) {\r
- MidiSequenceTableModel sequenceTableModel =\r
+ SequenceTrackListTableModel sequenceTableModel =\r
sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
String filename = sequenceTableModel.getFilename();\r
File midiFile;\r
}\r
};\r
};\r
+\r
/**\r
- * ファイル選択ダイアログ(アプレットでは使用不可)\r
+ * MIDIトラック数表示ラベル\r
*/\r
- private MidiFileChooser midiFileChooser;\r
-\r
+ private JLabel tracksLabel;\r
/**\r
* MIDIトラック選択状態\r
*/\r
@Override\r
public void valueChanged(ListSelectionEvent e) {\r
if( e.getValueIsAdjusting() ) return;\r
- MidiSequenceTableModel sequenceModel = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
+ SequenceTrackListTableModel sequenceModel = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
if( sequenceModel == null || isSelectionEmpty() ) {\r
midiEventsLabel.setText("MIDI Events (No track selected)");\r
- eventListTableView.setModel(new MidiTrackTableModel());\r
+ eventListTableView.setModel(new TrackEventListTableModel());\r
}\r
else {\r
int selIndex = getMinSelectionIndex();\r
- MidiTrackTableModel trackModel = sequenceModel.getTrackModel(selIndex);\r
+ TrackEventListTableModel trackModel = sequenceModel.getTrackModel(selIndex);\r
if( trackModel == null ) {\r
midiEventsLabel.setText("MIDI Events (No track selected)");\r
- eventListTableView.setModel(new MidiTrackTableModel());\r
+ eventListTableView.setModel(new TrackEventListTableModel());\r
}\r
else {\r
midiEventsLabel.setText(\r
eventListTableView.setModel(trackModel);\r
TableColumnModel tcm = eventListTableView.getColumnModel();\r
trackModel.sizeColumnWidthToFit(tcm);\r
- tcm.getColumn(MidiTrackTableModel.Column.MESSAGE.ordinal()).setCellEditor(eventCellEditor);\r
+ tcm.getColumn(TrackEventListTableModel.Column.MESSAGE.ordinal()).setCellEditor(eventCellEditor);\r
}\r
}\r
- updateButtonStatus();\r
+ setActionEnabled();\r
eventSelectionModel.setSelectionInterval(0,0);\r
}\r
});\r
sequenceListTableModel.fireSequenceChanged(seqSelectionModel);\r
}\r
};\r
- /**\r
- * MIDIトラックリストテーブルビュー\r
- */\r
- private JTable trackListTableView;\r
\r
/**\r
* MIDIイベント選択状態\r
public void valueChanged(ListSelectionEvent e) {\r
if( e.getValueIsAdjusting() ) return;\r
if( ! isSelectionEmpty() ) {\r
- MidiTrackTableModel trackModel = (MidiTrackTableModel)eventListTableView.getModel();\r
+ TrackEventListTableModel trackModel = (TrackEventListTableModel)eventListTableView.getModel();\r
int minIndex = getMinSelectionIndex();\r
if( trackModel.hasTrack() ) {\r
MidiEvent midiEvent = trackModel.getMidiEvent(minIndex);\r
) addSelectionInterval(partnerIndex, partnerIndex);\r
}\r
}\r
- updateButtonStatus();\r
+ setActionEnabled();\r
}\r
});\r
}};\r
*/\r
private JScrollPane scrollableEventTableView;\r
/**\r
- * MIDIトラック数表示ラベル\r
- */\r
- private JLabel tracksLabel = new JLabel("Tracks");\r
- /**\r
* MIDIイベント数表示ラベル\r
*/\r
- private JLabel midiEventsLabel = new JLabel("No track selected");\r
+ private JLabel midiEventsLabel;\r
/**\r
* MIDIイベント入力ダイアログ\r
*/\r
MidiEventDialog eventDialog = new MidiEventDialog();\r
/**\r
- * MIDIイベント除去ボタン\r
- */\r
- private JButton removeEventButton;\r
- /**\r
* Pair note on/off チェックボックス\r
*/\r
private JCheckBox pairNoteCheckbox;\r
/**\r
* 対象トラック\r
*/\r
- private MidiTrackTableModel midiTrackTableModel;\r
+ private TrackEventListTableModel midiTrackTableModel;\r
/**\r
* 対象シーケンス\r
*/\r
- private MidiSequenceTableModel sequenceTableModel;\r
+ private SequenceTrackListTableModel sequenceTableModel;\r
/**\r
* 選択されたイベント\r
*/\r
selectedIndex = -1;\r
currentTick = 0;\r
selectedMidiEvent = null;\r
- midiTrackTableModel = (MidiTrackTableModel)eventListTableView.getModel();\r
+ midiTrackTableModel = (TrackEventListTableModel)eventListTableView.getModel();\r
if( ! eventSelectionModel.isSelectionEmpty() ) {\r
selectedIndex = eventSelectionModel.getMinSelectionIndex();\r
selectedMidiEvent = midiTrackTableModel.getMidiEvent(selectedIndex);\r
{ putValue(NAME,"Paste"); }\r
public void actionPerformed(ActionEvent e) {\r
long tick = tickPositionModel.getTickPosition();\r
- ((MidiTrackTableModel)eventListTableView.getModel()).addMidiEvents(\r
+ ((TrackEventListTableModel)eventListTableView.getModel()).addMidiEvents(\r
copiedEventsToPaste, tick, copiedEventsPPQ\r
);\r
scrollToEventAt(tick);\r
*/\r
private MidiEventCellEditor eventCellEditor = new MidiEventCellEditor();\r
/**\r
- * イベント追加ボタン\r
- */\r
- private JButton addEventButton = new JButton(eventCellEditor.queryAddEventAction) {{\r
- setMargin(ZERO_INSETS);\r
- }};\r
- /**\r
- * イベントジャンプボタン\r
- */\r
- private JButton jumpEventButton = new JButton(eventCellEditor.queryJumpEventAction) {{\r
- setMargin(ZERO_INSETS);\r
- }};\r
- /**\r
- * イベント貼り付けボタン\r
- */\r
- private JButton pasteEventButton = new JButton(eventCellEditor.queryPasteEventAction) {{\r
- setMargin(ZERO_INSETS);\r
- }};\r
- /**\r
* ペースト用にコピーされたMIDIイベントの配列\r
*/\r
private MidiEvent copiedEventsToPaste[];\r
*/\r
private int copiedEventsPPQ = 0;\r
/**\r
- * ã\82¤ã\83\99ã\83³ã\83\88ã\82«ã\83\83ã\83\88ã\83\9cã\82¿ン\r
+ * ã\82¤ã\83\99ã\83³ã\83\88ã\82«ã\83\83ã\83\88ã\82¢ã\82¯ã\82·ã\83§ン\r
*/\r
- private JButton cutEventButton = new JButton("Cut") {{\r
- setMargin(ZERO_INSETS);\r
- addActionListener(\r
- new ActionListener() {\r
- public void actionPerformed(ActionEvent e) {\r
- if( ! confirm("Do you want to cut selected event ?\n選択したMIDIイベントを切り取りますか?"))\r
- return;\r
- MidiTrackTableModel trackTableModel = (MidiTrackTableModel)eventListTableView.getModel();\r
- copiedEventsToPaste = trackTableModel.getMidiEvents(eventSelectionModel);\r
- copiedEventsPPQ = sequenceListTableModel.getSequenceModel(seqSelectionModel).getSequence().getResolution();\r
- trackTableModel.removeMidiEvents(copiedEventsToPaste);\r
- sequenceListTableModel.fireSequenceChanged(seqSelectionModel);\r
- }\r
- }\r
- );\r
- }};\r
+ public Action cutEventAction = new AbstractAction("Cut") {\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ if( ! confirm("Do you want to cut selected event ?\n選択したMIDIイベントを切り取りますか?"))\r
+ return;\r
+ TrackEventListTableModel trackTableModel = (TrackEventListTableModel)eventListTableView.getModel();\r
+ copiedEventsToPaste = trackTableModel.getMidiEvents(eventSelectionModel);\r
+ copiedEventsPPQ = sequenceListTableModel.getSequenceModel(seqSelectionModel).getSequence().getResolution();\r
+ trackTableModel.removeMidiEvents(copiedEventsToPaste);\r
+ sequenceListTableModel.fireSequenceChanged(seqSelectionModel);\r
+ }\r
+ };\r
/**\r
- * ã\82¤ã\83\99ã\83³ã\83\88ã\82³ã\83\94ã\83¼ã\83\9cã\82¿ン\r
+ * ã\82¤ã\83\99ã\83³ã\83\88ã\82³ã\83\94ã\83¼ã\82¢ã\82¯ã\82·ã\83§ン\r
*/\r
- private JButton copyEventButton = new JButton("Copy") {{\r
- setMargin(ZERO_INSETS);\r
- addActionListener(\r
- new ActionListener() {\r
- public void actionPerformed(ActionEvent e) {\r
- MidiTrackTableModel trackTableModel = (MidiTrackTableModel)eventListTableView.getModel();\r
- copiedEventsToPaste = trackTableModel.getMidiEvents(eventSelectionModel);\r
- copiedEventsPPQ = sequenceListTableModel.getSequenceModel(seqSelectionModel).getSequence().getResolution();\r
- updateButtonStatus();\r
- }\r
- }\r
- );\r
- }};\r
+ public Action copyEventAction = new AbstractAction("Copy") {\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ TrackEventListTableModel trackTableModel = (TrackEventListTableModel)eventListTableView.getModel();\r
+ copiedEventsToPaste = trackTableModel.getMidiEvents(eventSelectionModel);\r
+ copiedEventsPPQ = sequenceListTableModel.getSequenceModel(seqSelectionModel).getSequence().getResolution();\r
+ setActionEnabled();\r
+ }\r
+ };\r
+ /**\r
+ * イベント削除アクション\r
+ */\r
+ public Action deleteEventAction = new AbstractAction("Delete", deleteIcon) {\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ if( ! confirm("Do you want to delete selected event ?\n選択したMIDIイベントを削除しますか?"))\r
+ return;\r
+ ((TrackEventListTableModel)eventListTableView.getModel()).removeMidiEvents(eventSelectionModel);\r
+ sequenceListTableModel.fireSequenceChanged(seqSelectionModel);\r
+ }\r
+ };\r
/**\r
* 新しい {@link MidiEditor} を構築します。\r
* @param deviceModelList MIDIデバイスモデルリスト\r
*/\r
public MidiEditor(MidiSequencerModel sequencerModel) {\r
+ sequenceListTableModel = new SequenceListTableModel(sequencerModel);\r
setTitle("MIDI Editor/Playlist - MIDI Chord Helper");\r
setBounds( 150, 200, 850, 500 );\r
setLayout(new FlowLayout());\r
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this, true);\r
- sequenceListTableModel = new SequenceListTableModel(sequencerModel);\r
- eventListTableView = new JTable(\r
- new MidiTrackTableModel(), null, eventSelectionModel\r
- );\r
try {\r
midiFileChooser = new MidiFileChooser();\r
}\r
setMargin(ZERO_INSETS);\r
}});\r
add( Box.createRigidArea(new Dimension(5, 0)) );\r
- add(new JButton(jumpSequenceAction){{\r
- setMargin(ZERO_INSETS);\r
- }});\r
+ add(new JButton(jumpSequenceAction){{ setMargin(ZERO_INSETS); }});\r
if( midiFileChooser != null ) {\r
add(Box.createRigidArea(new Dimension(5, 0)));\r
add(new JButton(midiFileChooser.saveMidiFileAction) {{\r
base64EncodeAction = new AbstractAction("Base64 Encode") {\r
@Override\r
public void actionPerformed(ActionEvent e) {\r
- MidiSequenceTableModel mstm = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
+ SequenceTrackListTableModel mstm = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
base64Dialog.setMIDIData(mstm.getMIDIdata(), mstm.getFilename());\r
base64Dialog.setVisible(true);\r
}\r
}};\r
JPanel trackListPanel = new JPanel() {{\r
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));\r
- add(tracksLabel);\r
+ add(tracksLabel = new JLabel("Tracks"));\r
add(Box.createRigidArea(new Dimension(0, 5)));\r
add(new JScrollPane(\r
trackListTableView = new JTable(\r
- new MidiSequenceTableModel(sequenceListTableModel),\r
+ new SequenceTrackListTableModel(sequenceListTableModel),\r
null,\r
trackSelectionModel\r
) {{\r
- ((MidiSequenceTableModel)getModel()).sizeColumnWidthToFit(getColumnModel());\r
+ ((SequenceTrackListTableModel)getModel()).sizeColumnWidthToFit(getColumnModel());\r
}}\r
));\r
add(Box.createRigidArea(new Dimension(0, 5)));\r
add(new JPanel() {{\r
- add(new JButton(addTrackAction) {{\r
- setMargin(ZERO_INSETS);\r
- }});\r
- add(new JButton(removeTrackAction) {{\r
- setMargin(ZERO_INSETS);\r
- }});\r
+ add(new JButton(addTrackAction) {{ setMargin(ZERO_INSETS); }});\r
+ add(new JButton(removeTrackAction) {{ setMargin(ZERO_INSETS); }});\r
}});\r
}};\r
- removeEventButton = new JButton("Delete", deleteIcon) {{\r
- setMargin(ZERO_INSETS);\r
- addActionListener(\r
- new ActionListener() {\r
- public void actionPerformed(ActionEvent e) {\r
- if( ! confirm("Do you want to delete selected event ?\n選択したMIDIイベントを削除しますか?"))\r
- return;\r
- ((MidiTrackTableModel)eventListTableView.getModel()).removeMidiEvents(eventSelectionModel);\r
- sequenceListTableModel.fireSequenceChanged(seqSelectionModel);\r
- }\r
- }\r
- );\r
- }};\r
JPanel eventListPanel = new JPanel() {{\r
- add(midiEventsLabel);\r
- add(scrollableEventTableView = new JScrollPane(eventListTableView));\r
+ add(midiEventsLabel = new JLabel("No track selected"));\r
+ add(scrollableEventTableView = new JScrollPane(\r
+ eventListTableView = new JTable(\r
+ new TrackEventListTableModel(), null, eventSelectionModel\r
+ )\r
+ ));\r
add(new JPanel() {{\r
add(\r
pairNoteCheckbox = new JCheckBox("Pair NoteON/OFF") {{\r
setModel(eventCellEditor.pairNoteOnOffModel);\r
}}\r
);\r
- add(jumpEventButton);\r
- add(addEventButton);\r
- add(copyEventButton);\r
- add(cutEventButton);\r
- add(pasteEventButton);\r
- add(removeEventButton);\r
+ add(new JButton(eventCellEditor.queryJumpEventAction) {{\r
+ setMargin(ZERO_INSETS);\r
+ }});\r
+ add(new JButton(eventCellEditor.queryAddEventAction) {{\r
+ setMargin(ZERO_INSETS);\r
+ }});\r
+ add(new JButton(copyEventAction) {{ setMargin(ZERO_INSETS); }});\r
+ add(new JButton(cutEventAction) {{ setMargin(ZERO_INSETS); }});\r
+ add(new JButton(eventCellEditor.queryPasteEventAction) {{\r
+ setMargin(ZERO_INSETS);\r
+ }});\r
+ add(new JButton(deleteEventAction) {{ setMargin(ZERO_INSETS); }});\r
}});\r
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));\r
}};\r
setDividerLocation(160);\r
}}\r
);\r
- seqSelectionModel.setSelectionInterval(0,0);\r
sequenceSelectionChanged();\r
}\r
public void dragEnter(DropTargetDragEvent event) {\r
setVisible(true);\r
}\r
/**\r
- * 選択されたシーケンスが変わったことを通知します。\r
+ * MIDIトラックリストテーブルビュー(選択中のシーケンスの中身)\r
+ */\r
+ private JTable trackListTableView;\r
+ /**\r
+ * 選択されたシーケンスが変わったときの動作\r
*/\r
public void sequenceSelectionChanged() {\r
- MidiSequenceTableModel sequenceTableModel = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
- boolean loaded = (sequenceTableModel != null);\r
- if(midiFileChooser != null) midiFileChooser.saveMidiFileAction.setEnabled(loaded);\r
- if(base64EncodeAction != null) base64EncodeAction.setEnabled(loaded);\r
- deleteSequenceAction.setEnabled(loaded);\r
- jumpSequenceAction.setEnabled(loaded);\r
- addTrackAction.setEnabled(loaded);\r
- if(loaded) {\r
+ SequenceTrackListTableModel sequenceModel = sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
+ boolean isSequenceSelected = (sequenceModel != null);\r
+ //\r
+ // ボタンイネーブル状態の更新\r
+ if(midiFileChooser != null)\r
+ midiFileChooser.saveMidiFileAction.setEnabled(isSequenceSelected);\r
+ if(base64EncodeAction != null)\r
+ base64EncodeAction.setEnabled(isSequenceSelected);\r
+ deleteSequenceAction.setEnabled(isSequenceSelected);\r
+ jumpSequenceAction.setEnabled(isSequenceSelected);\r
+ addTrackAction.setEnabled(isSequenceSelected);\r
+ //\r
+ // トラックリストの対象シーケンスを切り替える\r
+ if(isSequenceSelected) {\r
int selectedIndex = seqSelectionModel.getMinSelectionIndex();\r
- trackListTableView.setModel(sequenceTableModel);\r
- TableColumnModel tcm = trackListTableView.getColumnModel();\r
- sequenceTableModel.sizeColumnWidthToFit(tcm);\r
- tcm.getColumn(\r
- MidiSequenceTableModel.Column.RECORD_CHANNEL.ordinal()\r
- ).setCellEditor(\r
- sequenceTableModel.new RecordChannelCellEditor()\r
- );\r
+ trackListTableView.setModel(sequenceModel);\r
+ TableColumnModel trackColumnModel = trackListTableView.getColumnModel();\r
+ sequenceModel.sizeColumnWidthToFit(trackColumnModel);\r
+ int columnIndex = SequenceTrackListTableModel.Column.RECORD_CHANNEL.ordinal();\r
+ TableColumn trackColumn = trackColumnModel.getColumn(columnIndex);\r
+ trackColumn.setCellEditor(sequenceModel.new RecordChannelCellEditor());\r
trackSelectionModel.setSelectionInterval(0,0);\r
tracksLabel.setText(String.format("Tracks (in MIDI file No.%d)", selectedIndex));\r
}\r
else {\r
- trackListTableView.setModel(new MidiSequenceTableModel(sequenceListTableModel));\r
+ trackListTableView.setModel(new SequenceTrackListTableModel(sequenceListTableModel));\r
tracksLabel.setText("Tracks (No MIDI file selected)");\r
}\r
- updateButtonStatus();\r
+ setActionEnabled();\r
}\r
/**\r
* ボタン状態の更新\r
*/\r
- public void updateButtonStatus() {\r
+ public void setActionEnabled() {\r
boolean isTrackSelected = (\r
! trackSelectionModel.isSelectionEmpty() &&\r
sequenceListTableModel.getSequenceModel(seqSelectionModel) != null &&\r
);\r
removeTrackAction.setEnabled(isTrackSelected);\r
TableModel tm = eventListTableView.getModel();\r
- if( ! (tm instanceof MidiTrackTableModel) )\r
+ if( ! (tm instanceof TrackEventListTableModel) )\r
return;\r
- MidiTrackTableModel trackTableModel = (MidiTrackTableModel)tm;\r
+ //\r
+ //\r
+ TrackEventListTableModel trackTableModel = (TrackEventListTableModel)tm;\r
jumpSequenceAction.setEnabled(\r
trackTableModel != null && trackTableModel.getRowCount() > 0\r
);\r
trackTableModel == null || trackTableModel.getRowCount() == 0\r
) && isTrackSelected\r
);\r
- copyEventButton.setEnabled(isEventSelected);\r
- removeEventButton.setEnabled(isEventSelected);\r
- cutEventButton.setEnabled(isEventSelected);\r
- jumpEventButton.setEnabled(trackTableModel != null && isTrackSelected);\r
- addEventButton.setEnabled(trackTableModel != null && isTrackSelected);\r
- pasteEventButton.setEnabled(\r
+ //\r
+ // イベント操作のイネーブル状態更新\r
+ copyEventAction.setEnabled(isEventSelected);\r
+ deleteEventAction.setEnabled(isEventSelected);\r
+ cutEventAction.setEnabled(isEventSelected);\r
+ eventCellEditor.queryJumpEventAction.setEnabled(\r
+ trackTableModel != null && isTrackSelected\r
+ );\r
+ eventCellEditor.queryAddEventAction.setEnabled(\r
+ trackTableModel != null && isTrackSelected\r
+ );\r
+ eventCellEditor.queryPasteEventAction.setEnabled(\r
trackTableModel != null && isTrackSelected &&\r
copiedEventsToPaste != null && copiedEventsToPaste.length > 0\r
);\r
}\r
- public String getMIDIdataBase64() {\r
- base64Dialog.setMIDIData(\r
- sequenceListTableModel.sequencerModel.getSequenceTableModel().getMIDIdata()\r
- );\r
- return base64Dialog.getBase64Data();\r
- }\r
/**\r
* MIDIシーケンスを追加します。\r
* シーケンサーが停止中の場合、追加したシーケンスから再生を開始します。\r
* @return 選択されているシーケンスが録音可能な設定ならtrue\r
*/\r
public boolean isRecordable() {\r
- MidiSequenceTableModel sequenceTableModel =\r
+ SequenceTrackListTableModel sequenceTableModel =\r
sequenceListTableModel.getSequenceModel(seqSelectionModel);\r
return sequenceTableModel == null ? false : sequenceTableModel.isRecordable();\r
}\r
* @param tick MIDI tick\r
*/\r
public void scrollToEventAt(long tick) {\r
- MidiTrackTableModel trackModel = (MidiTrackTableModel)eventListTableView.getModel();\r
+ TrackEventListTableModel trackModel = (TrackEventListTableModel)eventListTableView.getModel();\r
int index = trackModel.tickToIndex(tick);\r
scrollableEventTableView.getVerticalScrollBar().setValue(\r
index * eventListTableView.getRowHeight()\r
"x 8",\r
"x 16",\r
};\r
- private JLabel titleLabel = new JLabel("Speed:");\r
+ private JLabel titleLabel;\r
private JSlider slider;\r
- private JComboBox<String> scaleComboBox = new JComboBox<String>(items) {{\r
- addActionListener(new ActionListener() {\r
- @Override\r
- public void actionPerformed(ActionEvent e) {\r
- int index = getSelectedIndex();\r
- BoundedRangeModel model = slider.getModel();\r
- if( index == 0 ) {\r
- model.setValue(0);\r
- slider.setVisible(false);\r
- titleLabel.setVisible(true);\r
- }\r
- else {\r
- int maxValue = ( index == 1 ? 7 : (index-1)*12 );\r
- model.setMinimum(-maxValue);\r
- model.setMaximum(maxValue);\r
- slider.setMajorTickSpacing( index == 1 ? 7 : 12 );\r
- slider.setMinorTickSpacing( index > 3 ? 12 : 1 );\r
- slider.setVisible(true);\r
- titleLabel.setVisible(false);\r
- }\r
- }\r
- });\r
- }};\r
public SequencerSpeedSlider(BoundedRangeModel model) {\r
- add(titleLabel);\r
+ add(titleLabel = new JLabel("Speed:"));\r
add(slider = new JSlider(model){{\r
setPaintTicks(true);\r
setMajorTickSpacing(12);\r
setMinorTickSpacing(1);\r
setVisible(false);\r
}});\r
- add(scaleComboBox);\r
+ add(new JComboBox<String>(items) {{\r
+ addActionListener(new ActionListener() {\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ int index = getSelectedIndex();\r
+ BoundedRangeModel model = slider.getModel();\r
+ if( index == 0 ) {\r
+ model.setValue(0);\r
+ slider.setVisible(false);\r
+ titleLabel.setVisible(true);\r
+ }\r
+ else {\r
+ int maxValue = ( index == 1 ? 7 : (index-1)*12 );\r
+ model.setMinimum(-maxValue);\r
+ model.setMaximum(maxValue);\r
+ slider.setMajorTickSpacing( index == 1 ? 7 : 12 );\r
+ slider.setMinorTickSpacing( index > 3 ? 12 : 1 );\r
+ slider.setVisible(true);\r
+ titleLabel.setVisible(false);\r
+ }\r
+ }\r
+ });\r
+ }});\r
}\r
}\r
\r
secondPosition = sec;\r
fireTableCellUpdated(getLoadedIndex(), Column.SEQ_POSITION.ordinal());\r
}\r
- private List<MidiSequenceTableModel> sequenceList = new ArrayList<>();\r
+ private List<SequenceTrackListTableModel> sequenceList = new ArrayList<>();\r
@Override\r
public int getRowCount() {\r
return sequenceList.size();\r
public int getTotalSeconds() {\r
int total = 0;\r
long usec;\r
- for( MidiSequenceTableModel m : sequenceList ) {\r
+ for( SequenceTrackListTableModel m : sequenceList ) {\r
usec = m.getSequence().getMicrosecondLength();\r
total += (int)( (usec < 0 ? usec += 0x100000000L : usec)/1000L/1000L );\r
}\r
* @return 未保存の修正内容を持つシーケンスがあればtrue\r
*/\r
public boolean isModified() {\r
- for( MidiSequenceTableModel m : sequenceList ) {\r
+ for( SequenceTrackListTableModel m : sequenceList ) {\r
if( m.isModified() ) return true;\r
}\r
return false;\r
* @param selectionModel 選択状態\r
* @return 選択されたMIDIシーケンスのテーブルモデル\r
*/\r
- public MidiSequenceTableModel getSequenceModel(ListSelectionModel selectionModel) {\r
+ public SequenceTrackListTableModel getSequenceModel(ListSelectionModel selectionModel) {\r
if( selectionModel.isSelectionEmpty() )\r
return null;\r
int selectedIndex = selectionModel.getMinSelectionIndex();\r
* 指定されたシーケンスが変更されたことを通知します。\r
* @param sequenceTableModel MIDIシーケンスモデル\r
*/\r
- public void fireSequenceChanged(MidiSequenceTableModel sequenceTableModel) {\r
+ public void fireSequenceChanged(SequenceTrackListTableModel sequenceTableModel) {\r
int index = sequenceList.indexOf(sequenceTableModel);\r
if( index < 0 ) return;\r
fireSequenceChanged(index,index);\r
*/\r
public void fireSequenceChanged(int minIndex, int maxIndex) {\r
for( int index = minIndex; index <= maxIndex; index++ ) {\r
- MidiSequenceTableModel model = sequenceList.get(index);\r
+ SequenceTrackListTableModel model = sequenceList.get(index);\r
model.setModified(true);\r
if( sequencerModel.getSequencer().getSequence() == model.getSequence() ) {\r
// シーケンサーに対して、同じシーケンスを再度セットする。\r
* @return 追加されたシーケンスのインデックス(先頭が 0)\r
*/\r
public int addSequence(Sequence seq, String filename) {\r
- sequenceList.add(new MidiSequenceTableModel(this, seq, filename));\r
+ sequenceList.add(new SequenceTrackListTableModel(this, seq, filename));\r
int lastIndex = sequenceList.size() - 1;\r
fireTableRowsInserted(lastIndex, lastIndex);\r
return lastIndex;\r
int oldIndex = getLoadedIndex();\r
if(index == oldIndex)\r
return;\r
- MidiSequenceTableModel sequenceTableModel = sequenceList.get(index);\r
+ SequenceTrackListTableModel sequenceTableModel = sequenceList.get(index);\r
sequencerModel.setSequenceTableModel(sequenceTableModel);\r
//\r
// 表示更新のための変更通知\r
/**\r
* MIDIシーケンス(トラックリスト)を表すテーブルモデル\r
*/\r
-class MidiSequenceTableModel extends AbstractTableModel {\r
+class SequenceTrackListTableModel extends AbstractTableModel {\r
/**\r
* 列の列挙型\r
*/\r
/**\r
* トラックリスト\r
*/\r
- private List<MidiTrackTableModel> trackModelList = new ArrayList<>();\r
+ private List<TrackEventListTableModel> trackModelList = new ArrayList<>();\r
/**\r
* 記録するMIDIチャンネル\r
*/\r
*/\r
private SequenceListTableModel sequenceListTableModel;\r
/**\r
- * 空の {@link MidiSequenceTableModel} を構築します。\r
+ * 空の {@link SequenceTrackListTableModel} を構築します。\r
* @param sequenceListTableModel 親のプレイリスト\r
*/\r
- public MidiSequenceTableModel(SequenceListTableModel sequenceListTableModel) {\r
+ public SequenceTrackListTableModel(SequenceListTableModel sequenceListTableModel) {\r
this.sequenceListTableModel = sequenceListTableModel;\r
}\r
/**\r
- * MIDIシーケンスとファイル名から {@link MidiSequenceTableModel} を構築します。\r
+ * MIDIシーケンスとファイル名から {@link SequenceTrackListTableModel} を構築します。\r
* @param sequenceListTableModel 親のプレイリスト\r
* @param sequence MIDIシーケンス\r
* @param filename ファイル名\r
*/\r
- public MidiSequenceTableModel(\r
+ public SequenceTrackListTableModel(\r
SequenceListTableModel sequenceListTableModel,\r
Sequence sequence,\r
String filename\r
}\r
if( --ch <= 0 || ch > MIDISpec.MAX_CHANNELS )\r
break;\r
- MidiTrackTableModel trackTableModel = trackModelList.get(row);\r
+ TrackEventListTableModel trackTableModel = trackModelList.get(row);\r
if( ch == trackTableModel.getChannel() ) break;\r
trackTableModel.setChannel(ch);\r
setModified(true);\r
fireTimeSignatureChanged();\r
Track tracks[] = sequence.getTracks();\r
for(Track track : tracks) {\r
- trackModelList.add(new MidiTrackTableModel(track, this));\r
+ trackModelList.add(new TrackEventListTableModel(track, this));\r
}\r
fireTableRowsInserted(0, tracks.length-1);\r
}\r
* @param index トラックのインデックス\r
* @return トラックモデル(見つからない場合null)\r
*/\r
- public MidiTrackTableModel getTrackModel(int index) {\r
+ public TrackEventListTableModel getTrackModel(int index) {\r
Track tracks[] = sequence.getTracks();\r
if( tracks.length != 0 ) {\r
Track track = tracks[index];\r
- for( MidiTrackTableModel model : trackModelList )\r
+ for( TrackEventListTableModel model : trackModelList )\r
if( model.getTrack() == track )\r
return model;\r
}\r
* @return 追加したトラックのインデックス(先頭 0)\r
*/\r
public int createTrack() {\r
- trackModelList.add(new MidiTrackTableModel(sequence.createTrack(), this));\r
+ trackModelList.add(new TrackEventListTableModel(sequence.createTrack(), this));\r
int lastRow = sequence.getTracks().length - 1;\r
fireTableRowsInserted(lastRow, lastRow);\r
return lastRow;\r
/**\r
* MIDIトラック(MIDIイベントリスト)テーブルモデル\r
*/\r
-class MidiTrackTableModel extends AbstractTableModel {\r
+class TrackEventListTableModel extends AbstractTableModel {\r
/**\r
* 列\r
*/\r
/**\r
* 親のシーケンスモデル\r
*/\r
- private MidiSequenceTableModel parent;\r
+ private SequenceTrackListTableModel parent;\r
/**\r
* 空のMIDIトラックモデルを構築します。\r
*/\r
- public MidiTrackTableModel() { }\r
+ public TrackEventListTableModel() { }\r
/**\r
* シーケンスに連動する空のMIDIトラックモデルを構築します。\r
* @parent 親のシーケンステーブルモデル\r
*/\r
- public MidiTrackTableModel(MidiSequenceTableModel parent) {\r
+ public TrackEventListTableModel(SequenceTrackListTableModel parent) {\r
this.parent = parent;\r
}\r
/**\r
* @param track ラップするMIDIトラック\r
* @param parent 親のシーケンスモデル\r
*/\r
- public MidiTrackTableModel(Track track, MidiSequenceTableModel parent) {\r
+ public TrackEventListTableModel(Track track, SequenceTrackListTableModel parent) {\r
this.track = track;\r
this.parent = parent;\r
}\r