+ * @param parent The MooTrackView that this element will be painted on.
+ * @param mn the note that will be graphically represented
+ */
+ public MooNoteElement (MooTrackView parent, MooNote mn) {
+ mtv = parent;
+ note = mn;
+ calculateString();
+ addMouseListener(new MAdapter());
+ setBorder(BorderFactory.createLineBorder(Color.black));
+ setBackground(bgColor);
+ textColor = Color.black;
+
+ // Defines coordinates.
+ pitchRect = new Rectangle(0, 0, 15, 10);
+ veloRect = new Rectangle(20, 0, 40, 10);
+
+ // Creates pop-up menu.
+ popup = new JPopupMenu();
+ PopupListener pList = new PopupListener();
+ popupProp = new JMenuItem("Preferences...");
+ popupProp.addActionListener(pList);
+ popup.add(popupProp);
+ popupRemove = new JMenuItem("Remove");
+ popupRemove.addActionListener(pList);
+ popup.add(popupRemove);
+ popupTranspOctUp = new JMenuItem("Transpose one octave up");
+ popupTranspOctUp.addActionListener(pList);
+ popup.add(popupTranspOctUp);
+ popupTranspOctDown = new JMenuItem("Transpose one octave down");
+ popupTranspOctDown.addActionListener(pList);
+ popup.add(popupTranspOctDown);
+ }
+
+ /**
+ * Returns the note of this element.
+ * @return the note
+ */
+ public MooNote getNote() {
+ return note;
+ }
+
+ /**
+ * Selects the current NoteElement.
+ */
+ public void select() {
+ selected = true;
+ mtv.selectNote(this);
+ setBackground(invBgColor);
+ textColor = Color.white;
+ repaint();
+ }
+
+ /**
+ * Deselects the current NoteElement.
+ */
+ public void deselect() {
+ selected = false;
+ // mtv.deselectNote(this);
+ setBackground(bgColor);
+ textColor = Color.black;
+ repaint();
+ }
+
+ /**
+ * Transposes the current note element the given number of halftones.
+ * @param halftones the number of halftones to transpose - positive for up, negative for down