7 * @author Andersson, Andreen, Lanneskog, Pehrson
11 public class MooViewCounter extends JPanel {
13 private int timeSig1, timeSig2, measure, halfBeat, beat, halfNote;
18 public MooViewCounter (int ts1, int ts2) {
21 setBackground(Color.black);
22 setPreferredSize(new Dimension(35,200*10));
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 if (!(g instanceof Graphics2D)) return;
51 Graphics2D g2 = (Graphics2D)g;
52 g2.setColor(Color.white);
53 for (int c = 0; c < 200; c++) {
54 g2.drawLine(0,c*10,5,c*10); // 1/16
55 g2.drawLine(0,c*10*halfBeat,10,c*10*halfBeat); // 1/8
56 g2.drawLine(0,c*10*beat,15,c*10*beat); // 1/4
57 g2.drawLine(0,c*10*halfNote,20,c*10*halfNote); // 1/2
58 g2.drawLine(0,c*10*measure,30,c*10*measure); // 1/1