picrate 0.5.0-java → 0.6.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +3 -1
- data/README.md +1 -1
- data/Rakefile +8 -6
- data/docs/_editors/geany.md +5 -4
- data/docs/_editors/vim.md +6 -0
- data/docs/_includes/head.html +1 -0
- data/docs/_libraries/control_panel.md +2 -2
- data/docs/_libraries/gl_video.md +21 -0
- data/docs/_posts/2018-05-06-getting_started.md +10 -9
- data/docs/_posts/2018-05-06-install_jruby.md +19 -2
- data/docs/_posts/2018-06-26-auto_install_picrate.md +19 -4
- data/docs/_posts/2018-11-18-building-gem.md +18 -0
- data/docs/_posts/2018-11-27-getting_started_geany.md +38 -0
- data/docs/about.md +21 -10
- data/docs/assets/android-chrome-192x192.png +0 -0
- data/docs/assets/android-chrome-512x512.png +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/geany.png +0 -0
- data/docs/assets/jwishy_picrate.png +0 -0
- data/docs/assets/picrate.svg +251 -0
- data/docs/index.html +8 -14
- data/lib/picrate/runner.rb +6 -2
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +10 -13
- data/mvnw +234 -0
- data/picrate.gemspec +2 -1
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/src/main/java/japplemenubar/JAppleMenuBar.java +10 -2
- data/src/main/java/monkstone/ColorUtil.java +11 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -0
- data/src/main/java/monkstone/PicrateLibrary.java +1 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -0
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleSlider.java +8 -8
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/Slider.java +3 -3
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/vecmath/AppRender.java +1 -0
- data/src/main/java/monkstone/vecmath/JRender.java +1 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -0
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -0
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +85 -16
- data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
- data/src/main/java/processing/core/PApplet.java +18 -12
- data/src/main/java/processing/core/PShape.java +1182 -305
- data/src/main/java/processing/core/PStyle.java +1 -1
- data/src/main/java/processing/core/PSurface.java +1 -1
- data/src/main/java/processing/data/FloatDict.java +196 -54
- data/src/main/java/processing/data/FloatList.java +167 -54
- data/src/main/java/processing/data/IntDict.java +211 -56
- data/src/main/java/processing/data/IntList.java +185 -52
- data/src/main/java/processing/data/JSONArray.java +69 -20
- data/src/main/java/processing/data/JSONObject.java +53 -12
- data/src/main/java/processing/data/Sort.java +40 -10
- data/src/main/java/processing/data/StringDict.java +159 -49
- data/src/main/java/processing/data/StringList.java +147 -42
- data/src/main/java/processing/data/Table.java +778 -223
- data/src/main/java/processing/data/TableRow.java +26 -2
- data/src/main/java/processing/data/XML.java +190 -50
- data/src/main/java/processing/event/Event.java +93 -0
- data/src/main/java/processing/event/KeyEvent.java +55 -13
- data/src/main/java/processing/event/MouseEvent.java +77 -1
- data/src/main/java/processing/event/TouchEvent.java +14 -1
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +8 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +228 -66
- data/src/main/java/processing/opengl/LinePath.java +131 -27
- data/src/main/java/processing/opengl/LineStroker.java +30 -5
- data/src/main/java/processing/opengl/PGL.java +4066 -865
- data/src/main/java/processing/opengl/PGraphics2D.java +38 -10
- data/src/main/java/processing/opengl/PGraphics3D.java +38 -6
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +1980 -474
- data/src/main/java/processing/opengl/PJOGL.java +1460 -248
- data/src/main/java/processing/opengl/PShader.java +904 -217
- data/src/main/java/processing/opengl/PShapeOpenGL.java +1811 -487
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +278 -71
- data/src/main/java/processing/opengl/Texture.java +610 -135
- data/src/main/java/processing/opengl/VertexBuffer.java +45 -9
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/vendors/Rakefile +1 -1
- metadata +13 -6
- data/docs/assets/circle_collisions.png +0 -0
- data/docs/favicon.ico +0 -0
|
@@ -114,6 +114,7 @@ public class JSONArray {
|
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
+
* @param reader
|
|
117
118
|
* @nowebref
|
|
118
119
|
*/
|
|
119
120
|
public JSONArray(Reader reader) {
|
|
@@ -162,6 +163,7 @@ public class JSONArray {
|
|
|
162
163
|
|
|
163
164
|
|
|
164
165
|
/**
|
|
166
|
+
* @param list
|
|
165
167
|
* @nowebref
|
|
166
168
|
*/
|
|
167
169
|
public JSONArray(IntList list) {
|
|
@@ -173,6 +175,7 @@ public class JSONArray {
|
|
|
173
175
|
|
|
174
176
|
|
|
175
177
|
/**
|
|
178
|
+
* @param list
|
|
176
179
|
* @nowebref
|
|
177
180
|
*/
|
|
178
181
|
public JSONArray(FloatList list) {
|
|
@@ -184,6 +187,7 @@ public class JSONArray {
|
|
|
184
187
|
|
|
185
188
|
|
|
186
189
|
/**
|
|
190
|
+
* @param list
|
|
187
191
|
* @nowebref
|
|
188
192
|
*/
|
|
189
193
|
public JSONArray(StringList list) {
|
|
@@ -228,6 +232,7 @@ public class JSONArray {
|
|
|
228
232
|
// TODO not decided whether we keep this one, but used heavily by JSONObject
|
|
229
233
|
/**
|
|
230
234
|
* Construct a JSONArray from an array
|
|
235
|
+
* @param array
|
|
231
236
|
* @throws RuntimeException If not an array.
|
|
232
237
|
*/
|
|
233
238
|
protected JSONArray(Object array) {
|
|
@@ -386,9 +391,10 @@ public class JSONArray {
|
|
|
386
391
|
|
|
387
392
|
|
|
388
393
|
/**
|
|
389
|
-
* Get a value from an index as a float.
|
|
390
|
-
|
|
394
|
+
* Get a value from an index as a float.JSON uses 'double' values
|
|
395
|
+
internally, so this is simply getDouble() cast to a float.
|
|
391
396
|
*
|
|
397
|
+
* @return
|
|
392
398
|
* @webref jsonarray:method
|
|
393
399
|
* @brief Gets the float value associated with an index
|
|
394
400
|
* @param index must be between 0 and length() - 1
|
|
@@ -400,8 +406,13 @@ public class JSONArray {
|
|
|
400
406
|
return (float) getDouble(index);
|
|
401
407
|
}
|
|
402
408
|
|
|
403
|
-
|
|
404
|
-
|
|
409
|
+
/**
|
|
410
|
+
*
|
|
411
|
+
* @param index
|
|
412
|
+
* @param defaultValue
|
|
413
|
+
* @return
|
|
414
|
+
*/
|
|
415
|
+
public float getFloat(int index, float defaultValue) {
|
|
405
416
|
try {
|
|
406
417
|
return getFloat(index);
|
|
407
418
|
} catch (Exception e) {
|
|
@@ -516,8 +527,13 @@ public class JSONArray {
|
|
|
516
527
|
throw new RuntimeException("JSONArray[" + index + "] is not a JSONArray.");
|
|
517
528
|
}
|
|
518
529
|
|
|
519
|
-
|
|
520
|
-
|
|
530
|
+
/**
|
|
531
|
+
*
|
|
532
|
+
* @param index
|
|
533
|
+
* @param defaultValue
|
|
534
|
+
* @return
|
|
535
|
+
*/
|
|
536
|
+
public JSONArray getJSONArray(int index, JSONArray defaultValue) {
|
|
521
537
|
try {
|
|
522
538
|
return getJSONArray(index);
|
|
523
539
|
} catch (Exception e) {
|
|
@@ -547,8 +563,13 @@ public class JSONArray {
|
|
|
547
563
|
throw new RuntimeException("JSONArray[" + index + "] is not a JSONObject.");
|
|
548
564
|
}
|
|
549
565
|
|
|
550
|
-
|
|
551
|
-
|
|
566
|
+
/**
|
|
567
|
+
*
|
|
568
|
+
* @param index
|
|
569
|
+
* @param defaultValue
|
|
570
|
+
* @return
|
|
571
|
+
*/
|
|
572
|
+
public JSONObject getJSONObject(int index, JSONObject defaultValue) {
|
|
552
573
|
try {
|
|
553
574
|
return getJSONObject(index);
|
|
554
575
|
} catch (Exception e) {
|
|
@@ -560,6 +581,7 @@ public class JSONArray {
|
|
|
560
581
|
/**
|
|
561
582
|
* Get this entire array as a String array.
|
|
562
583
|
*
|
|
584
|
+
* @return
|
|
563
585
|
* @webref jsonarray:method
|
|
564
586
|
* @brief Gets the entire array as an array of Strings
|
|
565
587
|
* @see JSONArray#getIntArray()
|
|
@@ -574,8 +596,9 @@ public class JSONArray {
|
|
|
574
596
|
|
|
575
597
|
|
|
576
598
|
/**
|
|
577
|
-
* Get this entire array as an int array.
|
|
599
|
+
* Get this entire array as an int array.Everything must be an int.
|
|
578
600
|
*
|
|
601
|
+
* @return
|
|
579
602
|
* @webref jsonarray:method
|
|
580
603
|
* @brief Gets the entire array as array of ints
|
|
581
604
|
* @see JSONArray#getStringArray()
|
|
@@ -589,7 +612,8 @@ public class JSONArray {
|
|
|
589
612
|
}
|
|
590
613
|
|
|
591
614
|
|
|
592
|
-
/** Get this entire array as a long array.
|
|
615
|
+
/** * Get this entire array as a long array.Everything must be an long.
|
|
616
|
+
* @return */
|
|
593
617
|
public long[] getLongArray() {
|
|
594
618
|
long[] outgoing = new long[size()];
|
|
595
619
|
for (int i = 0; i < size(); i++) {
|
|
@@ -599,7 +623,8 @@ public class JSONArray {
|
|
|
599
623
|
}
|
|
600
624
|
|
|
601
625
|
|
|
602
|
-
/** Get this entire array as a float array.
|
|
626
|
+
/** * Get this entire array as a float array.Everything must be an float.
|
|
627
|
+
* @return */
|
|
603
628
|
public float[] getFloatArray() {
|
|
604
629
|
float[] outgoing = new float[size()];
|
|
605
630
|
for (int i = 0; i < size(); i++) {
|
|
@@ -609,7 +634,8 @@ public class JSONArray {
|
|
|
609
634
|
}
|
|
610
635
|
|
|
611
636
|
|
|
612
|
-
/** Get this entire array as a double array.
|
|
637
|
+
/** * Get this entire array as a double array.Everything must be an double.
|
|
638
|
+
* @return */
|
|
613
639
|
public double[] getDoubleArray() {
|
|
614
640
|
double[] outgoing = new double[size()];
|
|
615
641
|
for (int i = 0; i < size(); i++) {
|
|
@@ -619,7 +645,8 @@ public class JSONArray {
|
|
|
619
645
|
}
|
|
620
646
|
|
|
621
647
|
|
|
622
|
-
/** Get this entire array as a boolean array.
|
|
648
|
+
/** * Get this entire array as a boolean array.Everything must be a boolean.
|
|
649
|
+
* @return */
|
|
623
650
|
public boolean[] getBooleanArray() {
|
|
624
651
|
boolean[] outgoing = new boolean[size()];
|
|
625
652
|
for (int i = 0; i < size(); i++) {
|
|
@@ -802,6 +829,7 @@ public class JSONArray {
|
|
|
802
829
|
|
|
803
830
|
/**
|
|
804
831
|
* @param value a JSONArray value
|
|
832
|
+
* @return
|
|
805
833
|
*/
|
|
806
834
|
public JSONArray append(JSONArray value) {
|
|
807
835
|
myArrayList.add(value);
|
|
@@ -811,6 +839,7 @@ public class JSONArray {
|
|
|
811
839
|
|
|
812
840
|
/**
|
|
813
841
|
* @param value a JSONObject value
|
|
842
|
+
* @return
|
|
814
843
|
*/
|
|
815
844
|
public JSONArray append(JSONObject value) {
|
|
816
845
|
myArrayList.add(value);
|
|
@@ -974,6 +1003,7 @@ public class JSONArray {
|
|
|
974
1003
|
// }
|
|
975
1004
|
|
|
976
1005
|
/**
|
|
1006
|
+
* @return
|
|
977
1007
|
* @webref jsonarray:method
|
|
978
1008
|
* @brief Sets the JSONArray value associated with an index value
|
|
979
1009
|
* @param index the index value to target
|
|
@@ -988,6 +1018,7 @@ public class JSONArray {
|
|
|
988
1018
|
}
|
|
989
1019
|
|
|
990
1020
|
/**
|
|
1021
|
+
* @return
|
|
991
1022
|
* @webref jsonarray:method
|
|
992
1023
|
* @brief Sets the JSONObject value associated with an index value
|
|
993
1024
|
* @param index the index value to target
|
|
@@ -1098,6 +1129,13 @@ public class JSONArray {
|
|
|
1098
1129
|
// return write(PApplet.createWriter(output), null);
|
|
1099
1130
|
// }
|
|
1100
1131
|
|
|
1132
|
+
/**
|
|
1133
|
+
*
|
|
1134
|
+
* @param file
|
|
1135
|
+
* @param options
|
|
1136
|
+
* @return
|
|
1137
|
+
*/
|
|
1138
|
+
|
|
1101
1139
|
|
|
1102
1140
|
public boolean save(File file, String options) {
|
|
1103
1141
|
PrintWriter writer = PApplet.createWriter(file);
|
|
@@ -1106,13 +1144,22 @@ public class JSONArray {
|
|
|
1106
1144
|
return success;
|
|
1107
1145
|
}
|
|
1108
1146
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1147
|
+
/**
|
|
1148
|
+
*
|
|
1149
|
+
* @param output
|
|
1150
|
+
* @return
|
|
1151
|
+
*/
|
|
1152
|
+
public boolean write(PrintWriter output) {
|
|
1111
1153
|
return write(output, null);
|
|
1112
1154
|
}
|
|
1113
1155
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1156
|
+
/**
|
|
1157
|
+
*
|
|
1158
|
+
* @param output
|
|
1159
|
+
* @param options
|
|
1160
|
+
* @return
|
|
1161
|
+
*/
|
|
1162
|
+
public boolean write(PrintWriter output, String options) {
|
|
1116
1163
|
int indentFactor = 2;
|
|
1117
1164
|
if (options != null) {
|
|
1118
1165
|
String[] opts = PApplet.split(options, ',');
|
|
@@ -1136,9 +1183,10 @@ public class JSONArray {
|
|
|
1136
1183
|
|
|
1137
1184
|
|
|
1138
1185
|
/**
|
|
1139
|
-
* Return the JSON data formatted with two spaces for indents.
|
|
1140
|
-
*
|
|
1141
|
-
|
|
1186
|
+
* Return the JSON data formatted with two spaces for indents.Chosen to do this since it's the most common case (e.g.
|
|
1187
|
+
* with println()).
|
|
1188
|
+
Same as format(2). Use the format() function for more options.
|
|
1189
|
+
* @return
|
|
1142
1190
|
*/
|
|
1143
1191
|
@Override
|
|
1144
1192
|
public String toString() {
|
|
@@ -1186,6 +1234,7 @@ public class JSONArray {
|
|
|
1186
1234
|
* <p>
|
|
1187
1235
|
* Warning: This method assumes that the data structure is acyclic.
|
|
1188
1236
|
*
|
|
1237
|
+
* @param writer
|
|
1189
1238
|
* @param indentFactor
|
|
1190
1239
|
* The number of spaces to add to each level of indentation.
|
|
1191
1240
|
* Use -1 to specify no indentation and no newlines.
|
|
@@ -220,6 +220,7 @@ public class JSONObject {
|
|
|
220
220
|
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
|
+
* @param reader
|
|
223
224
|
* @nowebref
|
|
224
225
|
*/
|
|
225
226
|
public JSONObject(Reader reader) {
|
|
@@ -306,6 +307,7 @@ public class JSONObject {
|
|
|
306
307
|
|
|
307
308
|
|
|
308
309
|
/**
|
|
310
|
+
* @param dict
|
|
309
311
|
* @nowebref
|
|
310
312
|
*/
|
|
311
313
|
public JSONObject(IntDict dict) {
|
|
@@ -317,6 +319,7 @@ public class JSONObject {
|
|
|
317
319
|
|
|
318
320
|
|
|
319
321
|
/**
|
|
322
|
+
* @param dict
|
|
320
323
|
* @nowebref
|
|
321
324
|
*/
|
|
322
325
|
public JSONObject(FloatDict dict) {
|
|
@@ -328,6 +331,7 @@ public class JSONObject {
|
|
|
328
331
|
|
|
329
332
|
|
|
330
333
|
/**
|
|
334
|
+
* @param dict
|
|
331
335
|
* @nowebref
|
|
332
336
|
*/
|
|
333
337
|
public JSONObject(StringDict dict) {
|
|
@@ -389,11 +393,11 @@ public class JSONObject {
|
|
|
389
393
|
|
|
390
394
|
|
|
391
395
|
/**
|
|
392
|
-
* Construct a JSONObject from a source JSON text string.
|
|
393
|
-
* This is the most commonly used JSONObject constructor.
|
|
396
|
+
* Construct a JSONObject from a source JSON text string.This is the most commonly used JSONObject constructor.
|
|
394
397
|
* @param source A string beginning
|
|
395
398
|
* with <code>{</code> <small>(left brace)</small> and ending
|
|
396
399
|
* with <code>}</code> <small>(right brace)</small>.
|
|
400
|
+
* @return
|
|
397
401
|
* @exception RuntimeException If there is a syntax error in the source
|
|
398
402
|
* string or a duplicated key.
|
|
399
403
|
*/
|
|
@@ -678,6 +682,7 @@ public class JSONObject {
|
|
|
678
682
|
|
|
679
683
|
|
|
680
684
|
/**
|
|
685
|
+
* @return
|
|
681
686
|
* @webref jsonobject:method
|
|
682
687
|
* @brief Gets the float value associated with a key
|
|
683
688
|
* @param key a key string
|
|
@@ -689,8 +694,13 @@ public class JSONObject {
|
|
|
689
694
|
return (float) getDouble(key);
|
|
690
695
|
}
|
|
691
696
|
|
|
692
|
-
|
|
693
|
-
|
|
697
|
+
/**
|
|
698
|
+
*
|
|
699
|
+
* @param key
|
|
700
|
+
* @param defaultValue
|
|
701
|
+
* @return
|
|
702
|
+
*/
|
|
703
|
+
public float getFloat(String key, float defaultValue) {
|
|
694
704
|
try {
|
|
695
705
|
return getFloat(key);
|
|
696
706
|
} catch (Exception e) {
|
|
@@ -1156,6 +1166,7 @@ public class JSONObject {
|
|
|
1156
1166
|
|
|
1157
1167
|
|
|
1158
1168
|
/**
|
|
1169
|
+
* @return
|
|
1159
1170
|
* @webref jsonobject:method
|
|
1160
1171
|
* @brief Put a key/String pair in the JSONObject
|
|
1161
1172
|
* @param key a key string
|
|
@@ -1202,6 +1213,7 @@ public class JSONObject {
|
|
|
1202
1213
|
}
|
|
1203
1214
|
|
|
1204
1215
|
/**
|
|
1216
|
+
* @return
|
|
1205
1217
|
* @webref jsonobject:method
|
|
1206
1218
|
* @brief Put a key/float pair in the JSONObject
|
|
1207
1219
|
* @param key a key string
|
|
@@ -1250,6 +1262,7 @@ public class JSONObject {
|
|
|
1250
1262
|
}
|
|
1251
1263
|
|
|
1252
1264
|
/**
|
|
1265
|
+
* @return
|
|
1253
1266
|
* @webref jsonobject:method
|
|
1254
1267
|
* @brief Sets the JSONObject value associated with a key
|
|
1255
1268
|
* @param key a key string
|
|
@@ -1263,6 +1276,7 @@ public class JSONObject {
|
|
|
1263
1276
|
}
|
|
1264
1277
|
|
|
1265
1278
|
/**
|
|
1279
|
+
* @return
|
|
1266
1280
|
* @webref jsonobject:method
|
|
1267
1281
|
* @brief Sets the JSONArray value associated with a key
|
|
1268
1282
|
* @param key a key string
|
|
@@ -1399,7 +1413,14 @@ public class JSONObject {
|
|
|
1399
1413
|
}
|
|
1400
1414
|
}
|
|
1401
1415
|
|
|
1402
|
-
|
|
1416
|
+
/**
|
|
1417
|
+
*
|
|
1418
|
+
* @param string
|
|
1419
|
+
* @param w
|
|
1420
|
+
* @return
|
|
1421
|
+
* @throws IOException
|
|
1422
|
+
*/
|
|
1423
|
+
static public Writer quote(String string, Writer w) throws IOException {
|
|
1403
1424
|
if (string == null || string.length() == 0) {
|
|
1404
1425
|
w.write("\"\"");
|
|
1405
1426
|
return w;
|
|
@@ -1570,6 +1591,13 @@ public class JSONObject {
|
|
|
1570
1591
|
// return save(PApplet.createWriter(output));
|
|
1571
1592
|
// }
|
|
1572
1593
|
|
|
1594
|
+
/**
|
|
1595
|
+
*
|
|
1596
|
+
* @param file
|
|
1597
|
+
* @param options
|
|
1598
|
+
* @return
|
|
1599
|
+
*/
|
|
1600
|
+
|
|
1573
1601
|
|
|
1574
1602
|
public boolean save(File file, String options) {
|
|
1575
1603
|
PrintWriter writer = PApplet.createWriter(file);
|
|
@@ -1578,13 +1606,22 @@ public class JSONObject {
|
|
|
1578
1606
|
return success;
|
|
1579
1607
|
}
|
|
1580
1608
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1609
|
+
/**
|
|
1610
|
+
*
|
|
1611
|
+
* @param output
|
|
1612
|
+
* @return
|
|
1613
|
+
*/
|
|
1614
|
+
public boolean write(PrintWriter output) {
|
|
1583
1615
|
return write(output, null);
|
|
1584
1616
|
}
|
|
1585
1617
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1618
|
+
/**
|
|
1619
|
+
*
|
|
1620
|
+
* @param output
|
|
1621
|
+
* @param options
|
|
1622
|
+
* @return
|
|
1623
|
+
*/
|
|
1624
|
+
public boolean write(PrintWriter output, String options) {
|
|
1588
1625
|
int indentFactor = 2;
|
|
1589
1626
|
if (options != null) {
|
|
1590
1627
|
String[] opts = PApplet.split(options, ',');
|
|
@@ -1608,9 +1645,10 @@ public class JSONObject {
|
|
|
1608
1645
|
|
|
1609
1646
|
|
|
1610
1647
|
/**
|
|
1611
|
-
* Return the JSON data formatted with two spaces for indents.
|
|
1612
|
-
*
|
|
1613
|
-
|
|
1648
|
+
* Return the JSON data formatted with two spaces for indents.Chosen to do this since it's the most common case (e.g.
|
|
1649
|
+
* with println()).
|
|
1650
|
+
Same as format(2). Use the format() function for more options.
|
|
1651
|
+
* @return
|
|
1614
1652
|
*/
|
|
1615
1653
|
@Override
|
|
1616
1654
|
public String toString() {
|
|
@@ -1812,6 +1850,9 @@ public class JSONObject {
|
|
|
1812
1850
|
* <p>
|
|
1813
1851
|
* Warning: This method assumes that the data structure is acyclical.
|
|
1814
1852
|
*
|
|
1853
|
+
* @param writer
|
|
1854
|
+
* @param indentFactor
|
|
1855
|
+
* @param indent
|
|
1815
1856
|
* @return The writer.
|
|
1816
1857
|
* @throws RuntimeException
|
|
1817
1858
|
*/
|
|
@@ -7,18 +7,27 @@ package processing.data;
|
|
|
7
7
|
*/
|
|
8
8
|
public abstract class Sort implements Runnable {
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
public Sort() { }
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
public void run() {
|
|
14
19
|
int c = size();
|
|
15
20
|
if (c > 1) {
|
|
16
21
|
sort(0, c - 1);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param i
|
|
28
|
+
* @param j
|
|
29
|
+
*/
|
|
30
|
+
protected void sort(int i, int j) {
|
|
22
31
|
int pivotIndex = (i+j)/2;
|
|
23
32
|
swap(pivotIndex, j);
|
|
24
33
|
int k = partition(i-1, j);
|
|
@@ -27,8 +36,13 @@ public abstract class Sort implements Runnable {
|
|
|
27
36
|
if ((j-k) > 1) sort(k+1, j);
|
|
28
37
|
}
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param left
|
|
42
|
+
* @param right
|
|
43
|
+
* @return
|
|
44
|
+
*/
|
|
45
|
+
protected int partition(int left, int right) {
|
|
32
46
|
int pivot = right;
|
|
33
47
|
do {
|
|
34
48
|
while (compare(++left, pivot) < 0) { }
|
|
@@ -39,8 +53,24 @@ public abstract class Sort implements Runnable {
|
|
|
39
53
|
return left;
|
|
40
54
|
}
|
|
41
55
|
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @return
|
|
59
|
+
*/
|
|
60
|
+
abstract public int size();
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param a
|
|
65
|
+
* @param b
|
|
66
|
+
* @return
|
|
67
|
+
*/
|
|
68
|
+
abstract public float compare(int a, int b);
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param a
|
|
73
|
+
* @param b
|
|
74
|
+
*/
|
|
75
|
+
abstract public void swap(int a, int b);
|
|
46
76
|
}
|