]> ruin.nu Git - moosique.git/blob - MooTrackView.java
no message
[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 implements ActionListener {
13
14         private MooTrackTitle title;
15         private NoteArea notes;
16         private Rectangle box;
17 <<<<<<< MooTrackView.java
18         private JPopupMenu popup;
19         private JMenuItem menuItem;
20         private String newline = "\n";
21         
22 =======
23         //private Rectangle box2;
24         //private JPanel notes;
25
26         private static final int PANEL_WIDTH = 65;
27         private static final int TITLE_HEIGHT = 45;
28         private static final int NOTEVIEW_HEIGHT = 200;
29         
30         /** 
31          * Creates 
32          */
33 >>>>>>> 1.13
34         public MooTrackView () {
35                 setLayout(new BorderLayout());
36                 this.setBorder(BorderFactory.createLineBorder(Color.black));
37                 add(trackTitle(), BorderLayout.NORTH);
38                 add(noteView(), BorderLayout.CENTER);
39         }
40         
41         private JPanel trackTitle () {
42                 title = new MooTrackTitle();
43                 title.setPreferredSize(new Dimension(PANEL_WIDTH, TITLE_HEIGHT));
44                 title.setBorder(BorderFactory.createLineBorder(Color.black));
45                 return title;
46         }
47
48         private JPanel noteView () {
49                 notes = new NoteArea(); 
50                 notes.setBackground(Color.white);
51                 notes.setBorder(BorderFactory.createLineBorder(Color.black));
52                 
53                 popup = new JPopupMenu();
54         menuItem = new JMenuItem("Add...");
55         menuItem.addActionListener(this);
56         popup.add(menuItem);
57         menuItem = new JMenuItem("Preferences...");
58         menuItem.addActionListener(this);
59         popup.add(menuItem);
60
61         MouseListener popupListener = new PopupListener();
62         notes.addMouseListener(popupListener);
63                 
64                 return notes;           
65         }
66         
67         public void actionPerformed(ActionEvent e) {
68         JMenuItem source = (JMenuItem)(e.getSource());
69         String s = "Action event detected."
70                    + newline
71                    + "    Event source: " + source.getText();
72      }
73     
74         class NoteArea extends JPanel {
75                 public void RectanglePanel() {
76                         setPreferredSize(new Dimension(20, 20));
77                         
78                 }
79                 
80                 public void paintComponent(Graphics g) {
81                         super.paintComponent(g);
82                         Graphics2D g2 = (Graphics2D)g;
83                         for (int c=0;c<1000;c=c+20) {
84                                 int r=0;
85                                 for (r=0;r<200;r=r+20) {
86                                         box = new Rectangle(r,c,20,20);
87                                         g2.setColor(Color.gray);
88                                         g2.draw(box);
89                                 }
90                         }
91                 }
92         }
93 <<<<<<< MooTrackView.java
94         
95         class PopupListener extends MouseAdapter {
96         public void mousePressed(MouseEvent e) {
97             maybeShowPopup(e);
98         }
99
100         public void mouseReleased(MouseEvent e) {
101             maybeShowPopup(e);
102         }
103
104         private void maybeShowPopup(MouseEvent e) {
105             if (e.isPopupTrigger()) {
106                 popup.show(e.getComponent(),
107                            e.getX(), e.getY());
108             }
109         }
110     }
111         
112         private static final int PANEL_WIDTH = 65;
113         private static final int TITLE_HEIGHT = 40;
114         private static final int NOTEVIEW_HEIGHT = 200;
115 =======
116 >>>>>>> 1.13
117 }