2 import java.awt.event.*;
6 * Graphical representation of a MIDI track.
8 * @author Andersson, Andreen, Lanneskog, Pehrson
12 public class MooTrackView extends JPanel {
14 private MooTrackTitle title;
15 private NoteArea notes;
16 private Rectangle box;
17 private Rectangle box2;
18 //private JPanel notes;
20 private static final int PANEL_WIDTH = 65;
21 private static final int TITLE_HEIGHT = 40;
22 private static final int NOTEVIEW_HEIGHT = 200;
27 public MooTrackView () {
28 addMouseMotionListener(doScrollRectToVisible);
29 addKeyListener(new MooKeyboard());
30 setLayout(new BorderLayout());
31 setBorder(BorderFactory.createLineBorder(Color.black));
32 add(trackTitle(), BorderLayout.NORTH);
33 add(noteView(), BorderLayout.CENTER);
36 MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
37 public void mouseDragged(MouseEvent e) {
38 Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
39 ((JPanel)e.getSource()).scrollRectToVisible(r);
43 private JPanel trackTitle () {
44 title = new MooTrackTitle();
45 title.setPreferredSize(new Dimension(PANEL_WIDTH, TITLE_HEIGHT));
46 title.setBorder(BorderFactory.createLineBorder(Color.black));
50 private JPanel noteView () {
51 notes = new NoteArea();
52 notes.setBackground(Color.white);
53 notes.setBorder(BorderFactory.createLineBorder(Color.black));
57 class NoteArea extends JPanel {
58 public void RectanglePanel() {
59 setPreferredSize(new Dimension(20, 20));
63 public void paintComponent(Graphics g) {
64 super.paintComponent(g);
65 Graphics2D g2 = (Graphics2D)g;
66 box = new Rectangle(0,0,20,20);
68 box2 = new Rectangle(20,0,20,20);