Subversion Repositories svn.mios

Rev

Rev 259 | 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.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
 
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 LfoGUI extends JPanel {
39
    private int[] snapvals = { 245, 246, 247, 248, 249, 250, 251, 252, 253,
40
            254, 255 };
41
 
42
    protected LfoGUI(Vector lfoGUIv, Vector env1GUIv, Vector env2GUIv) {
213 tk 43
        setLayout(new BorderLayout());
44
        this.setOpaque(false);
628 adamjking 45
 
213 tk 46
        JPanel topPanel = new JPanel();
47
        topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
48
        topPanel.setOpaque(false);
628 adamjking 49
 
213 tk 50
        JPanel panel1 = new JPanel();
628 adamjking 51
        panel1.setLayout(new GridLayout(3, 2));
52
        panel1.add(createLFO(lfoGUIv, "LFO 1", 0));
53
        panel1.add(createLFO(lfoGUIv, "LFO 4", 27));
54
        panel1.add(createLFO(lfoGUIv, "LFO 2", 9));
55
        panel1.add(createLFO(lfoGUIv, "LFO 5", 36));
56
        panel1.add(createLFO(lfoGUIv, "LFO 3", 18));
57
        panel1.add(createLFO(lfoGUIv, "LFO 6", 45));
213 tk 58
        panel1.setOpaque(false);
628 adamjking 59
 
213 tk 60
        JPanel panel2 = new JPanel();
628 adamjking 61
        panel2.setLayout(new GridLayout(1, 2));
62
        panel2.add(createENV(env1GUIv, "Envelope 1"));
63
        panel2.add(createENV(env2GUIv, "Envelope 2"));
213 tk 64
        panel2.setOpaque(false);
628 adamjking 65
 
213 tk 66
        topPanel.add(panel1);
67
        topPanel.add(panel2);
628 adamjking 68
        this.add(topPanel, BorderLayout.NORTH);
213 tk 69
    }
628 adamjking 70
 
213 tk 71
    protected JPanel createLFO(Vector midiParameterGUI, String s, int offset) {
72
        JPanel lfoPanel = new JPanel(new GridBagLayout());
73
        lfoPanel.setBorder(BorderFactory.createEtchedBorder());
74
        lfoPanel.setBorder(BorderFactory.createTitledBorder(s));
628 adamjking 75
        lfoPanel.setOpaque(false);
76
        GridBagConstraints c = new GridBagConstraints();
213 tk 77
        c.fill = GridBagConstraints.HORIZONTAL;
78
        c.ipadx = 10;
628 adamjking 79
 
213 tk 80
        // Buttons
628 adamjking 81
        c.gridx = 0;
82
        c.gridy = 0;
83
        c.gridwidth = 1;
84
        c.gridheight = 1;
85
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
86
                .elementAt(0 + offset), c);
87
        c.gridx = 0;
88
        c.gridy = 1;
89
        c.gridwidth = 1;
90
        c.gridheight = 1;
91
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
92
                .elementAt(1 + offset), c);
93
        c.gridx = 1;
94
        c.gridy = 0;
95
        c.gridwidth = 1;
96
        c.gridheight = 1;
97
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
98
                .elementAt(2 + offset), c);
99
        c.gridx = 1;
100
        c.gridy = 1;
101
        c.gridwidth = 1;
102
        c.gridheight = 1;
103
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
104
                .elementAt(8 + offset), c);
105
 
213 tk 106
        // Waveform selector
628 adamjking 107
        c.gridx = 2;
108
        c.gridy = 0;
109
        c.gridwidth = 5;
110
        c.gridheight = 2;
111
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
112
                .elementAt(3 + offset), c);
113
 
213 tk 114
        // Knobs
628 adamjking 115
        c.gridx = 7;
116
        c.gridy = 0;
117
        c.gridwidth = 1;
118
        c.gridheight = 1;
119
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
120
                .elementAt(4 + offset), c);
121
        c.gridx = 8;
122
        c.gridy = 0;
123
        c.gridwidth = 1;
124
        c.gridheight = 1;
125
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
126
                .elementAt(5 + offset), c);
127
        c.gridx = 7;
128
        c.gridy = 1;
129
        c.gridwidth = 1;
130
        c.gridheight = 1;
131
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
132
                .elementAt(6 + offset), c);
133
        c.gridx = 8;
134
        c.gridy = 1;
135
        c.gridwidth = 1;
136
        c.gridheight = 1;
137
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
138
                .elementAt(7 + offset), c);
139
 
140
        // Setup the 'rate'-knob behavior to be depending on the 'master sync'
141
        // switch
142
        ((SIDSysexParameterControlKnob) midiParameterGUI.elementAt(5 + offset))
143
                .setSnapvals(snapvals);
144
        ((SIDSysexParameterControlToggleButton) midiParameterGUI
145
                .elementAt(1 + offset))
146
                .setSnapParameter((SIDSysexParameterControlGUI) midiParameterGUI
147
                        .elementAt(5 + offset));
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
}