- 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;
+ /**
+ * Gets the note that is element represents
+ * @return the MooNote object.
+ */
+ public MooNote getNote(){
+ return note;
+ }
+
+ /**
+ * 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());
+ }