]> ruin.nu Git - moosique.git/blob - MooTrackView.java
Fixed the FileFilter, implemented some menu options, tweaked the GUI and organized...
[moosique.git] / MooTrackView.java
1 import javax.swing.*;
2 import java.awt.event.*;
3 import java.awt.*;
4
5 /**
6  * Graphical representation of a MIDI track.
7  * 
8  * @author  Andersson, Andreen, Lanneskog, Pehrson
9  * @version 1
10  */
11  
12 public class MooTrackView extends JPanel {
13
14         private MooTrackTitle title;
15         private NoteArea notes;
16         private Rectangle box;
17         private Rectangle box2;
18         //private JPanel notes;
19
20         private static final int PANEL_WIDTH = 65;
21         private static final int TITLE_HEIGHT = 40;
22         private static final int NOTEVIEW_HEIGHT = 200;
23         
24         /** 
25          * Creates 
26          */
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);
34         }
35         
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);
40         }
41         };
42         
43         private JPanel trackTitle () {
44                 title = new MooTrackTitle();
45                 title.setPreferredSize(new Dimension(PANEL_WIDTH, TITLE_HEIGHT));
46                 title.setBorder(BorderFactory.createLineBorder(Color.black));
47                 return title;
48         }
49
50         private JPanel noteView () {
51                 notes = new NoteArea(); 
52                 notes.setBackground(Color.white);
53                 notes.setBorder(BorderFactory.createLineBorder(Color.black));   
54                 return notes;           
55         }
56         
57         class NoteArea extends JPanel {
58                 public void RectanglePanel() {
59                         setPreferredSize(new Dimension(20, 20));
60                 }
61                 
62                 
63                 public void paintComponent(Graphics g) {
64                         super.paintComponent(g);
65                         Graphics2D g2 = (Graphics2D)g;
66                         box = new Rectangle(0,0,20,20);
67                         g2.draw(box);
68                         box2 = new Rectangle(20,0,20,20);
69                         g2.draw(box2);
70                 }
71         }
72 }