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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/editors/tab/TGBeatImpl.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 java.util.Iterator;
 
4
 
 
5
import org.herac.tuxguitar.gui.TuxGuitar;
 
6
import org.herac.tuxguitar.gui.editors.TGPainter;
 
7
import org.herac.tuxguitar.gui.editors.tab.layout.TrackSpacing;
 
8
import org.herac.tuxguitar.gui.editors.tab.layout.ViewLayout;
 
9
import org.herac.tuxguitar.gui.editors.tab.painters.TGNotePainter;
 
10
import org.herac.tuxguitar.gui.editors.tab.painters.TGSilencePainter;
 
11
import org.herac.tuxguitar.song.factory.TGFactory;
 
12
import org.herac.tuxguitar.song.models.TGBeat;
 
13
import org.herac.tuxguitar.song.models.TGDuration;
 
14
import org.herac.tuxguitar.song.models.TGTupleto;
 
15
 
 
16
public class TGBeatImpl extends TGBeat{
 
17
        /**
 
18
         * desviacion a la izquierda
 
19
         */
 
20
        public static final int JOINED_TYPE_NONE_LEFT = 1;
 
21
        /**
 
22
         * desviacion a la derecha
 
23
         */
 
24
        public static final int JOINED_TYPE_NONE_RIGHT = 2;
 
25
        /**
 
26
         * Union a la izquierda
 
27
         */
 
28
        public static final int JOINED_TYPE_LEFT = 3;
 
29
        /**
 
30
         * Union a la derecha
 
31
         */
 
32
        public static final int JOINED_TYPE_RIGHT = 4;
 
33
        
 
34
        private int posX;
 
35
        private int width;
 
36
        private TGNoteImpl maxNote;
 
37
        private TGNoteImpl minNote;
 
38
        private boolean[] usedStrings;
 
39
        private int joinedType;
 
40
        private boolean joinedGreaterThanQuarter;
 
41
        private TGBeatImpl join1;
 
42
        private TGBeatImpl join2;
 
43
        private TGBeatImpl previous;
 
44
        private TGBeatImpl next;
 
45
        private TGBeatGroup group;
 
46
        
 
47
        public TGBeatImpl(TGFactory factory){
 
48
                super(factory);
 
49
        }
 
50
        
 
51
        public int getPosX() {
 
52
                return this.posX;
 
53
        }
 
54
        
 
55
        public void setPosX(int posX) {
 
56
                this.posX = posX;
 
57
        }
 
58
        
 
59
        public int getWidth() {
 
60
                return this.width;
 
61
        }
 
62
        
 
63
        public void setWidth(int width) {
 
64
                this.width = width;
 
65
        }
 
66
        
 
67
        public TGNoteImpl getMinNote(){
 
68
                return this.minNote;
 
69
        }
 
70
        
 
71
        public TGNoteImpl getMaxNote(){
 
72
                return this.maxNote;
 
73
        }
 
74
        
 
75
        public TGMeasureImpl getMeasureImpl() {
 
76
                return (TGMeasureImpl)getMeasure();
 
77
        }
 
78
        
 
79
        public boolean[] getUsedStrings() {
 
80
                if(this.usedStrings == null){
 
81
                        this.usedStrings = new boolean[getMeasure().getTrack().stringCount()];
 
82
                }
 
83
                return this.usedStrings;
 
84
        }
 
85
        
 
86
        public TGBeatImpl getJoin1() {
 
87
                return this.join1;
 
88
        }
 
89
        
 
90
        public void setJoin1(TGBeatImpl join1) {
 
91
                this.join1 = join1;
 
92
        }
 
93
        
 
94
        public TGBeatImpl getJoin2() {
 
95
                return this.join2;
 
96
        }
 
97
        
 
98
        public void setJoin2(TGBeatImpl join2) {
 
99
                this.join2 = join2;
 
100
        }
 
101
        
 
102
        public boolean isJoinedGreaterThanQuarter() {
 
103
                return this.joinedGreaterThanQuarter;
 
104
        }
 
105
        
 
106
        public void setJoinedGreaterThanQuarter(boolean joinedGreaterThanQuarter) {
 
107
                this.joinedGreaterThanQuarter = joinedGreaterThanQuarter;
 
108
        }
 
109
        
 
110
        public int getJoinedType() {
 
111
                return this.joinedType;
 
112
        }
 
113
        
 
114
        public void setJoinedType(int joinedType) {
 
115
                this.joinedType = joinedType;
 
116
        }
 
117
        
 
118
        public void setPreviousBeat(TGBeatImpl previous){
 
119
                this.previous = previous;
 
120
        }
 
121
        
 
122
        public void setNextBeat(TGBeatImpl next){
 
123
                this.next = next;
 
124
        }
 
125
        
 
126
        public TGBeatGroup getBeatGroup() {
 
127
                return this.group;
 
128
        }
 
129
        
 
130
        public void setBeatGroup(TGBeatGroup group) {
 
131
                this.group = group;
 
132
        }
 
133
        
 
134
        public int getSpacing(){
 
135
                return getMeasureImpl().getBeatSpacing(this);
 
136
        }
 
137
        
 
138
        public boolean isPlaying(ViewLayout layout){
 
139
                return (getMeasureImpl().isPlaying(layout) && TuxGuitar.instance().getEditorCache().isPlaying(getMeasure(),this));
 
140
        }
 
141
        
 
142
        public void reset(){
 
143
                this.maxNote = null;
 
144
                this.minNote = null;
 
145
                this.usedStrings = new boolean[getMeasure().getTrack().stringCount()];
 
146
        }
 
147
        
 
148
        public void check(TGNoteImpl note){
 
149
                int value = note.getRealValue();
 
150
                if(this.maxNote == null || value > this.maxNote.getRealValue()){
 
151
                        this.maxNote = note;
 
152
                }
 
153
                if(this.minNote == null || value < this.minNote.getRealValue()){
 
154
                        this.minNote = note;
 
155
                }
 
156
                this.getUsedStrings();
 
157
                this.usedStrings[note.getString() - 1] = true;
 
158
        }
 
159
        
 
160
        public void play(){
 
161
                if(!TuxGuitar.instance().getPlayer().isRunning()){
 
162
                        new Thread(new Runnable() {
 
163
                                public void run() {
 
164
                                        TuxGuitar.instance().getPlayer().playBeat(getMeasure().getTrack(),getNotes());
 
165
                                }
 
166
                        }).start();
 
167
                }
 
168
        }
 
169
        
 
170
        public void update(ViewLayout layout) {
 
171
                if(!isRestBeat()){
 
172
                        this.joinedType = JOINED_TYPE_NONE_RIGHT;
 
173
                        this.joinedGreaterThanQuarter = false;
 
174
                        this.setJoin1(this);
 
175
                        this.setJoin2(this);
 
176
                        
 
177
                        boolean noteJoined = false;
 
178
                        boolean withPrev = false;
 
179
                        
 
180
                        //trato de unir con el componente anterior
 
181
                        if (this.previous != null && !this.previous.isRestBeat()) {
 
182
                                if (getMeasureImpl().canJoin(layout.getSongManager(),this, this.previous)) {
 
183
                                        withPrev = true;
 
184
                                        if (this.previous.getDuration().getValue() >= getDuration().getValue()) {
 
185
                                                this.setJoin1(this.previous);
 
186
                                                this.setJoin2(this);
 
187
                                                this.joinedType = JOINED_TYPE_LEFT;
 
188
                                                noteJoined = true;
 
189
                                        }
 
190
                                        if (this.previous.getDuration().getValue() > TGDuration.QUARTER){
 
191
                                                this.joinedGreaterThanQuarter = true;
 
192
                                        }
 
193
                                }
 
194
                        }
 
195
                        
 
196
                        //trato de unir con el componente que le sigue
 
197
                        if (this.next != null && !this.next.isRestBeat() ) {
 
198
                                if (getMeasureImpl().canJoin(layout.getSongManager(),this, this.next)) {
 
199
                                        if (this.next.getDuration().getValue() >= getDuration().getValue()) {
 
200
                                                this.setJoin2(this.next);
 
201
                                                if (this.previous == null || this.previous.isRestBeat() || this.previous.getDuration().getValue() < getDuration().getValue()) {
 
202
                                                        this.setJoin1(this);
 
203
                                                }
 
204
                                                noteJoined = true;
 
205
                                                this.joinedType = JOINED_TYPE_RIGHT;
 
206
                                        }
 
207
                                        if (this.next.getDuration().getValue() > TGDuration.QUARTER){
 
208
                                                this.joinedGreaterThanQuarter = true;
 
209
                                        }
 
210
                                }
 
211
                        }
 
212
                        
 
213
                        //si no hubo union decido para que lado girar la figura
 
214
                        if (!noteJoined && withPrev) {
 
215
                                this.joinedType = JOINED_TYPE_NONE_LEFT;
 
216
                        }
 
217
                }
 
218
        }
 
219
        /*
 
220
        public void paint(ViewLayout layout,TGPainter painter, int fromX, int fromY) {
 
221
                paint(layout, painter, fromX, fromY, false);
 
222
        }*/
 
223
        
 
224
        public void paint(ViewLayout layout,TGPainter painter, int fromX, int fromY/*,boolean playMode*/) {
 
225
                if(!layout.isPlayModeEnabled() && (layout.getStyle() & ViewLayout.DISPLAY_SCORE) != 0 ){
 
226
                        paintExtraLines(painter, layout,fromX, fromY);
 
227
                }
 
228
                
 
229
                if(isRestBeat()){
 
230
                        paintSilence(layout, painter, fromX, fromY);
 
231
                }
 
232
                else{
 
233
                        Iterator notes = getNotes().iterator();
 
234
                        while (notes.hasNext()) {
 
235
                                TGNoteImpl note = (TGNoteImpl)notes.next();
 
236
                                note.paint(layout,painter,fromX ,fromY);
 
237
                        }
 
238
                        if(!layout.isPlayModeEnabled()){
 
239
                                paintBeat(layout, painter, fromX, fromY) ;
 
240
                                
 
241
                                if(isChordBeat()){
 
242
                                        TGChordImpl chord = (TGChordImpl)getChord();
 
243
                                        chord.paint(layout,painter,fromX,fromY);
 
244
                                }
 
245
                        }
 
246
                }
 
247
        }
 
248
        
 
249
        //----silence
 
250
        public void paintSilence(ViewLayout layout,TGPainter painter, int fromX, int fromY) {
 
251
                int style = layout.getStyle();
 
252
                int x = 0;
 
253
                int firstLineY = 0;
 
254
                int lineSpacing = 0;
 
255
                int lineCount = 0;
 
256
                float y = 0;
 
257
                float scale = 0;
 
258
                
 
259
                if((style & ViewLayout.DISPLAY_SCORE) != 0 ){
 
260
                        x = fromX + getPosX() + getSpacing();
 
261
                        firstLineY = fromY + getPaintPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES);
 
262
                        lineSpacing = layout.getScoreLineSpacing();
 
263
                        lineCount = 5;
 
264
                        scale = (lineSpacing / 9.0f);
 
265
                }else{
 
266
                        x = fromX + getPosX() + getSpacing() - 1;
 
267
                        firstLineY = fromY + getPaintPosition(TrackSpacing.POSITION_TABLATURE);
 
268
                        lineSpacing = layout.getStringSpacing();
 
269
                        lineCount = getMeasure().getTrack().stringCount();
 
270
                        scale = (lineSpacing / 10.0f);
 
271
                }
 
272
                
 
273
                setStyle(layout, painter,(layout.isPlayModeEnabled() && isPlaying(layout)));
 
274
                painter.initPath(TGPainter.PATH_FILL);
 
275
                
 
276
                int duration = getDuration().getValue();
 
277
                if(duration == TGDuration.WHOLE){
 
278
                        y = firstLineY + ( lineCount <= 5 ? lineSpacing : lineSpacing * 2 );
 
279
                        TGSilencePainter.paintWhole(painter, x, y , scale);
 
280
                }
 
281
                if(duration == TGDuration.HALF){
 
282
                        y = firstLineY + ( lineCount <= 5 ? lineSpacing * 2 : lineSpacing * 3 ) - (scale * 3);
 
283
                        TGSilencePainter.paintHalf(painter, x, y , scale);
 
284
                }
 
285
                if(duration == TGDuration.QUARTER){
 
286
                        y = firstLineY + ((lineSpacing * (lineCount - 1)) / 2) - (scale * 8) ;
 
287
                        TGSilencePainter.paintQuarter(painter, x, y, scale);
 
288
                }
 
289
                else if(duration == TGDuration.EIGHTH){
 
290
                        y = firstLineY + ((lineSpacing * (lineCount - 1)) / 2) - (scale * 6) ;
 
291
                        TGSilencePainter.paintEighth(painter, x, y, scale);
 
292
                }
 
293
                else if(duration == TGDuration.SIXTEENTH){
 
294
                        y = firstLineY + ((lineSpacing * (lineCount - 1)) / 2) - (scale * 8) ;
 
295
                        TGSilencePainter.paintSixteenth(painter, x, y, scale);
 
296
                }
 
297
                else if(duration == TGDuration.THIRTY_SECOND){
 
298
                        y = firstLineY + ((lineSpacing * (lineCount - 1)) / 2) - (scale * 12) ;
 
299
                        TGSilencePainter.paintThirtySecond(painter, x, y, scale);
 
300
                }
 
301
                else if(duration == TGDuration.SIXTY_FOURTH){
 
302
                        y = firstLineY + ((lineSpacing * (lineCount - 1)) / 2) - (scale * 14) ;
 
303
                        TGSilencePainter.paintSixtyFourth(painter, x, y, scale);
 
304
                }
 
305
                
 
306
                painter.closePath();
 
307
                
 
308
                if(getDuration().isDotted() || getDuration().isDoubleDotted()){
 
309
                        layout.setDotStyle(painter);
 
310
                        painter.initPath();
 
311
                        painter.moveTo(x + 10,y +1);
 
312
                        painter.addOval(x + 10,y +1,1,1);
 
313
                        if(getDuration().isDoubleDotted()){
 
314
                                painter.moveTo(x + 13,y +1);
 
315
                                painter.addOval(x + 13,y +1,1,1);
 
316
                        }
 
317
                        painter.closePath();
 
318
                }
 
319
                if(!getDuration().getTupleto().isEqual(TGTupleto.NORMAL)){
 
320
                        layout.setTupletoStyle(painter);
 
321
                        if((style & ViewLayout.DISPLAY_SCORE) != 0 ){
 
322
                                painter.drawString(Integer.toString(getDuration().getTupleto().getEnters()), x,(fromY + getPaintPosition(TrackSpacing.POSITION_TUPLETO)));
 
323
                        }else{
 
324
                                painter.drawString(Integer.toString(getDuration().getTupleto().getEnters()),x,(fromY + getPaintPosition(TrackSpacing.POSITION_TUPLETO)));
 
325
                        }
 
326
                }
 
327
        }
 
328
        
 
329
        public void setStyle(ViewLayout layout, TGPainter painter, boolean playMode){
 
330
                if((layout.getStyle() & ViewLayout.DISPLAY_SCORE) != 0 ){
 
331
                        layout.setScoreSilenceStyle(painter, playMode);
 
332
                }else{
 
333
                        layout.setTabSilenceStyle(painter, playMode);
 
334
                }
 
335
        }
 
336
        
 
337
        public void paintExtraLines(TGPainter painter,ViewLayout layout,int fromX, int fromY){
 
338
                if(!isRestBeat()){
 
339
                        int scoreY = (fromY + getMeasureImpl().getTs().getPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES));
 
340
                        paintExtraLines(painter,layout,getMinNote(), fromX, scoreY);
 
341
                        paintExtraLines(painter,layout,getMaxNote(), fromX, scoreY);
 
342
                }
 
343
        }
 
344
        
 
345
        private void paintExtraLines(TGPainter painter,ViewLayout layout,TGNoteImpl note,int fromX,int fromY){
 
346
                float scale = layout.getScale();
 
347
                int y = fromY + note.getScorePosY();
 
348
                int x = fromX + getPosX() + getSpacing();
 
349
                float x1 = x - (4 * scale);
 
350
                float x2 = x + (12 * scale);
 
351
                
 
352
                int scoreLineSpacing = layout.getScoreLineSpacing();
 
353
                
 
354
                layout.setLineStyle(painter);
 
355
                if(y < fromY){
 
356
                        for(int i = fromY;i > y;i -= scoreLineSpacing){
 
357
                                painter.initPath();
 
358
                                painter.moveTo(x1,i);
 
359
                                painter.lineTo(x2,i);
 
360
                                painter.closePath();
 
361
                        }
 
362
                }else if(y > (fromY + (scoreLineSpacing * 4))){
 
363
                        for(int i = (fromY +(scoreLineSpacing * 5));i < (y + scoreLineSpacing);i += scoreLineSpacing){
 
364
                                painter.initPath();
 
365
                                painter.moveTo(x1,i);
 
366
                                painter.lineTo(x2,i);
 
367
                                painter.closePath();
 
368
                        }
 
369
                }
 
370
        }
 
371
        
 
372
        public void paintBeat(ViewLayout layout,TGPainter painter, int fromX, int fromY){
 
373
                if(!isRestBeat() ){
 
374
                        int style = layout.getStyle();
 
375
                        int spacing = getSpacing();
 
376
                        
 
377
                        if((style & ViewLayout.DISPLAY_SCORE) != 0){
 
378
                                paintScoreBeat(layout, painter, fromX, fromY+getPaintPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES), spacing);
 
379
                        }
 
380
                        if((style & ViewLayout.DISPLAY_TABLATURE) != 0 && (style & ViewLayout.DISPLAY_SCORE) == 0){
 
381
                                paintTablatureBeat(layout, painter, fromX, fromY + getPaintPosition(TrackSpacing.POSITION_TABLATURE), spacing);
 
382
                        }
 
383
                }
 
384
        }
 
385
        
 
386
        public void paintTablatureBeat(ViewLayout layout,TGPainter painter, int fromX, int fromY, int spacing){
 
387
                if(!isRestBeat() ){
 
388
                        int xMove = 2;
 
389
                        int stringSpacing = layout.getStringSpacing();
 
390
                        int x = ( fromX + getPosX() + spacing + xMove );
 
391
                        
 
392
                        int y1 = (fromY + getMeasureImpl().getTrackImpl().getTabHeight() + (stringSpacing / 2));
 
393
                        int y2 = (fromY + getMeasureImpl().getTrackImpl().getTabHeight() + ((stringSpacing / 2) * 5));
 
394
                        
 
395
                        if (getDuration().getValue() >= TGDuration.QUARTER) {
 
396
                                layout.setTabNoteFooterStyle(painter);
 
397
                                painter.initPath();
 
398
                                
 
399
                                boolean painting = false;
 
400
                                boolean[] usedStrings = getUsedStrings();
 
401
                                for (int i = 0; i < usedStrings.length; i++) {
 
402
                                        if (!usedStrings[i] && painting) {
 
403
                                                int stringPosition = (fromY + (stringSpacing * (i + 1)) - stringSpacing);
 
404
                                                int posY1 = stringPosition - (stringSpacing / 2);
 
405
                                                int posY2 = stringPosition + (stringSpacing / 2);
 
406
                                                posY2 = ((posY2 - posY1 < stringSpacing)?posY2 + 1:posY2);
 
407
                                                painter.moveTo(x, posY1);
 
408
                                                painter.lineTo(x, posY2);
 
409
                                        }
 
410
                                        painting = ( painting || usedStrings[i] );
 
411
                                }
 
412
                                painter.moveTo(x, y1);
 
413
                                painter.lineTo(x, y2);
 
414
                                painter.closePath();
 
415
                                if (getDuration().getValue() >= TGDuration.EIGHTH) {
 
416
                                        int x1 = 0;
 
417
                                        int x2 = 0;
 
418
                                        int scale = (layout.getStringSpacing() / 2);
 
419
                                        int joinedType = getJoinedType();
 
420
                                        if(joinedType == TGBeatImpl.JOINED_TYPE_NONE_RIGHT){
 
421
                                                x1 = getPosX() + xMove + spacing;
 
422
                                                x2 = getPosX() + xMove + spacing + 6;
 
423
                                        }else if(joinedType == TGBeatImpl.JOINED_TYPE_NONE_LEFT){
 
424
                                                x1 = getPosX() + xMove + spacing - 5;
 
425
                                                x2 = getPosX() + xMove + spacing;
 
426
                                        }else{
 
427
                                                x1 = getJoin1().getPosX() + xMove + getJoin1().getSpacing();
 
428
                                                x2 = getJoin2().getPosX() + xMove + getJoin2().getSpacing();
 
429
                                        }
 
430
                                        int index = ( getDuration().getIndex() - 2);
 
431
                                        if(index > 0){
 
432
                                                painter.setLineWidth(2);
 
433
                                                painter.initPath();
 
434
                                                for(int i = index; i > 0 ;i --){
 
435
                                                        painter.moveTo(fromX + x1, y2 + (scale - (i * scale)));
 
436
                                                        painter.lineTo(fromX + x2, y2 + (scale - (i * scale)));
 
437
                                                }
 
438
                                                painter.closePath();
 
439
                                                painter.setLineWidth(1);
 
440
                                        }
 
441
                                }
 
442
                        } else if (getDuration().getValue() == TGDuration.HALF) {
 
443
                                layout.setTabNoteFooterStyle(painter);
 
444
                                painter.initPath();
 
445
                                painter.moveTo(x, (y1 + ((y2 - y1) / 2)));
 
446
                                painter.lineTo(x, y2);
 
447
                                painter.closePath();
 
448
                        }
 
449
                        
 
450
                        //-------------puntillo--------------------------------------
 
451
                        if (getDuration().isDotted() || getDuration().isDoubleDotted()) {
 
452
                                int joinedType = getJoinedType();
 
453
                                
 
454
                                float scale = (stringSpacing / 10.0f);
 
455
                                float posX = ((getDuration().getValue() > TGDuration.WHOLE)?((joinedType == TGBeatImpl.JOINED_TYPE_NONE_RIGHT || joinedType == TGBeatImpl.JOINED_TYPE_RIGHT)?(x+ (4.0f * scale)):(x- (5.0f * scale))):x);
 
456
                                float posY = (y2 - ((getDuration().getValue() >= TGDuration.EIGHTH)? ((stringSpacing / 2) * (getDuration().getIndex() - 2)):(1.0f * scale)));
 
457
                                paintDot(layout, painter, posX, posY,scale);
 
458
                        }
 
459
                        
 
460
                        //-------------tresillo--------------------------------------
 
461
                        if (!getDuration().getTupleto().isEqual(TGTupleto.NORMAL)) {
 
462
                                layout.setTupletoStyle(painter);
 
463
                                painter.drawString(Integer.toString(getDuration().getTupleto().getEnters()), x - 3,((fromY - getPaintPosition(TrackSpacing.POSITION_TABLATURE)) + getPaintPosition(TrackSpacing.POSITION_TUPLETO)));
 
464
                        }
 
465
                }
 
466
        }
 
467
        
 
468
        public void paintScoreBeat(ViewLayout layout,TGPainter painter, int fromX, int fromY, int spacing){
 
469
                int vX = ( fromX + getPosX() + spacing );
 
470
                
 
471
                //TUPLETO
 
472
                if (!getDuration().getTupleto().isEqual(TGTupleto.NORMAL)) {
 
473
                        layout.setTupletoStyle(painter);
 
474
                        painter.drawString(Integer.toString(getDuration().getTupleto().getEnters()),vX ,((fromY - getPaintPosition(TrackSpacing.POSITION_SCORE_MIDDLE_LINES)) + getPaintPosition(TrackSpacing.POSITION_TUPLETO)));
 
475
                }
 
476
                //dibujo el pie
 
477
                if(getDuration().getValue() >= TGDuration.HALF){
 
478
                        layout.setScoreNoteFooterStyle(painter);
 
479
                        
 
480
                        float scale = layout.getScale();
 
481
                        float lineSpacing = layout.getScoreLineSpacing();
 
482
                        int direction = this.group.getDirection();
 
483
                        int key = getMeasure().getKeySignature();
 
484
                        int clef = getMeasure().getClef();
 
485
                        
 
486
                        int xMove = (direction == TGBeatGroup.DIRECTION_UP ? layout.getResources().getScoreNoteWidth() : 0);
 
487
                        int yMove = (direction == TGBeatGroup.DIRECTION_UP ? ((layout.getScoreLineSpacing() / 3) + 1) : ((layout.getScoreLineSpacing() / 3) * 2));
 
488
                        
 
489
                        int vY1 = fromY + ( direction == TGBeatGroup.DIRECTION_DOWN ? this.maxNote.getScorePosY() : this.minNote.getScorePosY() );
 
490
                        int vY2 = fromY + this.group.getY2(layout,getPosX() + spacing,key,clef);
 
491
                        
 
492
                        painter.initPath();
 
493
                        painter.moveTo(vX + xMove, vY1 + yMove);
 
494
                        painter.lineTo(vX + xMove, vY2);
 
495
                        painter.closePath();
 
496
                        
 
497
                        if (getDuration().getValue() >= TGDuration.EIGHTH) {
 
498
                                int index =  ( getDuration().getIndex() - 3);
 
499
                                if(index >= 0){
 
500
                                        int dir = (direction == TGBeatGroup.DIRECTION_DOWN)?1:-1;
 
501
                                        int joinedType = getJoinedType();
 
502
                                        boolean joinedGreaterThanQuarter = isJoinedGreaterThanQuarter();
 
503
                                        
 
504
                                        if((joinedType == TGBeatImpl.JOINED_TYPE_NONE_LEFT || joinedType == TGBeatImpl.JOINED_TYPE_NONE_RIGHT) && !joinedGreaterThanQuarter){
 
505
                                                float hX = (fromX + xMove + getPosX() + spacing);
 
506
                                                float hY = ( (fromY + this.group.getY2(layout,getPosX() + spacing,key,clef)) - ( (lineSpacing * 2)* dir )) ;
 
507
                                                for(int i = 0; i <= index; i ++){
 
508
                                                        painter.initPath(TGPainter.PATH_FILL);
 
509
                                                        TGNotePainter.paintFooter(painter,hX,(hY - ( (i * (lineSpacing / 2.0f)) * dir)),dir,lineSpacing);
 
510
                                                        painter.closePath();
 
511
                                                }
 
512
                                        }else{
 
513
                                                int hX1 = 0;
 
514
                                                int hX2 = 0;
 
515
                                                if(joinedType == TGBeatImpl.JOINED_TYPE_NONE_RIGHT){
 
516
                                                        hX1 = getPosX() + spacing;
 
517
                                                        hX2 = getPosX() + spacing + 6;
 
518
                                                }else if(joinedType == TGBeatImpl.JOINED_TYPE_NONE_LEFT){
 
519
                                                        hX1 = getPosX() + spacing - 5;
 
520
                                                        hX2 = getPosX() + spacing;
 
521
                                                }else{
 
522
                                                        hX1 = getJoin1().getPosX() + getJoin1().getSpacing();
 
523
                                                        hX2 = getJoin2().getPosX() + getJoin2().getSpacing();
 
524
                                                }
 
525
                                                int hY1 = fromY + this.group.getY2(layout,hX1,key,clef);
 
526
                                                int hY2 = fromY + this.group.getY2(layout,hX2,key,clef);
 
527
                                                //painter.setLineWidth(3);
 
528
                                                painter.setLineWidth(Math.max(1,Math.round(3f * scale)));
 
529
                                                painter.initPath();
 
530
                                                for(int i = 0; i <= index; i ++){
 
531
                                                        painter.moveTo(fromX + xMove + hX1, hY1 - ( (i * (5f * scale)) * dir));
 
532
                                                        painter.lineTo(fromX + xMove + hX2, hY2 - ( (i * (5f * scale)) * dir));
 
533
                                                        //painter.moveTo(fromX + xMove + hX1, hY1 - ( (i * (scale/1.6f)) * dir));
 
534
                                                        //painter.lineTo(fromX + xMove + hX2, hY2 - ( (i * (scale/1.6f)) * dir));
 
535
                                                }
 
536
                                                painter.closePath();
 
537
                                                painter.setLineWidth(1);
 
538
                                        }
 
539
                                }
 
540
                        }
 
541
                }
 
542
        }
 
543
        
 
544
        public void paintDot(ViewLayout layout,TGPainter painter,float fromX, float fromY,float scale){
 
545
                float dotSize = (3.0f * scale);
 
546
                float posX = fromX;
 
547
                float posY = fromY;
 
548
                layout.setDotStyle(painter);
 
549
                painter.initPath(TGPainter.PATH_FILL);
 
550
                painter.moveTo(posX - (dotSize / 2), posY - (dotSize / 2));
 
551
                painter.addOval(posX - (dotSize / 2), posY - (dotSize / 2), dotSize,dotSize);
 
552
                if(getDuration().isDoubleDotted()){
 
553
                        painter.moveTo(posX + (dotSize + 2) - (dotSize / 2), posY - (dotSize / 2));
 
554
                        painter.addOval(posX + (dotSize + 2) - (dotSize / 2), posY - (dotSize / 2), dotSize,dotSize);
 
555
                }
 
556
                painter.closePath();
 
557
        }
 
558
        
 
559
        public int getPaintPosition(int index){
 
560
                return getMeasureImpl().getTs().getPosition(index);
 
561
        }
 
562
        
 
563
        public void removeChord(){
 
564
                if(isChordBeat()){
 
565
                        TGChordImpl chord = (TGChordImpl)getChord();
 
566
                        chord.dispose();
 
567
                }
 
568
                super.removeChord();
 
569
        }
 
570
        
 
571
        public void dispose(){
 
572
                if(isChordBeat()){
 
573
                        TGChordImpl chord = (TGChordImpl)getChord();
 
574
                        chord.dispose();
 
575
                }
 
576
        }
 
577
}