2
* Created on 04-ene-2006
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.gui.editors.tab.layout;
9
import java.util.Iterator;
11
import org.eclipse.swt.graphics.Rectangle;
12
import org.herac.tuxguitar.gui.editors.TGPainter;
13
import org.herac.tuxguitar.gui.editors.tab.TGLyricImpl;
14
import org.herac.tuxguitar.gui.editors.tab.TGMeasureImpl;
15
import org.herac.tuxguitar.gui.editors.tab.TGTrackImpl;
16
import org.herac.tuxguitar.gui.editors.tab.Tablature;
21
* TODO To change the template for this generated type comment go to
22
* Window - Preferences - Java - Code Style - Code Templates
24
public class LinearViewLayout extends ViewLayout{
26
public LinearViewLayout(Tablature tablature,int style){
27
super(tablature,style);
34
public void paintSong(TGPainter painter,Rectangle clientArea,int fromX,int fromY) {
37
this.clearTrackPositions();
39
int style = getStyle();
40
int number = ((style & ViewLayout.DISPLAY_MULTITRACK) == 0?getTablature().getCaret().getTrack().getNumber():-1);
41
int posY = fromY + getFirstTrackSpacing();
42
int height = getFirstTrackSpacing();
44
Iterator tracks = getSongManager().getSong().getTracks();
45
while(tracks.hasNext()){
46
TGTrackImpl track = (TGTrackImpl) tracks.next();
47
if(number < 0 || track.getNumber() == number){
49
TrackSpacing ts = new TrackSpacing(this) ;
50
ts.setSize(TrackSpacing.POSITION_SCORE_MIDDLE_LINES, ((style & DISPLAY_SCORE) != 0 ?( (getScoreLineSpacing() * 5) ):0));
51
((TGLyricImpl)track.getLyrics()).start();
53
//------AUTO_SPACING---------------------------------------
56
// Need to score extra-lines in edition mode
57
if( (style & DISPLAY_TABLATURE) == 0 && (style & DISPLAY_SCORE) != 0 ){
58
maxY = ((getScoreLineSpacing() * 4) + (getScoreLineSpacing() * 4));
59
minY = -(getScoreLineSpacing() * 3);
62
Iterator measures = track.getMeasures();
63
while(measures.hasNext()){
64
TGMeasureImpl measure = (TGMeasureImpl)measures.next();
65
maxY = (measure.getMaxY() > maxY)?measure.getMaxY():maxY;
66
minY = (measure.getMinY() < minY)?measure.getMinY():minY;
67
measure.registerEffects(this,ts);
69
ts.setSize(TrackSpacing.POSITION_SCORE_UP_LINES, ( (style & DISPLAY_SCORE) != 0 ?Math.abs(minY):0));
70
if((style & DISPLAY_SCORE) != 0 && maxY + getMinScoreTabSpacing() > getScoreSpacing()){
71
ts.setSize(TrackSpacing.POSITION_SCORE_DOWN_LINES, (maxY - (getScoreLineSpacing() * 4)) );
74
if((style & DISPLAY_TABLATURE) != 0){
75
ts.setSize(TrackSpacing.POSITION_TABLATURE_TOP_SEPARATOR,((style & DISPLAY_SCORE) != 0 ?getMinScoreTabSpacing():getStringSpacing()));
76
ts.setSize(TrackSpacing.POSITION_TABLATURE, ((style & DISPLAY_SCORE) != 0 ?track.getTabHeight() + getStringSpacing() +1:track.getTabHeight() + ((getStringSpacing() / 2) * 5) +1 ) );
78
ts.setSize(TrackSpacing.POSITION_LYRIC,10);
79
checkDefaultSpacing(ts);
81
//----------------------------------------------------
82
paintMeasures(track,painter,fromX,posY,ts,clientArea);
83
paintLines(track,ts,painter,fromX + (getWidth() + 2),posY,(clientArea.width - (fromX + getWidth()) ));
85
trackHeight = ts.getSize();
86
addTrackPosition(track.getNumber(),posY,trackHeight);
88
posY += trackHeight + getTrackSpacing();
89
height += trackHeight + getTrackSpacing();
92
if(getWidth() > clientArea.width){
93
// solo para dar un espacio.
94
this.setWidth( getWidth() + getFirstMeasureSpacing());
96
this.setHeight(height);
97
this.paintCaret(painter);
100
public void paintMeasures(TGTrackImpl track,TGPainter painter,int fromX, int fromY,TrackSpacing ts,Rectangle clientArea) {
101
int posX = (fromX + getFirstMeasureSpacing());
103
int width = getFirstMeasureSpacing();
105
Iterator measures = track.getMeasures();
106
while(measures.hasNext()){
107
TGMeasureImpl measure = (TGMeasureImpl)measures.next();
109
//asigno la posicion dentro del compas
110
measure.setPosX(posX);
111
measure.setPosY(posY);
114
((TGLyricImpl)track.getLyrics()).setCurrentMeasure(measure);
116
//Solo pinto lo que entre en pantalla
117
boolean isAtX = ((posX + measure.getWidth(this)) > clientArea.x - 100 && posX < clientArea.x + clientArea.width + measure.getWidth(this) + 100);
118
boolean isAtY = (posY + ts.getSize() > clientArea.y && posY < clientArea.y + clientArea.height + 80);
120
paintMeasure(measure,painter,0);
121
((TGLyricImpl)track.getLyrics()).paintCurrentNoteBeats(painter,this,measure,posX, posY);
123
measure.setOutOfBounds(true);
126
int measureWidth = measure.getWidth(this);
127
posX += measureWidth;
128
width += measureWidth;
130
this.setWidth(Math.max(getWidth(),width));