/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSChannelOutputRoutingDlg.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/std/JSChannelOutputRoutingDlg.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1743 - (show annotations) (download)
Sat May 31 23:04:01 2008 UTC (15 years, 10 months ago) by iliev
File size: 4435 byte(s)
* Renamed the column labels in the Channel Routing dialog: The column
  representing the sampler channel's audio channels is "Audio In" and
  the column representing the audio device's channels is "Audio Out"
* Remember the last used tab in the Preferences dialog
* Fantasia: The sampler channels are now referenced by their position
  in the list, not by their ID
* Fantasia: Implemented options to show the channel number and/or the MIDI
  input port/channel on the sampler channel screen when using Small View
  (choose Edit/Preferences, then click the `Channels' tab)
* Fantasia: Migrated to substance 5

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * JSampler is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with JSampler; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 package org.jsampler.view.std;
24
25 import java.awt.Dimension;
26 import java.awt.Frame;
27
28 import javax.swing.DefaultCellEditor;
29 import javax.swing.JComboBox;
30 import javax.swing.JScrollPane;
31 import javax.swing.JTable;
32
33 import javax.swing.table.AbstractTableModel;
34 import javax.swing.table.TableColumn;
35 import javax.swing.table.JTableHeader;
36
37 import net.sf.juife.InformationDialog;
38 import net.sf.juife.JuifeUtils;
39
40 import org.jsampler.AudioDeviceModel;
41 import org.jsampler.CC;
42 import org.jsampler.task.Channel.SetAudioOutputChannel;
43
44 import org.linuxsampler.lscp.SamplerChannel;
45
46 import static org.jsampler.view.std.StdI18n.i18n;
47
48
49 /**
50 *
51 * @author Grigor Iliev
52 */
53 public class JSChannelOutputRoutingDlg extends InformationDialog {
54 private final ChannelRoutingTable channelRoutingTable;
55 private SamplerChannel channel;
56
57
58 /**
59 * Creates a new instance of JSChannelOutputRoutingDlg
60 */
61 public
62 JSChannelOutputRoutingDlg(Frame owner, SamplerChannel channel) {
63 super(owner, i18n.getLabel("JSChannelOutputRoutingDlg.title"));
64 this.channel = channel;
65
66 channelRoutingTable = new ChannelRoutingTable();
67 JScrollPane sp = new JScrollPane(channelRoutingTable);
68
69 sp.setPreferredSize (
70 JuifeUtils.getUnionSize(sp.getMinimumSize(), new Dimension(200, 150))
71 );
72
73 setMainPane(sp);
74
75
76 }
77
78 class ChannelRoutingTable extends JTable {
79 private String[] columnToolTips = {
80 i18n.getLabel("JSChannelOutputRoutingDlg.ttAudioIn", channel.getChannelId()),
81 i18n.getLabel("JSChannelOutputRoutingDlg.ttAudioOut"),
82 };
83
84 ChannelRoutingTable() {
85 super(new ChannelRoutingTableModel());
86
87 JComboBox cb = new JComboBox();
88 int devId = channel.getAudioOutputDevice();
89 AudioDeviceModel adm = CC.getSamplerModel().getAudioDeviceById(devId);
90
91 if(adm == null) {
92 setEnabled(false);
93 } else {
94 int chns = adm.getDeviceInfo().getAudioChannelCount();
95 for(Integer i = 0; i < chns; i++) cb.addItem(i);
96 }
97
98 TableColumn column = getColumnModel().getColumn(1);
99 column.setCellEditor(new DefaultCellEditor(cb));
100 }
101
102 protected JTableHeader
103 createDefaultTableHeader() {
104 return new JTableHeader(columnModel) {
105 public String getToolTipText(java.awt.event.MouseEvent e) {
106 java.awt.Point p = e.getPoint();
107 int i = columnModel.getColumnIndexAtX(p.x);
108 i = columnModel.getColumn(i).getModelIndex();
109 return columnToolTips[i];
110 }
111 };
112 }
113 }
114
115 class ChannelRoutingTableModel extends AbstractTableModel {
116 private String[] columnNames = {
117 i18n.getLabel("JSChannelOutputRoutingDlg.audioIn"),
118 i18n.getLabel("JSChannelOutputRoutingDlg.audioOut")
119 };
120
121 ChannelRoutingTableModel() {
122
123 }
124
125 public int
126 getColumnCount() { return columnNames.length; }
127
128 public String
129 getColumnName(int column) { return columnNames[column]; }
130
131 public int
132 getRowCount() { return channel.getAudioOutputChannels(); }
133
134 public Object
135 getValueAt(int row, int column) {
136 switch(column) {
137 case 0:
138 return row;
139 case 1:
140 return channel.getAudioOutputRouting()[row];
141 default: return null;
142 }
143
144 }
145
146 public boolean
147 isCellEditable(int row, int column) {
148 switch(column) {
149 case 0:
150 return false;
151 case 1:
152 return true;
153 default: return false;
154 }
155 }
156
157 public void
158 setValueAt(Object value, int row, int column) {
159 if(column == 0) return;
160 int c = channel.getChannelId();
161 int o = (Integer)getValueAt(row, 0);
162 int i = (Integer)value;
163 CC.getTaskQueue().add(new SetAudioOutputChannel(c, o, i));
164 channel.getAudioOutputRouting()[row] = i;
165
166 fireTableCellUpdated(row, column);
167 }
168 }
169 }

  ViewVC Help
Powered by ViewVC