]> ruin.nu Git - moosique.git/blob - MooView.java
no message
[moosique.git] / MooView.java
1 import javax.sound.midi.*;
2 import javax.swing.*;
3 import java.awt.*;
4 import java.awt.event.*;
5
6 /**
7  * The main view, the container of the track views.
8  * 
9  * @author  Einar Pehrson
10  */
11
12 public class MooView extends JScrollPane {
13
14         private Track[] tracks;
15         private MooTrackView[] trackViews;
16         private JPanel trackPanel;
17
18         /** 
19          * Creates the main view
20          */
21         public MooView(Track[] tracks) {
22                 super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
23
24                 this.tracks = tracks;
25
26                 trackPanel = new JPanel(new GridLayout(1,3), true);
27                 createTrackViews();
28                 setViewportView(trackPanel);
29         }
30
31         /** 
32          * Fills the track panel with track views for all tracks in the current sequence.
33          */
34         private void createTrackViews() {
35                 trackPanel.removeAll();
36                 ((GridLayout)trackPanel.getLayout()).setColumns(tracks.length);
37                 trackViews = new MooTrackView[tracks.length];
38                 for (int i = 0; i < tracks.length; i++) {
39                         trackViews[i] = new MooTrackView(tracks[i]);
40                         trackPanel.add(new MooTrackView(tracks[i]));
41                 }
42                 trackPanel.validate();
43         }
44
45         public void update(Track[] tracks) {
46                 this.tracks = tracks;
47                 createTrackViews();
48         }
49
50         /** 
51          * Creates a view for the given track and adds it to the main view.
52          * @param track         the track for which to add a view
53          */
54         public void addTrackView(Track track) {
55                 
56         }
57
58         /** 
59          * Removes the view for the given track.
60          * @param track         the track for which to remove the view
61          */
62         public void removeTrackView(Track track) {
63                 
64         }
65 }