-
Notifications
You must be signed in to change notification settings - Fork 1
/
PathParcelable.java
1575 lines (1309 loc) · 33.9 KB
/
PathParcelable.java
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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2015 Brian Hoffmann, slowpoke.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.slowpoke.androidtank.graphics;
import java.util.ArrayDeque;
import java.util.Arrays;
import android.annotation.TargetApi;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
/**
* An implementation of {@link Path} which can be parceled. Note that methods
* with {@link Path} parameters are not supported in this implementation.
*
* @author Brian
* @version 1.0
*/
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public class PathParcelable extends android.graphics.Path implements Parcelable {
private final ArrayDeque<PathAction> actions;
/**
* Create a new {@link PathParcelable} with default capacity.
*/
public PathParcelable() {
this(1024);
}
/**
* Create a new {@link PathParcelable}.
*
* @param initSize
* the initial capacity.
*/
public PathParcelable(int initSize) {
super();
super.incReserve(initSize);
actions = new ArrayDeque<PathAction>(initSize);
}
public PathParcelable(Parcel in) {
this(in.readInt());
PathAction[] array = (PathAction[]) in.readArray(getClass().getClassLoader());
actions.addAll(Arrays.asList(array));
setFillType(FillType.valueOf(in.readString()));
restoreFromParcel();
}
@Override
public void moveTo(float x, float y) {
super.moveTo(x, y);
actions.add(new MoveTo(x, y));
}
private void perform(final MoveTo action) {
super.moveTo(action.x, action.y);
}
@Override
public void lineTo(float x, float y) {
super.lineTo(x, y);
actions.add(new LineTo(x, y));
}
private void perform(final LineTo action) {
super.lineTo(action.x, action.y);
}
@Override
public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) {
super.cubicTo(x1, y1, x2, y2, x3, y3);
actions.add(new CubicTo(x1, y1, x2, y2, x3, y3));
}
private void perform(final CubicTo actions) {
super.cubicTo(actions.x1, actions.y1, actions.x2, actions.y2, actions.x3, actions.y3);
}
@Override
public void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) {
super.arcTo(oval, startAngle, sweepAngle, forceMoveTo);
actions.add(new ArcTo(oval, startAngle, sweepAngle, forceMoveTo));
}
@Override
public void arcTo(RectF oval, float startAngle, float sweepAngle) {
super.arcTo(oval, startAngle, sweepAngle);
actions.add(new ArcTo(oval, startAngle, sweepAngle, false));
}
private void perform(final ArcTo action) {
super.arcTo(action.oval, action.startAngle, action.sweepAngle, action.forceMoveTo);
}
@Override
public void addArc(RectF oval, float startAngle, float sweepAngle) {
super.addArc(oval, startAngle, sweepAngle);
actions.add(new AddArc(oval, startAngle, sweepAngle));
}
private void perform(final AddArc action) {
super.addArc(action.oval, action.startAngle, action.sweepAngle);
}
@Override
public void addCircle(float x, float y, float radius, Direction dir) {
super.addCircle(x, y, radius, dir);
actions.add(new AddCircle(x, y, radius, dir));
}
private void perform(final AddCircle action) {
super.addCircle(action.x, action.y, action.radius, action.dir);
}
@Override
public void addOval(RectF oval, Direction dir) {
super.addOval(oval, dir);
actions.add(new AddOval(oval, dir));
}
private void perform(final AddOval action) {
super.addOval(action.oval, action.dir);
}
/**
* Unsupported.
* @deprecated This method is not supported.
*/
@Override
@Deprecated
public void addPath(android.graphics.Path src) {
throw new UnsupportedOperationException();
}
/**
* Unsupported.
* @deprecated This method is not supported.
*/
@Override
@Deprecated
public void addPath(android.graphics.Path src, float dx, float dy) {
throw new UnsupportedOperationException();
}
/**
* Unsupported.
* @deprecated This method is not supported.
*/
@Override
@Deprecated
public void addPath(android.graphics.Path src, Matrix matrix) {
throw new UnsupportedOperationException();
}
@Override
public void addRect(float left, float top, float right, float bottom, Direction dir) {
super.addRect(left, top, right, bottom, dir);
actions.add(new AddRect(left, top, right, bottom, dir));
}
@Override
public void addRect(RectF rect, Direction dir) {
super.addRect(rect, dir);
actions.add(new AddRect(rect, dir));
}
private void perform(final AddRect action) {
super.addRect(action.rect, action.dir);
}
@Override
public void addRoundRect(RectF rect, float rx, float ry, Direction dir) {
super.addRoundRect(rect, rx, ry, dir);
actions.add(new AddRoundedRect(rect, rx, ry, dir));
}
private void perform(final AddRoundedRect action) {
super.addRoundRect(action.rect, action.rx, action.ry, action.dir);
}
@Override
public void addRoundRect(RectF rect, float[] radii, Direction dir) {
super.addRoundRect(rect, radii, dir);
actions.add(new AddRoundedRectCorners(rect, radii, dir));
}
private void perform(final AddRoundedRectCorners action) {
super.addRoundRect(action.rect, action.radii, action.dir);
}
@Override
public void quadTo(float x1, float y1, float x2, float y2) {
super.quadTo(x1, y1, x2, y2);
actions.add(new QuadTo(x1, y1, x2, y2));
}
private void perform(final QuadTo action) {
super.quadTo(action.x1, action.y1, action.x2, action.y2);
}
@Override
public void rCubicTo(float x1, float y1, float x2, float y2, float x3, float y3) {
super.rCubicTo(x1, y1, x2, y2, x3, y3);
actions.add(new RCubicTo(x1, y1, x2, y2, x3, y3));
}
private void perform(final RCubicTo action) {
super.rCubicTo(action.x1, action.y1, action.x2, action.y2, action.x3, action.y3);
}
@Override
public void rLineTo(float dx, float dy) {
super.rLineTo(dx, dy);
actions.add(new RLineTo(dx, dy));
}
private void perform(final RLineTo action) {
super.rLineTo(action.x, action.y);
}
@Override
public void rMoveTo(float dx, float dy) {
super.rMoveTo(dx, dy);
actions.add(new RMoveTo(dx, dy));
}
private void perform(final RMoveTo action) {
super.rMoveTo(action.x, action.y);
}
@Override
public void rQuadTo(float dx1, float dy1, float dx2, float dy2) {
super.rQuadTo(dx1, dy1, dx2, dy2);
actions.add(new RQuadTo(dx1, dy1, dx2, dy2));
}
private void perform(final RQuadTo action) {
super.rQuadTo(action.x1, action.y1, action.x2, action.y2);
}
@Override
public void offset(float dx, float dy) {
super.offset(dx, dy);
actions.add(new Offset(dx, dy));
}
private void perform(final Offset action) {
super.offset(action.x, action.y);
}
/**
* Unsupported.
* @deprecated This method is not supported.
*/
@Override
@Deprecated
public void offset(float dx, float dy, android.graphics.Path dst) {
throw new UnsupportedOperationException();
}
/**
* Unsupported.
* @deprecated This method is not supported.
*/
@Override
@Deprecated
public void set(android.graphics.Path src) {
throw new UnsupportedOperationException();
}
@Override
public void reset() {
super.reset();
actions.clear();
}
@Override
public void rewind() {
super.rewind();
actions.clear();
}
/**
* Unsupported.
* @deprecated This method is not supported.
*/
@Override
@Deprecated
public void transform(Matrix matrix, android.graphics.Path dst) {
throw new UnsupportedOperationException();
}
@Override
public void transform(Matrix matrix) {
super.transform(matrix);
this.actions.add(new MatrixTransformation(matrix));
}
private void perform(final MatrixTransformation action) {
super.transform(action.matrix);
}
@Override
public void close() {
super.close();
this.actions.add(new Close());
}
private void perform(final Close action) {
super.close();
}
@Override
public void setLastPoint(float dx, float dy) {
super.setLastPoint(dx, dy);
this.actions.add(new LastPoint(dx, dy));
}
private void perform(final LastPoint action) {
super.setLastPoint(action.x, action.y);
}
@Override
public void incReserve(int extraPtCount) {
super.incReserve(extraPtCount);
//actions.ensureCapacity(actions.size() + extraPtCount);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((actions == null) ? 0 : actions.hashCode());
result = prime * result + getFillType().hashCode();
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PathParcelable)) {
return false;
}
PathParcelable other = (PathParcelable) obj;
if (actions == null) {
if (other.actions != null) {
return false;
}
} else if (!actions.equals(other.actions)) {
return false;
}
if (getFillType() != other.getFillType()) {
return false;
}
return true;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(actions.size());
dest.writeArray(actions.toArray(new PathAction[actions.size()]));
dest.writeString(getFillType().name());
}
public static final Parcelable.Creator<PathParcelable> CREATOR = new Parcelable.Creator<PathParcelable>() {
public PathParcelable createFromParcel(Parcel in) {
return new PathParcelable(in);
}
public PathParcelable[] newArray(int size) {
return new PathParcelable[size];
}
};
private void restoreFromParcel() {
for (PathAction action : actions) {
switch (action.getType()) {
case MOVE_TO:
perform((MoveTo) action);
break;
case R_MOVE_TO:
perform((RMoveTo) action);
break;
case LINE_TO:
perform((LineTo) action);
break;
case R_LINE_TO:
perform((RLineTo) action);
break;
case CUPIC_TO:
perform((CubicTo) action);
break;
case R_CUBIC_TO:
perform((RCubicTo) action);
break;
case ARC_TO:
perform((ArcTo) action);
break;
case QUAD_TO:
perform((QuadTo) action);
break;
case R_QUAD_TO:
perform((RQuadTo) action);
break;
case ADD_ARC:
perform((AddArc) action);
break;
case ADD_CIRCLE:
perform((AddCircle) action);
break;
case ADD_OVAL:
perform((AddOval) action);
break;
case ADD_RECT:
perform((AddRect) action);
break;
case ADD_ROUNDED_RECT:
perform((AddRoundedRect) action);
break;
case ADD_ROUNDED_RECT_CORNERS:
perform((AddRoundedRectCorners) action);
break;
case OFFSET:
perform((Offset) action);
break;
case MATRIX_TRANSFORMATION:
perform((MatrixTransformation) action);
break;
case CLOSE:
perform((Close) action);
break;
case LAST_POINT:
perform((LastPoint) action);
break;
}
}
}
private static enum ActionType {
LINE_TO,
MOVE_TO,
CUPIC_TO,
ARC_TO,
QUAD_TO,
R_CUBIC_TO,
R_QUAD_TO,
R_LINE_TO,
R_MOVE_TO,
ADD_ARC,
ADD_CIRCLE,
ADD_OVAL,
ADD_RECT,
ADD_ROUNDED_RECT,
ADD_ROUNDED_RECT_CORNERS,
OFFSET,
MATRIX_TRANSFORMATION,
CLOSE,
LAST_POINT;
};
private static abstract class PathAction implements Parcelable {
public abstract ActionType getType();
@Override
public int describeContents() {
return getType().ordinal();
}
@Override
public boolean equals(Object other) {
if (other == null) {
return false;
}
if (!(other instanceof PathAction)) {
return false;
}
return this.getType() == ((PathAction) other).getType();
}
@Override
public int hashCode() {
return 31 + getType().hashCode();
}
}
private static class AddArc extends ArcTo {
public AddArc(final RectF oval, float startAngle, float sweepAngle) {
super(oval, startAngle, sweepAngle, false);
}
public AddArc(Parcel in) {
super(in);
}
@Override
public ActionType getType() {
return ActionType.ADD_ARC;
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<AddArc> CREATOR = new Parcelable.Creator<AddArc>() {
public AddArc createFromParcel(Parcel in) {
return new AddArc(in);
}
public AddArc[] newArray(int size) {
return new AddArc[size];
}
};
}
private static class AddCircle extends AddDirectionalFigure {
public final float x, y;
public final float radius;
public AddCircle(float x, float y, float radius, Direction dir) {
super(dir);
this.x = x;
this.y = y;
this.radius = radius;
}
public AddCircle(Parcel in) {
super(in);
this.x = in.readFloat();
this.y = in.readFloat();
this.radius = in.readFloat();
}
@Override
public ActionType getType() {
return ActionType.ADD_CIRCLE;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeFloat(x);
dest.writeFloat(y);
dest.writeFloat(radius);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<AddCircle> CREATOR = new Parcelable.Creator<AddCircle>() {
public AddCircle createFromParcel(Parcel in) {
return new AddCircle(in);
}
public AddCircle[] newArray(int size) {
return new AddCircle[size];
}
};
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Float.floatToIntBits(radius);
result = prime * result + Float.floatToIntBits(x);
result = prime * result + Float.floatToIntBits(y);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AddCircle)) {
return false;
}
AddCircle other = (AddCircle) obj;
if (Float.floatToIntBits(radius) != Float.floatToIntBits(other.radius)) {
return false;
}
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) {
return false;
}
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) {
return false;
}
return true;
}
}
private static abstract class AddDirectionalFigure extends PathAction {
public final Direction dir;
public AddDirectionalFigure(Direction dir) {
this.dir = dir;
}
public AddDirectionalFigure(Parcel in) {
this(Direction.valueOf(in.readString()));
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(dir.name());
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AddDirectionalFigure)) {
return false;
}
AddDirectionalFigure other = (AddDirectionalFigure) obj;
if (dir != other.dir) {
return false;
}
return true;
}
}
private static class AddOval extends AddDirectionalFigure {
public final RectF oval;
public AddOval(RectF oval, Direction dir) {
super(dir);
this.oval = oval;
}
public AddOval(Parcel in) {
super(in);
this.oval = (RectF) in.readParcelable(null);
}
@Override
public ActionType getType() {
return ActionType.ADD_OVAL;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeParcelable(oval, flags);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<AddOval> CREATOR = new Parcelable.Creator<AddOval>() {
public AddOval createFromParcel(Parcel in) {
return new AddOval(in);
}
public AddOval[] newArray(int size) {
return new AddOval[size];
}
};
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((oval == null) ? 0 : oval.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AddOval)) {
return false;
}
AddOval other = (AddOval) obj;
if (oval == null) {
if (other.oval != null) {
return false;
}
} else if (!oval.equals(other.oval)) {
return false;
}
return true;
}
}
private static class AddRect extends AddDirectionalFigure {
public final RectF rect;
public AddRect(RectF rect, Direction dir) {
super(dir);
this.rect = rect;
}
public AddRect(float left, float top, float right, float bottom, Direction dir) {
this(new RectF(left, top, right, bottom), dir);
}
public AddRect(Parcel in) {
super(in);
this.rect = (RectF) in.readParcelable(null);
}
@Override
public ActionType getType() {
return ActionType.ADD_RECT;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeParcelable(rect, flags);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<AddRect> CREATOR = new Parcelable.Creator<AddRect>() {
public AddRect createFromParcel(Parcel in) {
return new AddRect(in);
}
public AddRect[] newArray(int size) {
return new AddRect[size];
}
};
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((rect == null) ? 0 : rect.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AddRect)) {
return false;
}
AddRect other = (AddRect) obj;
if (rect == null) {
if (other.rect != null) {
return false;
}
} else if (!rect.equals(other.rect)) {
return false;
}
return true;
}
}
private static class AddRoundedRect extends AddRect {
public final float rx, ry;
public AddRoundedRect(RectF rect, float rx, float ry, Direction dir) {
super(rect, dir);
this.rx = rx;
this.ry = ry;
}
public AddRoundedRect(Parcel in) {
super(in);
this.rx = in.readFloat();
this.ry = in.readFloat();
}
@Override
public ActionType getType() {
return ActionType.ADD_ROUNDED_RECT;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeFloat(rx);
dest.writeFloat(ry);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<AddRoundedRect> CREATOR = new Parcelable.Creator<AddRoundedRect>() {
public AddRoundedRect createFromParcel(Parcel in) {
return new AddRoundedRect(in);
}
public AddRoundedRect[] newArray(int size) {
return new AddRoundedRect[size];
}
};
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Float.floatToIntBits(rx);
result = prime * result + Float.floatToIntBits(ry);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AddRoundedRect)) {
return false;
}
AddRoundedRect other = (AddRoundedRect) obj;
if (Float.floatToIntBits(rx) != Float.floatToIntBits(other.rx)) {
return false;
}
if (Float.floatToIntBits(ry) != Float.floatToIntBits(other.ry)) {
return false;
}
return true;
}
}
private static class AddRoundedRectCorners extends AddRect {
public final float[] radii;
public AddRoundedRectCorners(RectF rect, float[] radii, Direction dir) {
super(rect, dir);
this.radii = radii;
}
public AddRoundedRectCorners(Parcel in) {
super(in);
this.radii = new float[8];
in.readFloatArray(this.radii);
}
@Override
public ActionType getType() {
return ActionType.ADD_ROUNDED_RECT_CORNERS;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeFloatArray(this.radii);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<AddRoundedRectCorners> CREATOR = new Parcelable.Creator<AddRoundedRectCorners>() {
public AddRoundedRectCorners createFromParcel(Parcel in) {
return new AddRoundedRectCorners(in);
}
public AddRoundedRectCorners[] newArray(int size) {
return new AddRoundedRectCorners[size];
}
};
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Arrays.hashCode(radii);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AddRoundedRectCorners)) {
return false;
}
AddRoundedRectCorners other = (AddRoundedRectCorners) obj;
if (!Arrays.equals(radii, other.radii)) {
return false;
}
return true;
}
}
private static class ArcTo extends PathAction {
public final RectF oval;
public final float startAngle, sweepAngle;
public final boolean forceMoveTo;
public ArcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) {
this.oval = oval;
this.startAngle = startAngle;
this.sweepAngle = sweepAngle;
this.forceMoveTo = forceMoveTo;
}
public ArcTo(Parcel in) {
this.oval = (RectF) in.readParcelable(null);
this.startAngle = in.readFloat();
this.sweepAngle = in.readFloat();
this.forceMoveTo = in.readInt() == 1;
}
@Override
public ActionType getType() {
return ActionType.ARC_TO;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(oval, flags);
dest.writeFloat(startAngle);
dest.writeFloat(sweepAngle);
dest.writeInt(forceMoveTo ? 1 : 0);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<ArcTo> CREATOR = new Parcelable.Creator<ArcTo>() {
public ArcTo createFromParcel(Parcel in) {
return new ArcTo(in);
}