2
* Created on 23-nov-2005
4
* TODO To change the template for this generated file go to
5
* Window - Preferences - Java - Code Style - Code Templates
7
package org.herac.tuxguitar.song.models;
9
import java.util.ArrayList;
10
import java.util.Iterator;
11
import java.util.List;
13
import org.herac.tuxguitar.song.factory.TGFactory;
17
* TODO To change the template for this generated type comment go to
18
* Window - Preferences - Java - Code Style - Code Templates
20
public abstract class TGTrack {
21
public static final int MAX_OFFSET = 24;
22
public static final int MIN_OFFSET = -24;
27
private List measures;
29
private TGChannel channel;
30
private TGColor color;
31
private TGLyric lyrics;
34
public TGTrack(TGFactory factory) {
37
this.name = new String();
38
this.measures = new ArrayList();
39
this.strings = new ArrayList();
40
this.channel = factory.newChannel();
41
this.color = factory.newColor();
42
this.lyrics = factory.newLyric();
45
public int getNumber() {
49
public void setNumber(int number) {
53
public Iterator getMeasures() {
54
return this.measures.iterator();
57
public void addMeasure(TGMeasure measure){
58
measure.setTrack(this);
59
this.measures.add(measure);
62
public void addMeasure(int index,TGMeasure measure){
63
measure.setTrack(this);
64
this.measures.add(index,measure);
67
public TGMeasure getMeasure(int index){
68
if(index >= 0 && index < countMeasures()){
69
return (TGMeasure)this.measures.get(index);
74
public void removeMeasure(int index){
75
this.measures.remove(index);
78
public int countMeasures(){
79
return this.measures.size();
82
public TGChannel getChannel() {
86
public void setChannel(TGChannel channel) {
87
this.channel = channel;
90
public List getStrings() {
94
public void setStrings(List strings) {
95
this.strings = strings;
98
public TGColor getColor() {
102
public void setColor(TGColor color) {
106
public String getName() {
110
public void setName(String name) {
114
public int getOffset() {
118
public void setOffset(int offset) {
119
this.offset = offset;
122
public TGLyric getLyrics() {
126
public void setLyrics(TGLyric lyrics) {
127
this.lyrics = lyrics;
130
public TGString getString(int number){
131
return (TGString)this.strings.get(number - 1);
134
public int stringCount(){
135
return this.strings.size();
138
public boolean isPercussionTrack(){
139
return (getChannel().isPercussionChannel());
142
public TGSong getSong() {
146
public void setSong(TGSong song) {
151
this.strings.clear();
152
this.measures.clear();
155
public TGTrack clone(TGFactory factory,TGSong song){
156
TGTrack track = factory.newTrack();
157
copy(factory, song, track);
161
public void copy(TGFactory factory,TGSong song,TGTrack track){
163
track.setNumber(getNumber());
164
track.setName(getName());
165
track.setOffset(getOffset());
166
getChannel().copy(track.getChannel());
167
getColor().copy(track.getColor());
168
getLyrics().copy(track.getLyrics());
169
for (int i = 0; i < getStrings().size(); i++) {
170
TGString string = (TGString) getStrings().get(i);
171
track.getStrings().add(string.clone(factory));
173
for (int i = 0; i < countMeasures(); i++) {
174
TGMeasure measure = getMeasure(i);
175
track.addMeasure(measure.clone(factory,song.getMeasureHeader(i)));