X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooNoteElement.java;h=dd31c86b800cc2b7cb1e8a1c077f12bee74f8ad2;hb=b6312d2dc8b1a096ecb1dfe9e6590d9f7bf14f71;hp=3640113034b314f79112f2f2302891df2c81e7fa;hpb=2c2d2bff843fc32659acc06c9893a0439ed51c62;p=moosique.git diff --git a/MooNoteElement.java b/MooNoteElement.java index 3640113..dd31c86 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -9,39 +9,20 @@ import java.awt.event.*; * @version 1 */ -public class MooNoteElement extends JPanel{ +public class MooNoteElement extends JPanel { private MooNote note; + private int columns; private boolean selected; /** * Creates a new note element. - * @param mn The note that will be graphically represented + * @param mn the note that will be graphically represented + * @param rows the number of rows that the note will occupy */ - public MooNoteElement (MooNote mn) { + public MooNoteElement (MooNote mn, int rows) { 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); + columns = mn.getDuration() / 24; } /** @@ -67,30 +48,36 @@ public class MooNoteElement extends JPanel{ { super.paintComponent(g); - if (!(g instanceof Graphics2D)) - return; + if (note == null || !(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; + String n = ""; + int pitch = note.getPitch(); + switch (pitch % 12) { + case 0: n = "C"; break; + case 1: n = "C#"; break; + case 2: n = "D"; break; + case 3: n = "D#"; break; + case 4: n = "E"; break; + case 5: n = "F"; break; + case 6: n = "F#"; break; + case 7: n = "G"; break; + case 8: n ="G#"; break; + case 9: n = "A"; break; + case 10: n = "A#"; break; + case 11: n = "B"; break; } - g2.drawString(note +" "+(pitch/12), 2, 2); - + /* + switch(columns) { + case 0: + case 1: + ... + } + */ + + 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