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

Contents of /jsampler/trunk/src/org/jsampler/view/JSViewConfig.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2148 - (show annotations) (download)
Thu Oct 14 14:45:42 2010 UTC (8 years, 2 months ago) by iliev
File size: 4640 byte(s)
* Add/Edit Instrument dialog and New MIDI Instrument wizard
  are now resizable
* Using multicolumn menus for loading instruments from
  Instruments Database and selecting values in string list parameters

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2010 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;
24
25 import javax.swing.JPopupMenu;
26 import java.awt.event.KeyEvent;
27
28 import java.beans.PropertyChangeEvent;
29 import java.beans.PropertyChangeListener;
30
31 import org.jsampler.CC;
32 import org.jsampler.JSPrefs;
33 import org.jsampler.MidiInstrument;
34
35 import static org.jsampler.JSPrefs.*;
36
37 /**
38 * Provides the view configuration.
39 * @author Grigor Iliev
40 */
41 public abstract class JSViewConfig {
42 private boolean measurementUnitDecibel;
43
44 private int firstMidiBankNumber;
45 private int firstMidiProgramNumber;
46
47 /** Creates a new instance of <code>JSViewConfig</code> */
48 public
49 JSViewConfig() {
50 measurementUnitDecibel = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
51
52 String s = VOL_MEASUREMENT_UNIT_DECIBEL;
53 preferences().addPropertyChangeListener(s, new PropertyChangeListener() {
54 public void
55 propertyChange(PropertyChangeEvent e) {
56 boolean b;
57 b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
58 measurementUnitDecibel = b;
59 }
60 });
61
62 firstMidiBankNumber = preferences().getIntProperty(FIRST_MIDI_BANK_NUMBER);
63 firstMidiProgramNumber = preferences().getIntProperty(FIRST_MIDI_PROGRAM_NUMBER);
64
65 MidiInstrument.setFirstProgramNumber(firstMidiProgramNumber);
66
67 s = FIRST_MIDI_BANK_NUMBER;
68 preferences().addPropertyChangeListener(s, new PropertyChangeListener() {
69 public void
70 propertyChange(PropertyChangeEvent e) {
71 firstMidiBankNumber = preferences().getIntProperty(FIRST_MIDI_BANK_NUMBER);
72 }
73 });
74
75 s = FIRST_MIDI_PROGRAM_NUMBER;
76 preferences().addPropertyChangeListener(s, new PropertyChangeListener() {
77 public void
78 propertyChange(PropertyChangeEvent e) {
79 firstMidiProgramNumber = preferences().getIntProperty(FIRST_MIDI_PROGRAM_NUMBER);
80 MidiInstrument.setFirstProgramNumber(firstMidiProgramNumber);
81 }
82 });
83 }
84
85 /**
86 * Provides UI information for instruments database trees.
87 */
88 public abstract InstrumentsDbTreeView getInstrumentsDbTreeView();
89
90 /**
91 * Provides UI information for instruments database tables.
92 */
93 public abstract InstrumentsDbTableView getInstrumentsDbTableView();
94
95 public abstract BasicIconSet getBasicIconSet();
96
97 public abstract JSPrefs preferences();
98
99 /**
100 * Determines whether this view provides instruments database support.
101 * @return <code>false</code>
102 */
103 public boolean
104 getInstrumentsDbSupport() { return false; }
105
106 /**
107 * Determines whether the volume values should be shown in decibels.
108 */
109 public boolean
110 isMeasurementUnitDecibel() { return measurementUnitDecibel; }
111
112 /** Exports the view configuration of the current session. */
113 public String
114 exportSessionViewConfig() { return ""; }
115
116 private SessionViewConfig sessionViewConfig = null;
117
118 public SessionViewConfig
119 getSessionViewConfig() { return sessionViewConfig; }
120
121 public void
122 setSessionViewConfig(SessionViewConfig config) { sessionViewConfig = config; }
123
124 public int
125 getFirstMidiBankNumber() { return firstMidiBankNumber; }
126
127 public int
128 getFirstMidiProgramNumber() { return firstMidiProgramNumber; }
129
130 public int
131 getDefaultModKey() {
132 return CC.isMacOS() ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK;
133 }
134
135 /**
136 * Determines whether main menu is moved to
137 * the screen menu bar when running on Mac OS
138 */
139 public boolean
140 isUsingScreenMenuBar() {
141 if(!CC.isMacOS()) return false;
142 String s = System.getProperty("apple.laf.useScreenMenuBar");
143 return (s != null && "true".equalsIgnoreCase(s)) ? true : false;
144 }
145
146 /** Constructs a new multicolumn menu with the supplied string as its text. */
147 public javax.swing.JMenu
148 createMultiColumnMenu(String s) { return new net.sf.juife.MultiColumnMenu(s); }
149
150 /** Constructs a new multicolumn popup menu. */
151 public JPopupMenu
152 createMultiColumnPopupMenu()
153 { return new net.sf.juife.MultiColumnMenu.PopupMenu(); }
154 }

  ViewVC Help
Powered by ViewVC