]> ruin.nu Git - moosique.git/blobdiff - MooNoteElement.java
no message
[moosique.git] / MooNoteElement.java
index f6bda05e3b447642af0acffa007f5083e6eaf915..67555fcf5ccc80c45c85c7512b7ae69f1928ccd3 100644 (file)
@@ -14,7 +14,7 @@ public class MooNoteElement extends JPanel {
        private MooTrackView mtv;
        private MooNote note;
        private JPopupMenu popup;
-       private JMenuItem popupRemove, popupProp, popupTransposeOctUp, popupTransposeOctDown;
+       private JMenuItem popupRemove, popupProp, popupTranspOctUp, popupTranspOctDown;
        private Rectangle pitchRect, veloRect;
        private String notePitch, noteVelocity;
        private boolean selected = false;
@@ -25,7 +25,7 @@ public class MooNoteElement extends JPanel {
        /** 
         * Creates a new note element.
         * @param parent        The MooTrackView that this element will be painted on.
-        * @param mn    the note that will be graphically represented
+        * @param mn            the note that will be graphically represented
         */
        public MooNoteElement (MooTrackView parent, MooNote mn) {
                mtv = parent;
@@ -49,12 +49,12 @@ public class MooNoteElement extends JPanel {
                popupRemove = new JMenuItem("Remove");
                popupRemove.addActionListener(pList);
                popup.add(popupRemove);
-               popupTransposeOctUp = new JMenuItem("Transpose one octave up");
-               popupTransposeOctUp.addActionListener(pList);
-               popup.add(popupTransposeOctUp);
-               popupTransposeOctDown = new JMenuItem("Transpose one octave down");
-               popupTransposeOctDown.addActionListener(pList);
-               popup.add(popupTransposeOctDown);
+               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);
        }
 
        /** 
@@ -70,7 +70,7 @@ public class MooNoteElement extends JPanel {
         */
        public void select() {
                selected = true;
-               mtv.addSelected(this);
+               mtv.selectNote(this);
                setBackground(invBgColor);
                textColor = Color.white;
                repaint();
@@ -81,7 +81,7 @@ public class MooNoteElement extends JPanel {
         */
        public void deselect() {
                selected = false;
-               // mtv.removeSelected(this);
+               // mtv.deselectNote(this);
                setBackground(bgColor);
                textColor = Color.black;
                repaint();
@@ -134,7 +134,7 @@ public class MooNoteElement extends JPanel {
                        case 10: notePitch = "A#"; break;
                        case 11: notePitch = "B";  break;
                }
-               notePitch += pitch / 12;
+               notePitch += pitch / 12 - 1;
                noteVelocity = ""+note.getVelocity();
        }
 
@@ -146,6 +146,14 @@ public class MooNoteElement extends JPanel {
                mtv.removeNote(this);
        }
 
+       /**
+        * Updates the graphical content of the element and repaints it.
+        */
+       public void update() {
+               calculateString();
+               repaint();
+       }
+
        /**
         * layout this changed elemnt
         */
@@ -177,9 +185,9 @@ public class MooNoteElement extends JPanel {
                        if (e.isControlDown()) {
                                if (pitchRect.contains(e.getPoint())) {
                                        if (SwingUtilities.isRightMouseButton(e)) {
-                                               note.setPitch(note.getPitch() + 1);
+                                               note.transpose(1);
                                        } else if (SwingUtilities.isLeftMouseButton(e)) {
-                                               note.setPitch(note.getPitch() - 1);
+                                               note.transpose(-1);
                                        }
                                        Moosique.setEdited();
                                        calculateString();
@@ -223,19 +231,13 @@ public class MooNoteElement extends JPanel {
                                newLayout();
                        } else if (source == popupRemove) {
                                remove();
-                       } else if (source == popupTransposeOctUp) {
-                               note.setPitch(note.getPitch() + 12);
+                       } else if (source == popupTranspOctUp) {
+                               note.transpose(12);
                                update();
-                       } else if (source == popupTransposeOctDown) {
-                               note.setPitch(note.getPitch() - 12);
+                       } else if (source == popupTranspOctDown) {
+                               note.transpose(-12);
                                update();
                        }
                }
-
-               private void update() {
-                       calculateString();
-                       repaint();
-               }
-
        }
 }