- String note = ""; //TODO: shoudl really change this name..
- int pitch = this.note.getPitch();
- switch( pitch % 12)
- {
- case 0: note = "C"; break;
- case 1: note = "C#"; break;
- case 2: note = "D"; break;
- case 3: note = "D#"; break;
- case 4: note = "E"; break;
- case 5: note = "F"; break;
- case 6: note = "F#"; break;
- case 7: note = "G"; break;
- case 8: note ="G#"; break;
- case 9: note = "A"; break;
- case 10: note = "A#"; break;
- case 11: note = "B"; break;
+
+ /**
+ * Asks the MooTrackView that the note element is painted on to remove this element and the note.
+ */
+ protected void remove(){
+ mtv.removeNote(this);
+ }
+
+ /**
+ * Listener that checks the mouse actions on this element.
+ */
+ class MAdapter extends MouseAdapter {
+
+ /**
+ * If left mouse button is clicked, selects the note and plays it.
+ */
+ public void mouseClicked(MouseEvent e) {
+ if (SwingUtilities.isLeftMouseButton(e) && !e.isControlDown()) {
+ select();
+ // Play the note
+ }
+ }
+
+ /**
+ * Checks if the mouse is pressed.
+ * Increases the pitch or velocity if the right mouse button is pressed while holding CTRL.
+ * Decreases the pitch or velocity if the left mouse button is pressed while holding CTRL.
+ * @param e the event 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);
+ }
+ Moosique.setEdited();
+ calculateString();
+ repaint();
+ } 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);
+ }
+ Moosique.setEdited();
+ calculateString();
+ repaint();
+ }
+ } else maybeShowPopup(e);