Subversion Repositories svn.mios

Rev

Rev 250 | Rev 696 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 250 Rev 628
1
/*
1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
5
 *
6
 * This application is free software; you can redistribute it and/or modify
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
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
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
9
 * (at your option) any later version.
10
 *
10
 *
11
 * This application is distributed in the hope that it will be useful,
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
14
 * GNU General Public License for more details.
15
 *
15
 *
16
 * You should have received a copy of the GNU General Public License
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
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
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
19
 */
20
20
21
package org.midibox.sidedit.gui.drum;
21
package org.midibox.sidedit.gui.drum;
22
22
23
import java.awt.BorderLayout;
23
import java.awt.BorderLayout;
24
import java.awt.event.*;
24
import java.awt.Dimension;
25
import java.awt.FlowLayout;
25
import java.awt.FlowLayout;
26
import java.awt.Font;
26
import java.awt.Font;
27
import java.awt.GridBagConstraints;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
28
import java.awt.GridBagLayout;
29
import java.awt.GridLayout;
-
 
30
import java.awt.Dimension;
-
 
31
import java.awt.GridLayout;
-
 
32
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionEvent;
33
import java.awt.event.ActionListener;
30
import java.awt.event.ActionListener;
34
import java.util.Vector;
31
import java.util.Vector;
35
32
36
import javax.swing.AbstractButton;
-
 
37
import javax.swing.BorderFactory;
33
import javax.swing.BorderFactory;
38
import javax.swing.BoxLayout;
34
import javax.swing.BoxLayout;
39
import javax.swing.JComboBox;
35
import javax.swing.JComboBox;
40
import javax.swing.JLabel;
36
import javax.swing.JLabel;
41
import javax.swing.JPanel;
37
import javax.swing.JPanel;
42
import javax.swing.JSlider;
-
 
43
import javax.swing.JToggleButton;
-
 
44
38
45
import org.midibox.sidedit.SIDEditController;
-
 
46
import org.midibox.sidedit.SIDSysexInfo;
-
 
47
import org.midibox.sidedit.SIDSysexParameterControl;
39
import org.midibox.sidedit.SIDSysexParameterControl;
48
import org.midibox.utils.gui.ImageLoader;
-
 
49
import org.midibox.utils.gui.JVertLabel;
-
 
50
import org.midibox.utils.gui.Knob;
-
 
51
import org.midibox.utils.gui.MyButtonUI;
-
 
52
import  org.midibox.sidedit.gui.controls.*;
40
import org.midibox.sidedit.gui.SequencerButton;
53
import org.midibox.sidedit.gui.lead.LeadGUI;
41
import org.midibox.sidedit.gui.controls.SIDSysexParameterControlGUI;
54
import org.midibox.sidedit.gui.*;
-
 
-
 
42
55
public class SequencerGUI extends JPanel implements ActionListener{
43
public class SequencerGUI extends JPanel implements ActionListener {
56
    private JPanel seqPanel,currentPanel,seq1,seq2,seq3,seq4,seq5,seq6,seq7,seq8;
44
    private JPanel seqPanel, currentPanel, seq1, seq2, seq3, seq4, seq5, seq6,
-
 
45
            seq7, seq8;
57
    private JComboBox combo;
46
    private JComboBox combo;
58
    private int[] snapvals = {0,1,2,3,4,5,6,7,8,9,10,11,12};
47
    private int[] snapvals = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
59
   
48
60
    protected SequencerGUI(Vector V1GUIv, Vector V2GUIv) {
49
    protected SequencerGUI(Vector V1GUIv, Vector V2GUIv) {
61
        setLayout(new BorderLayout());
50
        setLayout(new BorderLayout());
62
        this.setOpaque(false);
51
        this.setOpaque(false);
63
       
52
64
        JPanel mainPanel = new JPanel();
53
        JPanel mainPanel = new JPanel();
65
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
54
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
66
        mainPanel.setOpaque(false);
55
        mainPanel.setOpaque(false);
67
       
56
68
        seqPanel = new JPanel();
57
        seqPanel = new JPanel();
69
        seqPanel.setLayout(new BoxLayout(seqPanel, BoxLayout.X_AXIS));
58
        seqPanel.setLayout(new BoxLayout(seqPanel, BoxLayout.X_AXIS));
70
        seqPanel.setBorder(BorderFactory.createEtchedBorder());
59
        seqPanel.setBorder(BorderFactory.createEtchedBorder());
71
        seqPanel.setBorder(BorderFactory.createTitledBorder("Sequencer data"));
60
        seqPanel.setBorder(BorderFactory.createTitledBorder("Sequencer data"));
72
        seqPanel.setOpaque(false);
61
        seqPanel.setOpaque(false);
73
       
62
74
        JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
63
        JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
75
        comboPanel.setOpaque(false);
64
        comboPanel.setOpaque(false);
-
 
65
        String[] s = { "Sequence #1", "Sequence #2", "Sequence #3",
76
        String[] s = {"Sequence #1","Sequence #2","Sequence #3","Sequence #4","Sequence #5","Sequence #6","Sequence #7","Sequence #8"};
66
                "Sequence #4", "Sequence #5", "Sequence #6", "Sequence #7",
-
 
67
                "Sequence #8" };
77
        combo = new JComboBox(s);
68
        combo = new JComboBox(s);
78
        combo.setPreferredSize(new Dimension(110,20));
69
        combo.setPreferredSize(new Dimension(110, 20));
79
        combo.setFont(new Font("sansserif", Font.BOLD, 11));
70
        combo.setFont(new Font("sansserif", Font.BOLD, 11));
80
        combo.addActionListener(this);
71
        combo.addActionListener(this);
81
        comboPanel.add(combo);
72
        comboPanel.add(combo);
82
        seqPanel.add(comboPanel);      
73
        seqPanel.add(comboPanel);
83
               
74
84
        seq1 = createSeqData(V2GUIv,0);
75
        seq1 = createSeqData(V2GUIv, 0);
85
        seq2 = createSeqData(V2GUIv,1);
76
        seq2 = createSeqData(V2GUIv, 1);
86
        seq3 = createSeqData(V2GUIv,2);
77
        seq3 = createSeqData(V2GUIv, 2);
87
        seq4 = createSeqData(V2GUIv,3);
78
        seq4 = createSeqData(V2GUIv, 3);
88
        seq5 = createSeqData(V2GUIv,4);
79
        seq5 = createSeqData(V2GUIv, 4);
89
        seq6 = createSeqData(V2GUIv,5);
80
        seq6 = createSeqData(V2GUIv, 5);
90
        seq7 = createSeqData(V2GUIv,6);
81
        seq7 = createSeqData(V2GUIv, 6);
91
        seq8 = createSeqData(V2GUIv,7);
82
        seq8 = createSeqData(V2GUIv, 7);
92
       
83
93
        currentPanel = seq1;
84
        currentPanel = seq1;
94
        seqPanel.add(currentPanel);
85
        seqPanel.add(currentPanel);
95
       
86
96
        mainPanel.add(createConfig(V1GUIv,"Sequencer setup"));
87
        mainPanel.add(createConfig(V1GUIv, "Sequencer setup"));
97
        mainPanel.add(seqPanel);
88
        mainPanel.add(seqPanel);
98
        this.add(mainPanel, BorderLayout.NORTH);
89
        this.add(mainPanel, BorderLayout.NORTH);
99
    }
90
    }
100
   
91
101
    protected JPanel createConfig(Vector vGUI, String s) {     
92
    protected JPanel createConfig(Vector vGUI, String s) {
102
        JPanel configPanel = new JPanel();
93
        JPanel configPanel = new JPanel();
103
        configPanel.setLayout(new BoxLayout(configPanel, BoxLayout.X_AXIS));       
94
        configPanel.setLayout(new BoxLayout(configPanel, BoxLayout.X_AXIS));
104
        configPanel.setBorder(BorderFactory.createEtchedBorder());
95
        configPanel.setBorder(BorderFactory.createEtchedBorder());
105
        configPanel.setBorder(BorderFactory.createTitledBorder(s));
96
        configPanel.setBorder(BorderFactory.createTitledBorder(s));
106
        configPanel.setOpaque(false);
97
        configPanel.setOpaque(false);
107
       
98
108
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(3));
99
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(3));
109
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(4));
100
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(4));
110
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(0));      
101
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(0));
111
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(1));
102
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(1));
112
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(2));      
103
        configPanel.add((SIDSysexParameterControlGUI) vGUI.elementAt(2));
113
        return configPanel;
104
        return configPanel;
114
    }  
105
    }
115
106
116
    protected JPanel createSeqData(Vector vGUI, int seqNr) {       
107
    protected JPanel createSeqData(Vector vGUI, int seqNr) {
117
        JPanel chanPanel = new JPanel();
108
        JPanel chanPanel = new JPanel();
118
        chanPanel.setLayout(new GridBagLayout());      
109
        chanPanel.setLayout(new GridBagLayout());
119
        chanPanel.setOpaque(false);
110
        chanPanel.setOpaque(false);
120
       
111
121
        GridBagConstraints c = new GridBagConstraints();       
112
        GridBagConstraints c = new GridBagConstraints();
122
        c.fill = GridBagConstraints.HORIZONTAL;
113
        c.fill = GridBagConstraints.HORIZONTAL;
123
        c.anchor = GridBagConstraints.CENTER;
114
        c.anchor = GridBagConstraints.CENTER;
124
       
115
125
        // Loop over all channels
116
        // Loop over all channels
126
        for(int chan=0;chan<8;chan++) {
117
        for (int chan = 0; chan < 8; chan++) {
127
            // Dummy panel to fill
118
            // Dummy panel to fill
-
 
119
            c.gridx = 0;
128
            c.gridx = 0;c.gridy = (2*chan)+2;c.gridheight=1;
120
            c.gridy = (2 * chan) + 2;
-
 
121
            c.gridheight = 1;
129
            JPanel transp = new JPanel();
122
            JPanel transp = new JPanel();
130
            transp.setOpaque(false);
123
            transp.setOpaque(false);
131
            chanPanel.add(transp, c);
124
            chanPanel.add(transp, c);
132
           
125
133
            // Row labels
126
            // Row labels
134
            c.gridwidth=2;
127
            c.gridwidth = 2;
-
 
128
            if (chan == 0) {
-
 
129
                c.gridx = 0;
-
 
130
                c.gridy = (2 * chan);
135
            if(chan==0) {c.gridx = 0;c.gridy = (2*chan); chanPanel.add(createSeqLabel("Step"), c);}
131
                chanPanel.add(createSeqLabel("Step"), c);
-
 
132
            }
-
 
133
            c.gridx = 0;
136
            c.gridx = 0;c.gridy = (2*chan)+1;
134
            c.gridy = (2 * chan) + 1;
137
            chanPanel.add(createSeqLabel("Chan."+Integer.toString(chan+1)), c);
135
            chanPanel.add(createSeqLabel("Chan." + Integer.toString(chan + 1)),
-
 
136
                    c);
138
            c.gridwidth=1;
137
            c.gridwidth = 1;
139
           
138
140
            int offset = (32*chan) + (seqNr*256) ; 
139
            int offset = (32 * chan) + (seqNr * 256);
141
            for(int col=0;col<16;col++) {              
140
            for (int col = 0; col < 16; col++) {
142
                // Column labels
141
                // Column labels
143
                if (chan==0) {
142
                if (chan == 0) {
144
                    JLabel label = new JLabel(Integer.toString(col+1));
143
                    JLabel label = new JLabel(Integer.toString(col + 1));
145
                    label.setHorizontalAlignment(JLabel.CENTER);
144
                    label.setHorizontalAlignment(JLabel.CENTER);
146
                    label.setFont(new Font("serif",Font.BOLD,10));
145
                    label.setFont(new Font("serif", Font.BOLD, 10));
147
                    label.setOpaque(false);
146
                    label.setOpaque(false);
-
 
147
                    c.gridx = col + 2;
148
                    c.gridx = col+2;c.gridy = (2*chan);
148
                    c.gridy = (2 * chan);
149
                    chanPanel.add(label, c);
149
                    chanPanel.add(label, c);
150
                }
150
                }
151
               
151
152
                // Buttons
152
                // Buttons
-
 
153
                c.gridx = col + 2;
153
                c.gridx = col+2;c.gridy = 1+(2*chan);              
154
                c.gridy = 1 + (2 * chan);
154
                SIDSysexParameterControl mp1 = ((SIDSysexParameterControlGUI) vGUI.elementAt(0+offset+col)).getMidiParameter();
155
                SIDSysexParameterControl mp1 = ((SIDSysexParameterControlGUI) vGUI
-
 
156
                        .elementAt(0 + offset + col)).getMidiParameter();
155
                SIDSysexParameterControl mp2 = ((SIDSysexParameterControlGUI) vGUI.elementAt(0+offset+col+16)).getMidiParameter();             
157
                SIDSysexParameterControl mp2 = ((SIDSysexParameterControlGUI) vGUI
-
 
158
                        .elementAt(0 + offset + col + 16)).getMidiParameter();
156
                chanPanel.add(new SequencerButton(mp1, mp2), c);               
159
                chanPanel.add(new SequencerButton(mp1, mp2), c);
157
            }      
160
            }
158
        }
161
        }
159
        return chanPanel;  
162
        return chanPanel;
160
    }  
163
    }
161
   
164
162
    public JLabel createSeqLabel(String s) {
165
    public JLabel createSeqLabel(String s) {
163
        JLabel label = new JLabel(s);
166
        JLabel label = new JLabel(s);
164
        label.setVerticalAlignment(JLabel.CENTER);
167
        label.setVerticalAlignment(JLabel.CENTER);
165
        label.setFont(new Font("serif",Font.BOLD,10));
168
        label.setFont(new Font("serif", Font.BOLD, 10));
166
        label.setOpaque(false);        
169
        label.setOpaque(false);
167
        label.setPreferredSize(new Dimension(35,10));
170
        label.setPreferredSize(new Dimension(35, 10));
168
        return label;
171
        return label;
169
    }
172
    }
170
   
173
171
    public void actionPerformed(ActionEvent ae) {
174
    public void actionPerformed(ActionEvent ae) {
172
        if (ae.getSource()==combo) {
175
        if (ae.getSource() == combo) {
173
            seqPanel.remove(currentPanel);
176
            seqPanel.remove(currentPanel);
174
            switch (combo.getSelectedIndex()) {
177
            switch (combo.getSelectedIndex()) {
175
                case 0:                
178
            case 0:
176
                    currentPanel = seq1;
179
                currentPanel = seq1;
177
                    break;
180
                break;
178
                case 1:                
181
            case 1:
179
                    currentPanel = seq2;   
182
                currentPanel = seq2;
180
                    break;
183
                break;
181
                case 2:
184
            case 2:
182
                    currentPanel = seq3;
185
                currentPanel = seq3;
183
                    break;
186
                break;
184
                case 3:
187
            case 3:
185
                    currentPanel = seq4;               
188
                currentPanel = seq4;
186
                    break;
189
                break;
187
                case 4:
190
            case 4:
188
                    currentPanel = seq5;
191
                currentPanel = seq5;
189
                    break;
192
                break;
190
                case 5:
193
            case 5:
191
                    currentPanel = seq6;
194
                currentPanel = seq6;
192
                    break;
195
                break;
193
                case 6:
196
            case 6:
194
                    currentPanel = seq7;
197
                currentPanel = seq7;
195
                    break;
198
                break;
196
                case 7:
199
            case 7:
197
                    currentPanel = seq8;                   
200
                currentPanel = seq8;
198
                    break;
201
                break;
199
            }
202
            }
200
            seqPanel.add(currentPanel);
203
            seqPanel.add(currentPanel);
201
            this.repaint();
204
            this.repaint();
202
        }
205
        }
203
    }
206
    }
204
}
207
}
205
 
208