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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/song/models/effects/BendEffect.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 26-dic-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.effects;
8
 
 
9
 
import java.util.ArrayList;
10
 
import java.util.Iterator;
11
 
import java.util.List;
12
 
 
13
 
/**
14
 
 * @author julian
15
 
 *
16
 
 * TODO To change the template for this generated type comment go to
17
 
 * Window - Preferences - Java - Code Style - Code Templates
18
 
 */
19
 
public class BendEffect {
20
 
        public static final int SEMITONE_LENGTH = 2;
21
 
    public static final int MAX_POSITION_LENGTH = 12;
22
 
    public static final int MAX_VALUE_LENGTH = (SEMITONE_LENGTH * 6);    
23
 
    
24
 
    private List points;
25
 
    
26
 
    private BendEffect(List points){
27
 
        this.points = points;
28
 
    }    
29
 
    
30
 
    public BendEffect(){
31
 
        this(new ArrayList());
32
 
    }
33
 
    
34
 
    public void addPoint(int position,int value){
35
 
        this.points.add(new BendPoint(position,value));
36
 
    }
37
 
    
38
 
    public List getPoints(){
39
 
        return this.points;
40
 
    }
41
 
    
42
 
    public Object clone(){
43
 
        List points = new ArrayList();
44
 
        Iterator it = getPoints().iterator();
45
 
        while(it.hasNext()){
46
 
            BendPoint point = (BendPoint)it.next();
47
 
            points.add(point.clone());
48
 
        }
49
 
        
50
 
        return new BendEffect(points);
51
 
    }
52
 
    
53
 
    public class BendPoint{
54
 
        private int position;
55
 
        private int value;
56
 
        
57
 
        public BendPoint(int position,int value){
58
 
            this.position = position;
59
 
            this.value = value;
60
 
        }
61
 
                      
62
 
        public int getPosition() {
63
 
            return position;
64
 
        }
65
 
        
66
 
        public int getValue() {
67
 
            return value;
68
 
        }
69
 
        
70
 
        public long getTime(long duration){
71
 
            return (duration * getPosition() / MAX_POSITION_LENGTH);
72
 
        }
73
 
        
74
 
        public Object clone(){
75
 
            return new BendPoint(getPosition(),getValue());
76
 
        }
77
 
    }
78
 
    
79
 
}