7 * @author Andersson, Andreen, Lanneskog, Pehrson
11 public class MooViewCounter extends JPanel {
13 private int measure, halfBeat, beat, halfNote;
18 private int timeSig1, timeSig2;
20 public MooViewCounter (int ts1, int ts2) {
25 case 16: measure = timeSig1;
27 case 8: measure = timeSig1 * 2;
28 halfBeat = measure/timeSig1;
30 case 4: measure = timeSig1 * (int)Math.pow(2,2);
31 beat = measure/timeSig1;
34 case 2: measure = timeSig1 * (int)Math.pow(2,3);
35 halfNote = measure/timeSig1;
39 case 1: measure = timeSig1 * (int)Math.pow(2,4);
48 public void paintComponent(Graphics g) {
49 super.paintComponent(g);
50 setBackground(Color.black);
51 if (!(g instanceof Graphics2D)) return;
52 Graphics2D g2 = (Graphics2D)g;
53 setPreferredSize(new Dimension(50,200*10));
54 g2.setColor(Color.white);
55 for (int c = 0; c < 200; c++) {
56 g2.drawLine(0,c*10,5,c*10); // 1/16
57 g2.drawLine(0,c*10*halfBeat,10,c*10*halfBeat); // 1/8
58 g2.drawLine(0,c*10*beat,15,c*10*beat); // 1/4
59 g2.drawLine(0,c*10*halfNote,20,c*10*halfNote); // 1/2
60 g2.drawLine(0,c*10*measure,35,c*10*measure); // 1/1