Subversion Repositories svn.mios

Rev

Rev 696 | 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.lead;
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;
628 adamjking 28
 
213 tk 29
import javax.swing.BorderFactory;
30
import javax.swing.BoxLayout;
31
import javax.swing.JPanel;
32
 
696 rutgerv 33
import org.midibox.sidedit.SIDSysexInfo;
628 adamjking 34
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlGUI;
35
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlKnob;
36
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlSlider;
37
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlToggleButton;
38
 
39
public class LfoGUI extends JPanel {
40
 
41
    protected LfoGUI(Vector lfoGUIv, Vector env1GUIv, Vector env2GUIv) {
213 tk 42
        setLayout(new BorderLayout());
43
        this.setOpaque(false);
628 adamjking 44
 
213 tk 45
        JPanel topPanel = new JPanel();
46
        topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
47
        topPanel.setOpaque(false);
628 adamjking 48
 
213 tk 49
        JPanel panel1 = new JPanel();
628 adamjking 50
        panel1.setLayout(new GridLayout(3, 2));
51
        panel1.add(createLFO(lfoGUIv, "LFO 1", 0));
52
        panel1.add(createLFO(lfoGUIv, "LFO 4", 27));
53
        panel1.add(createLFO(lfoGUIv, "LFO 2", 9));
54
        panel1.add(createLFO(lfoGUIv, "LFO 5", 36));
55
        panel1.add(createLFO(lfoGUIv, "LFO 3", 18));
56
        panel1.add(createLFO(lfoGUIv, "LFO 6", 45));
213 tk 57
        panel1.setOpaque(false);
628 adamjking 58
 
213 tk 59
        JPanel panel2 = new JPanel();
628 adamjking 60
        panel2.setLayout(new GridLayout(1, 2));
61
        panel2.add(createENV(env1GUIv, "Envelope 1"));
62
        panel2.add(createENV(env2GUIv, "Envelope 2"));
213 tk 63
        panel2.setOpaque(false);
628 adamjking 64
 
213 tk 65
        topPanel.add(panel1);
66
        topPanel.add(panel2);
628 adamjking 67
        this.add(topPanel, BorderLayout.NORTH);
213 tk 68
    }
628 adamjking 69
 
213 tk 70
    protected JPanel createLFO(Vector midiParameterGUI, String s, int offset) {
71
        JPanel lfoPanel = new JPanel(new GridBagLayout());
72
        lfoPanel.setBorder(BorderFactory.createEtchedBorder());
73
        lfoPanel.setBorder(BorderFactory.createTitledBorder(s));
628 adamjking 74
        lfoPanel.setOpaque(false);
75
        GridBagConstraints c = new GridBagConstraints();
213 tk 76
        c.fill = GridBagConstraints.HORIZONTAL;
77
        c.ipadx = 10;
628 adamjking 78
 
213 tk 79
        // Buttons
628 adamjking 80
        c.gridx = 0;
81
        c.gridy = 0;
82
        c.gridwidth = 1;
83
        c.gridheight = 1;
84
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
85
                .elementAt(0 + offset), c);
86
        c.gridx = 0;
87
        c.gridy = 1;
88
        c.gridwidth = 1;
89
        c.gridheight = 1;
90
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
91
                .elementAt(1 + offset), c);
92
        c.gridx = 1;
93
        c.gridy = 0;
94
        c.gridwidth = 1;
95
        c.gridheight = 1;
96
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
97
                .elementAt(2 + offset), c);
98
        c.gridx = 1;
99
        c.gridy = 1;
100
        c.gridwidth = 1;
101
        c.gridheight = 1;
102
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
103
                .elementAt(8 + offset), c);
104
 
213 tk 105
        // Waveform selector
628 adamjking 106
        c.gridx = 2;
107
        c.gridy = 0;
108
        c.gridwidth = 5;
109
        c.gridheight = 2;
110
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
111
                .elementAt(3 + offset), c);
112
 
213 tk 113
        // Knobs
628 adamjking 114
        c.gridx = 7;
115
        c.gridy = 0;
116
        c.gridwidth = 1;
117
        c.gridheight = 1;
118
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
119
                .elementAt(4 + offset), c);
120
        c.gridx = 8;
121
        c.gridy = 0;
122
        c.gridwidth = 1;
123
        c.gridheight = 1;
124
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
125
                .elementAt(5 + offset), c);
126
        c.gridx = 7;
127
        c.gridy = 1;
128
        c.gridwidth = 1;
129
        c.gridheight = 1;
130
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
131
                .elementAt(6 + offset), c);
132
        c.gridx = 8;
133
        c.gridy = 1;
134
        c.gridwidth = 1;
135
        c.gridheight = 1;
136
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
137
                .elementAt(7 + offset), c);
138
 
139
        // Setup the 'rate'-knob behavior to be depending on the 'master sync'
140
        // switch
738 adamjking 141
        ((SIDSysexParameterControlKnob) midiParameterGUI.elementAt(5 + offset))
142
                .setSnapVals(new int[] { 245, 246, 247, 248, 249, 250, 251,
143
                        252, 253, 254, 255 }, SIDSysexInfo.rates);
144
        ((SIDSysexParameterControlToggleButton) midiParameterGUI
145
                .elementAt(1 + offset))
146
                .setSnapParameter((SIDSysexParameterControlGUI) midiParameterGUI
147
                        .elementAt(5 + offset));
628 adamjking 148
 
213 tk 149
        return lfoPanel;
150
    }
628 adamjking 151
 
213 tk 152
    protected JPanel createENV(Vector midiParameterGUI, String s) {
153
        JPanel envTopPanel = new JPanel();
154
        envTopPanel.setLayout(new BoxLayout(envTopPanel, BoxLayout.Y_AXIS));
155
        envTopPanel.setBorder(BorderFactory.createEtchedBorder());
156
        envTopPanel.setBorder(BorderFactory.createTitledBorder(s));
157
        envTopPanel.setOpaque(false);
628 adamjking 158
 
213 tk 159
        JPanel envPanel = new JPanel();
160
        envPanel.setLayout(new BoxLayout(envPanel, BoxLayout.X_AXIS));
628 adamjking 161
        envPanel.setOpaque(false);
162
 
213 tk 163
        // SubPanel1
164
        JPanel subPanel1 = new JPanel();
628 adamjking 165
        subPanel1.setLayout(new GridLayout(3, 2));
166
        subPanel1.setOpaque(false);
167
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
168
                .elementAt(3));
169
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
170
                .elementAt(5));
171
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
172
                .elementAt(4));
173
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
174
                .elementAt(7));
175
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
176
                .elementAt(2));
177
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
178
                .elementAt(15));
213 tk 179
        envPanel.add(subPanel1);
628 adamjking 180
 
181
        envPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
182
                .elementAt(6));
183
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(6))
184
                .setHeight(120);
185
 
213 tk 186
        // SubPanel2
187
        JPanel subPanel2 = new JPanel();
628 adamjking 188
        subPanel2.setLayout(new GridLayout(3, 1));
189
        subPanel2.setOpaque(false);
190
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
191
                .elementAt(8));
192
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
193
                .elementAt(10));
194
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
195
                .elementAt(16));
213 tk 196
        envPanel.add(subPanel2);
628 adamjking 197
 
198
        envPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
199
                .elementAt(9));
200
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(9))
201
                .setHeight(120);
202
 
203
        envPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
204
                .elementAt(11));
205
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(11))
206
                .setHeight(120);
207
 
213 tk 208
        // SubPanel4
209
        JPanel subPanel4 = new JPanel();
628 adamjking 210
        subPanel4.setLayout(new GridLayout(3, 1));
211
        subPanel4.setOpaque(false);
212
        subPanel4.add((SIDSysexParameterControlGUI) midiParameterGUI
213
                .elementAt(12));
214
        subPanel4.add((SIDSysexParameterControlGUI) midiParameterGUI
215
                .elementAt(14));
216
        subPanel4.add((SIDSysexParameterControlGUI) midiParameterGUI
217
                .elementAt(17));
213 tk 218
        envPanel.add(subPanel4);
628 adamjking 219
 
220
        envPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
221
                .elementAt(13));
222
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(13))
223
                .setHeight(120);
224
 
213 tk 225
        envTopPanel.add(envPanel);
628 adamjking 226
 
213 tk 227
        // SubPanel5
228
        JPanel subPanel5 = new JPanel();
229
        subPanel5.setLayout(new BoxLayout(subPanel5, BoxLayout.X_AXIS));
628 adamjking 230
        subPanel5.setOpaque(false);
231
 
232
        subPanel5.add((SIDSysexParameterControlGUI) midiParameterGUI
233
                .elementAt(0));
234
        subPanel5.add((SIDSysexParameterControlGUI) midiParameterGUI
235
                .elementAt(1));
236
 
213 tk 237
        envTopPanel.add(subPanel5);
628 adamjking 238
 
213 tk 239
        return envTopPanel;
240
    }
628 adamjking 241
}