X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooNoteElement.java;h=c502b4d568cd47e6269e0fb79e0cd3ff1f753ec9;hb=fe67e0acf0d44c09dcfbbfd1a02a91f43d2cf60e;hp=e854a44fd030a0f211635a8b5b715623097c9bff;hpb=c83e74facf762222fe4578f175408cc50d360518;p=moosique.git diff --git a/MooNoteElement.java b/MooNoteElement.java index e854a44..c502b4d 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -12,36 +12,18 @@ import java.awt.event.*; 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) { 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; + setBorder(BorderFactory.createLineBorder(Color.black)); } /** @@ -67,17 +49,12 @@ public class MooNoteElement extends JPanel { { 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; @@ -92,8 +69,16 @@ public class MooNoteElement extends JPanel { case 11: n = "B"; break; } - g2.drawString(n +" "+(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