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.bassline;
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 lfoLGUIv, Vector lfoRGUIv, Vector envLGUIv,
43
            Vector envRGUIv) {
213 tk 44
        setLayout(new BorderLayout());
45
        setOpaque(false);
628 adamjking 46
 
213 tk 47
        JPanel topPanel = new JPanel();
48
        topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
49
        topPanel.setOpaque(false);
628 adamjking 50
 
213 tk 51
        JPanel panel1 = new JPanel();
52
        panel1.setOpaque(false);
628 adamjking 53
        panel1.setLayout(new GridLayout(2, 2));
54
        panel1.add(createLFO(lfoLGUIv, "LFO 1 (left)", 0));
55
        panel1.add(createLFO(lfoRGUIv, "LFO 1 (right)", 0));
56
        panel1.add(createLFO(lfoLGUIv, "LFO 2 (left)", 11));
57
        panel1.add(createLFO(lfoRGUIv, "LFO 2 (right)", 11));
58
 
213 tk 59
        JPanel panel2 = new JPanel();
628 adamjking 60
        panel2.setLayout(new GridLayout(1, 2));
61
        panel2.add(createENV(envLGUIv, "Envelope 1 (left)"));
62
        panel2.add(createENV(envRGUIv, "Envelope 2 (right)"));
213 tk 63
        panel2.setOpaque(false);
628 adamjking 64
 
213 tk 65
        topPanel.add(panel1);
66
        topPanel.add(panel2);
628 adamjking 67
        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 = 5;
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(2 + 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(3 + 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(1 + 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(4 + 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(5 + 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(9 + offset), c);
126
        c.gridx = 9;
127
        c.gridy = 0;
128
        c.gridwidth = 1;
129
        c.gridheight = 1;
130
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
131
                .elementAt(10 + offset), c);
132
        c.gridx = 7;
133
        c.gridy = 1;
134
        c.gridwidth = 1;
135
        c.gridheight = 1;
136
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
137
                .elementAt(6 + offset), c);
138
        c.gridx = 8;
139
        c.gridy = 1;
140
        c.gridwidth = 1;
141
        c.gridheight = 1;
142
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
143
                .elementAt(7 + offset), c);
144
        c.gridx = 9;
145
        c.gridy = 1;
146
        c.gridwidth = 1;
147
        c.gridheight = 1;
148
        lfoPanel.add((SIDSysexParameterControlGUI) midiParameterGUI
149
                .elementAt(8 + offset), c);
150
 
151
        // Setup the 'rate'-knob behavior to be depending on the 'master sync'
152
        // switch
153
        ((SIDSysexParameterControlKnob) midiParameterGUI.elementAt(6 + offset))
154
                .setSnapvals(snapvals);
155
        ((SIDSysexParameterControlToggleButton) midiParameterGUI
156
                .elementAt(2 + offset))
157
                .setSnapParameter((SIDSysexParameterControlGUI) midiParameterGUI
158
                        .elementAt(6 + offset));
159
 
213 tk 160
        return lfoPanel;
161
    }
628 adamjking 162
 
213 tk 163
    protected JPanel createENV(Vector midiParameterGUI, String s) {
164
        JPanel envTopPanel = new JPanel();
165
        envTopPanel.setLayout(new BoxLayout(envTopPanel, BoxLayout.Y_AXIS));
166
        envTopPanel.setBorder(BorderFactory.createEtchedBorder());
167
        envTopPanel.setBorder(BorderFactory.createTitledBorder(s));
168
        envTopPanel.setOpaque(false);
628 adamjking 169
 
213 tk 170
        JPanel envPanel = new JPanel();
171
        envPanel.setLayout(new BoxLayout(envPanel, BoxLayout.X_AXIS));
628 adamjking 172
        envPanel.setOpaque(false);
173
 
213 tk 174
        // SubPanel1
175
        JPanel subPanel1 = new JPanel();
628 adamjking 176
        subPanel1.setLayout(new GridLayout(1, 4));
177
        subPanel1.setOpaque(false);
178
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
179
                .elementAt(7));
180
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(7))
181
                .setHeight(120);
182
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
183
                .elementAt(8));
184
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(8))
185
                .setHeight(120);
186
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
187
                .elementAt(9));
188
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(9))
189
                .setHeight(120);
190
        subPanel1.add((SIDSysexParameterControlGUI) midiParameterGUI
191
                .elementAt(10));
192
        ((SIDSysexParameterControlSlider) midiParameterGUI.elementAt(10))
193
                .setHeight(120);
194
 
213 tk 195
        envPanel.add(subPanel1);
628 adamjking 196
 
213 tk 197
        // SubPanel2
198
        JPanel subPanel2 = new JPanel();
628 adamjking 199
        subPanel2.setLayout(new GridLayout(3, 5));
200
        subPanel2.setOpaque(false);
201
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
202
                .elementAt(4));
203
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
204
                .elementAt(5));
205
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
206
                .elementAt(6));
207
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
208
                .elementAt(12));
209
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
210
                .elementAt(11));
211
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
212
                .elementAt(3));
213
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
214
                .elementAt(0));
215
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
216
                .elementAt(1));
217
        subPanel2.add((SIDSysexParameterControlGUI) midiParameterGUI
218
                .elementAt(2));
213 tk 219
        envPanel.add(subPanel2);
628 adamjking 220
 
213 tk 221
        envTopPanel.add(envPanel);
628 adamjking 222
 
213 tk 223
        return envTopPanel;
224
    }
628 adamjking 225
}