]> ruin.nu Git - moosique.git/blobdiff - MooNoteElement.java
no message
[moosique.git] / MooNoteElement.java
index b42bcb96e73f2a2b532ae28e72b02d79cfe3f248..1225fe9833ad905f5c98a65136c86cd058357831 100644 (file)
@@ -12,6 +12,8 @@ import java.awt.event.*;
 public class MooNoteElement extends JPanel{
 
        private MooNote note;
+       private boolean selected;
+
        /** 
         * Creates a new note element.
         * @param mn The note that will be graphically represented
@@ -39,10 +41,25 @@ public class MooNoteElement extends JPanel{
                };
                MouseListener listener = new MouseList();
                addMouseListener(listener);
-                       
        }
 
-       /***
+       /** 
+        * Returns true if the current NoteElement is selected, otherwise false.
+        * @return if the element is selected
+        */
+       public boolean isSelected() {
+               return selected;
+       }
+
+       /** 
+        * Selects the current NoteElement.
+        * @param state if the element should be selected
+        */
+       public void setSelected(boolean state) {
+               selected = state;
+       }
+
+       /**
         *
         */
        public void paintComponent(Graphics g)
@@ -52,8 +69,27 @@ public class MooNoteElement extends JPanel{
                if (!(g instanceof Graphics2D))
                        return;
                Graphics2D g2 = (Graphics2D)g;
+               
+               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;
+               }
+               
+               g2.drawString(note +" "+(pitch/12), 2, 2);
 
-               //Draw the note representation
        }
                        
-}
+}
\ No newline at end of file