File: WaveDrawContext.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 35,764 kB
  • ctags: 26,929
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (668 lines) | stat: -rw-r--r-- 25,360 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
/*
 * WaveDrawContext.cs
 * Copyright © 2009-2011 kbinani
 *
 * This file is part of org.kbinani.cadencii.
 *
 * org.kbinani.cadencii is free software; you can redistribute it and/or
 * modify it under the terms of the GPLv3 License.
 *
 * org.kbinani.cadencii is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
#if JAVA

package org.kbinani.cadencii;

import java.awt.*;
import java.util.*;
import org.kbinani.*;
import org.kbinani.apputil.*;
import org.kbinani.media.*;
import org.kbinani.vsq.*;

#else

using System;
using org.kbinani.media;
using org.kbinani;
using org.kbinani.java.awt;
using org.kbinani.java.util;
using org.kbinani.vsq;
using org.kbinani.apputil;

namespace org.kbinani.cadencii.new_
{
    using boolean = System.Boolean;

    public class WaveDrawContext : IDisposable
    {
        private short[] mEnvOut = null;

        public void load( String file )
        {

        }

        public void dispose()
        {
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。
        /// 縦軸の拡大率は引数<paramref name="scale_y"/>で指定します。
        /// </summary>
        /// <param name="g">描画に使用するグラフィクスオブジェクト</param>
        /// <param name="pen">描画に使用するペン</param>
        /// <param name="rect">描画範囲</param>
        /// <param name="clock_start">描画開始位置のゲートタイム</param>
        /// <param name="clock_end">描画終了位置のゲートタイム</param>
        /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param>
        /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param>
        /// <param name="scale_y">Y軸方向の描画スケール。デフォルトは1.0</param>
        public void draw(
            Graphics2D g,
            Color pen,
            Rectangle rect,
            int clock_start,
            int clock_end,
            TempoVector tempo_table,
            float pixel_per_clock,
            float scale_y )
        {
            drawCore( g, pen, rect, clock_start, clock_end, tempo_table, pixel_per_clock, scale_y, false );
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。
        /// 縦軸は最大振幅がちょうど描画範囲に収まるよう調節されます。
        /// </summary>
        /// <param name="g">描画に使用するグラフィクスオブジェクト</param>
        /// <param name="pen">描画に使用するペン</param>
        /// <param name="rect">描画範囲</param>
        /// <param name="clock_start">描画開始位置のゲートタイム</param>
        /// <param name="clock_end">描画終了位置のゲートタイム</param>
        /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param>
        /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param>
        public void draw(
            Graphics2D g,
            Color pen,
            Rectangle rect,
            int clock_start,
            int clock_end,
            TempoVector tempo_table,
            float pixel_per_clock )
        {
            drawCore( g, pen, rect, clock_start, clock_end, tempo_table, pixel_per_clock, 1.0f, true );
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。
        /// </summary>
        /// <param name="g">描画に使用するグラフィクスオブジェクト</param>
        /// <param name="pen">描画に使用するペン</param>
        /// <param name="rect">描画範囲</param>
        /// <param name="clock_start">描画開始位置のゲートタイム</param>
        /// <param name="clock_end">描画終了位置のゲートタイム</param>
        /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param>
        /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param>
        /// <param name="scale_y">Y軸方向の描画スケール。デフォルトは1.0</param>
        /// <param name="auto_maximize">自動で最大化するかどうか</param>
        private void drawCore(
            Graphics2D g,
            Color pen,
            Rectangle rect,
            int clock_start,
            int clock_end,
            TempoVector tempo_table,
            float pixel_per_clock,
            float scale_y,
            boolean auto_maximize )
        {
        }

#if !JAVA
        public void Dispose()
        {
            dispose();
        }
#endif
    }

}

namespace org.kbinani.cadencii
{
    using boolean = System.Boolean;
#endif

    /// <summary>
    /// WAVEファイルのデータをグラフィクスに書き込む操作を行うクラス
    /// </summary>
#if JAVA
    public class WaveDrawContext
#else
    public class WaveDrawContext : IDisposable
#endif
    {
#if JAVA
        private byte[] mWave;
#else
        private sbyte[] mWave;
#endif
        private int mSampleRate = 44100;
        private String mName;
        private float mLength;
        private PolylineDrawer mDrawer = null;
        private float mMaxAmplitude = 0.0f;
        private float mActualMaxAmplitude = 0.0f;

        /// <summary>
        /// 読み込むWAVEファイルを指定したコンストラクタ。初期化と同時にWAVEファイルの読込みを行います。
        /// </summary>
        /// <param name="file">読み込むWAVEファイルのパス</param>
        public WaveDrawContext( String file )
        {
            load( file );
            mDrawer = new PolylineDrawer( null, 1024 );
        }

        /// <summary>
        /// デフォルトのコンストラクタ。
        /// </summary>
        public WaveDrawContext()
        {
#if JAVA
            mWave = new byte[0];
#else
            mWave = new sbyte[0];
#endif
            mLength = 0.0f;
            mDrawer = new PolylineDrawer( null, 1024 );
        }

        /// <summary>
        /// 保持しているWAVEデータを破棄します。
        /// </summary>
        public void unload()
        {
            mDrawer.clear();
#if JAVA
            mWave = new byte[0];
#else
            mWave = new sbyte[0];
#endif
            mLength = 0.0f;
        }

        /// <summary>
        /// 指定したファイルの指定した区間を追加で読み込みます
        /// </summary>
        /// <param name="file"></param>
        /// <param name="sec_from"></param>
        /// <param name="sec_to"></param>
        public void reloadPartial( String file, double sec_from, double sec_to )
        {
            if ( !fsys.isFileExists( file ) ) {
                return;
            }

            WaveRateConverter wr = null;
            try {
                wr = new WaveRateConverter( new WaveReader( file ), mSampleRate );
                int saFrom = (int)(sec_from * mSampleRate);
                int saTo = (int)(sec_to * mSampleRate);

                // バッファを確保
                int buflen = 1024;
                double[] left = new double[buflen];
                double[] right = new double[buflen];

                // まず、読み込んだ区間の最大振幅を調べる
                int remain = saTo - saFrom;
                int pos = saFrom;
                double max = 0.0;
                while ( remain > 0 ) {
                    int delta = remain > buflen ? buflen : remain;
                    wr.read( pos, delta, left, right );
                    for ( int i = 0; i < delta; i++ ) {
                        double d = Math.Abs( (left[i] + right[i]) * 0.5 );
                        max = d > max ? d : max;
                    }
                    remain -= delta;
                    pos += delta;
                }

                // バッファが足りなければ確保
                int oldLength = mWave.Length;
                if ( oldLength < saTo ) {
#if JAVA
#if JAVA_1_5
                    byte[] old = mWave;
                    mWave = new byte[saTo];
                    for( int i = 0; i < oldLength; i++ ){
                        mWave[i] = old[i];
                    }
#else
                    mWave = Arrays.copyOf( mWave, saTo );
#endif
#else
                    Array.Resize( ref mWave, saTo );
#endif
                    saFrom = oldLength;
                }

                if ( mMaxAmplitude < max ) {
                    // 既存の波形の最大振幅より、読み込み部分の最大波形が大きいようなら、
                    // 既存波形の縮小を行う
                    double ampall = 1.0 / max;
                    for ( int i = 0; i < mWave.Length; i++ ) {
                        double vold = mWave[i] / 127.0 * mMaxAmplitude;
                        double vnew = vold * ampall;
#if JAVA
                        mWave[i] = (byte)(vnew * 127);
#else
                        mWave[i] = (sbyte)(vnew * 127);
#endif
                    }

                }

                // 最大振幅の値を更新
                mMaxAmplitude = (max > mMaxAmplitude) ? (float)max : mMaxAmplitude;

                // 今度は波形を取得するために読み込む
                double amp = (mMaxAmplitude > 0.0f) ? (1.0 / mMaxAmplitude) : 0.0;
                remain = saTo - saFrom;
                pos = saFrom;
                while ( remain > 0 ) {
                    int delta = remain > buflen ? buflen : remain;
                    wr.read( pos, delta, left, right );

                    for ( int i = 0; i < delta; i++ ) {
                        double d = (left[i] + right[i]) * 0.5 * amp;
#if JAVA
                        byte b = (byte)(d * 127);
#else
                        sbyte b = (sbyte)(d * 127);
#endif
                        mWave[pos + i] = b;
                    }

                    pos += delta;
                    remain -= delta;
                }
                left = null;
                right = null;

                // mActualMaxAmplitudeの値を更新
                mActualMaxAmplitude = 0.0f;
                for ( int i = 0; i < mWave.Length; i++ ) {
                    double d = Math.Abs( mWave[i] / 127.0 * mMaxAmplitude );
                    mActualMaxAmplitude = (d > mActualMaxAmplitude) ? (float)d : mActualMaxAmplitude;
                }
            } catch ( Exception ex ) {
                serr.println( "WaveDrawContext#reloadPartial; ex=" + ex );
            } finally {
                if ( wr != null ) {
                    try {
                        wr.close();
                    } catch ( Exception ex2 ) {
                        serr.println( "WaveDrawContext#reloadPartial; ex2=" + ex2 );
                    }
                }
            }
        }

        /// <summary>
        /// WAVEファイルを読み込みます。
        /// </summary>
        /// <param name="file">読み込むWAVEファイルのパス</param>
        public void load( String file )
        {
            if ( !fsys.isFileExists( file ) ) {
#if JAVA
                mWave = new byte[0];
#else
                mWave = new sbyte[0];
#endif
                mLength = 0.0f;
                return;
            }

            Wave wr = null;
            try {
                wr = new Wave( file );
                int len = (int)wr.getTotalSamples();
#if JAVA
                mWave = new byte[len];
#else
                mWave = new sbyte[len];
#endif
                mSampleRate = (int)wr.getSampleRate();
                mLength = wr.getTotalSamples() / (float)wr.getSampleRate();
                int count = (int)wr.getTotalSamples();

                // 最大振幅を検出
                double max = 0.0;
                for ( int i = 0; i < count; i++ ) {
                    double b = Math.Abs( wr.getDouble( i ) );
                    max = b > max ? b : max;
                }

                // 最大振幅の値を更新
                mMaxAmplitude = (float)max;
                mActualMaxAmplitude = mMaxAmplitude;

                // 波形を読み込む
                double amp = (max > 0.0) ? (1.0 / max) : 0.0;
                for ( int i = 0; i < count; i++ ) {
                    double b = wr.getDouble( i ) * amp;
#if JAVA
                    mWave[i] = (byte)(127 * b);
#else
                    mWave[i] = (sbyte)(127 * b);
#endif
                }
            } catch ( Exception ex ) {
#if JAVA
                ex.printStackTrace();
#endif
            } finally {
                if ( wr != null ) {
                    try {
                        wr.dispose();
                    } catch ( Exception ex2 ) {
                    }
                }
            }
            if ( mWave == null ) {
#if JAVA
                mWave = new byte[0];
#else
                mWave = new sbyte[0];
#endif
                mSampleRate = 44100;
                mLength = 0.0f;
            }
        }

        /// <summary>
        /// このWAVE描画コンテキストの名前を取得します。
        /// </summary>
        /// <returns>この描画コンテキストの名前</returns>
        public String getName()
        {
            return mName;
        }

        /// <summary>
        /// このWAVE描画コンテキストの名前を設定します。
        /// </summary>
        /// <param name="value">この描画コンテキストの名前</param>
        public void setName( String value )
        {
            mName = value;
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータの、秒数を取得します。
        /// </summary>
        /// <returns>保持しているWAVEデータの長さ(秒)</returns>
        public float getLength()
        {
            return mLength;
        }

#if !JAVA
        /// <summary>
        /// デストラクタ。disposeメソッドを呼び出します。
        /// </summary>
        ~WaveDrawContext()
        {
            dispose();
        }
#endif

#if !JAVA
        /// <summary>
        /// このWAVE描画コンテキストが使用しているリソースを開放します。
        /// </summary>
        public void Dispose()
        {
            dispose();
        }
#endif

        /// <summary>
        /// このWAVE描画コンテキストが使用しているリソースを開放します。
        /// </summary>
        public void dispose()
        {
            mWave = null;
#if JAVA
            System.gc();
#else
            GC.Collect();
#endif
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。
        /// 縦軸の拡大率は引数<paramref name="scale_y"/>で指定します。
        /// </summary>
        /// <param name="g">描画に使用するグラフィクスオブジェクト</param>
        /// <param name="pen">描画に使用するペン</param>
        /// <param name="rect">描画範囲</param>
        /// <param name="clock_start">描画開始位置のゲートタイム</param>
        /// <param name="clock_end">描画終了位置のゲートタイム</param>
        /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param>
        /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param>
        /// <param name="scale_y">Y軸方向の描画スケール。デフォルトは1.0</param>
        public void draw(
            Graphics2D g,
            Color pen,
            Rectangle rect,
            int clock_start,
            int clock_end,
            TempoVector tempo_table,
            float pixel_per_clock,
            float scale_y )
        {
            drawCore( g, pen, rect, clock_start, clock_end, tempo_table, pixel_per_clock, scale_y, false );
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。
        /// 縦軸は最大振幅がちょうど描画範囲に収まるよう調節されます。
        /// </summary>
        /// <param name="g">描画に使用するグラフィクスオブジェクト</param>
        /// <param name="pen">描画に使用するペン</param>
        /// <param name="rect">描画範囲</param>
        /// <param name="clock_start">描画開始位置のゲートタイム</param>
        /// <param name="clock_end">描画終了位置のゲートタイム</param>
        /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param>
        /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param>
        public void draw(
            Graphics2D g,
            Color pen,
            Rectangle rect,
            int clock_start,
            int clock_end,
            TempoVector tempo_table,
            float pixel_per_clock )
        {
            drawCore( g, pen, rect, clock_start, clock_end, tempo_table, pixel_per_clock, 1.0f, true );
        }

        /// <summary>
        /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。
        /// </summary>
        /// <param name="g">描画に使用するグラフィクスオブジェクト</param>
        /// <param name="pen">描画に使用するペン</param>
        /// <param name="rect">描画範囲</param>
        /// <param name="clock_start">描画開始位置のゲートタイム</param>
        /// <param name="clock_end">描画終了位置のゲートタイム</param>
        /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param>
        /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param>
        /// <param name="scale_y">Y軸方向の描画スケール。デフォルトは1.0</param>
        /// <param name="auto_maximize">自動で最大化するかどうか</param>
        private void drawCore(
            Graphics2D g,
            Color pen,
            Rectangle rect,
            int clock_start,
            int clock_end,
            TempoVector tempo_table,
            float pixel_per_clock,
            float scale_y,
            boolean auto_maximize )
        {
            if ( mWave.Length == 0 ) {
                return;
            }
#if DEBUG
            double startedTime = PortUtil.getCurrentTime();
#endif
            mDrawer.setGraphics( g );
            mDrawer.clear();
            double secStart = tempo_table.getSecFromClock( clock_start );
            double secEnd = tempo_table.getSecFromClock( clock_end );
            int sStart0 = (int)(secStart * mSampleRate) - 1;
            int sEnd0 = (int)(secEnd * mSampleRate) + 1;

            int count = tempo_table.size();
            int sStart = 0;
            double cStart = 0.0;
            float order_y = 1.0f;
            if ( auto_maximize ) {
                order_y = rect.height / 2.0f / 127.0f * mMaxAmplitude / mActualMaxAmplitude;
            } else {
                order_y = rect.height / 127.0f * scale_y * mMaxAmplitude;
            }
            int ox = rect.x;
            int oy = rect.height / 2;
            int last = mWave[0];
            int lastx = ox;
            int lastYMax = oy - (int)(last * order_y);
            int lastYMin = lastYMax;
            int lasty = lastYMin;
            int lasty2 = lastYMin;
            boolean skipped = false;
            mDrawer.append( ox, lasty );
            int xmax = rect.x + rect.width;
            int lastTempo = 500000;
            for ( int i = 0; i <= count; i++ ) {
                double time = 0.0;
                int tempo = 500000;
                int cEnd = 0;
                if ( i < count ) {
                    TempoTableEntry entry = tempo_table.get( i );
                    time = entry.Time;
                    tempo = entry.Tempo;
                    cEnd = entry.Clock;
                } else {
                    time = tempo_table.getSecFromClock( clock_end );
                    tempo = tempo_table.get( i - 1 ).Tempo;
                    cEnd = clock_end;
                }
                int sEnd = (int)(time * mSampleRate);

                // sStartサンプルからsThisEndサンプルまでを描画する(必要なら!)
                if ( sEnd < sStart0 ) {
                    sStart = sEnd;
                    cStart = cEnd;
                    lastTempo = tempo;
                    continue;
                }
                if ( sEnd0 < sStart ) {
                    break;
                }

                // 
                int xoffset = (int)(cStart * pixel_per_clock) - AppManager.mMainWindowController.getStartToDrawX() + AppManager.keyOffset;
                double sec_per_clock = lastTempo * 1e-6 / 480.0;
                lastTempo = tempo;
                double pixel_per_sample = 1.0 / mSampleRate / sec_per_clock * pixel_per_clock;
                int j0 = sStart;
                if ( j0 < 0 ) {
                    j0 = 0;
                }
                int j1 = sEnd;
                if ( mWave.Length < j1 ) {
                    j1 = mWave.Length;
                }

                // 第j0サンプルのデータを画面に描画したときのx座標がいくらになるか?
                int draftStartX = xoffset + (int)((j0 - sStart) * pixel_per_sample);
                if ( draftStartX < rect.x ) {
                    j0 = (int)((rect.x - xoffset) / pixel_per_sample) + sStart;
                }
                // 第j1サンプルのデータを画面に描画した時のx座標がいくらになるか?
                int draftEndX = xoffset + (int)((j1 - sStart) * pixel_per_sample);
                if ( rect.x + rect.width < draftEndX ) {
                    j1 = (int)((rect.x + rect.width - xoffset) / pixel_per_sample) + sStart;
                }

                boolean breakRequired = false;
                for ( int j = j0; j < j1; j++ ) {
                    int v = mWave[j];
                    if ( v == last ) {
                        skipped = true;
                        continue;
                    }
                    int x = xoffset + (int)((j - sStart) * pixel_per_sample);
                    if ( xmax < x ) {
                        breakRequired = true;
                        break;
                    }
                    if ( x < rect.x ) {
                        continue;
                    }
                    int y = oy - (int)(v * order_y);
                    if ( lastx == x ) {
                        lastYMax = Math.Max( lastYMax, y );
                        lastYMin = Math.Min( lastYMin, y );
                        continue;
                    }

                    if ( skipped ) {
                        mDrawer.append( x - 1, lasty );
                        lastx = x - 1;
                    }
                    if ( lastYMax == lastYMin ) {
                        mDrawer.append( x, y );
                    } else {
                        if ( lasty2 != lastYMin ) {
                            mDrawer.append( lastx, lastYMin );
                        }
                        mDrawer.append( lastx, lastYMax );
                        if ( lastYMax != lasty ) {
                            mDrawer.append( lastx, lasty );
                        }
                        mDrawer.append( x, y );
                    }
                    lasty2 = lasty;
                    lastx = x;
                    lastYMin = y;
                    lastYMax = y;
                    lasty = y;
                    last = v;
                    skipped = false;
                }
                sStart = sEnd;
                cStart = cEnd;
                if ( breakRequired ) {
                    break;
                }
            }

            mDrawer.append( rect.x + rect.width, lasty );
            mDrawer.flush();
        }
    }

#if !JAVA
}
#endif