Subversion Repositories svn.mios

Rev

Rev 505 | 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;
628 adamjking 24
import java.awt.Dimension;
213 tk 25
import java.awt.Font;
26
import java.awt.GridBagConstraints;
27
import java.awt.GridBagLayout;
28
import java.awt.GridLayout;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionListener;
31
import java.util.Vector;
32
 
33
import javax.swing.BorderFactory;
34
import javax.swing.BoxLayout;
505 rutgerv 35
import javax.swing.ButtonGroup;
213 tk 36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
505 rutgerv 38
import javax.swing.JRadioButton;
213 tk 39
 
628 adamjking 40
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlGUI;
41
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlKnob;
42
 
43
public class SequencerGUI extends JPanel implements ActionListener {
44
    private JPanel seqPanel, currentPanel, seq1, seq2, seq3, seq4, seq5, seq6,
45
            seq7, seq8;
505 rutgerv 46
    private JRadioButton radioButtons[];
628 adamjking 47
    private int[] snapvals = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
48
 
213 tk 49
    protected SequencerGUI(Vector V1GUIv, Vector V2GUIv, Vector V3GUIv) {
50
        setLayout(new BorderLayout());
51
        this.setOpaque(false);
628 adamjking 52
 
53
        JPanel mainPanel = new JPanel();
213 tk 54
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
55
        mainPanel.setOpaque(false);
628 adamjking 56
 
213 tk 57
        seqPanel = new JPanel();
58
        seqPanel.setLayout(new BoxLayout(seqPanel, BoxLayout.X_AXIS));
59
        seqPanel.setBorder(BorderFactory.createEtchedBorder());
60
        seqPanel.setBorder(BorderFactory.createTitledBorder("Sequencer data"));
61
        seqPanel.setOpaque(false);
628 adamjking 62
 
505 rutgerv 63
        JPanel comboPanel = new JPanel();
64
        comboPanel.setLayout(new BoxLayout(comboPanel, BoxLayout.Y_AXIS));
628 adamjking 65
        comboPanel.setOpaque(false);
66
        String[] s = { "Sequence #1", "Sequence #2", "Sequence #3",
67
                "Sequence #4", "Sequence #5", "Sequence #6", "Sequence #7",
68
                "Sequence #8" };
505 rutgerv 69
        ButtonGroup bg = new ButtonGroup();
70
        radioButtons = new JRadioButton[s.length];
628 adamjking 71
        for (int i = 0; i < s.length; i++) {
505 rutgerv 72
            radioButtons[i] = new JRadioButton(s[i], true);
73
            radioButtons[i].setOpaque(false);
74
            radioButtons[i].addActionListener(this);
75
            bg.add(radioButtons[i]);
76
            comboPanel.add(radioButtons[i]);
628 adamjking 77
        }
78
 
213 tk 79
        seqPanel.add(comboPanel);
628 adamjking 80
 
81
        seq1 = createSeqData(V1GUIv, 0);
82
        seq2 = createSeqData(V1GUIv, 96);
83
        seq3 = createSeqData(V1GUIv, 192);
84
        seq4 = createSeqData(V1GUIv, 288);
85
        seq5 = createSeqData(V1GUIv, 384);
86
        seq6 = createSeqData(V1GUIv, 480);
87
        seq7 = createSeqData(V1GUIv, 576);
88
        seq8 = createSeqData(V1GUIv, 672);
89
 
213 tk 90
        currentPanel = seq1;
91
        seqPanel.add(currentPanel);
628 adamjking 92
 
213 tk 93
        JPanel setupPanel = new JPanel();
94
        setupPanel.setLayout(new BoxLayout(setupPanel, BoxLayout.X_AXIS));
628 adamjking 95
        setupPanel.setOpaque(false);
96
        setupPanel.add(createConfig(V2GUIv, "Sequencer setup (left)"));
97
        setupPanel.add(createConfig(V3GUIv, "Sequencer setup (right)"));
98
 
213 tk 99
        mainPanel.add(setupPanel);
100
        mainPanel.add(seqPanel);
628 adamjking 101
        this.add(mainPanel, BorderLayout.NORTH);
213 tk 102
    }
628 adamjking 103
 
104
    protected JPanel createConfig(Vector vGUI, String s) {
213 tk 105
        JPanel configPanel = new JPanel();
628 adamjking 106
        configPanel.setLayout(new GridLayout(2, 4));
213 tk 107
        configPanel.setBorder(BorderFactory.createEtchedBorder());
108
        configPanel.setBorder(BorderFactory.createTitledBorder(s));
109
        configPanel.setOpaque(false);
110
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(0));
111
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(4));
628 adamjking 112
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(1));
213 tk 113
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(3));
628 adamjking 114
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(2));
213 tk 115
        return configPanel;
628 adamjking 116
    }
213 tk 117
 
628 adamjking 118
    protected JPanel createSeqData(Vector vGUI, int offset) {
213 tk 119
        JPanel seqPanel = new JPanel();
628 adamjking 120
        seqPanel.setLayout(new GridBagLayout());
213 tk 121
        seqPanel.setOpaque(false);
628 adamjking 122
        GridBagConstraints c = new GridBagConstraints();
123
        c.fill = GridBagConstraints.HORIZONTAL;
124
 
125
        String[] names = { "Step", "Note", "Octave", "Param", "Glide",
126
                "Accent", "Gate" };
127
        for (int row = 0; row < 7; row++) {
213 tk 128
            c.gridx = 0;
129
            c.gridy = row;
130
            JLabel label = new JLabel(names[row]);
131
            label.setVerticalAlignment(JLabel.CENTER);
628 adamjking 132
            label.setFont(new Font("serif", Font.BOLD, 10));
133
            label.setOpaque(false);
134
            label.setPreferredSize(new Dimension(35, 10));
213 tk 135
            seqPanel.add(label, c);
136
        }
628 adamjking 137
        for (int col = 0; col < 16; col++) {
138
            c.gridx = col + 1;
213 tk 139
            c.gridy = 0;
140
            c.anchor = GridBagConstraints.CENTER;
628 adamjking 141
            JLabel label = new JLabel(Integer.toString(col + 1));
213 tk 142
            label.setHorizontalAlignment(JLabel.CENTER);
628 adamjking 143
            label.setFont(new Font("serif", Font.BOLD, 10));
144
            label.setOpaque(false);
213 tk 145
            seqPanel.add(label, c);
146
        }
628 adamjking 147
        for (int col = 0; col < 16; col++) {
148
            for (int row = 0; row < 6; row++) {
149
                c.gridx = col + 1;
150
                c.gridy = row + 1;
151
                seqPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(row
152
                        + (6 * col) + offset), c);
153
                if (row == 0) {
154
                    ((SIDSysexParameterControlKnob) vGUI.elementAt(row
155
                            + (6 * col) + offset)).setSnapvals(snapvals);
156
                    ((SIDSysexParameterControlKnob) vGUI.elementAt(row
157
                            + (6 * col) + offset)).setSnap(true);
213 tk 158
                }
159
            }
628 adamjking 160
        }
213 tk 161
        return seqPanel;
628 adamjking 162
    }
163
 
213 tk 164
    public void actionPerformed(ActionEvent ae) {
628 adamjking 165
        for (int i = 1; i < radioButtons.length; i++) {
166
            if ((ae.getSource() == radioButtons[i])
167
                    && (radioButtons[i].isSelected())) {
505 rutgerv 168
                seqPanel.remove(currentPanel);
169
                switch (i) {
628 adamjking 170
                case 0:
213 tk 171
                    currentPanel = seq1;
172
                    break;
628 adamjking 173
                case 1:
174
                    currentPanel = seq2;
213 tk 175
                    break;
176
                case 2:
177
                    currentPanel = seq3;
178
                    break;
179
                case 3:
628 adamjking 180
                    currentPanel = seq4;
213 tk 181
                    break;
182
                case 4:
183
                    currentPanel = seq5;
184
                    break;
185
                case 5:
186
                    currentPanel = seq6;
187
                    break;
188
                case 6:
189
                    currentPanel = seq7;
190
                    break;
191
                case 7:
628 adamjking 192
                    currentPanel = seq8;
193
                    break;
194
                }
505 rutgerv 195
                seqPanel.add(currentPanel);
196
                this.repaint();
197
                break;
213 tk 198
            }
199
        }
200
    }
201
}