picrate 0.3.0-java → 0.4.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/CHANGELOG.md +1 -2
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/picrate.rb +1 -0
- data/lib/picrate/app.rb +4 -4
- data/lib/picrate/helper_methods.rb +0 -4
- data/lib/picrate/version.rb +1 -1
- data/library/color_group/color_group.rb +27 -0
- data/picrate.gemspec +1 -1
- data/pom.rb +5 -5
- data/pom.xml +5 -5
- data/src/main/java/monkstone/ColorUtil.java +57 -32
- data/src/main/java/processing/awt/PShapeJava2D.java +33 -9
- data/src/main/java/processing/awt/PSurfaceAWT.java +169 -76
- data/src/main/java/processing/core/PApplet.java +15921 -13981
- data/src/main/java/processing/core/PConstants.java +981 -475
- data/src/main/java/processing/core/PFont.java +202 -50
- data/src/main/java/processing/core/PGraphics.java +8470 -7323
- data/src/main/java/processing/core/PImage.java +212 -42
- data/src/main/java/processing/core/PMatrix.java +160 -21
- data/src/main/java/processing/core/PMatrix2D.java +178 -18
- data/src/main/java/processing/core/PMatrix3D.java +324 -48
- data/src/main/java/processing/core/PShape.java +42 -20
- data/src/main/java/processing/core/PShapeOBJ.java +91 -16
- data/src/main/java/processing/core/PShapeSVG.java +253 -53
- data/src/main/java/processing/core/PStyle.java +179 -34
- data/src/main/java/processing/core/PSurface.java +94 -13
- data/src/main/java/processing/core/PSurfaceNone.java +140 -35
- data/src/main/java/processing/core/PVector.java +87 -10
- data/src/main/java/processing/data/JSONObject.java +2 -2
- data/src/main/java/processing/event/Event.java +69 -86
- data/src/main/java/processing/event/MouseEvent.java +102 -102
- data/src/main/java/processing/opengl/PJOGL.java +3 -0
- data/test/color_group_test.rb +33 -0
- data/vendors/Rakefile +1 -1
- metadata +7 -4
@@ -138,6 +138,8 @@ public class PVector implements Serializable {
|
|
138
138
|
|
139
139
|
/**
|
140
140
|
* Constructor for a 2D vector: z coordinate is set to 0.
|
141
|
+
* @param x
|
142
|
+
* @param y
|
141
143
|
*/
|
142
144
|
public PVector(float x, float y) {
|
143
145
|
this.x = x;
|
@@ -153,6 +155,7 @@ public class PVector implements Serializable {
|
|
153
155
|
*
|
154
156
|
* ( end auto-generated )
|
155
157
|
*
|
158
|
+
* @return
|
156
159
|
* @webref pvector:method
|
157
160
|
* @param x the x component of the vector
|
158
161
|
* @param y the y component of the vector
|
@@ -170,6 +173,7 @@ public class PVector implements Serializable {
|
|
170
173
|
/**
|
171
174
|
* @param x the x component of the vector
|
172
175
|
* @param y the y component of the vector
|
176
|
+
* @return
|
173
177
|
*/
|
174
178
|
public PVector set(float x, float y) {
|
175
179
|
this.x = x;
|
@@ -181,6 +185,7 @@ public class PVector implements Serializable {
|
|
181
185
|
|
182
186
|
/**
|
183
187
|
* @param v any variable of type PVector
|
188
|
+
* @return
|
184
189
|
*/
|
185
190
|
public PVector set(PVector v) {
|
186
191
|
x = v.x;
|
@@ -193,6 +198,7 @@ public class PVector implements Serializable {
|
|
193
198
|
/**
|
194
199
|
* Set the x, y (and maybe z) coordinates using a float[] array as the source.
|
195
200
|
* @param source array to copy from
|
201
|
+
* @return
|
196
202
|
*/
|
197
203
|
public PVector set(float[] source) {
|
198
204
|
if (source.length >= 2) {
|
@@ -250,6 +256,8 @@ public class PVector implements Serializable {
|
|
250
256
|
* Make a new 2D unit vector with a random direction. Pass in the parent
|
251
257
|
* PApplet if you want randomSeed() to work (and be predictable). Or leave
|
252
258
|
* it null and be... random.
|
259
|
+
* @param target
|
260
|
+
* @param parent
|
253
261
|
* @return the random PVector
|
254
262
|
*/
|
255
263
|
static public PVector random2D(PVector target, PApplet parent) {
|
@@ -300,6 +308,8 @@ public class PVector implements Serializable {
|
|
300
308
|
|
301
309
|
/**
|
302
310
|
* Make a new 3D unit vector with a random direction
|
311
|
+
* @param target
|
312
|
+
* @param parent
|
303
313
|
* @return the random PVector
|
304
314
|
*/
|
305
315
|
static public PVector random3D(PVector target, PApplet parent) {
|
@@ -345,6 +355,7 @@ public class PVector implements Serializable {
|
|
345
355
|
/**
|
346
356
|
* Make a new 2D unit vector from an angle
|
347
357
|
*
|
358
|
+
* @param angle
|
348
359
|
* @param target the target vector (if null, a new vector will be created)
|
349
360
|
* @return the PVector
|
350
361
|
*/
|
@@ -365,6 +376,7 @@ public class PVector implements Serializable {
|
|
365
376
|
*
|
366
377
|
* ( end auto-generated )
|
367
378
|
*
|
379
|
+
* @return
|
368
380
|
* @webref pvector:method
|
369
381
|
* @usage web_application
|
370
382
|
* @brief Get a copy of the vector
|
@@ -373,8 +385,12 @@ public class PVector implements Serializable {
|
|
373
385
|
return new PVector(x, y, z);
|
374
386
|
}
|
375
387
|
|
376
|
-
|
377
|
-
|
388
|
+
/**
|
389
|
+
*
|
390
|
+
* @return
|
391
|
+
* @deprecated
|
392
|
+
*/
|
393
|
+
@Deprecated
|
378
394
|
public PVector get() {
|
379
395
|
return copy();
|
380
396
|
}
|
@@ -382,6 +398,7 @@ public class PVector implements Serializable {
|
|
382
398
|
|
383
399
|
/**
|
384
400
|
* @param target
|
401
|
+
* @return
|
385
402
|
*/
|
386
403
|
public float[] get(float[] target) {
|
387
404
|
if (target == null) {
|
@@ -449,6 +466,7 @@ public class PVector implements Serializable {
|
|
449
466
|
*
|
450
467
|
* ( end auto-generated )
|
451
468
|
*
|
469
|
+
* @return
|
452
470
|
* @webref pvector:method
|
453
471
|
* @usage web_application
|
454
472
|
* @param v the vector to be added
|
@@ -465,6 +483,7 @@ public class PVector implements Serializable {
|
|
465
483
|
/**
|
466
484
|
* @param x x component of the vector
|
467
485
|
* @param y y component of the vector
|
486
|
+
* @return
|
468
487
|
*/
|
469
488
|
public PVector add(float x, float y) {
|
470
489
|
this.x += x;
|
@@ -474,7 +493,10 @@ public class PVector implements Serializable {
|
|
474
493
|
|
475
494
|
|
476
495
|
/**
|
496
|
+
* @param x
|
497
|
+
* @param y
|
477
498
|
* @param z z component of the vector
|
499
|
+
* @return
|
478
500
|
*/
|
479
501
|
public PVector add(float x, float y, float z) {
|
480
502
|
this.x += x;
|
@@ -488,6 +510,7 @@ public class PVector implements Serializable {
|
|
488
510
|
* Add two vectors
|
489
511
|
* @param v1 a vector
|
490
512
|
* @param v2 another vector
|
513
|
+
* @return
|
491
514
|
*/
|
492
515
|
static public PVector add(PVector v1, PVector v2) {
|
493
516
|
return add(v1, v2, null);
|
@@ -496,7 +519,10 @@ public class PVector implements Serializable {
|
|
496
519
|
|
497
520
|
/**
|
498
521
|
* Add two vectors into a target vector
|
522
|
+
* @param v1
|
499
523
|
* @param target the target vector (if null, a new vector will be created)
|
524
|
+
* @param v2
|
525
|
+
* @return
|
500
526
|
*/
|
501
527
|
static public PVector add(PVector v1, PVector v2, PVector target) {
|
502
528
|
if (target == null) {
|
@@ -519,6 +545,7 @@ public class PVector implements Serializable {
|
|
519
545
|
*
|
520
546
|
* ( end auto-generated )
|
521
547
|
*
|
548
|
+
* @return
|
522
549
|
* @webref pvector:method
|
523
550
|
* @usage web_application
|
524
551
|
* @param v any variable of type PVector
|
@@ -535,6 +562,7 @@ public class PVector implements Serializable {
|
|
535
562
|
/**
|
536
563
|
* @param x the x component of the vector
|
537
564
|
* @param y the y component of the vector
|
565
|
+
* @return
|
538
566
|
*/
|
539
567
|
public PVector sub(float x, float y) {
|
540
568
|
this.x -= x;
|
@@ -544,7 +572,10 @@ public class PVector implements Serializable {
|
|
544
572
|
|
545
573
|
|
546
574
|
/**
|
575
|
+
* @param x
|
576
|
+
* @param y
|
547
577
|
* @param z the z component of the vector
|
578
|
+
* @return
|
548
579
|
*/
|
549
580
|
public PVector sub(float x, float y, float z) {
|
550
581
|
this.x -= x;
|
@@ -558,6 +589,7 @@ public class PVector implements Serializable {
|
|
558
589
|
* Subtract one vector from another
|
559
590
|
* @param v1 the x, y, and z components of a PVector object
|
560
591
|
* @param v2 the x, y, and z components of a PVector object
|
592
|
+
* @return
|
561
593
|
*/
|
562
594
|
static public PVector sub(PVector v1, PVector v2) {
|
563
595
|
return sub(v1, v2, null);
|
@@ -566,7 +598,10 @@ public class PVector implements Serializable {
|
|
566
598
|
|
567
599
|
/**
|
568
600
|
* Subtract one vector from another and store in another vector
|
601
|
+
* @param v1
|
602
|
+
* @param v2
|
569
603
|
* @param target PVector in which to store the result
|
604
|
+
* @return
|
570
605
|
*/
|
571
606
|
static public PVector sub(PVector v1, PVector v2, PVector target) {
|
572
607
|
if (target == null) {
|
@@ -585,6 +620,7 @@ public class PVector implements Serializable {
|
|
585
620
|
*
|
586
621
|
* ( end auto-generated )
|
587
622
|
*
|
623
|
+
* @return
|
588
624
|
* @webref pvector:method
|
589
625
|
* @usage web_application
|
590
626
|
* @brief Multiply a vector by a scalar
|
@@ -600,6 +636,8 @@ public class PVector implements Serializable {
|
|
600
636
|
|
601
637
|
/**
|
602
638
|
* @param v the vector to multiply by the scalar
|
639
|
+
* @param n
|
640
|
+
* @return
|
603
641
|
*/
|
604
642
|
static public PVector mult(PVector v, float n) {
|
605
643
|
return mult(v, n, null);
|
@@ -608,7 +646,10 @@ public class PVector implements Serializable {
|
|
608
646
|
|
609
647
|
/**
|
610
648
|
* Multiply a vector by a scalar, and write the result into a target PVector.
|
649
|
+
* @param v
|
611
650
|
* @param target PVector in which to store the result
|
651
|
+
* @param n
|
652
|
+
* @return
|
612
653
|
*/
|
613
654
|
static public PVector mult(PVector v, float n, PVector target) {
|
614
655
|
if (target == null) {
|
@@ -627,6 +668,7 @@ public class PVector implements Serializable {
|
|
627
668
|
*
|
628
669
|
* ( end auto-generated )
|
629
670
|
*
|
671
|
+
* @return
|
630
672
|
* @webref pvector:method
|
631
673
|
* @usage web_application
|
632
674
|
* @brief Divide a vector by a scalar
|
@@ -643,6 +685,7 @@ public class PVector implements Serializable {
|
|
643
685
|
/**
|
644
686
|
* Divide a vector by a scalar and return the result in a new vector.
|
645
687
|
* @param v the vector to divide by the scalar
|
688
|
+
* @param n
|
646
689
|
* @return a new vector that is v1 / n
|
647
690
|
*/
|
648
691
|
static public PVector div(PVector v, float n) {
|
@@ -652,7 +695,10 @@ public class PVector implements Serializable {
|
|
652
695
|
|
653
696
|
/**
|
654
697
|
* Divide a vector by a scalar and store the result in another vector.
|
698
|
+
* @param v
|
655
699
|
* @param target PVector in which to store the result
|
700
|
+
* @param n
|
701
|
+
* @return
|
656
702
|
*/
|
657
703
|
static public PVector div(PVector v, float n, PVector target) {
|
658
704
|
if (target == null) {
|
@@ -672,6 +718,7 @@ public class PVector implements Serializable {
|
|
672
718
|
*
|
673
719
|
* ( end auto-generated )
|
674
720
|
*
|
721
|
+
* @return
|
675
722
|
* @webref pvector:method
|
676
723
|
* @usage web_application
|
677
724
|
* @param v the x, y, and z coordinates of a PVector
|
@@ -720,6 +767,7 @@ public class PVector implements Serializable {
|
|
720
767
|
* @param x x component of the vector
|
721
768
|
* @param y y component of the vector
|
722
769
|
* @param z z component of the vector
|
770
|
+
* @return
|
723
771
|
*/
|
724
772
|
public float dot(float x, float y, float z) {
|
725
773
|
return this.x*x + this.y*y + this.z*z;
|
@@ -729,6 +777,7 @@ public class PVector implements Serializable {
|
|
729
777
|
/**
|
730
778
|
* @param v1 any variable of type PVector
|
731
779
|
* @param v2 any variable of type PVector
|
780
|
+
* @return
|
732
781
|
*/
|
733
782
|
static public float dot(PVector v1, PVector v2) {
|
734
783
|
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
|
@@ -743,6 +792,7 @@ public class PVector implements Serializable {
|
|
743
792
|
*
|
744
793
|
* ( end auto-generated )
|
745
794
|
*
|
795
|
+
* @return
|
746
796
|
* @webref pvector:method
|
747
797
|
* @param v the vector to calculate the cross product
|
748
798
|
* @brief Calculate and return the cross product
|
@@ -755,6 +805,7 @@ public class PVector implements Serializable {
|
|
755
805
|
/**
|
756
806
|
* @param v any variable of type PVector
|
757
807
|
* @param target PVector to store the result
|
808
|
+
* @return
|
758
809
|
*/
|
759
810
|
public PVector cross(PVector v, PVector target) {
|
760
811
|
float crossX = y * v.z - v.y * z;
|
@@ -774,6 +825,7 @@ public class PVector implements Serializable {
|
|
774
825
|
* @param v1 any variable of type PVector
|
775
826
|
* @param v2 any variable of type PVector
|
776
827
|
* @param target PVector to store the result
|
828
|
+
* @return
|
777
829
|
*/
|
778
830
|
static public PVector cross(PVector v1, PVector v2, PVector target) {
|
779
831
|
float crossX = v1.y * v2.z - v2.y * v1.z;
|
@@ -796,6 +848,7 @@ public class PVector implements Serializable {
|
|
796
848
|
*
|
797
849
|
* ( end auto-generated )
|
798
850
|
*
|
851
|
+
* @return
|
799
852
|
* @webref pvector:method
|
800
853
|
* @usage web_application
|
801
854
|
* @brief Normalize the vector to a length of 1
|
@@ -834,6 +887,7 @@ public class PVector implements Serializable {
|
|
834
887
|
*
|
835
888
|
* ( end auto-generated )
|
836
889
|
*
|
890
|
+
* @return
|
837
891
|
* @webref pvector:method
|
838
892
|
* @usage web_application
|
839
893
|
* @param max the maximum magnitude for the vector
|
@@ -855,6 +909,7 @@ public class PVector implements Serializable {
|
|
855
909
|
*
|
856
910
|
* ( end auto-generated )
|
857
911
|
*
|
912
|
+
* @return
|
858
913
|
* @webref pvector:method
|
859
914
|
* @usage web_application
|
860
915
|
* @param len the new length for this vector
|
@@ -897,8 +952,12 @@ public class PVector implements Serializable {
|
|
897
952
|
return angle;
|
898
953
|
}
|
899
954
|
|
900
|
-
|
901
|
-
|
955
|
+
/**
|
956
|
+
*
|
957
|
+
* @return
|
958
|
+
* @deprecated
|
959
|
+
*/
|
960
|
+
@Deprecated
|
902
961
|
public float heading2D() {
|
903
962
|
return heading();
|
904
963
|
}
|
@@ -911,6 +970,7 @@ public class PVector implements Serializable {
|
|
911
970
|
*
|
912
971
|
* ( end auto-generated )
|
913
972
|
*
|
973
|
+
* @return
|
914
974
|
* @webref pvector:method
|
915
975
|
* @usage web_application
|
916
976
|
* @brief Rotate the vector by an angle (2D only)
|
@@ -932,6 +992,7 @@ public class PVector implements Serializable {
|
|
932
992
|
*
|
933
993
|
* ( end auto-generated )
|
934
994
|
*
|
995
|
+
* @return
|
935
996
|
* @webref pvector:method
|
936
997
|
* @usage web_application
|
937
998
|
* @brief Linear interpolate the vector to another vector
|
@@ -951,6 +1012,8 @@ public class PVector implements Serializable {
|
|
951
1012
|
* Linear interpolate between two vectors (returns a new PVector object)
|
952
1013
|
* @param v1 the vector to start from
|
953
1014
|
* @param v2 the vector to lerp to
|
1015
|
+
* @param amt
|
1016
|
+
* @return
|
954
1017
|
*/
|
955
1018
|
public static PVector lerp(PVector v1, PVector v2, float amt) {
|
956
1019
|
PVector v = v1.copy();
|
@@ -964,6 +1027,8 @@ public class PVector implements Serializable {
|
|
964
1027
|
* @param x the x component to lerp to
|
965
1028
|
* @param y the y component to lerp to
|
966
1029
|
* @param z the z component to lerp to
|
1030
|
+
* @param amt
|
1031
|
+
* @return
|
967
1032
|
*/
|
968
1033
|
public PVector lerp(float x, float y, float z, float amt) {
|
969
1034
|
this.x = PApplet.lerp(this.x, x, amt);
|
@@ -980,6 +1045,7 @@ public class PVector implements Serializable {
|
|
980
1045
|
*
|
981
1046
|
* ( end auto-generated )
|
982
1047
|
*
|
1048
|
+
* @return
|
983
1049
|
* @webref pvector:method
|
984
1050
|
* @usage web_application
|
985
1051
|
* @param v1 the x, y, and z components of a PVector
|
@@ -1011,8 +1077,11 @@ public class PVector implements Serializable {
|
|
1011
1077
|
return (float) Math.acos(amt);
|
1012
1078
|
}
|
1013
1079
|
|
1014
|
-
|
1015
|
-
|
1080
|
+
/**
|
1081
|
+
*
|
1082
|
+
* @return
|
1083
|
+
*/
|
1084
|
+
@Override
|
1016
1085
|
public String toString() {
|
1017
1086
|
return "[ " + x + ", " + y + ", " + z + " ]";
|
1018
1087
|
}
|
@@ -1027,6 +1096,7 @@ public class PVector implements Serializable {
|
|
1027
1096
|
*
|
1028
1097
|
* ( end auto-generated )
|
1029
1098
|
*
|
1099
|
+
* @return
|
1030
1100
|
* @webref pvector:method
|
1031
1101
|
* @usage: web_application
|
1032
1102
|
* @brief Return a representation of the vector as a float array
|
@@ -1041,8 +1111,12 @@ public class PVector implements Serializable {
|
|
1041
1111
|
return array;
|
1042
1112
|
}
|
1043
1113
|
|
1044
|
-
|
1045
|
-
|
1114
|
+
/**
|
1115
|
+
*
|
1116
|
+
* @param obj
|
1117
|
+
* @return
|
1118
|
+
*/
|
1119
|
+
@Override
|
1046
1120
|
public boolean equals(Object obj) {
|
1047
1121
|
if (!(obj instanceof PVector)) {
|
1048
1122
|
return false;
|
@@ -1051,8 +1125,11 @@ public class PVector implements Serializable {
|
|
1051
1125
|
return x == p.x && y == p.y && z == p.z;
|
1052
1126
|
}
|
1053
1127
|
|
1054
|
-
|
1055
|
-
|
1128
|
+
/**
|
1129
|
+
*
|
1130
|
+
* @return
|
1131
|
+
*/
|
1132
|
+
@Override
|
1056
1133
|
public int hashCode() {
|
1057
1134
|
int result = 1;
|
1058
1135
|
result = 31 * result + Float.floatToIntBits(x);
|
@@ -1387,7 +1387,7 @@ public class JSONObject {
|
|
1387
1387
|
* @param string A String
|
1388
1388
|
* @return A String correctly formatted for insertion in a JSON text.
|
1389
1389
|
*/
|
1390
|
-
static
|
1390
|
+
static public String quote(String string) {
|
1391
1391
|
StringWriter sw = new StringWriter();
|
1392
1392
|
synchronized (sw.getBuffer()) {
|
1393
1393
|
try {
|
@@ -1399,7 +1399,7 @@ public class JSONObject {
|
|
1399
1399
|
}
|
1400
1400
|
}
|
1401
1401
|
|
1402
|
-
static
|
1402
|
+
static public Writer quote(String string, Writer w) throws IOException {
|
1403
1403
|
if (string == null || string.length() == 0) {
|
1404
1404
|
w.write("\"\"");
|
1405
1405
|
return w;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
2
|
|
3
|
-
/*
|
3
|
+
/*
|
4
4
|
Part of the Processing project - http://processing.org
|
5
5
|
|
6
6
|
Copyright (c) 2012 The Processing Foundation
|
@@ -18,108 +18,91 @@
|
|
18
18
|
Public License along with this library; if not, write to the
|
19
19
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
20
|
Boston, MA 02111-1307 USA
|
21
|
-
*/
|
22
|
-
|
21
|
+
*/
|
23
22
|
package processing.event;
|
24
23
|
|
25
|
-
|
26
24
|
public class Event {
|
27
|
-
protected Object nativeObject;
|
28
|
-
|
29
|
-
protected long millis;
|
30
|
-
protected int action;
|
31
|
-
|
32
|
-
// These correspond to the java.awt.Event modifiers (not to be confused with
|
33
|
-
// the newer getModifiersEx), though they're not guaranteed to in the future.
|
34
|
-
static public final int SHIFT = 1 << 0;
|
35
|
-
static public final int CTRL = 1 << 1;
|
36
|
-
static public final int META = 1 << 2;
|
37
|
-
static public final int ALT = 1 << 3;
|
38
|
-
protected int modifiers;
|
39
|
-
|
40
|
-
// Types of events. As with all constants in Processing, brevity's preferred.
|
41
|
-
static public final int KEY = 1;
|
42
|
-
static public final int MOUSE = 2;
|
43
|
-
static public final int TOUCH = 3;
|
44
|
-
protected int flavor;
|
45
|
-
|
46
|
-
|
47
|
-
public Event(Object nativeObject, long millis, int action, int modifiers) {
|
48
|
-
this.nativeObject = nativeObject;
|
49
|
-
this.millis = millis;
|
50
|
-
this.action = action;
|
51
|
-
this.modifiers = modifiers;
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
public int getFlavor() {
|
56
|
-
return flavor;
|
57
|
-
}
|
58
|
-
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Get the platform-native event object. This might be the java.awt event
|
62
|
-
* on the desktop, though if you're using OpenGL on the desktop it'll be a
|
63
|
-
* NEWT event that JOGL uses. Android events are something else altogether.
|
64
|
-
* Bottom line, use this only if you know what you're doing, and don't make
|
65
|
-
* assumptions about the class type.
|
66
|
-
*/
|
67
|
-
public Object getNative() {
|
68
|
-
return nativeObject;
|
69
|
-
}
|
70
25
|
|
26
|
+
protected Object nativeObject;
|
27
|
+
|
28
|
+
protected long millis;
|
29
|
+
protected int action;
|
30
|
+
|
31
|
+
// These correspond to the java.awt.Event modifiers (not to be confused with
|
32
|
+
// the newer getModifiersEx), though they're not guaranteed to in the future.
|
33
|
+
static public final int SHIFT = 1;
|
34
|
+
static public final int CTRL = 1 << 1;
|
35
|
+
static public final int META = 1 << 2;
|
36
|
+
static public final int ALT = 1 << 3;
|
37
|
+
protected int modifiers;
|
38
|
+
|
39
|
+
// Types of events. As with all constants in Processing, brevity's preferred.
|
40
|
+
static public final int KEY = 1;
|
41
|
+
static public final int MOUSE = 2;
|
42
|
+
static public final int TOUCH = 3;
|
43
|
+
protected int flavor;
|
44
|
+
|
45
|
+
public Event(Object nativeObject, long millis, int action, int modifiers) {
|
46
|
+
this.nativeObject = nativeObject;
|
47
|
+
this.millis = millis;
|
48
|
+
this.action = action;
|
49
|
+
this.modifiers = modifiers;
|
50
|
+
}
|
51
|
+
|
52
|
+
public int getFlavor() {
|
53
|
+
return flavor;
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Get the platform-native event object. This might be the java.awt event on
|
58
|
+
* the desktop, though if you're using OpenGL on the desktop it'll be a NEWT
|
59
|
+
* event that JOGL uses. Android events are something else altogether.
|
60
|
+
* Bottom line, use this only if you know what you're doing, and don't make
|
61
|
+
* assumptions about the class type.
|
62
|
+
*
|
63
|
+
* @return
|
64
|
+
*/
|
65
|
+
public Object getNative() {
|
66
|
+
return nativeObject;
|
67
|
+
}
|
71
68
|
|
72
69
|
// public void setNative(Object nativeObject) {
|
73
70
|
// this.nativeObject = nativeObject;
|
74
71
|
// }
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
return millis;
|
79
|
-
}
|
80
|
-
|
72
|
+
public long getMillis() {
|
73
|
+
return millis;
|
74
|
+
}
|
81
75
|
|
82
76
|
// public void setMillis(long millis) {
|
83
77
|
// this.millis = millis;
|
84
78
|
// }
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
return action;
|
89
|
-
}
|
90
|
-
|
79
|
+
public int getAction() {
|
80
|
+
return action;
|
81
|
+
}
|
91
82
|
|
92
83
|
// public void setAction(int action) {
|
93
84
|
// this.action = action;
|
94
85
|
// }
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
return modifiers;
|
99
|
-
}
|
100
|
-
|
86
|
+
public int getModifiers() {
|
87
|
+
return modifiers;
|
88
|
+
}
|
101
89
|
|
102
90
|
// public void setModifiers(int modifiers) {
|
103
91
|
// this.modifiers = modifiers;
|
104
92
|
// }
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
public boolean isAltDown() {
|
123
|
-
return (modifiers & ALT) != 0;
|
124
|
-
}
|
125
|
-
}
|
93
|
+
public boolean isShiftDown() {
|
94
|
+
return (modifiers & SHIFT) != 0;
|
95
|
+
}
|
96
|
+
|
97
|
+
public boolean isControlDown() {
|
98
|
+
return (modifiers & CTRL) != 0;
|
99
|
+
}
|
100
|
+
|
101
|
+
public boolean isMetaDown() {
|
102
|
+
return (modifiers & META) != 0;
|
103
|
+
}
|
104
|
+
|
105
|
+
public boolean isAltDown() {
|
106
|
+
return (modifiers & ALT) != 0;
|
107
|
+
}
|
108
|
+
}
|