]> ruin.nu Git - moosique.git/blobdiff - MooNoteElement.java
.
[moosique.git] / MooNoteElement.java
index 969433fb928eec864372b0a68f23950f4b65d5ad..3640113034b314f79112f2f2302891df2c81e7fa 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
@@ -19,6 +21,7 @@ public class MooNoteElement extends JPanel{
        public MooNoteElement (MooNote mn) {
                note = mn;
                setPreferredSize(new Dimension(20,20));
+               setFont(new Font("Helvetica", Font.PLAIN, 10));
 
                class MouseList implements MouseListener{
                        public void mouseClicked(MouseEvent event){
@@ -39,7 +42,22 @@ 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;
        }
 
        /**
@@ -52,7 +70,7 @@ 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)
@@ -70,9 +88,9 @@ public class MooNoteElement extends JPanel{
                        case 10: note = "A#"; break;
                        case 11: note = "B"; break;
                }
-               
+
                g2.drawString(note +" "+(pitch/12), 2, 2);
 
        }
-                       
+
 }