1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2011 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 SamplerBrowserView getSamplerBrowserView(); |
96 |
|
97 |
public abstract BasicIconSet getBasicIconSet(); |
98 |
|
99 |
public abstract JSPrefs preferences(); |
100 |
|
101 |
/** |
102 |
* Determines whether this view provides instruments database support. |
103 |
* @return <code>false</code> |
104 |
*/ |
105 |
public boolean |
106 |
getInstrumentsDbSupport() { return false; } |
107 |
|
108 |
/** |
109 |
* Determines whether the volume values should be shown in decibels. |
110 |
*/ |
111 |
public boolean |
112 |
isMeasurementUnitDecibel() { return measurementUnitDecibel; } |
113 |
|
114 |
/** Exports the view configuration of the current session. */ |
115 |
public String |
116 |
exportSessionViewConfig() { return ""; } |
117 |
|
118 |
private SessionViewConfig sessionViewConfig = null; |
119 |
|
120 |
public SessionViewConfig |
121 |
getSessionViewConfig() { return sessionViewConfig; } |
122 |
|
123 |
public void |
124 |
setSessionViewConfig(SessionViewConfig config) { sessionViewConfig = config; } |
125 |
|
126 |
public int |
127 |
getFirstMidiBankNumber() { return firstMidiBankNumber; } |
128 |
|
129 |
public int |
130 |
getFirstMidiProgramNumber() { return firstMidiProgramNumber; } |
131 |
|
132 |
public int |
133 |
getDefaultModKey() { |
134 |
return CC.isMacOS() ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK; |
135 |
} |
136 |
|
137 |
/** |
138 |
* Determines whether main menu is moved to |
139 |
* the screen menu bar when running on Mac OS |
140 |
*/ |
141 |
public boolean |
142 |
isUsingScreenMenuBar() { |
143 |
if(!CC.isMacOS()) return false; |
144 |
String s = System.getProperty("apple.laf.useScreenMenuBar"); |
145 |
return (s != null && "true".equalsIgnoreCase(s)) ? true : false; |
146 |
} |
147 |
|
148 |
/** Constructs a new multicolumn menu with the supplied string as its text. */ |
149 |
public javax.swing.JMenu |
150 |
createMultiColumnMenu(String s) { return new net.sf.juife.MultiColumnMenu(s); } |
151 |
|
152 |
/** Constructs a new multicolumn popup menu. */ |
153 |
public JPopupMenu |
154 |
createMultiColumnPopupMenu() |
155 |
{ return new net.sf.juife.MultiColumnMenu.PopupMenu(); } |
156 |
} |