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

Diff of /jsampler/trunk/src/org/jsampler/view/std/JSChannelsDefaultSettingsPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1333 by iliev, Thu Aug 30 22:44:29 2007 UTC revision 1334 by iliev, Sun Sep 9 17:43:30 2007 UTC
# Line 23  Line 23 
23  package org.jsampler.view.std;  package org.jsampler.view.std;
24    
25  import java.awt.Dialog;  import java.awt.Dialog;
26    import java.awt.Dimension;
27  import java.awt.GridBagConstraints;  import java.awt.GridBagConstraints;
28  import java.awt.GridBagLayout;  import java.awt.GridBagLayout;
29  import java.awt.Insets;  import java.awt.Insets;
# Line 31  import java.awt.event.ActionEvent; Line 32  import java.awt.event.ActionEvent;
32  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
33    
34  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
35    import javax.swing.Box;
36    import javax.swing.BoxLayout;
37  import javax.swing.JComboBox;  import javax.swing.JComboBox;
38  import javax.swing.JDialog;  import javax.swing.JDialog;
39  import javax.swing.JLabel;  import javax.swing.JLabel;
40    import javax.swing.JSlider;
41  import javax.swing.JPanel;  import javax.swing.JPanel;
42    
43    import javax.swing.event.ChangeEvent;
44    import javax.swing.event.ChangeListener;
45    
46  import net.sf.juife.InformationDialog;  import net.sf.juife.InformationDialog;
47    import net.sf.juife.JuifeUtils;
48    
49  import org.linuxsampler.lscp.SamplerEngine;  import org.linuxsampler.lscp.SamplerEngine;
50    
# Line 61  public class JSChannelsDefaultSettingsPa Line 69  public class JSChannelsDefaultSettingsPa
69          private final JLabel lAudioOutput =          private final JLabel lAudioOutput =
70                  new JLabel(i18n.getLabel("JSChannelsDefaultSettingsPane.lAudioOutput"));                  new JLabel(i18n.getLabel("JSChannelsDefaultSettingsPane.lAudioOutput"));
71                    
72            private final JLabel lChannelVolume =
73                    new JLabel(i18n.getLabel("JSChannelsDefaultSettingsPane.lChannelVolume"));
74            
75            private final JLabel lMidiMap =
76                    new JLabel(i18n.getLabel("JSChannelsDefaultSettingsPane.lMidiMap"));
77            
78          private final JComboBox cbDefaultEngine = new JComboBox();          private final JComboBox cbDefaultEngine = new JComboBox();
79          private final JComboBox cbMidiInput = new JComboBox();          private final JComboBox cbMidiInput = new JComboBox();
80          private final JComboBox cbAudioOutput = new JComboBox();          private final JComboBox cbAudioOutput = new JComboBox();
81            private final JSlider slChannelVolume = new JSlider(0, 100);
82            private final JComboBox cbMidiMap = new JComboBox();
83            
84            private final JLabel lVolume = new JLabel();
85                    
86          private final static String strFirstDevice =          private final static String strFirstDevice =
87                  i18n.getLabel("JSChannelsDefaultSettingsPane.strFirstDevice");                  i18n.getLabel("JSChannelsDefaultSettingsPane.strFirstDevice");
# Line 71  public class JSChannelsDefaultSettingsPa Line 89  public class JSChannelsDefaultSettingsPa
89          private final static String strFirstDeviceNextChannel =          private final static String strFirstDeviceNextChannel =
90                  i18n.getLabel("JSChannelsDefaultSettingsPane.strFirstDeviceNextChannel");                  i18n.getLabel("JSChannelsDefaultSettingsPane.strFirstDeviceNextChannel");
91                    
92            private class NoMap {
93                    public String
94                    toString() { return "[None]"; }
95            }
96            
97            private NoMap noMap = new NoMap();
98            
99            private class DefaultMap {
100                    public String
101                    toString() { return "[Default]"; }
102            }
103            
104            private DefaultMap defaultMap = new DefaultMap();
105            
106          /** Creates a new instance of <code>JSChannelsDefaultSettingsPane</code> */          /** Creates a new instance of <code>JSChannelsDefaultSettingsPane</code> */
107          public          public
108          JSChannelsDefaultSettingsPane() {          JSChannelsDefaultSettingsPane() {
# Line 97  public class JSChannelsDefaultSettingsPa Line 129  public class JSChannelsDefaultSettingsPa
129                  c.gridy = 2;                  c.gridy = 2;
130                  gridbag.setConstraints(lAudioOutput, c);                  gridbag.setConstraints(lAudioOutput, c);
131                  add(lAudioOutput);                  add(lAudioOutput);
132    
133                    c.gridx = 0;
134                    c.gridy = 3;
135                    gridbag.setConstraints(lMidiMap, c);
136                    add(lMidiMap);
137    
138                    c.gridx = 0;
139                    c.gridy = 4;
140                    gridbag.setConstraints(lChannelVolume, c);
141                    add(lChannelVolume);
142                                    
143                  c.fill = GridBagConstraints.HORIZONTAL;                  c.fill = GridBagConstraints.HORIZONTAL;
144                  c.gridx = 1;                  c.gridx = 1;
# Line 116  public class JSChannelsDefaultSettingsPa Line 158  public class JSChannelsDefaultSettingsPa
158                  gridbag.setConstraints(cbAudioOutput, c);                  gridbag.setConstraints(cbAudioOutput, c);
159                  add(cbAudioOutput);                  add(cbAudioOutput);
160                                    
161                    c.gridx = 1;
162                    c.gridy = 3;
163                    gridbag.setConstraints(cbMidiMap, c);
164                    add(cbMidiMap);
165                    
166                    JPanel volumePane = new JPanel();
167                    volumePane.setOpaque(false);
168                    volumePane.setLayout(new BoxLayout(volumePane, BoxLayout.X_AXIS));
169                    
170                    Dimension d = slChannelVolume.getPreferredSize();
171                    slChannelVolume.setMaximumSize(new Dimension(d.width > 300 ? d.width : 300, d.height));
172                    slChannelVolume.setOpaque(false);
173                    volumePane.add(slChannelVolume);
174                    
175                    volumePane.add(Box.createRigidArea(new Dimension(6, 0)));
176                    
177                    lVolume.setHorizontalAlignment(lVolume.RIGHT);
178                    
179                    // We use this to set the size of the lVolume that will be used in setVolume()
180                    // to prevent the frequent resizing of lVolume
181                    lVolume.setText("100%");
182                    
183                    volumePane.add(lVolume);
184                    
185                    slChannelVolume.addChangeListener(new ChangeListener() {
186                            public void
187                            stateChanged(ChangeEvent e) { updateVolume(); }
188                    });
189                    
190                    int v = preferences().getIntProperty(DEFAULT_CHANNEL_VOLUME);
191                    slChannelVolume.setValue(v);
192                    
193                    c.gridx = 1;
194                    c.gridy = 4;
195                    gridbag.setConstraints(volumePane, c);
196                    add(volumePane);
197                    
198                  for(SamplerEngine e : CC.getSamplerModel().getEngines()) {                  for(SamplerEngine e : CC.getSamplerModel().getEngines()) {
199                          cbDefaultEngine.addItem(e);                          cbDefaultEngine.addItem(e);
200                  }                  }
# Line 152  public class JSChannelsDefaultSettingsPa Line 231  public class JSChannelsDefaultSettingsPa
231                          public void                          public void
232                          actionPerformed(ActionEvent e) { changeDefaultAudioOutput(); }                          actionPerformed(ActionEvent e) { changeDefaultAudioOutput(); }
233                  });                  });
234                    
235                    cbMidiMap.addItem(noMap);
236                    cbMidiMap.addItem(defaultMap);
237                    
238                    String midiMap = preferences().getStringProperty(DEFAULT_MIDI_INSTRUMENT_MAP);
239                    if(midiMap.equals("midiInstrumentMap.none")) {
240                            cbMidiMap.setSelectedItem(noMap);
241                    } else if(midiMap.equals("midiInstrumentMap.default")) {
242                            cbMidiMap.setSelectedItem(defaultMap);
243                    }
244                    
245                    cbMidiMap.addActionListener(new ActionListener() {
246                            public void
247                            actionPerformed(ActionEvent e) { changeDefaultMidiMap(); }
248                    });
249          }          }
250                    
251          public JDialog          public JDialog
# Line 191  public class JSChannelsDefaultSettingsPa Line 285  public class JSChannelsDefaultSettingsPa
285                  }                  }
286          }          }
287                    
288            private void
289            changeDefaultMidiMap() {
290                    Object o = cbMidiMap.getSelectedItem();
291                    if(o == null) return;
292                    String s = DEFAULT_MIDI_INSTRUMENT_MAP;
293                    if(o == noMap) {
294                            preferences().setStringProperty(s, "midiInstrumentMap.none");
295                    } else if(o == defaultMap) {
296                            preferences().setStringProperty(s, "midiInstrumentMap.default");
297                    }
298            }
299            
300            private void
301            updateVolume() {
302                    int volume = slChannelVolume.getValue();
303                    Dimension d = lVolume.getPreferredSize();
304                    lVolume.setText(String.valueOf(volume) + '%');
305                    d = JuifeUtils.getUnionSize(d, lVolume.getPreferredSize());
306                    lVolume.setMinimumSize(d);
307                    lVolume.setPreferredSize(d);
308                    lVolume.setMaximumSize(d);
309                    
310                    if(slChannelVolume.getValueIsAdjusting()) return;
311                    preferences().setIntProperty(DEFAULT_CHANNEL_VOLUME, slChannelVolume.getValue());
312            }
313            
314          private static JSPrefs          private static JSPrefs
315          preferences() { return CC.getViewConfig().preferences(); }          preferences() { return CC.getViewConfig().preferences(); }
316  }  }

Legend:
Removed from v.1333  
changed lines
  Added in v.1334

  ViewVC Help
Powered by ViewVC