Subversion Repositories svn.mios

Rev

Rev 303 | Rev 696 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
213 tk 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.sidedit.gui.multi;
22
 
23
import java.awt.BorderLayout;
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.GridLayout;
27
import java.util.Vector;
28
 
29
import javax.swing.BorderFactory;
30
import javax.swing.BoxLayout;
31
import javax.swing.JPanel;
32
 
628 adamjking 33
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlGUI;
34
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlKnob;
35
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlSlider;
36
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlToggleButton;
37
 
38
public class InstrumentGUI extends JPanel {
39
    private int[] snapvals1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
40
    private int[] snapvals = { 245, 246, 247, 248, 249, 250, 251, 252, 253,
41
            254, 255 };
42
 
213 tk 43
    protected InstrumentGUI(Vector V1GUIv, Vector V2GUIv) {
44
        setLayout(new BorderLayout());
45
        this.setOpaque(false);
628 adamjking 46
 
213 tk 47
        JPanel panel = new JPanel();
48
        panel.setOpaque(false);
49
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
628 adamjking 50
 
51
        JPanel panel1 = new JPanel(new GridLayout(1, 2));
213 tk 52
        panel1.setOpaque(false);
628 adamjking 53
 
54
        JPanel panel2 = new JPanel(new GridLayout(1, 2));
213 tk 55
        panel2.setOpaque(false);
628 adamjking 56
 
57
        JPanel panel3 = new JPanel(new GridLayout(1, 2));
58
        panel3.setOpaque(false);
59
 
60
        panel.add(createGlob(V2GUIv, "Master Settings"));
61
 
62
        panel1.add(createVoice(V1GUIv, "Voice"));
63
        panel1.add(createENV(V2GUIv, "Envelope", 29));
64
        panel2.add(createLFO(V2GUIv, "LFO 1", 7));
65
        panel2.add(createLFO(V2GUIv, "LFO 2", 18));
66
        panel3.add(createArp(V1GUIv, "Arpeggiator"));
213 tk 67
        panel.add(panel1);
68
        panel.add(panel2);
69
        panel.add(panel3);
628 adamjking 70
 
71
        this.add(panel, BorderLayout.NORTH);
213 tk 72
    }
73
 
628 adamjking 74
    protected JPanel createGlob(Vector vGUI, String s) {
213 tk 75
        JPanel globPanel = new JPanel();
76
        globPanel.setLayout(new BoxLayout(globPanel, BoxLayout.X_AXIS));
77
        globPanel.setBorder(BorderFactory.createEtchedBorder());
78
        globPanel.setBorder(BorderFactory.createTitledBorder(s));
79
        globPanel.setOpaque(false);
628 adamjking 80
 
213 tk 81
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(0));
82
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(1));
83
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(2));
84
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(3));
85
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(4));
628 adamjking 86
        ((SIDSysexParameterControlKnob) vGUI.elementAt(4))
87
                .setSnapvals(snapvals1);
213 tk 88
        ((SIDSysexParameterControlKnob) vGUI.elementAt(4)).setSnap(true);
89
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(5));
90
        globPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(6));
91
        return globPanel;
92
    }
628 adamjking 93
 
213 tk 94
    protected JPanel createVoice(Vector vGUI, String s) {
628 adamjking 95
 
213 tk 96
        JPanel voicePanel = new JPanel();
97
        voicePanel.setLayout(new BoxLayout(voicePanel, BoxLayout.X_AXIS));
98
        voicePanel.setBorder(BorderFactory.createEtchedBorder());
99
        voicePanel.setBorder(BorderFactory.createTitledBorder(s));
100
        voicePanel.setOpaque(false);
628 adamjking 101
 
213 tk 102
        JPanel subPanel1 = new JPanel();
103
        subPanel1.setLayout(new BoxLayout(subPanel1, BoxLayout.Y_AXIS));
104
        subPanel1.setOpaque(false);
628 adamjking 105
 
213 tk 106
        JPanel subPanel2 = new JPanel();
107
        subPanel2.setLayout(new BoxLayout(subPanel2, BoxLayout.Y_AXIS));
108
        subPanel2.setOpaque(false);
628 adamjking 109
 
213 tk 110
        // Waveform selection
111
        subPanel1.add((SIDSysexParameterControlGUI) vGUI.elementAt(2));
628 adamjking 112
 
213 tk 113
        // Tuning Panel
114
        JPanel tunePanel = new JPanel();
628 adamjking 115
        tunePanel.setLayout(new GridLayout(2, 3));
213 tk 116
        tunePanel.setOpaque(false);
117
        tunePanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(10));
118
        tunePanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(11));
119
        tunePanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(12));
120
        tunePanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(7));
121
        tunePanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(8));
122
        tunePanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(13));
123
        subPanel2.add(tunePanel);
628 adamjking 124
 
213 tk 125
        // Portamento Panel
126
        JPanel portaPanel = new JPanel();
127
        portaPanel.setLayout(new BoxLayout(portaPanel, BoxLayout.X_AXIS));
128
        portaPanel.setOpaque(false);
628 adamjking 129
 
213 tk 130
        portaPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(1));
131
        portaPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(0));
628 adamjking 132
 
213 tk 133
        subPanel2.add(portaPanel);
628 adamjking 134
 
213 tk 135
        // Envelope Panel
136
        JPanel envPanel = new JPanel();
137
        envPanel.setLayout(new BoxLayout(envPanel, BoxLayout.X_AXIS));
138
        envPanel.setOpaque(false);
139
        envPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(9));
140
        envPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(3));
141
        envPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(4));
142
        envPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(5));
143
        envPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(6));
144
        subPanel1.add(envPanel);
628 adamjking 145
 
213 tk 146
        voicePanel.add(subPanel1);
147
        voicePanel.add(subPanel2);
148
        return voicePanel;
628 adamjking 149
    }
150
 
213 tk 151
    protected JPanel createLFO(Vector midiParameterGUI, String s, int offset) {
152
        JPanel lfoPanel = new JPanel(new GridBagLayout());
153
        lfoPanel.setBorder(BorderFactory.createEtchedBorder());
154
        lfoPanel.setBorder(BorderFactory.createTitledBorder(s));
628 adamjking 155
        lfoPanel.setOpaque(false);
156
        GridBagConstraints c = new GridBagConstraints();
213 tk 157
        c.fill = GridBagConstraints.HORIZONTAL;
158
        c.ipadx = 5;
628 adamjking 159
 
213 tk 160
        // Buttons
628 adamjking 161
        c.gridx = 0;
162
        c.gridy = 0;
163
        c.gridwidth = 1;
164
        c.gridheight = 1;
165
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
166
                .elementAt(0 + offset), c);
167
        c.gridx = 0;
168
        c.gridy = 1;
169
        c.gridwidth = 1;
170
        c.gridheight = 1;
171
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
172
                .elementAt(2 + offset), c);
173
        c.gridx = 1;
174
        c.gridy = 0;
175
        c.gridwidth = 1;
176
        c.gridheight = 1;
177
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
178
                .elementAt(3 + offset), c);
179
        c.gridx = 1;
180
        c.gridy = 1;
181
        c.gridwidth = 1;
182
        c.gridheight = 1;
183
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
184
                .elementAt(1 + offset), c);
185
 
213 tk 186
        // Waveform selector
628 adamjking 187
        c.gridx = 2;
188
        c.gridy = 0;
189
        c.gridwidth = 5;
190
        c.gridheight = 2;
191
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
192
                .elementAt(4 + offset), c);
193
 
213 tk 194
        // Knobs
628 adamjking 195
        c.gridx = 7;
196
        c.gridy = 0;
197
        c.gridwidth = 1;
198
        c.gridheight = 1;
199
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
200
                .elementAt(5 + offset), c);
201
        c.gridx = 8;
202
        c.gridy = 0;
203
        c.gridwidth = 1;
204
        c.gridheight = 1;
205
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
206
                .elementAt(9 + offset), c);
207
        c.gridx = 9;
208
        c.gridy = 0;
209
        c.gridwidth = 1;
210
        c.gridheight = 1;
211
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
212
                .elementAt(10 + offset), c);
213
        c.gridx = 7;
214
        c.gridy = 1;
215
        c.gridwidth = 1;
216
        c.gridheight = 1;
217
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
218
                .elementAt(6 + offset), c);
219
        c.gridx = 8;
220
        c.gridy = 1;
221
        c.gridwidth = 1;
222
        c.gridheight = 1;
223
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
224
                .elementAt(7 + offset), c);
225
        c.gridx = 9;
226
        c.gridy = 1;
227
        c.gridwidth = 1;
228
        c.gridheight = 1;
229
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
230
                .elementAt(8 + offset), c);
231
 
232
        // Setup the 'rate'-knob behavior to be depending on the 'master sync'
233
        // switch
234
        ((SIDSysexParameterControlKnob) midiParameterGUI.elementAt(6 + offset))
235
                .setSnapvals(snapvals);
236
        ((SIDSysexParameterControlToggleButton) midiParameterGUI
237
                .elementAt(2 + offset))
238
                .setSnapParameter((SIDSysexParameterControlGUI) midiParameterGUI
239
                        .elementAt(6 + offset));
240
 
213 tk 241
        return lfoPanel;
242
    }
628 adamjking 243
 
244
    protected JPanel createArp(Vector vGUI, String s) {
213 tk 245
        JPanel arpPanel = new JPanel();
246
        arpPanel.setLayout(new BoxLayout(arpPanel, BoxLayout.X_AXIS));
247
        arpPanel.setBorder(BorderFactory.createEtchedBorder());
248
        arpPanel.setBorder(BorderFactory.createTitledBorder(s));
249
        arpPanel.setOpaque(false);
628 adamjking 250
 
213 tk 251
        JPanel subPanel1 = new JPanel(new GridBagLayout());
252
        subPanel1.setOpaque(false);
628 adamjking 253
        GridBagConstraints c = new GridBagConstraints();
213 tk 254
        c.fill = GridBagConstraints.HORIZONTAL;
255
        c.ipadx = 10;
256
        // First row
628 adamjking 257
        c.gridx = 0;
258
        c.gridy = 0;
259
        c.gridwidth = 1;
213 tk 260
        subPanel1.add((SIDSysexParameterControlGUI) vGUI.elementAt(14), c);
628 adamjking 261
        c.gridx = 1;
262
        c.gridy = 0;
263
        c.gridwidth = 2;
213 tk 264
        subPanel1.add((SIDSysexParameterControlGUI) vGUI.elementAt(15), c);
628 adamjking 265
 
213 tk 266
        // Second row
628 adamjking 267
        c.gridx = 0;
268
        c.gridy = 1;
269
        c.gridwidth = 1;
213 tk 270
        subPanel1.add((SIDSysexParameterControlGUI) vGUI.elementAt(20), c);
628 adamjking 271
        c.gridx = 1;
272
        c.gridy = 1;
273
        c.gridwidth = 1;
213 tk 274
        subPanel1.add((SIDSysexParameterControlGUI) vGUI.elementAt(23), c);
628 adamjking 275
        c.gridx = 2;
276
        c.gridy = 1;
277
        c.gridwidth = 1;
213 tk 278
        subPanel1.add((SIDSysexParameterControlGUI) vGUI.elementAt(22), c);
628 adamjking 279
 
213 tk 280
        JPanel subPanel2 = new JPanel();
628 adamjking 281
        subPanel2.setLayout(new GridLayout(2, 3));
213 tk 282
        subPanel2.setOpaque(false);
628 adamjking 283
 
213 tk 284
        subPanel2.add((SIDSysexParameterControlGUI) vGUI.elementAt(16));
285
        subPanel2.add((SIDSysexParameterControlGUI) vGUI.elementAt(17));
286
        subPanel2.add((SIDSysexParameterControlGUI) vGUI.elementAt(18));
287
        subPanel2.add((SIDSysexParameterControlGUI) vGUI.elementAt(21));
288
        subPanel2.add((SIDSysexParameterControlGUI) vGUI.elementAt(19));
289
        arpPanel.add(subPanel1);
290
        arpPanel.add(subPanel2);
291
        return arpPanel;
628 adamjking 292
    }
293
 
213 tk 294
    protected JPanel createENV(Vector midiParameterGUI, String s, int offset) {
295
        JPanel envTopPanel = new JPanel();
296
        envTopPanel.setLayout(new BoxLayout(envTopPanel, BoxLayout.Y_AXIS));
297
        envTopPanel.setBorder(BorderFactory.createEtchedBorder());
298
        envTopPanel.setBorder(BorderFactory.createTitledBorder(s));
299
        envTopPanel.setOpaque(false);
628 adamjking 300
 
213 tk 301
        JPanel envPanel = new JPanel();
302
        envPanel.setLayout(new BoxLayout(envPanel, BoxLayout.X_AXIS));
628 adamjking 303
        envPanel.setOpaque(false);
304
 
213 tk 305
        // SubPanel1
306
        JPanel subPanel1 = new JPanel();
628 adamjking 307
        subPanel1.setLayout(new GridLayout(1, 4));
308
        subPanel1.setOpaque(false);
309
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
310
                .elementAt(7 + offset));
311
        ((SIDSysexParameterControlSlider) midiParameterGUI
312
                .elementAt(7 + offset)).setHeight(120);
313
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
314
                .elementAt(8 + offset));
315
        ((SIDSysexParameterControlSlider) midiParameterGUI
316
                .elementAt(8 + offset)).setHeight(120);
317
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
318
                .elementAt(9 + offset));
319
        ((SIDSysexParameterControlSlider) midiParameterGUI
320
                .elementAt(9 + offset)).setHeight(120);
321
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
322
                .elementAt(10 + offset));
323
        ((SIDSysexParameterControlSlider) midiParameterGUI
324
                .elementAt(10 + offset)).setHeight(120);
325
 
213 tk 326
        envPanel.add(subPanel1);
628 adamjking 327
 
213 tk 328
        JPanel fill = new JPanel();
329
        fill.setOpaque(false);
628 adamjking 330
 
213 tk 331
        // SubPanel2
332
        JPanel subPanel2 = new JPanel();
628 adamjking 333
        subPanel2.setLayout(new GridLayout(3, 5));
334
        subPanel2.setOpaque(false);
335
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
336
                .elementAt(4 + offset));
337
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
338
                .elementAt(5 + offset));
339
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
340
                .elementAt(6 + offset));
341
        subPanel2.add(fill);
342
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
343
                .elementAt(11 + offset));
344
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
345
                .elementAt(3 + offset));
346
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
347
                .elementAt(0 + offset));
348
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
349
                .elementAt(1 + offset));
350
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
351
                .elementAt(2 + offset));
213 tk 352
        envPanel.add(subPanel2);
628 adamjking 353
 
213 tk 354
        envTopPanel.add(envPanel);
628 adamjking 355
 
213 tk 356
        return envTopPanel;
628 adamjking 357
    }
358
 
213 tk 359
}