1 import javax.sound.midi.*;
4 import java.awt.event.*;
7 * The main view, the container of the track views.
9 * @author Einar Pehrson
12 public class MooView extends JScrollPane {
14 private Track[] tracks;
15 private MooTrackView[] trackViews;
16 private JPanel trackPanel;
19 * Creates the main view
21 public MooView(Sequence seq) {
22 super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
23 tracks = seq.getTracks();
26 trackPanel = new JPanel(new GridLayout(1,3), true);
28 setViewportView(trackPanel);
32 * Fills the track panel with track views for all tracks in the current sequence.
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]));
42 trackPanel.validate();
45 public void setSequence(Sequence seq) {
46 tracks = seq.getTracks();
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();
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
60 public void addTrackView(Track track) {
65 * Removes the view for the given track.
66 * @param track the track for which to remove the view
68 public void removeTrackView(Track track) {