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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/editors/tab/LyricPainter.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
 
package org.herac.tuxguitar.gui.editors.tab;
2
 
 
3
 
import org.eclipse.swt.graphics.GC;
4
 
import org.herac.tuxguitar.gui.editors.tab.layout.TrackSpacing;
5
 
import org.herac.tuxguitar.gui.editors.tab.layout.ViewLayout;
6
 
 
7
 
public class LyricPainter {
8
 
        private SongTrackCoords trackCoords;
9
 
        private String[] lyricBeats;            
10
 
        private int from;       
11
 
        private int height;
12
 
        int nextIndex = 0;
13
 
        
14
 
        public LyricPainter(SongTrackCoords trackCoords){
15
 
                this.trackCoords = trackCoords;
16
 
                this.update();
17
 
        }
18
 
        
19
 
        public void update(){
20
 
                this.lyricBeats = trackCoords.getTrack().getLyrics().getLyricBeats();
21
 
                this.from = trackCoords.getTrack().getLyrics().getFrom();
22
 
                this.height = 0;
23
 
                if(this.lyricBeats != null && this.lyricBeats.length > 0){
24
 
                        this.height = 10;
25
 
                }
26
 
        }
27
 
           
28
 
        public void start(){
29
 
                this.start(0);
30
 
        }
31
 
 
32
 
        public void start(int index){
33
 
                this.nextIndex = index;
34
 
        }
35
 
 
36
 
 
37
 
        public void setCurrentMeasure(MeasureCoords measure){
38
 
                if(measure.getMeasure().getNumber() >= from){
39
 
                        measure.setLyricBeatIndex(nextIndex);
40
 
                        this.nextIndex += measure.getBeatPositions().size();
41
 
                }else{
42
 
                        measure.setLyricBeatIndex(-1);
43
 
                        this.start();
44
 
                }
45
 
        }
46
 
 
47
 
        public void paintCurrentNoteBeats(GC gc,ViewLayout layout,MeasureCoords currentMeasure ,int fromX,int fromY){
48
 
                int beatIndex = currentMeasure.getLyricBeatIndex();
49
 
                if(this.lyricBeats != null && beatIndex >= 0 && beatIndex < this.lyricBeats.length){
50
 
                        for(int i = 0;i < currentMeasure.getBeatPositions().size();i ++){
51
 
                                MeasureCoords.BeatPosition noteBeat = (MeasureCoords.BeatPosition)currentMeasure.getBeatPositions().get(i);
52
 
                        
53
 
                                if((beatIndex + i) < this.lyricBeats.length){
54
 
                                        String str = lyricBeats[beatIndex + i];
55
 
                                        if(str.trim().length() > 0){
56
 
                                                int x = fromX + noteBeat.getPosX();
57
 
                                        
58
 
                                                layout.setLyricStyle(gc);
59
 
                                                if(layout.isPlayModeEnabled() && noteBeat.isPlayingBeat()){
60
 
                                                layout.setPlayNoteColor(gc);
61
 
                                        }                                                                                       
62
 
                                                
63
 
                                                gc.drawString(str,x + 13,(fromY + currentMeasure.getTs().getPosition(TrackSpacing.POSITION_LYRIC)));
64
 
                                                layout.setTabNoteColor(gc);
65
 
                                        }                       
66
 
                                }
67
 
                        }               
68
 
                }
69
 
        }
70
 
 
71
 
        public int getHeight(){
72
 
                return height;
73
 
        }
74
 
}
75