*/
public static class VersionInfo {
public static final String NAME = "MIDI Chord Helper";
- public static final String VERSION = "Ver.20160622.1";
+ public static final String VERSION = "Ver.20160623.1";
public static final String COPYRIGHT = "Copyright (C) 2004-2016";
public static final String AUTHER = "@きよし - Akiyoshi Kamide";
public static final String URL = "http://www.yk.rim.or.jp/~kamide/music/chordhelper/";
*/
public class ReceiverListModel extends AbstractListModel<Receiver> {
protected MidiDeviceModel deviceModel;
- public ReceiverListModel(MidiDeviceModel deviceModel) {
- this.deviceModel = deviceModel;
- }
+ public ReceiverListModel(MidiDeviceModel deviceModel) { this.deviceModel = deviceModel; }
@Override
public Receiver getElementAt(int index) {
return deviceModel.getMidiDevice().getReceivers().get(index);
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
-import javax.swing.JLabel;
import javax.swing.JList;
-import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
/**
*/
public class ReceiverListView extends JList<Receiver> {
/**
- * レシーバを描画するクラス
+ * このリストによって表示される{@link Receiver}のリストを保持するデータモデルを返します。
+ * @return 表示される{@link Receiver}のリストを提供するデータモデル
*/
- private static class CellRenderer extends JLabel implements ListCellRenderer<Receiver> {
- public Component getListCellRendererComponent(JList<? extends Receiver> list,
- Receiver value, int index, boolean isSelected, boolean cellHasFocus)
- {
- setEnabled(list.isEnabled());
- setFont(list.getFont());
- setOpaque(true);
- if (isSelected) {
- setBackground(list.getSelectionBackground());
- setForeground(list.getSelectionForeground());
- } else {
- setBackground(list.getBackground());
- setForeground(list.getForeground());
- }
- setIcon(MidiDeviceDialog.MIDI_CONNECTER_ICON);
- setToolTipText("受信端子(Rx):ドラッグ&ドロップしてTxに接続できます。");
- return this;
- }
- }
+ @Override
+ public ReceiverListModel getModel() { return (ReceiverListModel) super.getModel(); }
/**
* 引数で指定された{@link Receiver}のセル範囲を示す、
* リストの座標系内の境界の矩形を返します。対応するセルがない場合はnullを返します。
return getCellBounds(index,index);
}
/**
- * このリストによって表示される{@link Receiver}のリストを保持するデータモデルを返します。
- * @return 表示される{@link Receiver}のリストを提供するデータモデル
- */
- @Override
- public ReceiverListModel getModel() {
- return (ReceiverListModel) super.getModel();
- }
- /**
* 仮想MIDI端子リストビューを生成します。
* @param model このビューから参照されるデータモデル
* @param cablePane MIDIケーブル描画面
*/
public ReceiverListView(ReceiverListModel model, MidiCablePane cablePane) {
super(model);
- setCellRenderer(new CellRenderer());
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setLayoutOrientation(JList.HORIZONTAL_WRAP);
setVisibleRowCount(0);
- //
- // レシーバのドラッグを受け付ける
+ setCellRenderer(new TransceiverListCellRenderer<Receiver>() {
+ public Component getListCellRendererComponent(JList<? extends Receiver> list,
+ Receiver value, int index, boolean isSelected, boolean cellHasFocus)
+ {
+ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ setToolTipText("受信端子(Rx):ドラッグ&ドロップしてTxに接続できます。");
+ return this;
+ }
+ });
+ DragSource dragSource = new DragSource();
DragGestureListener dgl = new DragGestureListener() {
@Override
public void dragGestureRecognized(DragGestureEvent event) {
if( (event.getDragAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0 ) return;
- MidiCablePane.dragging.setData(getModel().getElementAt(locationToIndex(event.getDragOrigin())));
+ Receiver rx = getModel().getElementAt(locationToIndex(event.getDragOrigin()));
+ MidiCablePane.dragging.setData(rx);
event.startDrag(DragSource.DefaultLinkDrop, MidiCablePane.dragging, cablePane.dragSourceListener);
}
};
- DragSource dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dgl);
dragSource.addDragSourceMotionListener(cablePane.dragSourceMotionListener);
//
@Override
public void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
- int maskedBits = event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE;
- if( maskedBits == 0 ) {
+ if( (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0 ) {
event.dropComplete(false);
return;
}
--- /dev/null
+package camidion.chordhelper.mididevice;
+
+import java.awt.Component;
+
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+
+public class TransceiverListCellRenderer<E> extends JLabel implements ListCellRenderer<E> {
+ public Component getListCellRendererComponent(JList<? extends E> list,
+ E value, int index, boolean isSelected, boolean cellHasFocus)
+ {
+ setEnabled(list.isEnabled());
+ setFont(list.getFont());
+ setOpaque(true);
+ if (isSelected) {
+ setBackground(list.getSelectionBackground());
+ setForeground(list.getSelectionForeground());
+ } else {
+ setBackground(list.getBackground());
+ setForeground(list.getForeground());
+ }
+ setIcon(MidiDeviceDialog.MIDI_CONNECTER_ICON);
+ return this;
+ }
+}
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
-import javax.swing.JLabel;
import javax.swing.JList;
-import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
/**
*/
public class TransmitterListView extends JList<Transmitter> {
/**
- * トランスミッタを描画するクラス
+ * このリストによって表示される{@link Transmitter}のリストを保持するデータモデルを返します。
+ * @return 表示される{@link Transmitter}のリストを提供するデータモデル
*/
- private static class CellRenderer extends JLabel implements ListCellRenderer<Transmitter> {
- public Component getListCellRendererComponent(JList<? extends Transmitter> list,
- Transmitter value, int index, boolean isSelected, boolean cellHasFocus)
- {
- setEnabled(list.isEnabled());
- setFont(list.getFont());
- setOpaque(true);
- if (isSelected) {
- setBackground(list.getSelectionBackground());
- setForeground(list.getSelectionForeground());
- } else {
- setBackground(list.getBackground());
- setForeground(list.getForeground());
- }
- setIcon(MidiDeviceDialog.MIDI_CONNECTER_ICON);
- if( value instanceof DummyTransmitter ) {
- setToolTipText("未接続の送信端子(Tx):ドラッグ&ドロップしてRxに接続できます。");
- } else {
- setToolTipText("接続済の送信端子(Tx):ドラッグ&ドロップして接続先Rxを変更、または切断できます。");
- }
- return this;
- }
- }
+ @Override
+ public TransmitterListModel getModel() { return (TransmitterListModel) super.getModel(); }
/**
* 引数で指定された{@link Transmitter}のセル範囲を示す、
* リストの座標系内の境界の矩形を返します。対応するセルがない場合はnullを返します。
return getCellBounds(index,index);
}
/**
- * このリストによって表示される{@link Transmitter}のリストを保持するデータモデルを返します。
- * @return 表示される{@link Transmitter}のリストを提供するデータモデル
- */
- @Override
- public TransmitterListModel getModel() {
- return (TransmitterListModel) super.getModel();
- }
- /**
* 仮想MIDI端子リストビューを生成します。
* @param model このビューから参照されるデータモデル
* @param cablePane MIDIケーブル描画面
*/
public TransmitterListView(TransmitterListModel model, MidiCablePane cablePane) {
super(model);
- setCellRenderer(new CellRenderer());
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setLayoutOrientation(JList.HORIZONTAL_WRAP);
setVisibleRowCount(0);
- //
- // トランスミッタのドラッグを受け付ける
+ setCellRenderer(new TransceiverListCellRenderer<Transmitter>() {
+ @Override
+ public Component getListCellRendererComponent(JList<? extends Transmitter> list,
+ Transmitter value, int index, boolean isSelected, boolean cellHasFocus)
+ {
+ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ if( value instanceof DummyTransmitter ) {
+ setToolTipText("未接続の送信端子(Tx):ドラッグ&ドロップしてRxに接続できます。");
+ } else {
+ setToolTipText("接続済の送信端子(Tx):ドラッグ&ドロップして接続先Rxを変更、または切断できます。");
+ }
+ return this;
+ }
+ });
+ DragSource dragSource = new DragSource();
DragGestureListener dgl = new DragGestureListener() {
@Override
public void dragGestureRecognized(DragGestureEvent event) {
});
}
};
- DragSource dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dgl);
dragSource.addDragSourceMotionListener(cablePane.dragSourceMotionListener);
//
@Override
public void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
- int maskedBits = event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE;
- if( maskedBits == 0 ) {
+ if( (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0 ) {
event.dropComplete(false);
return;
}