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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/song/models/TGMeasure.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-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 java.util.ArrayList;
 
10
import java.util.List;
 
11
 
 
12
import org.herac.tuxguitar.song.factory.TGFactory;
 
13
 
 
14
/**
 
15
 * @author julian
 
16
 *
 
17
 * TODO To change the template for this generated type comment go to
 
18
 * Window - Preferences - Java - Code Style - Code Templates
 
19
 */
 
20
public abstract class TGMeasure {
 
21
        
 
22
        public static final int CLEF_TREBLE = 1;
 
23
        public static final int CLEF_BASS = 2;
 
24
        public static final int CLEF_TENOR = 3;
 
25
        public static final int CLEF_ALTO = 4;
 
26
        
 
27
        public static final int DEFAULT_CLEF = CLEF_TREBLE;
 
28
        public static final int DEFAULT_KEY_SIGNATURE= 0;
 
29
        
 
30
        private TGMeasureHeader header;
 
31
        private TGTrack track;
 
32
        private int clef;
 
33
        private int keySignature;
 
34
        
 
35
        private List beats;
 
36
        
 
37
        public TGMeasure(TGMeasureHeader header){
 
38
                this.header = header;
 
39
                this.clef = DEFAULT_CLEF;
 
40
                this.keySignature = DEFAULT_KEY_SIGNATURE;
 
41
                this.beats = new ArrayList();
 
42
        }
 
43
        
 
44
        public TGTrack getTrack() {
 
45
                return this.track;
 
46
        }
 
47
        
 
48
        public void setTrack(TGTrack track) {
 
49
                this.track = track;
 
50
        }
 
51
        
 
52
        public int getClef() {
 
53
                return this.clef;
 
54
        }
 
55
        
 
56
        public void setClef(int clef) {
 
57
                this.clef = clef;
 
58
        }
 
59
        
 
60
        public int getKeySignature() {
 
61
                return this.keySignature;
 
62
        }
 
63
        
 
64
        public void setKeySignature(int keySignature) {
 
65
                this.keySignature = keySignature;
 
66
        }
 
67
        
 
68
        public List getBeats() {
 
69
                return this.beats;
 
70
        }
 
71
        
 
72
        public void addBeat(TGBeat beat){
 
73
                beat.setMeasure(this);
 
74
                this.beats.add(beat);
 
75
        }
 
76
        
 
77
        public void moveBeat(int index,TGBeat beat){
 
78
                this.beats.remove(beat);
 
79
                this.beats.add(index,beat);
 
80
        }
 
81
        
 
82
        public void removeBeat(TGBeat beat){
 
83
                this.beats.remove(beat);
 
84
        }
 
85
        
 
86
        public TGBeat getBeat(int index){
 
87
                if(index >= 0 && index < countBeats()){
 
88
                        return (TGBeat)this.beats.get(index);
 
89
                }
 
90
                return null;
 
91
        }
 
92
        
 
93
        public int countBeats(){
 
94
                return this.beats.size();
 
95
        }
 
96
        
 
97
        public TGMeasureHeader getHeader() {
 
98
                return this.header;
 
99
        }
 
100
        
 
101
        public void setHeader(TGMeasureHeader header) {
 
102
                this.header = header;
 
103
        }
 
104
        
 
105
        public int getNumber() {
 
106
                return this.header.getNumber();
 
107
        }
 
108
        
 
109
        public int getRepeatClose() {
 
110
                return this.header.getRepeatClose();
 
111
        }
 
112
        
 
113
        public long getStart() {
 
114
                return this.header.getStart();
 
115
        }
 
116
        
 
117
        public TGTempo getTempo() {
 
118
                return this.header.getTempo();
 
119
        }
 
120
        
 
121
        public TGTimeSignature getTimeSignature() {
 
122
                return this.header.getTimeSignature();
 
123
        }
 
124
        
 
125
        public boolean isRepeatOpen() {
 
126
                return this.header.isRepeatOpen();
 
127
        }
 
128
        
 
129
        public int getTripletFeel() {
 
130
                return this.header.getTripletFeel();
 
131
        }
 
132
        
 
133
        public long getLength() {
 
134
                return this.header.getLength();
 
135
        }
 
136
        
 
137
        public boolean hasMarker() {
 
138
                return this.header.hasMarker();
 
139
        }
 
140
        
 
141
        public TGMarker getMarker(){
 
142
                return this.header.getMarker();
 
143
        }
 
144
        
 
145
        public void makeEqual(TGMeasure measure){
 
146
                this.clef = measure.getClef();
 
147
                this.keySignature = measure.getKeySignature();
 
148
                this.beats.clear();
 
149
                for(int i = 0; i < measure.countBeats(); i ++){
 
150
                        TGBeat beat = measure.getBeat(i);
 
151
                        this.addBeat(beat);
 
152
                }
 
153
        }
 
154
        
 
155
        public TGMeasure clone(TGFactory factory,TGMeasureHeader header){
 
156
                TGMeasure measure = factory.newMeasure(header);
 
157
                measure.setClef(getClef());
 
158
                measure.setKeySignature(getKeySignature());
 
159
                for(int i = 0; i < countBeats(); i ++){
 
160
                        TGBeat beat = (TGBeat)this.beats.get(i);
 
161
                        measure.addBeat(beat.clone(factory));
 
162
                }
 
163
                return measure;
 
164
        }
 
165
}