- JPanel panel = new JPanel();
- panel.setMaximumSize(new Dimension(120,27));
- panel.setLayout(new GridLayout(2,4));
-
- add(panel);
-
- panel.add(new JPanel());
-
- measure = createProjIndLabel("Mrs", 10);
- panel.add(measure);
-
- beats = createProjIndLabel("Beat", 10);
- panel.add(beats);
-
- ticks = createProjIndLabel("Tick", 10);
- panel.add(ticks);
-
- panel.add(new JPanel());
-
- measurevalue = createProjIndLabel("1", 12);
- panel.add(measurevalue);
-
- beatsvalue = createProjIndLabel("1",12);
- panel.add(beatsvalue);
-
- ticksvalue = createProjIndLabel("1", 12);
- panel.add(ticksvalue);
-
- playimage = Toolkit.getDefaultToolkit().getImage("images/play.gif");
- pauseimage = Toolkit.getDefaultToolkit().getImage("images/pause.gif");
-
- }
-
- /**
- * creates a JButton for the toolbar
- * @param imagelocation the imagelacation of the the image displayed in the button
- * @param tooltip the tooltip associated with this button
- * @return button the button to be attached to the toolbar
- */
- private JButton createButton(String imagelocation, String tooltip) {
- JButton button = new JButton (new ImageIcon(imagelocation));
- button.setToolTipText(tooltip);
- button.addActionListener(this);
- return button;
- }
-
- /**
- * creates JLabels for the progressindikator, attached to the toolbar
- * @param title the titel displayed on the label
- * @param fontsize the fontzise of the text displayed on the label
- * @param fontstyle the fontstyle of the text displayed on the label
- * @return titelvalue the label that is a part of the progressindikator
- */
- private JLabel createProjIndLabel(String title, int fontsize){
- JLabel titelvalue = new JLabel(title,JLabel.CENTER);
- titelvalue.setFont(new Font("Times New Roman",
- Font.BOLD ,fontsize));
- titelvalue.setBorder(BorderFactory.createLineBorder(Color.black));
- return titelvalue;
+ // Creates progress indicator
+ measure = createLabel("Msr", 10);
+ beats = createLabel("Beat", 10);
+ ticks = createLabel("Tick", 10);
+ measuresValue = formatProgInd(createLabel("1", 16));
+ beatsValue = formatProgInd(createLabel("1", 16));
+ ticksValue = formatProgInd(createLabel("1", 16));
+ JPanel spacenorth = new JPanel();
+ spacenorth.setBackground(bgColor);
+ JPanel spacesouth = new JPanel();
+ spacesouth.setBackground(bgColor);
+
+ // Creates progress indicator panel and adds components
+ progIndPanel = new JPanel();
+ progIndPanel.setMaximumSize(new Dimension(120,27));
+ progIndPanel.setLayout(new GridLayout(2,4));
+ progIndPanel.add(spacenorth);
+ progIndPanel.add(measure);
+ progIndPanel.add(beats);
+ progIndPanel.add(ticks);
+ progIndPanel.add(spacesouth);
+ progIndPanel.add(measuresValue);
+ progIndPanel.add(beatsValue);
+ progIndPanel.add(ticksValue);
+ add(progIndPanel);
+ }
+
+ /**
+ * Updates the progress indicator.
+ * @param tickPosition the tick position to visualize
+ */
+ public void updateProgInd(long tickPosition) {
+ ticksPerBeat = Moosique.getSequence().getResolution();
+ if (tickPosition == 0) {
+ resetProgInd();
+ } else {
+ // Otherwise, calculates the current song position in measures, beats and ticks.
+ long measures = tickPosition / (beatsPerMeasure * ticksPerBeat);
+ long beats = (tickPosition - measures * beatsPerMeasure * ticksPerBeat) / ticksPerBeat;
+ long ticks = tickPosition - measures * beatsPerMeasure * ticksPerBeat - beats * ticksPerBeat;
+ measuresValue.setText(Long.toString(1 + measures));
+ beatsValue.setText(Long.toString(1 + beats));
+ ticksValue.setText(Long.toString(1 + ticks));