3 import java.awt.event.*;
6 * Graphical representation of a MIDI note.
8 * @author Andersson, Andreen, Lanneskog, Pehrson
12 public class MooNoteElement extends JPanel{
16 * Creates a new note element.
17 * @param mn The note that will be graphically represented
19 public MooNoteElement (MooNote mn) {
21 setPreferredSize(new Dimension(20,20));
23 class MouseList implements MouseListener{
24 public void mouseClicked(MouseEvent event){
25 //Bring upp dialog to edit note.
28 public void mouseEntered(MouseEvent event){
29 //Show note props in statusbar?
32 public void mouseExited(MouseEvent event){
36 public void mousePressed(MouseEvent event){ }
38 public void mouseReleased(MouseEvent event){}
40 MouseListener listener = new MouseList();
41 addMouseListener(listener);
48 public void paintComponent(Graphics g)
50 super.paintComponent(g);
52 if (!(g instanceof Graphics2D))
54 Graphics2D g2 = (Graphics2D)g;
56 String note = ""; //TODO: shoudl really change this name..
57 int pitch = this.note.getPitch();
60 case 0: note = "C"; break;
61 case 1: note = "C#"; break;
62 case 2: note = "D"; break;
63 case 3: note = "D#"; break;
64 case 4: note = "E"; break;
65 case 5: note = "F"; break;
66 case 6: note = "F#"; break;
67 case 7: note = "G"; break;
68 case 8: note ="G#"; break;
69 case 9: note = "A"; break;
70 case 10: note = "A#"; break;
71 case 11: note = "B"; break;
74 g2.drawString(note +" "+(pitch/12), 2, 2);