]> ruin.nu Git - moosique.git/blob - MooView.java
some restructuring..
[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(Sequence seq) {
22                 super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
23                 tracks = seq.getTracks();
24
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 setSequence(Sequence seq) {
46                 tracks = seq.getTracks();
47                 createTrackViews();
48         }
49
50         public void update() {
51                 // Calls on each track view to update itself.
52                 for (int i = 0; i < trackViews.length; i++) {
53                         //trackViews[i].update();
54                 }
55         }
56         /** 
57          * Creates a view for the given track and adds it to the main view.
58          * @param track         the track for which to add a view
59          */
60         public void addTrackView(Track track) {
61                 
62         }
63
64         /** 
65          * Removes the view for the given track.
66          * @param track         the track for which to remove the view
67          */
68         public void removeTrackView(Track track) {
69                 
70         }
71 }