7 * @author Andersson, Andreen, Lanneskog, Pehrson
11 public class MooViewCounter extends JPanel {
13 //public static final int LINE_LENGTH;
14 private int measure, halfBeat, beat, halfNote;
15 //private String check;
21 private int timeSig1, timeSig2;
23 public MooViewCounter (int ts1, int ts2) {
28 case 16: measure = timeSig1;
30 case 8: measure = timeSig1 * 2;
31 halfBeat = measure/timeSig1;
33 case 4: measure = timeSig1 * (int)Math.pow(2,2);
35 case 2: measure = timeSig1 * (int)Math.pow(2,3);
37 case 1: measure = timeSig1 * (int)Math.pow(2,4);
43 public void paintComponent(Graphics g) {
44 super.paintComponent(g);
45 setBackground(Color.black);
46 if (!(g instanceof Graphics2D)) return;
47 Graphics2D g2 = (Graphics2D)g;
48 setPreferredSize(new Dimension(50,200*10));
49 g2.setColor(Color.white);
50 for (int c = 0; c < 200; c++) {
51 g2.drawLine(0,c*10,5,c*10); // 1/16
52 g2.drawLine(0,c*10*halfBeat,10,c*10*halfBeat); // 1/8
53 g2.drawLine(0,c*10*(beat/4),15,c*10*(beat/4)); // 1/4
54 g2.drawLine(0,c*10*(halfNote/2),20,c*10*(halfNote/2)); // 1/2
55 g2.drawLine(0,c*10*measure,35,c*10*measure); // 1/1