+ * @param aTrack the track that this tracktitle is operating on.
+ */
+ public MooTrackTitle (Track aTrack) {
+ setDoubleBuffered(true);
+ track = aTrack;
+
+ // Finds track name, program change and channel.
+ MidiMessage msg;
+ int status;
+ for (int i = 0; i < track.size(); i++) {
+ msg = track.get(i).getMessage();
+ status = msg.getStatus();
+ if (status == MetaMessage.META) {
+ if (((MetaMessage)msg).getType() == 3) {
+ trackNameMessage = (MetaMessage)msg;
+ trackName = new String(trackNameMessage.getData());
+ }
+ } else if (status >= 192 && status <= 207) {
+ programChangeMessage = (ShortMessage)msg;
+ channel = status - 192;
+ }
+ }
+
+ // Creates and places components.
+ setLayout(new GridLayout(4,1));
+ setBorder(BorderFactory.createLineBorder(Color.black));
+ TitleListener tl = new TitleListener();
+
+ setPreferredSize(new Dimension(MooTrackView.VIEW_WIDTH,70));
+ title = new JTextField(trackName);
+ title.setFont(Moosique.getGUI().FONT);
+ title.addFocusListener(new TitleFocusListener());
+ add(title);
+
+ int type;
+ if (channel == 9) type = MooInstrumentList.DRUMS;
+ else type = MooInstrumentList.INSTRUMENTS;
+ instruments = new MooInstrumentList(channel, type);
+ // instruments = new MooInstrumentList(channel, type, programChangeMessage);
+ add(instruments);
+
+ channelBox = new JComboBox();
+ channelBox.setFont(Moosique.getGUI().FONT);
+ for (int i = 1; i <= 16; i++)
+ channelBox.addItem(new Integer(i));
+
+ channelBox.setSelectedIndex(channel);
+
+ channelBox.addActionListener(tl);
+ add(channelBox);
+
+ JPanel checkboxes = new JPanel();
+ checkboxes.setLayout(new GridLayout(1,3));
+
+ mute = new JCheckBox("Mute");
+ mute.setSelected(false);
+ Moosique.setTrackMute(track, false);
+ mute.setFont(Moosique.getGUI().FONT);
+ mute.addActionListener(tl);
+ checkboxes.add(mute);
+
+ solo = new JCheckBox("Solo");
+ solo.setSelected(false);
+ Moosique.setTrackSolo(track, false);
+ solo.setFont(Moosique.getGUI().FONT);
+ solo.addActionListener(tl);
+ checkboxes.add(solo);
+
+ record = new JButton("Record");
+ record.setFont(Moosique.getGUI().FONT);
+ record.addActionListener(tl);
+ checkboxes.add(record);
+
+ add(checkboxes);
+ }
+
+ /**
+ * Returns the channel of the track that the view is visualising.
+ * @return the chanel of the visualised track