3 import java.awt.event.*;
6 * Graphical representation of a MIDI note.
8 * @author Andersson, Andreen, Lanneskog, Pehrson
12 public class MooNoteElement extends JPanel {
15 private boolean selected;
18 * Creates a new note element.
19 * @param mn The note that will be graphically represented
21 public MooNoteElement (MooNote mn) {
26 * Returns true if the current NoteElement is selected, otherwise false.
27 * @return if the element is selected
29 public boolean isSelected() {
34 * Selects the current NoteElement.
35 * @param state if the element should be selected
37 public void setSelected(boolean state) {
44 public void paintComponent(Graphics g)
46 super.paintComponent(g);
51 if (!(g instanceof Graphics2D))
53 Graphics2D g2 = (Graphics2D)g;
56 int pitch = note.getPitch();
59 case 0: n = "C"; break;
60 case 1: n = "C#"; break;
61 case 2: n = "D"; break;
62 case 3: n = "D#"; break;
63 case 4: n = "E"; break;
64 case 5: n = "F"; break;
65 case 6: n = "F#"; break;
66 case 7: n = "G"; break;
67 case 8: n ="G#"; break;
68 case 9: n = "A"; break;
69 case 10: n = "A#"; break;
70 case 11: n = "B"; break;
72 g2.setFont(new Font("Helvetica", Font.PLAIN, 8));
74 g2.drawString(n + " "+ note.getVelocity(), 1, 9);