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);
48 if (note == null || !(g instanceof Graphics2D)) return;
49 Graphics2D g2 = (Graphics2D)g;
52 int pitch = note.getPitch();
54 case 0: n = "C"; break;
55 case 1: n = "C#"; break;
56 case 2: n = "D"; break;
57 case 3: n = "D#"; break;
58 case 4: n = "E"; break;
59 case 5: n = "F"; break;
60 case 6: n = "F#"; break;
61 case 7: n = "G"; break;
62 case 8: n ="G#"; break;
63 case 9: n = "A"; break;
64 case 10: n = "A#"; break;
65 case 11: n = "B"; break;
67 g2.setFont(new Font("Helvetica", Font.PLAIN, 8));
69 g2.drawString(n + " "+ note.getVelocity(), 1, 9);