f@0
|
1 /*
|
f@0
|
2 Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation.
|
f@0
|
3
|
f@0
|
4 Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/)
|
f@0
|
5
|
f@0
|
6 This program is free software: you can redistribute it and/or modify
|
f@0
|
7 it under the terms of the GNU General Public License as published by
|
f@0
|
8 the Free Software Foundation, either version 3 of the License, or
|
f@0
|
9 (at your option) any later version.
|
f@0
|
10
|
f@0
|
11 This program is distributed in the hope that it will be useful,
|
f@0
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
f@0
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
f@0
|
14 GNU General Public License for more details.
|
f@0
|
15
|
f@0
|
16 You should have received a copy of the GNU General Public License
|
f@0
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
f@0
|
18 */
|
f@0
|
19 package uk.ac.qmul.eecs.depic.daw.beads.sonification;
|
f@0
|
20
|
f@0
|
21
|
f@0
|
22 import java.awt.GridBagConstraints;
|
f@0
|
23 import java.awt.GridBagLayout;
|
f@0
|
24 import java.awt.Insets;
|
f@0
|
25 import java.util.prefs.Preferences;
|
f@0
|
26
|
f@0
|
27 import javax.swing.JLabel;
|
f@0
|
28 import javax.swing.JSpinner;
|
f@0
|
29 import javax.swing.SpinnerNumberModel;
|
f@0
|
30
|
f@0
|
31 import uk.ac.qmul.eecs.depic.daw.gui.PreferencesPanel;
|
f@0
|
32
|
f@0
|
33 import javax.swing.JCheckBox;
|
f@0
|
34
|
f@2
|
35 /**
|
f@2
|
36 *
|
f@2
|
37 * GUI panel for setting preferences for the sonification. It is in this package and not in
|
f@2
|
38 * the gui package because it's specific to this sonification. The gui package is more
|
f@2
|
39 * a general purpose set of graphical classes for the DAW, regardless of the sonification.
|
f@2
|
40 *
|
f@2
|
41 * However this class extends PreferencesPanel, which is an abstraction of a preference panel
|
f@2
|
42 * to allow other packages to plug in their custom preference settings panels,
|
f@2
|
43 * without making the gui package dependent on them.
|
f@2
|
44 *
|
f@2
|
45 */
|
f@0
|
46 public class SonificationPrefsPanel extends PreferencesPanel {
|
f@0
|
47 private static String [] keys = new String [] {
|
f@0
|
48 "selection.filter",
|
f@0
|
49 "borders.threshold",
|
f@0
|
50 "render_val.ref",
|
f@0
|
51 "render_curve.gain"
|
f@0
|
52 };
|
f@0
|
53
|
f@0
|
54 private static final long serialVersionUID = 1L;
|
f@0
|
55 private JSpinner selectionFilterSpinner;
|
f@0
|
56 private JSpinner borderThresholdSpinner;
|
f@0
|
57 private JCheckBox valRefCheckBox;
|
f@0
|
58 private JLabel lblRenderCurveGain;
|
f@0
|
59 private JSpinner curveGainSpinner;
|
f@0
|
60
|
f@0
|
61
|
f@0
|
62 private static SonificationPrefsPanel singleton;
|
f@0
|
63 public static SonificationPrefsPanel getInstance(){
|
f@0
|
64 if(singleton == null)
|
f@0
|
65 singleton = new SonificationPrefsPanel();
|
f@0
|
66 return singleton;
|
f@0
|
67 }
|
f@0
|
68
|
f@0
|
69 /**
|
f@0
|
70 * Create the panel.
|
f@0
|
71 */
|
f@0
|
72 private SonificationPrefsPanel() {
|
f@0
|
73
|
f@0
|
74 GridBagLayout gridBagLayout = new GridBagLayout();
|
f@0
|
75 gridBagLayout.columnWidths = new int[]{30, 70, 78, 53, 0};
|
f@0
|
76 gridBagLayout.rowHeights = new int[]{30, 18, 0, 0, 0, 0, 0};
|
f@0
|
77 gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
f@0
|
78 gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
f@0
|
79 setLayout(gridBagLayout);
|
f@0
|
80
|
f@0
|
81 JLabel selectionFilterLabel = new JLabel("Selection filter :");
|
f@0
|
82 GridBagConstraints gbc_selectionFilterLabel = new GridBagConstraints();
|
f@0
|
83 gbc_selectionFilterLabel.anchor = GridBagConstraints.WEST;
|
f@0
|
84 gbc_selectionFilterLabel.insets = new Insets(0, 0, 5, 5);
|
f@0
|
85 gbc_selectionFilterLabel.gridx = 1;
|
f@0
|
86 gbc_selectionFilterLabel.gridy = 1;
|
f@0
|
87 add(selectionFilterLabel, gbc_selectionFilterLabel);
|
f@0
|
88
|
f@0
|
89 /* prefs are used to initialize the spinners and the grain ugens */
|
f@0
|
90 Preferences prefs = Preferences.userNodeForPackage(BeadsSonification.class);
|
f@0
|
91
|
f@0
|
92 selectionFilterSpinner = new JSpinner();
|
f@0
|
93 selectionFilterSpinner.setModel(new SpinnerNumberModel(
|
f@0
|
94 new Integer(prefs.getInt(getPrefsList()[0], new Integer(500))),
|
f@0
|
95 new Integer(0), // min value
|
f@0
|
96 new Integer(1000), // max value
|
f@0
|
97 new Integer(10))); // increment
|
f@0
|
98 GridBagConstraints gbc_selectionFilterSpinner = new GridBagConstraints();
|
f@0
|
99 gbc_selectionFilterSpinner.insets = new Insets(0, 0, 5, 0);
|
f@0
|
100 gbc_selectionFilterSpinner.anchor = GridBagConstraints.NORTH;
|
f@0
|
101 gbc_selectionFilterSpinner.fill = GridBagConstraints.HORIZONTAL;
|
f@0
|
102 gbc_selectionFilterSpinner.gridx = 3;
|
f@0
|
103 gbc_selectionFilterSpinner.gridy = 1;
|
f@0
|
104 add(selectionFilterSpinner, gbc_selectionFilterSpinner);
|
f@0
|
105
|
f@0
|
106 JLabel borderThreshLabel = new JLabel("Border Threshold :"); // FIXME boudles
|
f@0
|
107 GridBagConstraints gbc_borderThreshLabel = new GridBagConstraints();
|
f@0
|
108 gbc_borderThreshLabel.anchor = GridBagConstraints.WEST;
|
f@0
|
109 gbc_borderThreshLabel.insets = new Insets(0, 0, 5, 5);
|
f@0
|
110 gbc_borderThreshLabel.gridx = 1;
|
f@0
|
111 gbc_borderThreshLabel.gridy = 2;
|
f@0
|
112 add(borderThreshLabel, gbc_borderThreshLabel);
|
f@0
|
113
|
f@0
|
114 borderThresholdSpinner = new JSpinner();
|
f@0
|
115 borderThresholdSpinner.setModel(new SpinnerNumberModel(
|
f@0
|
116 new Float(prefs.getFloat(getPrefsList()[1], new Float(-0.1f))),
|
f@0
|
117 new Float(-0.1f), // min value
|
f@0
|
118 new Float(1.0f), // max value
|
f@0
|
119 new Float(0.05f))); // increment
|
f@0
|
120 GridBagConstraints gbc_borderThreshSpinner = new GridBagConstraints();
|
f@0
|
121 gbc_borderThreshSpinner.insets = new Insets(0, 0, 5, 0);
|
f@0
|
122 gbc_borderThreshSpinner.fill = GridBagConstraints.HORIZONTAL;
|
f@0
|
123 gbc_borderThreshSpinner.anchor = GridBagConstraints.NORTH;
|
f@0
|
124 gbc_borderThreshSpinner.gridx = 3;
|
f@0
|
125 gbc_borderThreshSpinner.gridy = 2;
|
f@0
|
126 add(borderThresholdSpinner, gbc_borderThreshSpinner);
|
f@0
|
127
|
f@0
|
128 JLabel sequenceValRefLabel = new JLabel("Sequence val ref:");
|
f@0
|
129 GridBagConstraints gbc_sequenceValRefLabel = new GridBagConstraints();
|
f@0
|
130 gbc_sequenceValRefLabel.anchor = GridBagConstraints.WEST;
|
f@0
|
131 gbc_sequenceValRefLabel.insets = new Insets(0, 0, 5, 5);
|
f@0
|
132 gbc_sequenceValRefLabel.gridx = 1;
|
f@0
|
133 gbc_sequenceValRefLabel.gridy = 3;
|
f@0
|
134 add(sequenceValRefLabel, gbc_sequenceValRefLabel);
|
f@0
|
135
|
f@0
|
136 valRefCheckBox = new JCheckBox("");
|
f@0
|
137 valRefCheckBox.setSelected(prefs.getBoolean(getPrefsList()[3], false));
|
f@0
|
138 sequenceValRefLabel.setLabelFor(valRefCheckBox);
|
f@0
|
139 GridBagConstraints gbc_valRefCheckBox = new GridBagConstraints();
|
f@0
|
140 gbc_valRefCheckBox.anchor = GridBagConstraints.WEST;
|
f@0
|
141 gbc_valRefCheckBox.insets = new Insets(0, 0, 5, 0);
|
f@0
|
142 gbc_valRefCheckBox.gridx = 3;
|
f@0
|
143 gbc_valRefCheckBox.gridy = 3;
|
f@0
|
144 add(valRefCheckBox, gbc_valRefCheckBox);
|
f@0
|
145
|
f@0
|
146 lblRenderCurveGain = new JLabel("Render Curve Gain:");
|
f@0
|
147 GridBagConstraints gbc_lblRenderCurveGain = new GridBagConstraints();
|
f@0
|
148 gbc_lblRenderCurveGain.insets = new Insets(0, 0, 5, 5);
|
f@0
|
149 gbc_lblRenderCurveGain.gridx = 1;
|
f@0
|
150 gbc_lblRenderCurveGain.gridy = 4;
|
f@0
|
151 add(lblRenderCurveGain, gbc_lblRenderCurveGain);
|
f@0
|
152
|
f@0
|
153 curveGainSpinner = new JSpinner();
|
f@0
|
154 curveGainSpinner.setModel(new SpinnerNumberModel(
|
f@0
|
155 new Float(prefs.getFloat(getPrefsList()[3], new Float(1.0f))),
|
f@0
|
156 new Float(0), // min value
|
f@0
|
157 new Float(1), // max value
|
f@0
|
158 new Float(0.1))); // increment
|
f@0
|
159 GridBagConstraints gbc_spinner = new GridBagConstraints();
|
f@0
|
160 gbc_spinner.insets = new Insets(0, 0, 5, 0);
|
f@0
|
161 gbc_spinner.fill = GridBagConstraints.HORIZONTAL;
|
f@0
|
162 gbc_spinner.gridx = 3;
|
f@0
|
163 gbc_spinner.gridy = 4;
|
f@0
|
164 add(curveGainSpinner, gbc_spinner);
|
f@0
|
165
|
f@0
|
166 /* sets all the strings for the screen reader */
|
f@0
|
167 configureAccessibleContext();
|
f@0
|
168 }
|
f@0
|
169
|
f@0
|
170
|
f@0
|
171 private void configureAccessibleContext(){
|
f@0
|
172 borderThresholdSpinner.getEditor().getAccessibleContext().setAccessibleName("Border Threshold"); // FIXME bundle
|
f@0
|
173 selectionFilterSpinner.getEditor().getAccessibleContext().setAccessibleName("Selectionf Filter");
|
f@0
|
174 }
|
f@0
|
175
|
f@0
|
176 @Override
|
f@0
|
177 public void savePrefs() {
|
f@0
|
178 Preferences prefs = Preferences.userNodeForPackage(BeadsSonification.class);
|
f@0
|
179
|
f@0
|
180 prefs.putInt(getPrefsList()[0], (Integer)selectionFilterSpinner.getValue());
|
f@0
|
181 prefs.putFloat(getPrefsList()[1], (Float)borderThresholdSpinner.getValue());
|
f@0
|
182 prefs.putBoolean(getPrefsList()[2], (Boolean)valRefCheckBox.isSelected());
|
f@0
|
183 prefs.putFloat(getPrefsList()[3], (Float)curveGainSpinner.getValue());
|
f@0
|
184
|
f@0
|
185 }
|
f@0
|
186
|
f@0
|
187 @Override
|
f@0
|
188 public String getTitle(){
|
f@0
|
189 return "Sonification Synthesis";
|
f@0
|
190 }
|
f@0
|
191
|
f@0
|
192 @Override
|
f@0
|
193 public String[] getPrefsList() {
|
f@0
|
194 return keys;
|
f@0
|
195 }
|
f@0
|
196 }
|
f@0
|
197
|