~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/song/models/TGTempo.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on 29-nov-2005
 
3
 *
 
4
 * TODO To change the template for this generated file go to
 
5
 * Window - Preferences - Java - Code Style - Code Templates
 
6
 */
 
7
package org.herac.tuxguitar.song.models;
 
8
 
 
9
import org.herac.tuxguitar.song.factory.TGFactory;
 
10
 
 
11
/**
 
12
 * @author julian
 
13
 *
 
14
 * TODO To change the template for this generated type comment go to
 
15
 * Window - Preferences - Java - Code Style - Code Templates
 
16
 */
 
17
public abstract class TGTempo {
 
18
        private static final int SECOND_IN_MILLIS = 1000;
 
19
        
 
20
        private int value;
 
21
        
 
22
        public TGTempo(){
 
23
                this.value = 120;
 
24
        }
 
25
        
 
26
        public int getValue() {
 
27
                return this.value;
 
28
        }
 
29
        
 
30
        public void setValue(int value) {
 
31
                this.value = value;
 
32
        }
 
33
        
 
34
        public long getInMillis(){
 
35
                double millis = (60.00 / getValue() * SECOND_IN_MILLIS);
 
36
                return (long)millis;
 
37
        }
 
38
        
 
39
        public long getInUSQ(){
 
40
                double usq = ((60.00 / getValue() * SECOND_IN_MILLIS) * 1000.00);
 
41
                return (long)usq;
 
42
        }
 
43
        
 
44
        public static TGTempo fromUSQ(TGFactory factory,int usq){
 
45
                double value = ((60.00 * SECOND_IN_MILLIS) / (usq / 1000.00));
 
46
                TGTempo tempo = factory.newTempo();
 
47
                tempo.setValue((int)value);
 
48
                return tempo;
 
49
        }
 
50
        
 
51
        public TGTempo clone(TGFactory factory){
 
52
                TGTempo tempo = factory.newTempo();
 
53
                copy(tempo);
 
54
                return tempo;
 
55
        }
 
56
        
 
57
        public void copy(TGTempo tempo){
 
58
                tempo.setValue(getValue());
 
59
        }
 
60
        
 
61
}