]> ruin.nu Git - moosique.git/blobdiff - MooNoteElement.java
added comments
[moosique.git] / MooNoteElement.java
index 1729f4aeeed79d06196fc4bb2a504de3e208b1c0..6f372349e5372c2e657f71333366075c0d4dfe50 100644 (file)
@@ -13,7 +13,6 @@ public class MooNoteElement extends JPanel {
 
        private MooTrackView mtv;
        private MooNote note;
-       private int columns;
        private boolean selected;
        private Rectangle pitchRect, veloRect;
        public static final Color bgColor = new Color(160, 218, 255);
@@ -24,14 +23,13 @@ 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 rows  the number of rows that the note will occupy
         */
        public MooNoteElement (MooTrackView parent, MooNote mn) {
                mtv = parent;
                note = mn;
                calculateString();
-               columns = mn.getDuration() / (Moosique.getSequence().getResolution() / 4);
                setBorder(BorderFactory.createLineBorder(Color.black));
                setBackground(bgColor);
                addMouseListener(new MAdapter());
@@ -70,7 +68,8 @@ public class MooNoteElement extends JPanel {
        }
 
        /**
-        *
+        * Draws the string that shows the note's properties.
+        * @param g     The Graphics object used to draw the strings.
         */
        public void paintComponent(Graphics g)
        {
@@ -90,6 +89,9 @@ public class MooNoteElement extends JPanel {
                g2.drawString("" + noteVelocity, 21, 9);
        }
 
+       /**
+        * Calculate what the string that shows the note properties should look like.
+        */
        protected void calculateString(){
 
                noteVelocity = ""; 
@@ -115,11 +117,25 @@ public class MooNoteElement extends JPanel {
                noteVelocity = ""+note.getVelocity();
        }
 
+       /**
+        * 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())) {
@@ -138,13 +154,15 @@ public class MooNoteElement extends JPanel {
                                        calculateString();
                                }
                                e.getComponent().repaint();
-                       }
-                       else if (e.isPopupTrigger()) {
+                       } 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();
@@ -156,8 +174,11 @@ public class MooNoteElement extends JPanel {
                }
        }
 
+       /**
+        * Asks the MooTrackView that it's painted on to remove this element and the note.
+        */
        protected void remove(){
-               mtv.remove(this);
+               mtv.removeNote(this, note);
        }
 
 }