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
20 * @param rows the number of rows that the note will occupy
22 public MooNoteElement (MooNote mn, int rows) {
27 * Returns true if the current NoteElement is selected, otherwise false.
28 * @return if the element is selected
30 public boolean isSelected() {
35 * Selects the current NoteElement.
36 * @param state if the element should be selected
38 public void setSelected(boolean state) {
45 public void paintComponent(Graphics g)
47 super.paintComponent(g);
49 if (note == null || !(g instanceof Graphics2D)) return;
50 Graphics2D g2 = (Graphics2D)g;
53 int pitch = note.getPitch();
55 case 0: n = "C"; break;
56 case 1: n = "C#"; break;
57 case 2: n = "D"; break;
58 case 3: n = "D#"; break;
59 case 4: n = "E"; break;
60 case 5: n = "F"; break;
61 case 6: n = "F#"; break;
62 case 7: n = "G"; break;
63 case 8: n ="G#"; break;
64 case 9: n = "A"; break;
65 case 10: n = "A#"; break;
66 case 11: n = "B"; break;
68 g2.setFont(new Font("Helvetica", Font.PLAIN, 8));
70 g2.drawString(n + " "+ note.getVelocity(), 1, 9);