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