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.List;
12
import org.herac.tuxguitar.song.factory.TGFactory;
17
* TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
19
public abstract class TGBeat {
21
private TGDuration duration;
22
private TGMeasure measure;
25
private TGChord chord;
28
public TGBeat(TGFactory factory) {
29
this.start = TGDuration.QUARTER_TIME;
30
this.duration = factory.newDuration();
31
this.notes = new ArrayList();
34
public long getStart() {
38
public void setStart(long start) {
42
public TGDuration getDuration() {
46
public void setDuration(TGDuration duration) {
47
this.duration = duration;
50
public TGMeasure getMeasure() {
54
public void setMeasure(TGMeasure measure) {
55
this.measure = measure;
58
public List getNotes() {
62
public void addNote(TGNote note){
67
public void moveNote(int index,TGNote note){
68
getNotes().remove(note);
69
getNotes().add(index,note);
72
public void removeNote(TGNote note){
73
this.notes.remove(note);
76
public TGNote getNote(int index){
77
if(index >= 0 && index < countNotes()){
78
return (TGNote)this.notes.get(index);
83
public int countNotes(){
84
return this.notes.size();
87
public void setChord(TGChord chord) {
89
this.chord.setBeat(this);
92
public TGChord getChord() {
96
public void removeChord() {
100
public TGText getText() {
104
public void setText(TGText text) {
106
this.text.setBeat(this);
109
public void removeText(){
113
public boolean isRestBeat(){
114
return this.notes.isEmpty();
117
public boolean isChordBeat(){
118
return ( this.chord != null );
121
public boolean isTextBeat(){
122
return ( this.text != null );
125
public TGBeat clone(TGFactory factory){
126
TGBeat beat = factory.newBeat();
127
beat.setStart(getStart());
128
getDuration().copy(beat.getDuration());
130
for(int i = 0;i < countNotes();i++){
131
TGNote note = (TGNote)this.notes.get(i);
132
beat.addNote(note.clone(factory));
134
if(this.chord != null){
135
beat.setChord( this.chord.clone(factory));
137
if(this.text != null){
138
beat.setText( this.text.clone(factory));
b'\\ No newline at end of file'