~teemu-heinamaki/ubuntu/maverick/tuxguitar/merge-from-debian

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2009-04-25 19:49:27 UTC
  • mfrom: (1.1.3 upstream) (2.1.7 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090425194927-pblqed0zxp0pmyeq
Tags: 1.1-1
* New Upstream Release (Closes: #489859) (LP: #366476)
* Merged patch : tuxguitar_1.0.dak-1ubuntu1.patch
* debian/README.txt
  - suggests to install tuxguitar-jsa

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.song.models;
 
2
 
 
3
import org.herac.tuxguitar.song.factory.TGFactory;
 
4
 
 
5
public abstract class TGStroke {
 
6
        
 
7
        public static final int STROKE_NONE = 0;
 
8
        public static final int STROKE_UP = 1;
 
9
        public static final int STROKE_DOWN = -1;
 
10
        
 
11
        private int direction;
 
12
        private int value;
 
13
        
 
14
        public TGStroke(){
 
15
                this.direction = STROKE_NONE;
 
16
        }
 
17
 
 
18
        public int getDirection() {
 
19
                return this.direction;
 
20
        }
 
21
 
 
22
        public void setDirection(int direction) {
 
23
                this.direction = direction;
 
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 int getIncrementTime( TGBeat beat ){
 
35
                long duration = 0;
 
36
                if( this.value > 0 ){
 
37
                        for(int v = 0; v < beat.countVoices(); v ++){
 
38
                                TGVoice voice = beat.getVoice( v );
 
39
                                if( !voice.isEmpty() ){
 
40
                                        long currentDuration = voice.getDuration().getTime();
 
41
                                        if(duration == 0 || currentDuration < duration){
 
42
                                                duration = ( currentDuration <= TGDuration.QUARTER_TIME ? currentDuration : TGDuration.QUARTER_TIME );
 
43
                                        }
 
44
                                }
 
45
                        }
 
46
                        if( duration > 0 ){
 
47
                                return Math.round( ( ( duration / 8.0f ) * ( 4.0f / this.value ) ) );
 
48
                        }
 
49
                }
 
50
                return 0;
 
51
        }
 
52
        
 
53
        public TGStroke clone(TGFactory factory){
 
54
                TGStroke stroke = factory.newStroke();
 
55
                copy(stroke);
 
56
                return stroke;
 
57
        }
 
58
        
 
59
        public void copy(TGStroke stroke){
 
60
                stroke.setValue(getValue());
 
61
                stroke.setDirection(getDirection());
 
62
        }
 
63
}