+
+ /**
+ * Listener that checks the mouse actions on this element.
+ */
+ class MAdapter extends MouseAdapter {
+ /**
+ * Checks if the mouse is pressed.
+ * Pops up the menu if right mousebutton is used.
+ * Increases the pitch or velocity if the right mousebutton is pressed while holding ctrl down.
+ * Decreases the pitch or velocity if the left mousebutton is pressed while holding ctrl down.
+ * @param e The events recieved.
+ */
+ public void mousePressed(MouseEvent e) {
+ if (e.isControlDown()) {
+ if (pitchRect.contains(e.getPoint())) {
+ if (SwingUtilities.isRightMouseButton(e)) {
+ note.setPitch(note.getPitch() + 1);
+ } else if (SwingUtilities.isLeftMouseButton(e)) {
+ note.setPitch(note.getPitch() - 1);
+ }
+ calculateString();
+ } else if (veloRect.contains(e.getPoint())) {
+ if (SwingUtilities.isRightMouseButton(e)) {
+ note.setVelocity(note.getVelocity() + 1);
+ } else if (SwingUtilities.isLeftMouseButton(e)) {
+ note.setVelocity(note.getVelocity() - 1);
+ }
+ calculateString();
+ }
+ e.getComponent().repaint();
+ } else if (e.isPopupTrigger()) {
+ popup.show(e.getComponent(), e.getX(), e.getY());
+ }
+ }
+ }
+
+ /**
+ * Listens on the actions made to the popupmenu.
+ */
+ class PopupListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ Object source = e.getSource();
+ if (source == popupProp) {
+ new MooDialog(note);
+ } else if (source == popupRemove) {
+ remove();
+ }
+ }
+ }
+
+ /**
+ * Asks the MooTrackView that it's painted on to remove this element and the note.
+ */
+ protected void remove(){
+ mtv.removeNote(this, note);
+ }
+
+}