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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/editors/tab/TGNoteImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080619003030-agens2gvd5m4dacu
New upstream release (Closes: #481728) also (LP: #176979, #212207)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on 29-nov-2005
 
3
 *
 
4
 * TODO To change the template for this generated file go to
 
5
 * Window - Preferences - Java - Code Style - Code Templates
 
6
 */
 
7
package org.herac.tuxguitar.gui.editors.tab;
 
8
 
 
9
import java.util.Iterator;
 
10
 
 
11
import org.eclipse.swt.graphics.Point;
 
12
import org.eclipse.swt.graphics.Rectangle;
 
13
import org.herac.tuxguitar.gui.editors.TGPainter;
 
14
import org.herac.tuxguitar.gui.editors.tab.layout.TrackSpacing;
 
15
import org.herac.tuxguitar.gui.editors.tab.layout.ViewLayout;
 
16
import org.herac.tuxguitar.gui.editors.tab.painters.TGKeySignaturePainter;
 
17
import org.herac.tuxguitar.gui.editors.tab.painters.TGNotePainter;
 
18
import org.herac.tuxguitar.song.factory.TGFactory;
 
19
import org.herac.tuxguitar.song.models.TGBeat;
 
20
import org.herac.tuxguitar.song.models.TGDuration;
 
21
import org.herac.tuxguitar.song.models.TGNote;
 
22
import org.herac.tuxguitar.song.models.TGNoteEffect;
 
23
import org.herac.tuxguitar.song.models.effects.TGEffectHarmonic;
 
24
 
 
25
/**
 
26
 * @author julian
 
27
 * 
 
28
 * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
 
29
 */
 
30
public class TGNoteImpl extends TGNote {
 
31
        /**
 
32
         * Grupo al que pertenece este beat
 
33
         */
 
34
        private TGBeatGroup group;
 
35
        
 
36
        private Rectangle noteOrientation;
 
37
        
 
38
        private int tabPosY;
 
39
        
 
40
        private int scorePosY;
 
41
        
 
42
        private int accidental;
 
43
        
 
44
        public TGNoteImpl(TGFactory factory) {
 
45
                super(factory);
 
46
                this.noteOrientation = new Rectangle(0,0,0,0);
 
47
        }
 
48
        
 
49
        /**
 
50
         * Actualiza los valores para dibujar
 
51
         */
 
52
        public void update(ViewLayout layout) {
 
53
                this.accidental = getMeasureImpl().getNoteAccidental( getRealValue() );
 
54
                this.tabPosY = ( (getString() * layout.getStringSpacing()) - layout.getStringSpacing() );
 
55
                this.scorePosY = this.group.getY1(layout,this,getMeasureImpl().getKeySignature(),getMeasureImpl().getClef());
 
56
        }
 
57
        
 
58
        /**
 
59
         * Pinta la nota
 
60
         */
 
61
        public void paint(ViewLayout layout,TGPainter painter, int fromX, int fromY) {
 
62
                int spacing = getBeatImpl().getSpacing();
 
63
                paintScoreNote(layout, painter, fromX, fromY + getPaintPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES),spacing);
 
64
                if(!layout.isPlayModeEnabled()){
 
65
                        paintOfflineEffects(layout, painter,fromX,fromY, spacing);
 
66
                }
 
67
                paintTablatureNote(layout, painter, fromX, fromY + getPaintPosition(TrackSpacing.POSITION_TABLATURE),spacing);
 
68
        }
 
69
        
 
70
        private void paintOfflineEffects(ViewLayout layout,TGPainter painter,int fromX, int fromY, int spacing){
 
71
                TGNoteEffect effect = getEffect();
 
72
                
 
73
                layout.setOfflineEffectStyle(painter);
 
74
                if(effect.isAccentuatedNote()){
 
75
                        int x = fromX + getPosX() + spacing;
 
76
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_ACCENTUATED_EFFECT));
 
77
                        paintAccentuated(layout, painter, x, y);
 
78
                }
 
79
                else if(effect.isHeavyAccentuatedNote()){
 
80
                        int x = fromX + getPosX() + spacing;
 
81
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_ACCENTUATED_EFFECT));
 
82
                        paintHeavyAccentuated(layout, painter, x, y);
 
83
                }
 
84
                if(effect.isFadeIn()){
 
85
                        int x = fromX + getPosX() + spacing;
 
86
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_FADE_IN));
 
87
                        paintFadeIn(layout, painter, x, y);
 
88
                }
 
89
                if(effect.isHarmonic() && (layout.getStyle() & ViewLayout.DISPLAY_SCORE) == 0 ){
 
90
                        int x = fromX + getPosX() + spacing;
 
91
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_HARMONIC_EFFEC));
 
92
                        String key = new String();
 
93
                        key = effect.getHarmonic().isNatural()?TGEffectHarmonic.KEY_NATURAL:key;
 
94
                        key = effect.getHarmonic().isArtificial()?TGEffectHarmonic.KEY_ARTIFICIAL:key;
 
95
                        key = effect.getHarmonic().isTapped()?TGEffectHarmonic.KEY_TAPPED:key;
 
96
                        key = effect.getHarmonic().isPinch()?TGEffectHarmonic.KEY_PINCH:key;
 
97
                        key = effect.getHarmonic().isSemi()?TGEffectHarmonic.KEY_SEMI:key;
 
98
                        painter.drawString(key,x, y);
 
99
                }
 
100
                if(effect.isTapping()){
 
101
                        int x = fromX + getPosX() + spacing;
 
102
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_TAPPING_EFFEC));
 
103
                        painter.drawString("T",x, y);
 
104
                }
 
105
                else if(effect.isSlapping()){
 
106
                        int x = fromX + getPosX() + spacing;
 
107
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_TAPPING_EFFEC));
 
108
                        painter.drawString("S",x, y);
 
109
                }
 
110
                else if(effect.isPopping()){
 
111
                        int x = fromX + getPosX() + spacing;
 
112
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_TAPPING_EFFEC));
 
113
                        painter.drawString("P",x, y);
 
114
                }
 
115
                if(effect.isPalmMute()){
 
116
                        int x = fromX + getPosX() + spacing;
 
117
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_PALM_MUTE_EFFEC));
 
118
                        painter.drawString("P.M",x, y);
 
119
                }
 
120
                if(effect.isVibrato()){
 
121
                        int x = fromX + getPosX() + spacing;
 
122
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_VIBRATO_EFFEC));
 
123
                        paintVibrato(layout, painter,x,y);
 
124
                }
 
125
                if(effect.isTrill()){
 
126
                        int x = fromX + getPosX() + spacing;
 
127
                        int y = (fromY + getPaintPosition(TrackSpacing.POSITION_VIBRATO_EFFEC));
 
128
                        paintTrill(layout, painter,x,y);
 
129
                }
 
130
        }
 
131
        
 
132
        /**
 
133
         * Pinta la nota en la tablatura
 
134
         */
 
135
        public void paintTablatureNote(ViewLayout layout,TGPainter painter, int fromX, int fromY, int spacing) {
 
136
                int style = layout.getStyle();
 
137
                if((style & ViewLayout.DISPLAY_TABLATURE) != 0){
 
138
                        int stringSpacing = layout.getStringSpacing();
 
139
                        int x = fromX + getPosX() + spacing + 2;
 
140
                        int y = fromY + getTabPosY();
 
141
                        
 
142
                        this.noteOrientation.x = x;
 
143
                        this.noteOrientation.y = y;
 
144
                        this.noteOrientation.width = 1;
 
145
                        this.noteOrientation.height = 1;
 
146
                        
 
147
                        layout.setTabNoteStyle(painter, (layout.isPlayModeEnabled() && getBeatImpl().isPlaying(layout)));
 
148
                        //-------------ligadura--------------------------------------
 
149
                        if (isTiedNote() && (style & ViewLayout.DISPLAY_SCORE) == 0) {
 
150
                                float tX = 0;
 
151
                                float tY = 0;
 
152
                                float tWidth = 0;
 
153
                                float tHeight = (stringSpacing * 3);
 
154
                                TGNoteImpl noteForTie = getNoteForTie();
 
155
                                if (noteForTie != null) {
 
156
                                        tX = (fromX + noteForTie.getPosX() + noteForTie.getBeatImpl().getSpacing());
 
157
                                        tY = (fromY + noteForTie.getTabPosY() + stringSpacing);
 
158
                                        tWidth = (x - tX);
 
159
                                }else{
 
160
                                        Rectangle r = layout.getNoteOrientation(painter,x,y,this);
 
161
                                        tX = r.x - (stringSpacing * 2);
 
162
                                        tY = (fromY + getTabPosY() + stringSpacing);
 
163
                                        tWidth = (stringSpacing * 2);
 
164
                                }
 
165
                                painter.initPath();
 
166
                                painter.addArc(tX, (tY - tHeight ), tWidth, tHeight, 225,90);
 
167
                                painter.closePath();
 
168
                                
 
169
                        //-------------nota--------------------------------------
 
170
                        } else if(!isTiedNote()){
 
171
                                Rectangle r = layout.getNoteOrientation(painter,x,y,this);
 
172
                                this.noteOrientation.x = r.x;
 
173
                                this.noteOrientation.y = r.y;
 
174
                                this.noteOrientation.width = r.width;
 
175
                                this.noteOrientation.height = r.height;
 
176
                                String visualNote = (getEffect().isDeadNote())?"X":Integer.toString(getValue());
 
177
                                visualNote = (getEffect().isGhostNote())?"(" + visualNote + ")":visualNote;
 
178
                                painter.drawString(visualNote, this.noteOrientation.x, this.noteOrientation.y);
 
179
                        }
 
180
                        
 
181
                        //-------------efectos--------------------------------------
 
182
                        if(! layout.isPlayModeEnabled() ){
 
183
                                
 
184
                                paintEffects(layout,painter,fromX,fromY,spacing);
 
185
                                
 
186
                                if((style & ViewLayout.DISPLAY_SCORE) == 0){
 
187
                                        int y1 = (fromY + getMeasureImpl().getTrackImpl().getTabHeight() + (stringSpacing / 2));
 
188
                                        int y2 = (fromY + getMeasureImpl().getTrackImpl().getTabHeight() + ((stringSpacing / 2) * 5));
 
189
                                        
 
190
                                        //-------------tremolo picking--------------------------------------
 
191
                                        if(getEffect().isTremoloPicking()){
 
192
                                                layout.setTabEffectStyle(painter);
 
193
                                                painter.initPath();
 
194
                                                int posy = (y1 + ((y2 - y1) / 2));
 
195
                                                for(int i = TGDuration.EIGHTH;i <= getEffect().getTremoloPicking().getDuration().getValue(); i += i){
 
196
                                                        painter.moveTo(x - 3, posy - 1);
 
197
                                                        painter.lineTo(x + 4,posy + 1);
 
198
                                                        posy += 4;
 
199
                                                }
 
200
                                                painter.setLineWidth(2);
 
201
                                                painter.closePath();
 
202
                                                painter.setLineWidth(1);
 
203
                                        }
 
204
                                }
 
205
                        }
 
206
                }
 
207
        }
 
208
        
 
209
        /**
 
210
         * Pinta la nota en la partitura
 
211
         */
 
212
        private void paintScoreNote(ViewLayout layout,TGPainter painter, int fromX, int fromY, int spacing) {
 
213
                if((layout.getStyle() & ViewLayout.DISPLAY_SCORE) != 0 ){
 
214
                        float scale = layout.getScoreLineSpacing();
 
215
                        int direction = this.group.getDirection();
 
216
                        int key = getMeasureImpl().getKeySignature();
 
217
                        int clef = getMeasureImpl().getClef();
 
218
                        
 
219
                        int x = ( fromX + getPosX() + spacing );
 
220
                        int y1 = ( fromY + getScorePosY() ) ;
 
221
                        
 
222
                        //-------------foreground--------------------------------------
 
223
                        boolean playing = (layout.isPlayModeEnabled() && getBeatImpl().isPlaying(layout));
 
224
                        
 
225
                        layout.setScoreNoteStyle(painter,playing);
 
226
                        
 
227
                        //----------ligadura---------------------------------------
 
228
                        if (isTiedNote()) {
 
229
                                TGNoteImpl noteForTie = getNoteForTie();
 
230
                                float tScale = (scale / 8.0f);
 
231
                                float tX = x - (20.0f * tScale);
 
232
                                float tY = y1 - (2.0f * tScale);
 
233
                                float tWidth = (20.0f * tScale);
 
234
                                float tHeight = (30.0f * tScale);
 
235
                                if (noteForTie != null) {
 
236
                                        int tNoteX = (fromX + noteForTie.getPosX() + noteForTie.getBeatImpl().getSpacing());
 
237
                                        int tNoteY = (fromY + getScorePosY());
 
238
                                        tX = tNoteX + (6.0f * tScale);
 
239
                                        tY = tNoteY - (3.0f * tScale);
 
240
                                        tWidth = (x - tNoteX) - (3.0f * tScale);
 
241
                                        tHeight = (35.0f * tScale);
 
242
                                }
 
243
                                painter.initPath();
 
244
                                painter.addArc(tX,tY, tWidth, tHeight, 45, 90);
 
245
                                painter.closePath();
 
246
                        }
 
247
                        //----------sostenido--------------------------------------
 
248
                        if(this.accidental == TGMeasureImpl.NATURAL){
 
249
                                painter.initPath(TGPainter.PATH_FILL);
 
250
                                TGKeySignaturePainter.paintNatural(painter,(x - (scale - (scale / 4)) ),(y1 + (scale / 2)), scale);
 
251
                                painter.closePath();
 
252
                        }
 
253
                        else if(this.accidental == TGMeasureImpl.SHARP){
 
254
                                painter.initPath(TGPainter.PATH_FILL);
 
255
                                TGKeySignaturePainter.paintSharp(painter,(x - (scale - (scale / 4)) ),(y1 + (scale / 2)), scale);
 
256
                                painter.closePath();
 
257
                        }
 
258
                        else if(this.accidental == TGMeasureImpl.FLAT){
 
259
                                painter.initPath(TGPainter.PATH_FILL);
 
260
                                TGKeySignaturePainter.paintFlat(painter,(x - (scale - (scale / 4)) ),(y1 + (scale / 2)), scale);
 
261
                                painter.closePath();
 
262
                        }
 
263
                        //----------fin sostenido--------------------------------------
 
264
                        if(getEffect().isHarmonic()){
 
265
                                if( layout.isBufferEnabled() ){
 
266
                                        painter.drawImage(layout.getResources().getHarmonicNote(getBeat().getDuration().getValue(),playing),x,y1);
 
267
                                }else{
 
268
                                        boolean full = (getBeat().getDuration().getValue() >= TGDuration.QUARTER);
 
269
                                        painter.initPath((full ? TGPainter.PATH_DRAW | TGPainter.PATH_FILL : TGPainter.PATH_DRAW));
 
270
                                        TGNotePainter.paintHarmonic(painter,x,y1+1,(layout.getScoreLineSpacing() - 2) );
 
271
                                        painter.closePath();
 
272
                                }
 
273
                        }else{
 
274
                                if( layout.isBufferEnabled() ){
 
275
                                        painter.drawImage(layout.getResources().getScoreNote(getBeat().getDuration().getValue(),playing),x,y1);
 
276
                                }else{
 
277
                                        boolean full = (getBeat().getDuration().getValue() >= TGDuration.QUARTER);
 
278
                                        painter.initPath((full ? TGPainter.PATH_FILL : TGPainter.PATH_DRAW));
 
279
                                        TGNotePainter.paintNote(painter,x,y1+1, ((full ? layout.getScoreLineSpacing() + 1 : layout.getScoreLineSpacing() ) - 2) );
 
280
                                        painter.closePath();
 
281
                                }
 
282
                        }
 
283
                        
 
284
                        if(! layout.isPlayModeEnabled() ){
 
285
                                
 
286
                                if(getEffect().isGrace()){
 
287
                                        paintGrace(layout, painter,x ,y1);
 
288
                                }
 
289
                                
 
290
                                //PUNTILLO y DOBLE PUNTILLO
 
291
                                if (getBeat().getDuration().isDotted() || getBeat().getDuration().isDoubleDotted()) {
 
292
                                        getBeatImpl().paintDot(layout, painter,( x + (12.0f * (scale / 8.0f) ) ), ( y1 + (layout.getScoreLineSpacing()/ 2)), (scale / 10.0f) );
 
293
                                }
 
294
                                
 
295
                                //dibujo el pie
 
296
                                if(getBeat().getDuration().getValue() >= TGDuration.HALF){
 
297
                                        layout.setScoreNoteFooterStyle(painter);
 
298
                                        int xMove = (direction == TGBeatGroup.DIRECTION_UP ? layout.getResources().getScoreNoteWidth() : 0);
 
299
                                        int y2 = fromY + this.group.getY2(layout,getPosX() + spacing,key,clef);
 
300
                                        
 
301
                                        //staccato
 
302
                                        if (getEffect().isStaccato()) {
 
303
                                                int size = 3;
 
304
                                                int sX = x + xMove;
 
305
                                                int sY = (y2 + (4 * ((direction == TGBeatGroup.DIRECTION_UP)?-1:1)));
 
306
                                                layout.setScoreEffectStyle(painter);
 
307
                                                painter.initPath(TGPainter.PATH_FILL);
 
308
                                                painter.moveTo(sX - (size / 2),sY - (size / 2));
 
309
                                                painter.addOval(sX - (size / 2),sY - (size / 2),size,size);
 
310
                                                painter.closePath();
 
311
                                        }
 
312
                                        //tremolo picking
 
313
                                        if(getEffect().isTremoloPicking()){
 
314
                                                layout.setScoreEffectStyle(painter);
 
315
                                                painter.initPath();
 
316
                                                int tpY = fromY;
 
317
                                                if((direction == TGBeatGroup.DIRECTION_UP)){
 
318
                                                        tpY += (this.group.getMaxNote().getScorePosY() - layout.getScoreLineSpacing() - 4);
 
319
                                                }else{
 
320
                                                        tpY += (this.group.getMinNote().getScorePosY() + layout.getScoreLineSpacing() + 4);
 
321
                                                }
 
322
                                                for(int i = TGDuration.EIGHTH;i <= getEffect().getTremoloPicking().getDuration().getValue(); i += i){
 
323
                                                        painter.moveTo(x + xMove - 3, tpY + 1);
 
324
                                                        painter.lineTo(x + xMove + 4,tpY - 1);
 
325
                                                        tpY += 4;
 
326
                                                }
 
327
                                                painter.setLineWidth(2);
 
328
                                                painter.closePath();
 
329
                                                painter.setLineWidth(1);
 
330
                                        }
 
331
                                }else{
 
332
                                        //staccato
 
333
                                        if (getEffect().isStaccato()) {
 
334
                                                int size = 3;
 
335
                                                int sX = x + (layout.getResources().getScoreNoteWidth() / 2);
 
336
                                                int sY = (fromY + this.group.getMinNote().getScorePosY() + layout.getScoreLineSpacing()) + 2;
 
337
                                                layout.setScoreEffectStyle(painter);
 
338
                                                painter.initPath(TGPainter.PATH_FILL);
 
339
                                                painter.moveTo(sX - (size / 2),sY - (size / 2));
 
340
                                                painter.addOval(sX - (size / 2),sY - (size / 2),size,size);
 
341
                                                painter.closePath();
 
342
                                        }
 
343
                                        //tremolo picking
 
344
                                        if(getEffect().isTremoloPicking()){
 
345
                                                layout.setScoreEffectStyle(painter);
 
346
                                                painter.initPath();
 
347
                                                int tpX = (x + (layout.getResources().getScoreNoteWidth() / 2));
 
348
                                                int tpY = fromY + (this.group.getMaxNote().getScorePosY() - layout.getScoreLineSpacing() - 4);
 
349
                                                for(int i = TGDuration.EIGHTH;i <= getEffect().getTremoloPicking().getDuration().getValue(); i += i){
 
350
                                                        painter.moveTo(tpX - 3, tpY + 1);
 
351
                                                        painter.lineTo(tpX + 4,tpY - 1);
 
352
                                                        tpY += 4;
 
353
                                                }
 
354
                                                painter.setLineWidth(2);
 
355
                                                painter.closePath();
 
356
                                                painter.setLineWidth(1);
 
357
                                        }
 
358
                                }
 
359
                        }
 
360
                }
 
361
        }
 
362
        
 
363
        /**
 
364
         * Encuentra la nota a la que esta ligada
 
365
         */
 
366
        private TGNoteImpl getNoteForTie() {
 
367
                for (int i = getMeasureImpl().countBeats() - 1; i >= 0; i--) {
 
368
                        TGBeat beat = getMeasureImpl().getBeat(i);
 
369
                        if (beat.getStart() < getBeat().getStart() && !beat.isRestBeat()) {
 
370
                                Iterator it = beat.getNotes().iterator();
 
371
                                while(it.hasNext()){
 
372
                                        TGNoteImpl note = (TGNoteImpl)it.next();
 
373
                                        if (note.getString() == getString()) {
 
374
                                                return note;
 
375
                                        }
 
376
                                }
 
377
                        }
 
378
                }
 
379
                return null;
 
380
        }
 
381
        
 
382
        /**
 
383
         * Pinta los efectos
 
384
         */
 
385
        private void paintEffects(ViewLayout layout,TGPainter painter, int fromX, int fromY, int spacing){
 
386
                int x = fromX + getPosX() + spacing;
 
387
                int y = fromY + getTabPosY();
 
388
                TGNoteEffect effect = getEffect();
 
389
                if(effect.isGrace()){
 
390
                        layout.setGraceStyle(painter);
 
391
                        String value = Integer.toString(effect.getGrace().getFret());
 
392
                        Point gracePoint = painter.getStringExtent(value);
 
393
                        painter.drawString(value, (this.noteOrientation.x - gracePoint.x - 2), this.noteOrientation.y );
 
394
                }
 
395
                if(effect.isBend()){
 
396
                        paintBend(layout, painter,(this.noteOrientation.x + this.noteOrientation.width), y);
 
397
                }else if(effect.isTremoloBar()){
 
398
                        paintTremoloBar(layout, painter,(this.noteOrientation.x + this.noteOrientation.width), y);
 
399
                }else if(effect.isSlide() || effect.isHammer()){
 
400
                        int nextFromX = fromX;
 
401
                        TGNoteImpl nextNote = (TGNoteImpl)layout.getSongManager().getMeasureManager().getNextNote(getMeasureImpl(),getBeat().getStart(),getString());
 
402
                        if(effect.isSlide()){
 
403
                                paintSlide(layout, painter, nextNote, x, y, nextFromX);
 
404
                        }else if(effect.isHammer()){
 
405
                                paintHammer(layout, painter, nextNote, x, y, nextFromX);
 
406
                        }
 
407
                }
 
408
        }
 
409
        
 
410
        private void paintBend(ViewLayout layout,TGPainter painter,int fromX,int fromY){
 
411
                float scale = layout.getScale();
 
412
                float x = (fromX + (1.0f * scale));
 
413
                float y = (fromY - (2.0f * scale));
 
414
                
 
415
                layout.setTabEffectStyle(painter);
 
416
                
 
417
                painter.initPath();
 
418
                painter.moveTo( x, y );
 
419
                painter.lineTo( x + (1.0f * scale), y );
 
420
                painter.cubicTo(x + (1.0f * scale), y,  x + (3.0f * scale), y , x + (3.0f * scale), y - (2.0f * scale));
 
421
                painter.lineTo( x + (3.0f * scale), y - (12.0f * scale));
 
422
                painter.lineTo( x + (1.0f * scale), y - (10.0f * scale));
 
423
                painter.moveTo( x + (3.0f * scale), y - (12.0f * scale));
 
424
                painter.lineTo( x + (5.0f * scale), y - (10.0f * scale));
 
425
                painter.closePath();
 
426
        }
 
427
        
 
428
        private void paintTremoloBar(ViewLayout layout,TGPainter painter,int fromX,int fromY){
 
429
                float scale = layout.getScale();
 
430
                float x1 = fromX + (1.0f * scale);
 
431
                float x2 = x1 + (8.0f * scale);
 
432
                float y1 = fromY;
 
433
                float y2 = y1 + (9.0f * scale);
 
434
                layout.setTabEffectStyle(painter);
 
435
                painter.initPath();
 
436
                painter.moveTo(x1,y1);
 
437
                painter.lineTo(x1 + ( (x2 - x1) / 2 ),y2);
 
438
                painter.lineTo(x2,y1);
 
439
                painter.closePath();
 
440
        }
 
441
        
 
442
        private void paintSlide(ViewLayout layout,TGPainter painter,TGNoteImpl nextNote,int fromX,int fromY,int nextFromX){
 
443
                float xScale = layout.getScale();
 
444
                float yScale = (layout.getStringSpacing() / 10.0f);
 
445
                float yMove = (3.0f * yScale);
 
446
                float x = fromX;
 
447
                float y = fromY;
 
448
                layout.setTabEffectStyle(painter);
 
449
                if(nextNote != null){
 
450
                        float nextX = nextNote.getPosX() + nextFromX + nextNote.getBeatImpl().getSpacing();
 
451
                        float nextY = y;
 
452
                        
 
453
                        if(nextNote.getValue() < getValue()){
 
454
                                y -= yMove;
 
455
                                nextY += yMove;
 
456
                        }else if(nextNote.getValue() > getValue()){
 
457
                                y += yMove;
 
458
                                nextY -= yMove;
 
459
                        }else{
 
460
                                y -= yMove;
 
461
                                nextY -= yMove;
 
462
                        }
 
463
                        painter.initPath();
 
464
                        painter.moveTo(x + (6.0f * xScale),y);
 
465
                        painter.lineTo(nextX - (3.0f * xScale),nextY);
 
466
                        painter.closePath();
 
467
                }else{
 
468
                        painter.initPath();
 
469
                        painter.moveTo(x + (6.0f * xScale),y - yMove);
 
470
                        painter.lineTo(x + (17.0f * xScale),y - yMove);
 
471
                        painter.closePath();
 
472
                }
 
473
        }
 
474
        
 
475
        private void paintHammer(ViewLayout layout,TGPainter painter,TGNoteImpl nextNote,int fromX,int fromY,int nextFromX){
 
476
                float xScale = layout.getScale();
 
477
                float yScale = (layout.getStringSpacing() / 10.0f);
 
478
                
 
479
                float x = (fromX + (7.0f * xScale));
 
480
                float y = (fromY - (5.0f * yScale));
 
481
                
 
482
                float width = (nextNote != null)?( (nextNote.getPosX() + nextFromX + nextNote.getBeatImpl().getSpacing()) - (4.0f * xScale) - x ):(10.0f * xScale);
 
483
                float height = (15.0f * yScale);
 
484
                layout.setTabEffectStyle(painter);
 
485
                painter.initPath();
 
486
                painter.addArc(x,y, width, height, 45,90);
 
487
                painter.closePath();
 
488
        }
 
489
        
 
490
        private void paintGrace(ViewLayout layout, TGPainter painter,int fromX,int fromY){
 
491
                float scale = ( layout.getScoreLineSpacing() / 2.25f );
 
492
                
 
493
                float x = fromX - (2f * scale);
 
494
                float y = fromY + (scale / 3);
 
495
                
 
496
                layout.setTabEffectStyle(painter);
 
497
                painter.initPath(TGPainter.PATH_FILL);
 
498
                TGNotePainter.paintFooter(painter,x, y , -1 , scale);
 
499
                painter.closePath();
 
500
                
 
501
                painter.initPath();
 
502
                painter.moveTo(x, y - (2f * scale));
 
503
                painter.lineTo(x, y + (2f * scale) - (scale / 4f));
 
504
                painter.closePath();
 
505
                
 
506
                painter.initPath(TGPainter.PATH_DRAW | TGPainter.PATH_FILL);
 
507
                TGNotePainter.paintNote(painter,x - scale*1.33f, y + scale + (scale / 4f),  scale);
 
508
                painter.closePath();
 
509
                
 
510
                painter.initPath();
 
511
                painter.moveTo(x - scale, y );
 
512
                painter.lineTo(x + scale, y - scale);
 
513
                painter.closePath();
 
514
        }
 
515
        
 
516
        private void paintVibrato(ViewLayout layout, TGPainter painter,int fromX,int fromY){
 
517
                float scale = layout.getScale();
 
518
                float x = fromX;
 
519
                float y = fromY + (2.0f * scale);
 
520
                float width = ( getBeatImpl().getWidth() - (2.0f * scale) );
 
521
                
 
522
                int loops = (int)(width / (6.0f * scale) );
 
523
                if(loops > 0 ){
 
524
                        layout.setTabEffectStyle(painter);
 
525
                        painter.initPath(TGPainter.PATH_FILL);
 
526
                        painter.moveTo(( x + ((2.0f) * scale) ),( y + (1.0f * scale) ));
 
527
                        for( int i = 0; i < loops ; i ++ ){
 
528
                                x = (fromX + ( (6.0f * scale) * i ) );
 
529
                                painter.lineTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ));
 
530
                                painter.cubicTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ),( x + (3.0f * scale) ), y ,( x + (4.0f * scale) ),( y + (1.0f * scale) ));
 
531
                                painter.lineTo(( x + (6.0f * scale) ),( y + (3.0f * scale) ));
 
532
                        }
 
533
                        
 
534
                        painter.lineTo(( x + (7.0f * scale) ),( y + (2.0f * scale) ));
 
535
                        painter.cubicTo(( x + (7.0f * scale) ),( y + (2.0f * scale) ),( x + (8.0f * scale) ),( y + (2.0f * scale) ),( x + (7.0f * scale) ),( y + (3.0f * scale) ));
 
536
                        
 
537
                        for( int i = (loops - 1); i >= 0 ; i -- ){
 
538
                                x = (fromX + ( (6.0f * scale) * i ) );
 
539
                                painter.lineTo(( x + (6.0f * scale) ),( y + (4.0f * scale) ));
 
540
                                painter.cubicTo(( x + (6.0f * scale) ),( y + (4.0f * scale) ),( x + (5.0f * scale) ),( y + (5.0f * scale) ),( x + (4.0f * scale) ),( y + (4.0f * scale) ));
 
541
                                painter.lineTo(( x + (2.0f * scale) ),( y + (2.0f * scale) ));
 
542
                                painter.lineTo(( x + (1.0f * scale) ),( y + (3.0f * scale) ));
 
543
                        }
 
544
                        painter.cubicTo(( x + (1.0f * scale) ),( y + (3.0f * scale) ), x ,( y + (3.0f * scale) ),( x + (1.0f * scale) ),( y + (2.0f * scale) ));
 
545
                        painter.lineTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ));
 
546
                        painter.closePath();
 
547
                }
 
548
        }
 
549
        
 
550
        private void paintTrill(ViewLayout layout, TGPainter painter,int fromX,int fromY){
 
551
                String string = "Tr";
 
552
                Point stringSize = painter.getStringExtent( string );
 
553
                float scale = layout.getScale();
 
554
                float x = fromX + stringSize.x;
 
555
                float y = fromY + (   (stringSize.y - (5.0f * scale)) / 2.0f );
 
556
                float width = ( getBeatImpl().getWidth() - stringSize.x - (2.0f * scale) );
 
557
                
 
558
                int loops = (int)(width / (6.0f * scale) );
 
559
                if(loops > 0 ){
 
560
                        painter.drawString(string, fromX, fromY);
 
561
                        
 
562
                        layout.setTabEffectStyle(painter);
 
563
                        painter.initPath(TGPainter.PATH_FILL);
 
564
                        painter.moveTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ));
 
565
                        for( int i = 0; i < loops ; i ++ ){
 
566
                                x = (fromX + stringSize.x + ( (6.0f * scale) * i ) );
 
567
                                painter.lineTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ));
 
568
                                painter.cubicTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ),( x + (3.0f * scale) ), y ,( x + (4.0f * scale) ),( y + (1.0f * scale) ));
 
569
                                painter.lineTo(( x + (6.0f * scale) ),( y + (3.0f * scale) ));
 
570
                        }
 
571
                        
 
572
                        painter.lineTo(( x + (7.0f * scale) ),( y + (2.0f * scale) ));
 
573
                        painter.cubicTo(( x + (7.0f * scale) ),( y + (2.0f * scale) ),( x + (8.0f * scale) ),( y + (2.0f * scale) ),( x + (7.0f * scale) ),( y + (3.0f * scale) ));
 
574
                        
 
575
                        for( int i = (loops - 1); i >= 0 ; i -- ){
 
576
                                x = (fromX + stringSize.x + ( (6.0f * scale) * i ) );
 
577
                                painter.lineTo(( x + (6.0f * scale) ),( y + (4.0f * scale) ));
 
578
                                painter.cubicTo(( x + (6.0f * scale) ),( y + (4.0f * scale) ),( x + (5.0f * scale) ),( y + (5.0f * scale) ),( x + (4.0f * scale) ),( y + (4.0f * scale) ));
 
579
                                painter.lineTo(( x + (2.0f * scale) ),( y + (2.0f * scale) ));
 
580
                                painter.lineTo(( x + (1.0f * scale) ),( y + (3.0f * scale) ));
 
581
                        }
 
582
                        painter.cubicTo(( x + (1.0f * scale) ),( y + (3.0f * scale) ), x ,( y + (3.0f * scale) ),( x + (1.0f * scale) ),( y + (2.0f * scale) ));
 
583
                        painter.lineTo(( x + (2.0f * scale) ),( y + (1.0f * scale) ));
 
584
                        painter.closePath();
 
585
                }
 
586
        }
 
587
        
 
588
        private void paintFadeIn(ViewLayout layout, TGPainter painter,int fromX,int fromY){
 
589
                float scale = layout.getScale();
 
590
                float x = fromX;
 
591
                float y = fromY + (4.0f * scale );
 
592
                float width = getBeatImpl().getWidth();
 
593
                painter.initPath();
 
594
                painter.moveTo ( x , y );
 
595
                painter.cubicTo( x , y , x + width, y,  x + width, y - (4.0f * scale ));
 
596
                painter.moveTo ( x , y );
 
597
                painter.cubicTo( x , y , x + width, y,  x + width, y + (4.0f * scale ));
 
598
                painter.closePath();
 
599
        }
 
600
        
 
601
        private void paintAccentuated(ViewLayout layout, TGPainter painter,int fromX,int fromY){
 
602
                float scale = layout.getScale();
 
603
                float x = fromX;
 
604
                float y = fromY + (2f * scale );
 
605
                painter.initPath();
 
606
                painter.moveTo( x , y );
 
607
                painter.lineTo( x + (6.0f * scale ) , y + (2.5f * scale ));
 
608
                painter.lineTo( x , y + (5.0f * scale ));
 
609
                painter.closePath();
 
610
        }
 
611
        
 
612
        private void paintHeavyAccentuated(ViewLayout layout, TGPainter painter,int fromX,int fromY){
 
613
                float scale = layout.getScale();
 
614
                float x = fromX;
 
615
                float y = fromY;
 
616
                painter.initPath();
 
617
                painter.moveTo( x , y + (5.0f * scale ) );
 
618
                painter.lineTo( x + (3.0f * scale ) , y + (1.0f * scale ));
 
619
                painter.lineTo( x + (6.0f * scale ) , y + (5.0f * scale ) );
 
620
                painter.closePath();
 
621
        }
 
622
        
 
623
        public int getRealValue(){
 
624
                return (getValue() + getMeasureImpl().getTrack().getString(getString()).getValue());
 
625
        }
 
626
        
 
627
        public int getScorePosY() {
 
628
                return this.scorePosY;
 
629
        }
 
630
        
 
631
        public int getTabPosY() {
 
632
                return this.tabPosY;
 
633
        }
 
634
        
 
635
        public TGMeasureImpl getMeasureImpl(){
 
636
                return getBeatImpl().getMeasureImpl();
 
637
        }
 
638
        
 
639
        public int getPaintPosition(int index){
 
640
                return getMeasureImpl().getTs().getPosition(index);
 
641
        }
 
642
        
 
643
        public TGBeatImpl getBeatImpl() {
 
644
                return (TGBeatImpl)super.getBeat();
 
645
        }
 
646
        
 
647
        public TGBeatGroup getBeatGroup() {
 
648
                return this.group;
 
649
        }
 
650
        
 
651
        public void setBeatGroup(TGBeatGroup group) {
 
652
                this.group = group;
 
653
        }
 
654
        
 
655
        public int getPosX() {
 
656
                return getBeatImpl().getPosX();
 
657
        }
 
658
}
 
 
b'\\ No newline at end of file'