1 |
iliev |
1285 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2195 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1285 |
* |
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 |
iliev |
2148 |
import javax.swing.JPopupMenu; |
26 |
iliev |
1864 |
import java.awt.event.KeyEvent; |
27 |
|
|
|
28 |
iliev |
1540 |
import java.beans.PropertyChangeEvent; |
29 |
|
|
import java.beans.PropertyChangeListener; |
30 |
|
|
|
31 |
iliev |
1864 |
import org.jsampler.CC; |
32 |
iliev |
1285 |
import org.jsampler.JSPrefs; |
33 |
iliev |
1767 |
import org.jsampler.MidiInstrument; |
34 |
iliev |
1285 |
|
35 |
iliev |
1767 |
import static org.jsampler.JSPrefs.*; |
36 |
iliev |
1540 |
|
37 |
iliev |
1285 |
/** |
38 |
|
|
* Provides the view configuration. |
39 |
|
|
* @author Grigor Iliev |
40 |
|
|
*/ |
41 |
|
|
public abstract class JSViewConfig { |
42 |
iliev |
1540 |
private boolean measurementUnitDecibel; |
43 |
iliev |
1285 |
|
44 |
iliev |
1767 |
private int firstMidiBankNumber; |
45 |
|
|
private int firstMidiProgramNumber; |
46 |
|
|
|
47 |
iliev |
1285 |
/** Creates a new instance of <code>JSViewConfig</code> */ |
48 |
|
|
public |
49 |
|
|
JSViewConfig() { |
50 |
iliev |
1540 |
measurementUnitDecibel = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL); |
51 |
iliev |
1285 |
|
52 |
iliev |
1540 |
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 |
iliev |
1767 |
|
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 |
iliev |
1285 |
} |
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 |
iliev |
2195 |
public abstract SamplerBrowserView getSamplerBrowserView(); |
96 |
|
|
|
97 |
iliev |
1752 |
public abstract BasicIconSet getBasicIconSet(); |
98 |
|
|
|
99 |
iliev |
1285 |
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 |
iliev |
1540 |
|
108 |
|
|
/** |
109 |
|
|
* Determines whether the volume values should be shown in decibels. |
110 |
|
|
*/ |
111 |
|
|
public boolean |
112 |
|
|
isMeasurementUnitDecibel() { return measurementUnitDecibel; } |
113 |
iliev |
1752 |
|
114 |
|
|
/** Exports the view configuration of the current session. */ |
115 |
|
|
public String |
116 |
|
|
exportSessionViewConfig() { return ""; } |
117 |
iliev |
1767 |
|
118 |
iliev |
1818 |
private SessionViewConfig sessionViewConfig = null; |
119 |
|
|
|
120 |
|
|
public SessionViewConfig |
121 |
|
|
getSessionViewConfig() { return sessionViewConfig; } |
122 |
|
|
|
123 |
|
|
public void |
124 |
|
|
setSessionViewConfig(SessionViewConfig config) { sessionViewConfig = config; } |
125 |
|
|
|
126 |
iliev |
1767 |
public int |
127 |
|
|
getFirstMidiBankNumber() { return firstMidiBankNumber; } |
128 |
|
|
|
129 |
|
|
public int |
130 |
|
|
getFirstMidiProgramNumber() { return firstMidiProgramNumber; } |
131 |
iliev |
1864 |
|
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 |
iliev |
2148 |
|
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 |
iliev |
1285 |
} |