* @version 1
*/
-public class MooNoteElement extends JPanel{
+public class MooNoteElement extends JPanel {
private MooNote note;
private boolean selected;
*/
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){
- //Bring upp dialog to edit note.
- }
-
- public void mouseEntered(MouseEvent event){
- //Show note props in statusbar?
- }
-
- public void mouseExited(MouseEvent event){
- //Reset statusbar?
- }
-
- public void mousePressed(MouseEvent event){ }
-
- public void mouseReleased(MouseEvent event){}
- };
- MouseListener listener = new MouseList();
- addMouseListener(listener);
}
/**
{
super.paintComponent(g);
- if (note == null)
- return;
-
- if (!(g instanceof Graphics2D))
- return;
+ if (note == null || !(g instanceof Graphics2D)) return;
Graphics2D g2 = (Graphics2D)g;
String n = "";
int pitch = note.getPitch();
- switch( pitch % 12)
- {
+ switch (pitch % 12) {
case 0: n = "C"; break;
case 1: n = "C#"; break;
case 2: n = "D"; break;
case 10: n = "A#"; break;
case 11: n = "B"; break;
}
-
- g2.drawString(n +" "+(pitch/12), 2, 2);
-
+ g2.setFont(new Font("Helvetica", Font.PLAIN, 8));
+ n = n +(pitch/12);
+ g2.drawString(n + " "+ note.getVelocity(), 1, 9);
}
-
-}
+}
\ No newline at end of file