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.ArrayList;
10
import java.util.Iterator;
11
import java.util.List;
13
import org.eclipse.swt.graphics.Point;
14
import org.eclipse.swt.graphics.Rectangle;
15
import org.herac.tuxguitar.gui.TuxGuitar;
16
import org.herac.tuxguitar.gui.editors.TGPainter;
17
import org.herac.tuxguitar.gui.editors.tab.Caret;
18
import org.herac.tuxguitar.gui.editors.tab.TGBeatImpl;
19
import org.herac.tuxguitar.gui.editors.tab.TGChordImpl;
20
import org.herac.tuxguitar.gui.editors.tab.TGLyricImpl;
21
import org.herac.tuxguitar.gui.editors.tab.TGMeasureHeaderImpl;
22
import org.herac.tuxguitar.gui.editors.tab.TGMeasureImpl;
23
import org.herac.tuxguitar.gui.editors.tab.TGResources;
24
import org.herac.tuxguitar.gui.editors.tab.TGTrackImpl;
25
import org.herac.tuxguitar.gui.editors.tab.Tablature;
26
import org.herac.tuxguitar.gui.system.config.TGConfigKeys;
27
import org.herac.tuxguitar.gui.system.config.TGConfigManager;
28
import org.herac.tuxguitar.song.managers.TGSongManager;
29
import org.herac.tuxguitar.song.models.TGDuration;
30
import org.herac.tuxguitar.song.models.TGMeasure;
31
import org.herac.tuxguitar.song.models.TGNote;
36
* TODO To change the template for this generated type comment go to
37
* Window - Preferences - Java - Code Style - Code Templates
39
public abstract class ViewLayout {
40
public static final int MODE_PAGE = 1;
41
public static final int MODE_LINEAR = 2;
42
public static final int DEFAULT_MODE = MODE_LINEAR;
44
public static final int DISPLAY_COMPACT = 0x01;
45
public static final int DISPLAY_MULTITRACK = 0x02;
46
public static final int DISPLAY_SCORE = 0x04;
47
public static final int DISPLAY_TABLATURE = 0x08;
48
public static final int DISPLAY_CHORD_NAME = 0x10;
49
public static final int DISPLAY_CHORD_DIAGRAM = 0x20;
51
private Tablature tablature;
53
private float fontScale;
57
private int minBufferSeparator;
58
private int minTopSpacing;
59
private int minScoreTabSpacing;
60
private int stringSpacing;
61
private int scoreLineSpacing;
62
private int scoreSpacing;
63
private int trackSpacing;
64
private int firstTrackSpacing;
65
private int firstMeasureSpacing;
66
private int chordFretIndexSpacing;
67
private int chordStringSpacing;
68
private int chordFretSpacing;
69
private int chordNoteSize;
70
private int repeatEndingSpacing;
71
private int effectSpacing;
72
private int tupletoSpacing;
73
private int textSpacing;
74
private boolean bufferEnabled;
75
private boolean playModeEnabled;
77
private List trackPositions;
79
private TGResources resources;
81
public ViewLayout(Tablature tablature,int style){
82
this(tablature, style, 1.0f );
85
public ViewLayout(Tablature tablature,int style, float scale){
86
this.tablature = tablature;
87
this.trackPositions = new ArrayList();
88
this.playModeEnabled = false;
89
this.resources = new TGResources(this);
91
if((this.style & DISPLAY_TABLATURE) == 0 && (this.style & DISPLAY_SCORE) == 0 ){
92
this.style |= DISPLAY_TABLATURE;
97
protected void init( float initScale ){
98
TGConfigManager config = TuxGuitar.instance().getConfig();
99
this.setBufferEnabled(true);
100
this.setStringSpacing( (int)(config.getIntConfigValue(TGConfigKeys.TAB_LINE_SPACING) * initScale ) );
101
this.setScoreLineSpacing( (int)(config.getIntConfigValue(TGConfigKeys.SCORE_LINE_SPACING) * initScale ) );
102
this.setScale( checkScale() );
103
this.setFontScale( getScale() );
104
this.setFirstMeasureSpacing( Math.round( 20f * getScale() ) );
105
this.setMinBufferSeparator( Math.round( 20f * getScale() ) );
106
this.setMinTopSpacing( Math.round( 30f * getScale() ) );
107
this.setMinScoreTabSpacing( Math.round( config.getIntConfigValue(TGConfigKeys.MIN_SCORE_TABLATURE_SPACING) * getScale() ) );
108
this.setScoreSpacing( (( getScoreLineSpacing() * 4) + getMinScoreTabSpacing() ) );
109
this.setFirstTrackSpacing( Math.round(config.getIntConfigValue(TGConfigKeys.FIRST_TRACK_SPACING) * getScale() ) );
110
this.setTrackSpacing( Math.round(config.getIntConfigValue(TGConfigKeys.TRACK_SPACING) * getScale() ) );
112
this.setChordFretIndexSpacing( Math.round( 8f * getScale() ) );
113
this.setChordStringSpacing( Math.round( 5f * getScale() ) );
114
this.setChordFretSpacing( Math.round( 6f * getScale() ) );
115
this.setChordNoteSize( Math.round( 4f * getScale() ) );
116
this.setRepeatEndingSpacing( Math.round( 20f * getScale() ) );
117
this.setTextSpacing( Math.round( 15f * getScale() ) );
118
this.setTupletoSpacing( Math.round( 10f * getScale() ) );
119
this.setEffectSpacing( Math.round( 8f * getScale() ) );
122
public abstract void paintSong(TGPainter painter,Rectangle clientArea,int fromX,int fromY);
124
public abstract int getMode();
126
public void paint(TGPainter painter,Rectangle clientArea,int fromX,int fromY){
127
this.playModeEnabled = false;
128
paintSong(painter,clientArea,fromX,fromY);
131
public void paintMeasure(TGMeasureImpl measure,TGPainter painter,int spacing) {
132
measure.setSpacing(spacing);
133
measure.paintMeasure(this,painter);
136
public void updateSong(){
141
public void updateTracks() {
142
int trackCount = getSongManager().getSong().countTracks();
143
int measureCount = getSongManager().getSong().countMeasureHeaders();
144
for (int measureIdx = 0; measureIdx < measureCount; measureIdx++) {
145
TGMeasureHeaderImpl header = (TGMeasureHeaderImpl)getSongManager().getSong().getMeasureHeader(measureIdx);
146
header.update(this, measureIdx);
147
for (int trackIdx = 0; trackIdx < trackCount; trackIdx++) {
148
TGTrackImpl track = (TGTrackImpl)getSongManager().getSong().getTrack(trackIdx);
149
TGMeasureImpl measure = (TGMeasureImpl) track.getMeasure(measureIdx);
150
measure.create(this);
152
for (int trackIdx = 0; trackIdx < trackCount; trackIdx++) {
153
TGTrackImpl track = (TGTrackImpl)getSongManager().getSong().getTrack(trackIdx);
154
TGMeasureImpl measure = (TGMeasureImpl)track.getMeasure(measureIdx);
156
measure.update(this);
161
private void updateCaret(){
162
this.tablature.getCaret().update();
165
public void fireUpdate(int measureNumber){
166
int measureIndex = (measureNumber - 1);
167
int trackCount = getSongManager().getSong().countTracks();
168
TGMeasureHeaderImpl header = (TGMeasureHeaderImpl)getSongManager().getSong().getMeasureHeader(measureIndex);
169
header.update(this, measureIndex);
170
for (int trackIdx = 0; trackIdx < trackCount; trackIdx++) {
171
TGTrackImpl track = (TGTrackImpl)getSongManager().getSong().getTrack(trackIdx);
172
TGMeasureImpl measure = null;
173
measure = (TGMeasureImpl) track.getMeasure(measureIndex);
174
measure.create(this);
176
for (int trackIdx = 0; trackIdx < trackCount; trackIdx++) {
177
TGTrackImpl track = (TGTrackImpl)getSongManager().getSong().getTrack(trackIdx);
178
TGMeasureImpl measure = (TGMeasureImpl) track.getMeasure(measureIndex);
179
measure.update(this);
184
public void reloadStyles(){
185
this.getResources().load();
191
public void paintLines(TGTrackImpl track,TrackSpacing ts,TGPainter painter,int x,int y,int width) {
193
setLineStyle(painter);
194
int tempX = ((x < 0)?0:x);
198
if( (this.style & DISPLAY_SCORE) != 0 ){
199
int posY = tempY + ts.getPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES);
202
for(int i = 1;i <= 5;i ++){
203
painter.moveTo(tempX, posY);
204
painter.lineTo(tempX + width,posY);
205
posY += getScoreLineSpacing();
210
if((this.style & DISPLAY_TABLATURE) != 0){
211
tempY += ts.getPosition(TrackSpacing.POSITION_TABLATURE);
214
for(int i = 0; i < track.stringCount();i++){
215
painter.moveTo(tempX,tempY);
216
painter.lineTo(tempX + width,tempY);
217
tempY += getStringSpacing();
227
public void paintCaret(TGPainter painter) {
228
if(isCaretVisible() && ((this.style & (DISPLAY_TABLATURE | DISPLAY_SCORE) ) != 0 )){
229
Caret caret = getTablature().getCaret();
230
if(!caret.getMeasure().isOutOfBounds()){
231
caret.paintCaret(this,painter);
237
* Pinta el compas y las notas que estan sonando
239
public void paintPlayMode(TGPainter painter,TGMeasureImpl measure,TGBeatImpl beat,boolean paintMeasure){
240
this.playModeEnabled = true;
244
measure.paintMeasure(this,painter);
247
beat.paint(this,painter,measure.getPosX() + measure.getHeaderImpl().getLeftSpacing(this), measure.getPosY());
250
((TGLyricImpl)measure.getTrackImpl().getLyrics()).paintCurrentNoteBeats(painter,this,measure,measure.getPosX(), measure.getPosY());
252
this.playModeEnabled = false;
255
protected float checkScale(){
256
float v1 = ((this.style & DISPLAY_SCORE) != 0 ? (getScoreLineSpacing() * 1.25f ) : 0 );
257
float v2 = ((this.style & DISPLAY_TABLATURE) != 0 ? getStringSpacing() : 0 );
258
float scale = (Math.max(v1,v2) / 10.0f);
262
protected void checkDefaultSpacing(TrackSpacing ts){
263
int checkPosition = -1;
264
//int minBufferSeparator = (Math.round( getMinBufferSeparator() * getScale() ));
265
int minBufferSeparator = getMinBufferSeparator();
266
if( (this.style & DISPLAY_SCORE) != 0 ){
267
int bufferSeparator = (ts.getPosition(TrackSpacing.POSITION_SCORE_UP_LINES) - ts.getPosition(TrackSpacing.POSITION_BUFFER_SEPARATOR));
268
if(bufferSeparator < minBufferSeparator ) {
269
ts.setSize(TrackSpacing.POSITION_BUFFER_SEPARATOR,minBufferSeparator - bufferSeparator);
271
checkPosition = ts.getPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES);
273
else if((this.style & DISPLAY_TABLATURE) != 0){
274
int bufferSeparator = (ts.getPosition(TrackSpacing.POSITION_TABLATURE) - ts.getPosition(TrackSpacing.POSITION_BUFFER_SEPARATOR));
275
if(bufferSeparator < minBufferSeparator ) {
276
ts.setSize(TrackSpacing.POSITION_BUFFER_SEPARATOR,minBufferSeparator - bufferSeparator);
278
checkPosition = ts.getPosition(TrackSpacing.POSITION_TABLATURE);
281
if(checkPosition >= 0 && checkPosition < getMinTopSpacing()){
282
ts.setSize(TrackSpacing.POSITION_TOP, (getMinTopSpacing() - checkPosition));
287
* Calcula el espacio minimo entre negras, dependiendo de la duracion de la nota
289
public int getSpacingForQuarter(TGDuration duration){
290
double spacing = (((double)TGDuration.QUARTER_TIME / (double)duration.getTime()) * getMinSpacing(duration));
295
* Calcula el Espacio minimo que quedara entre nota y nota
297
protected float getMinSpacing(TGDuration duration){
298
float scale = getScale();
299
switch(duration.getValue()){
300
case TGDuration.WHOLE:
301
return (50.0f * scale);
302
case TGDuration.HALF:
303
return (30.0f * scale);
304
case TGDuration.QUARTER:
305
return (25.0f * scale);
306
case TGDuration.EIGHTH:
307
return (20.0f * scale);
309
return (18.0f * scale);
314
* Calcula el Espacio que ocupara el pulso
316
public float getBeatWidth(TGBeatImpl beat){
317
float scale = getScale();
318
TGDuration duration = beat.getDuration();
319
if(duration != null){
320
switch(duration.getValue()){
321
case TGDuration.WHOLE:
322
return (30.0f * scale);
323
case TGDuration.HALF:
324
return (25.0f * scale);
325
case TGDuration.QUARTER:
326
return (21.0f * scale);
327
case TGDuration.EIGHTH:
328
return (20.0f * scale);
329
case TGDuration.SIXTEENTH:
330
return (19.0f * scale);
331
case TGDuration.THIRTY_SECOND:
332
return (18.0f * scale);
334
return (17.0f * scale);
337
return (20.0f * scale);
340
public boolean isCaretVisible(){
344
public boolean isPlayModeEnabled(){
345
return this.playModeEnabled;
348
public void setMeasureNumberStyle(TGPainter painter){
349
painter.setFont(getResources().getDefaultFont());
350
painter.setBackground(getResources().getBackgroundColor());
351
painter.setForeground(getResources().getColorRed());
354
public void setDivisionsStyle(TGPainter painter, boolean fill){
355
painter.setFont(getResources().getDefaultFont());
356
painter.setBackground( (fill ? getResources().getColorBlack() :getResources().getBackgroundColor() ));
357
painter.setForeground(getResources().getColorBlack());
360
public void setTempoStyle(TGPainter painter, boolean fontStyle){
361
painter.setFont(getResources().getDefaultFont());
362
painter.setForeground(getResources().getColorBlack());
363
painter.setBackground( ( fontStyle ? getResources().getBackgroundColor() : getResources().getColorBlack() ));
366
public void setTripletFeelStyle(TGPainter painter, boolean fontStyle){
367
painter.setFont(getResources().getDefaultFont());
368
painter.setForeground(getResources().getColorBlack());
369
painter.setBackground( ( fontStyle ? getResources().getBackgroundColor() : getResources().getColorBlack() ));
372
public void setMeasurePlayingStyle(TGPainter painter){
373
painter.setBackground(getResources().getBackgroundColor());
374
painter.setForeground(getResources().getColorBlack());
377
public void setGraceStyle(TGPainter painter){
378
painter.setFont(getResources().getGraceFont());
379
painter.setBackground(getResources().getBackgroundColor());
382
public void setLyricStyle(TGPainter painter,boolean playMode){
383
painter.setFont(getResources().getLyricFont());
384
painter.setBackground(getResources().getBackgroundColor());
385
painter.setForeground( (playMode ? getResources().getPlayNoteColor() : getResources().getColorBlack()) );
388
public void setTextStyle(TGPainter painter){
389
painter.setFont(getResources().getTextFont());
390
painter.setBackground(getResources().getBackgroundColor());
391
painter.setForeground(getResources().getColorBlack());
394
public void setTimeSignatureStyle(TGPainter painter){
395
painter.setFont(getResources().getTimeSignatureFont());
396
painter.setForeground(getResources().getColorBlack());
397
painter.setBackground(getResources().getBackgroundColor());
400
public void setKeySignatureStyle(TGPainter painter){
401
painter.setBackground(getResources().getColorBlack());
404
public void setClefStyle(TGPainter painter){
405
painter.setBackground(getResources().getColorBlack());
408
public void setLineStyle(TGPainter painter){
409
painter.setLineWidth(1);
410
painter.setForeground(getResources().getLineColor());
413
public void setCaretStyle(TGPainter painter){
414
painter.setForeground(getResources().getLineColor());
417
public void setScoreSilenceStyle(TGPainter painter,boolean playMode){
418
painter.setForeground( (playMode ? getResources().getPlayNoteColor() : getResources().getScoreNoteColor() ));
419
painter.setBackground( (playMode ? getResources().getPlayNoteColor() : getResources().getScoreNoteColor() ));
422
public void setTabSilenceStyle(TGPainter painter,boolean playMode){
423
painter.setForeground( (playMode ? getResources().getPlayNoteColor() : getResources().getTabNoteColor() ));
424
painter.setBackground( (playMode ? getResources().getPlayNoteColor() : getResources().getTabNoteColor() ));
427
public void setScoreNoteStyle(TGPainter painter,boolean playing){
428
painter.setForeground( (playing ? getResources().getPlayNoteColor() : getResources().getScoreNoteColor() ));
429
painter.setBackground( (playing ? getResources().getPlayNoteColor() : getResources().getScoreNoteColor() ));
432
public void setScoreNoteFooterStyle(TGPainter painter){
433
painter.setForeground( getResources().getScoreNoteColor());
434
painter.setBackground( getResources().getScoreNoteColor());
437
public void setScoreEffectStyle(TGPainter painter){
438
painter.setForeground( getResources().getScoreNoteColor());
439
painter.setBackground( getResources().getScoreNoteColor());
442
public void setTabNoteStyle(TGPainter painter,boolean playMode){
443
painter.setForeground( (playMode ? getResources().getPlayNoteColor() : getResources().getTabNoteColor() ));
444
painter.setBackground( getResources().getBackgroundColor() );
445
painter.setFont(getResources().getNoteFont());
448
public void setTabNoteFooterStyle(TGPainter painter){
449
painter.setForeground( getResources().getTabNoteColor());
450
painter.setBackground( getResources().getTabNoteColor());
453
public void setTabEffectStyle(TGPainter painter){
454
painter.setForeground( getResources().getTabNoteColor());
455
painter.setBackground( getResources().getTabNoteColor());
458
public void setPlayNoteColor(TGPainter painter){
459
painter.setForeground(getResources().getPlayNoteColor());
460
painter.setBackground(getResources().getPlayNoteColor());
463
public void setOfflineEffectStyle(TGPainter painter){
464
painter.setForeground(getResources().getColorBlack());
465
painter.setBackground(getResources().getBackgroundColor());
466
painter.setFont(getResources().getDefaultFont());
469
public void setDotStyle(TGPainter painter){
470
painter.setForeground(getResources().getColorBlack());
471
painter.setBackground(getResources().getColorBlack());
474
public void setTupletoStyle(TGPainter painter){
475
painter.setForeground(getResources().getColorBlack());
476
painter.setBackground(getResources().getBackgroundColor());
477
painter.setFont(getResources().getDefaultFont());
480
public void setRepeatEndingStyle(TGPainter painter){
481
painter.setForeground(getResources().getColorBlack());
482
painter.setBackground(getResources().getBackgroundColor());
483
painter.setFont(getResources().getDefaultFont());
486
public void setChordStyle(TGChordImpl chord){
487
chord.setFont(getResources().getChordFont());
488
chord.setForegroundColor(getResources().getColorBlack());
489
chord.setBackgroundColor(getResources().getBackgroundColor());
490
chord.setColor(getResources().getLineColor());
491
chord.setNoteColor(getResources().getTabNoteColor());
492
chord.setTonicColor(getResources().getTabNoteColor());
493
chord.setStyle(this.style);
494
chord.setFretSpacing(getChordFretSpacing());
495
chord.setStringSpacing(getChordStringSpacing());
496
chord.setNoteSize(getChordNoteSize());
497
chord.setFirstFretSpacing(getChordFretIndexSpacing());
498
chord.setFirstFretFont(getResources().getChordFretFont());
501
public Rectangle getNoteOrientation(TGPainter painter,int x,int y,TGNote note){
502
String noteAsString = null;
503
if (note.isTiedNote()){
505
noteAsString = (note.getEffect().isGhostNote())?"(" + noteAsString + ")":noteAsString;
506
}else if(note.getEffect().isDeadNote()){
508
noteAsString = (note.getEffect().isGhostNote())?"(" + noteAsString + ")":noteAsString;
510
noteAsString = Integer.toString(note.getValue());
511
noteAsString = (note.getEffect().isGhostNote())?"(" + noteAsString + ")":noteAsString;
513
return getOrientation(painter,x,y,noteAsString);
516
public Rectangle getOrientation(TGPainter painter,int x,int y,String s){
517
Point point = painter.getStringExtent(s);
518
return new Rectangle((x - (point.x / 2)),(y - (point.y / 2)),point.x, point.y );
521
public TGSongManager getSongManager() {
522
return getTablature().getSongManager();
525
public Tablature getTablature() {
526
return this.tablature;
529
public void setTablature(Tablature tablature) {
530
this.tablature = tablature;
533
public TGResources getResources(){
534
return this.resources;
537
public int getHeight() {
541
public void setHeight(int height) {
542
this.height = height;
545
public int getWidth() {
549
public void setWidth(int width) {
553
public int getStyle(){
557
public void setStyle(int style){
561
public float getScale() {
565
public void setScale(float scale) {
569
public float getFontScale() {
570
return this.fontScale;
573
public void setFontScale(float fontScale) {
574
this.fontScale = fontScale;
577
public boolean isBufferEnabled() {
578
return this.bufferEnabled;
581
public void setBufferEnabled(boolean bufferEnabled) {
582
this.bufferEnabled = bufferEnabled;
585
public int getFirstMeasureSpacing() {
586
return this.firstMeasureSpacing;
589
public void setFirstMeasureSpacing(int firstMeasureSpacing) {
590
this.firstMeasureSpacing = firstMeasureSpacing;
593
public int getMinBufferSeparator() {
594
return this.minBufferSeparator;
597
public void setMinBufferSeparator(int minBufferSeparator) {
598
this.minBufferSeparator = minBufferSeparator;
601
public int getMinTopSpacing() {
602
return this.minTopSpacing;
605
public void setMinTopSpacing(int minTopSpacing) {
606
this.minTopSpacing = minTopSpacing;
609
public int getMinScoreTabSpacing() {
610
return this.minScoreTabSpacing;
613
public void setMinScoreTabSpacing(int minScoreTabSpacing) {
614
this.minScoreTabSpacing = minScoreTabSpacing;
617
public int getScoreLineSpacing() {
618
return this.scoreLineSpacing;
621
public void setScoreLineSpacing(int scoreLineSpacing) {
622
this.scoreLineSpacing = scoreLineSpacing;
625
public int getScoreSpacing() {
626
return this.scoreSpacing;
629
public void setScoreSpacing(int scoreSpacing) {
630
this.scoreSpacing = scoreSpacing;
633
public int getFirstTrackSpacing() {
634
return this.firstTrackSpacing;
637
public void setFirstTrackSpacing(int firstTrackSpacing) {
638
this.firstTrackSpacing = firstTrackSpacing;
641
public int getTrackSpacing() {
642
return this.trackSpacing;
645
public void setTrackSpacing(int trackSpacing) {
646
this.trackSpacing = trackSpacing;
649
public int getStringSpacing() {
650
return this.stringSpacing;
653
public void setStringSpacing(int stringSpacing) {
654
this.stringSpacing = stringSpacing;
657
public int getChordFretIndexSpacing() {
658
return this.chordFretIndexSpacing;
661
public void setChordFretIndexSpacing(int chordFretIndexSpacing) {
662
this.chordFretIndexSpacing = chordFretIndexSpacing;
665
public int getChordStringSpacing() {
666
return this.chordStringSpacing;
669
public void setChordStringSpacing(int chordStringSpacing) {
670
this.chordStringSpacing = chordStringSpacing;
673
public int getChordFretSpacing() {
674
return this.chordFretSpacing;
677
public void setChordFretSpacing(int chordFretSpacing) {
678
this.chordFretSpacing = chordFretSpacing;
681
public int getChordNoteSize() {
682
return this.chordNoteSize;
685
public void setChordNoteSize(int chordNoteSize) {
686
this.chordNoteSize = chordNoteSize;
689
public int getRepeatEndingSpacing() {
690
return this.repeatEndingSpacing;
693
public void setRepeatEndingSpacing(int repeatEndingSpacing) {
694
this.repeatEndingSpacing = repeatEndingSpacing;
697
public int getTupletoSpacing() {
698
return this.tupletoSpacing;
701
public void setTupletoSpacing(int tupletoSpacing) {
702
this.tupletoSpacing = tupletoSpacing;
705
public int getTextSpacing() {
706
return this.textSpacing;
709
public void setTextSpacing(int textSpacing) {
710
this.textSpacing = textSpacing;
713
public int getEffectSpacing() {
714
return this.effectSpacing;
717
public void setEffectSpacing(int effectSpacing) {
718
this.effectSpacing = effectSpacing;
721
public int getDefaultChordSpacing(){
723
if( (this.style & DISPLAY_CHORD_DIAGRAM) != 0 ){
724
spacing += ( (TGChordImpl.MAX_FRETS * getChordFretSpacing()) + getChordFretSpacing());
726
if( (this.style & DISPLAY_CHORD_NAME) != 0 ){
727
spacing += Math.round( (15f * getScale()) );
732
public boolean isFirstMeasure(TGMeasure measure){
733
return (measure.getNumber() == 1);
736
public boolean isLastMeasure(TGMeasure measure){
737
return (measure.getNumber() == getSongManager().getSong().countMeasureHeaders());
740
protected void clearTrackPositions(){
741
this.trackPositions.clear();
744
protected void addTrackPosition(int track,int posY,int height){
745
this.trackPositions.add(new TrackPosition(track,posY,height));
748
public int getTrackNumberAt(int y){
749
TrackPosition trackPos = getTrackPositionAt(y);
750
return ((trackPos != null)?trackPos.getTrack():-1);
753
public TrackPosition getTrackPositionAt(int y){
754
TrackPosition trackPos = null;
755
int minorDistance = 0;
757
Iterator it = this.trackPositions.iterator();
759
TrackPosition pos = (TrackPosition)it.next();
760
int distanceY = Math.min(Math.abs(y - (pos.getPosY())), Math.abs(y - (pos.getPosY() + pos.getHeight() - 10)));
761
if(trackPos == null || distanceY < minorDistance){
763
minorDistance = distanceY;
769
public void disposeLayout(){
770
this.getResources().dispose();
773
public class TrackPosition{
778
public TrackPosition(int track,int posY,int height){
781
this.height = height;
784
public int getPosY() {
788
public int getHeight() {
792
public int getTrack() {