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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/song/models/TGChord.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-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;
 
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 TGChord {
 
18
        private int firstFret;
 
19
        private int[] strings;
 
20
        private String name;
 
21
        private TGBeat beat;
 
22
        
 
23
        public TGChord(int length){
 
24
                this.strings = new int[length];
 
25
                for(int i = 0;i < this.strings.length;i++){
 
26
                        this.strings[i] = -1;
 
27
                }
 
28
        }
 
29
        
 
30
        public TGBeat getBeat() {
 
31
                return this.beat;
 
32
        }
 
33
        
 
34
        public void setBeat(TGBeat beat) {
 
35
                this.beat = beat;
 
36
        }
 
37
        
 
38
        public void addFretValue(int string,int fret){
 
39
                if(string >= 0 && string < this.strings.length){
 
40
                        this.strings[string] = fret;
 
41
                }
 
42
        }
 
43
        
 
44
        public int getFretValue(int string){
 
45
                if(string >= 0 && string < this.strings.length){
 
46
                        return this.strings[string];
 
47
                }
 
48
                return -1;
 
49
        }
 
50
        
 
51
        public int getFirstFret() {
 
52
                return this.firstFret;
 
53
        }
 
54
        
 
55
        public void setFirstFret(int firstFret) {
 
56
                this.firstFret = firstFret;
 
57
        }
 
58
        
 
59
        public int[] getStrings() {
 
60
                return this.strings;
 
61
        }
 
62
        
 
63
        public void setStrings(int[] strings) {
 
64
                this.strings = strings;
 
65
        }
 
66
        
 
67
        public int countStrings(){
 
68
                return this.strings.length;
 
69
        }
 
70
        
 
71
        public int countNotes(){
 
72
                int count = 0;
 
73
                for(int i = 0;i < this.strings.length;i++){
 
74
                        if(this.strings[i] >= 0){
 
75
                                count ++;
 
76
                        }
 
77
                }
 
78
                return count;
 
79
        }
 
80
        
 
81
        public String getName() {
 
82
                return this.name;
 
83
        }
 
84
        
 
85
        public void setName(String name) {
 
86
                this.name = name;
 
87
        }
 
88
        
 
89
        public TGChord clone(TGFactory factory){
 
90
                TGChord chord = factory.newChord(this.strings.length);
 
91
                chord.setName(getName());
 
92
                chord.setFirstFret(getFirstFret());
 
93
                for(int i = 0;i < chord.strings.length;i++){
 
94
                        chord.strings[i] = this.strings[i];
 
95
                }
 
96
                return chord;
 
97
        }
 
98
        
 
99
}