Skip to content

Commit 362def0

Browse files
committed
2 parents f9741dd + c79fd2b commit 362def0

File tree

5 files changed

+140
-46
lines changed

5 files changed

+140
-46
lines changed

app/src/processing/app/EditorToolbar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList
7878

7979
protected ArrayList<Button> buttons;
8080

81-
static final int ARROW_WIDTH = 6;
81+
static final int ARROW_WIDTH = 7;
8282
static final int ARROW_HEIGHT = 6;
8383
static Image modeArrow;
8484

core/src/processing/data/JSONArray.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,12 @@ public boolean getBoolean(int index) {
391391
/**
392392
* Get the JSONArray associated with an index.
393393
*
394-
* @param index The index must be between 0 and length() - 1.
395-
* @return A JSONArray value.
394+
* @webref jsonobject:method
395+
* @brief Gets the JSONArray associated with an index value
396+
* @param index must be between 0 and length() - 1.
397+
* @return A JSONArray value.
396398
* @throws JSONException If there is no value for the index. or if the
397399
* value is not a JSONArray
398-
* @webref jsonarray:method
399-
* @brief Get the JSONArray associated with an index
400400
*/
401401
public JSONArray getJSONArray(int index) {
402402
Object object = this.get(index);
@@ -410,12 +410,12 @@ public JSONArray getJSONArray(int index) {
410410
/**
411411
* Get the JSONObject associated with an index.
412412
*
413-
* @param index subscript
414-
* @return A JSONObject value.
413+
* @webref jsonobject:method
414+
* @brief Gets the JSONObject associated with an index value
415+
* @param index the index value of the object to get
416+
* @return A JSONObject value.
415417
* @throws JSONException If there is no value for the index or if the
416418
* value is not a JSONObject
417-
* @webref jsonarray:method
418-
* @brief Get the JSONObject associated with an index
419419
*/
420420
public JSONObject getJSONObject(int index) {
421421
Object object = this.get(index);
@@ -928,7 +928,9 @@ public JSONArray setBoolean(int index, boolean value) {
928928

929929
/**
930930
* @webref jsonarray:method
931-
* @brief To come...
931+
* @brief Sets the JSONArray value associated with an index value
932+
* @param index the index value to target
933+
* @param value the value to assign
932934
*/
933935
public JSONArray setJSONArray(int index, JSONArray value) {
934936
set(index, value);
@@ -937,7 +939,9 @@ public JSONArray setJSONArray(int index, JSONArray value) {
937939

938940
/**
939941
* @webref jsonarray:method
940-
* @brief To come...
942+
* @brief Sets the JSONObject value associated with an index value
943+
* @param index the index value to target
944+
* @param value the value to assign
941945
*/
942946
public JSONArray setJSONObject(int index, JSONObject value) {
943947
set(index, value);
@@ -978,7 +982,7 @@ private JSONArray set(int index, Object value) {
978982
* Get the number of elements in the JSONArray, included nulls.
979983
*
980984
* @webref jsonarray:method
981-
* @brief Gets the number of elements in the JSONArray, included nulls
985+
* @brief Gets the number of elements in the JSONArray
982986
* @return The length (or size).
983987
*/
984988
public int size() {
@@ -1001,8 +1005,8 @@ protected boolean isNull(int index) {
10011005
* Remove an index and close the hole.
10021006
*
10031007
* @webref jsonarray:method
1004-
* @brief Remove an index and close the hole
1005-
* @param index The index of the element to be removed.
1008+
* @brief Removes an element
1009+
* @param index the index value of the element to be removed
10061010
* @return The value that was associated with the index, or null if there was no value.
10071011
*/
10081012
public Object remove(int index) {

core/src/processing/data/JSONObject.java

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ private Object get(String key) {
555555
/**
556556
* Gets the String associated with a key
557557
*
558-
* @param key A key string.
559-
* @return A string which is the value.
560-
* @throws JSONException if there is no string value for the key.
561558
* @webref jsonobject:method
562559
* @brief Gets the string associated with a key
560+
* @param key a key string
561+
* @return A string which is the value.
562+
* @throws JSONException if there is no string value for the key.
563563
*/
564564
public String getString(String key) {
565565
Object object = this.get(key);
@@ -573,12 +573,12 @@ public String getString(String key) {
573573
/**
574574
* Gets the int value associated with a key
575575
*
576-
* @param key A key string.
577-
* @return The integer value.
578-
* @throws JSONException if the key is not found or if the value cannot
579-
* be converted to an integer.
580576
* @webref jsonobject:method
581577
* @brief Gets the int value associated with a key
578+
* @param key a key string
579+
* @return The integer value.
580+
* @throws JSONException if the key is not found or if the value cannot
581+
* be converted to an integer.
582582
*/
583583
public int getInt(String key) {
584584
Object object = this.get(key);
@@ -613,7 +613,8 @@ public long getLong(String key) {
613613

614614
/**
615615
* @webref jsonobject:method
616-
* @brief To come...
616+
* @brief Gets the float value associated with a key
617+
* @param key a key string
617618
*/
618619
public float getFloat(String key) {
619620
return (float) getDouble(key);
@@ -642,11 +643,11 @@ public double getDouble(String key) {
642643
/**
643644
* Get the boolean value associated with a key.
644645
*
645-
* @param key A key string.
646-
* @return The truth.
647-
* @throws JSONException if the value is not a Boolean or the String "true" or "false".
648646
* @webref jsonobject:method
649647
* @brief Gets the boolean value associated with a key
648+
* @param key a key string
649+
* @return The truth.
650+
* @throws JSONException if the value is not a Boolean or the String "true" or "false".
650651
*/
651652
public boolean getBoolean(String key) {
652653
Object object = this.get(key);
@@ -666,11 +667,11 @@ public boolean getBoolean(String key) {
666667
/**
667668
* Get the JSONArray value associated with a key.
668669
*
669-
* @brief Gets the JSONArray value associated with a key
670670
* @webref jsonobject:method
671-
* @param key A key string
672-
* @return A JSONArray which is the value.
673-
* @throws JSONException if the key is not found or if the value is not a JSONArray.
671+
* @brief Gets the JSONArray value associated with a key
672+
* @param key a key string
673+
* @return A JSONArray which is the value.
674+
* @throws JSONException if the key is not found or if the value is not a JSONArray.
674675
*/
675676
public JSONArray getJSONArray(String key) {
676677
Object object = this.get(key);
@@ -684,11 +685,11 @@ public JSONArray getJSONArray(String key) {
684685
/**
685686
* Get the JSONObject value associated with a key.
686687
*
687-
* @param key A key string.
688-
* @return A JSONObject which is the value.
689-
* @throws JSONException if the key is not found or if the value is not a JSONObject.
690688
* @webref jsonobject:method
691689
* @brief Gets the JSONObject value associated with a key
690+
* @param key a key string
691+
* @return A JSONObject which is the value.
692+
* @throws JSONException if the key is not found or if the value is not a JSONObject.
692693
*/
693694
public JSONObject getJSONObject(String key) {
694695
Object object = this.get(key);
@@ -1113,7 +1114,9 @@ private void populateMap(Object bean) {
11131114

11141115
/**
11151116
* @webref jsonobject:method
1116-
* @brief To come...
1117+
* @brief Put a key/String pair in the JSONObject
1118+
* @param key a key string
1119+
* @param value the value to assign
11171120
*/
11181121
public JSONObject setString(String key, String value) {
11191122
return put(key, value);
@@ -1123,12 +1126,12 @@ public JSONObject setString(String key, String value) {
11231126
/**
11241127
* Put a key/int pair in the JSONObject.
11251128
*
1126-
* @param key A key string.
1127-
* @param value An int which is the value.
1128-
* @return this.
1129-
* @throws JSONException If the key is null.
11301129
* @webref jsonobject:method
11311130
* @brief Put a key/int pair in the JSONObject
1131+
* @param key a key string
1132+
* @param value the value to assign
1133+
* @return this.
1134+
* @throws JSONException If the key is null.
11321135
*/
11331136
public JSONObject setInt(String key, int value) {
11341137
this.put(key, new Integer(value));
@@ -1151,7 +1154,9 @@ public JSONObject setLong(String key, long value) {
11511154

11521155
/**
11531156
* @webref jsonobject:method
1154-
* @brief To come...
1157+
* @brief Put a key/float pair in the JSONObject
1158+
* @param key a key string
1159+
* @param value the value to assign
11551160
*/
11561161
public JSONObject setFloat(String key, float value) {
11571162
this.put(key, new Double(value));
@@ -1176,12 +1181,12 @@ public JSONObject setDouble(String key, double value) {
11761181
/**
11771182
* Put a key/boolean pair in the JSONObject.
11781183
*
1179-
* @param key A key string.
1180-
* @param value A boolean which is the value.
1181-
* @return this.
1182-
* @throws JSONException If the key is null.
11831184
* @webref jsonobject:method
11841185
* @brief Put a key/boolean pair in the JSONObject
1186+
* @param key a key string
1187+
* @param value the value to assign
1188+
* @return this.
1189+
* @throws JSONException If the key is null.
11851190
*/
11861191
public JSONObject setBoolean(String key, boolean value) {
11871192
this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
@@ -1190,15 +1195,19 @@ public JSONObject setBoolean(String key, boolean value) {
11901195

11911196
/**
11921197
* @webref jsonobject:method
1193-
* @brief To come...
1198+
* @brief Sets the JSONObject value associated with a key
1199+
* @param key a key string
1200+
* @param value value to assign
11941201
*/
11951202
public JSONObject setJSONObject(String key, JSONObject value) {
11961203
return put(key, value);
11971204
}
11981205

11991206
/**
12001207
* @webref jsonobject:method
1201-
* @brief To come...
1208+
* @brief Sets the JSONArray value associated with a key
1209+
* @param key a key string
1210+
* @param value value to assign
12021211
*/
12031212
public JSONObject setJSONArray(String key, JSONArray value) {
12041213
return put(key, value);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
IntList lottery;
3+
IntList results;
4+
IntList ticket;
5+
6+
void setup() {
7+
size(640, 360);
8+
frameRate(30);
9+
lottery = new IntList();
10+
results = new IntList();
11+
ticket = new IntList();
12+
// Let's add some numbers to our list
13+
for (int i = 0; i < 20; i++) {
14+
lottery.append(i);
15+
}
16+
17+
for (int i = 0; i < 5; i++) {
18+
int index = int(random(lottery.size()));
19+
ticket.append(lottery.get(index));
20+
}
21+
}
22+
23+
void draw() {
24+
background(51);
25+
26+
lottery.shuffle();
27+
28+
showList(lottery, 16, 48);
29+
showList(results, 16, 100);
30+
showList(ticket, 16, 140);
31+
32+
for (int i = 0; i < results.size(); i++) {
33+
if (results.get(i) == ticket.get(i)) {
34+
fill(0, 255, 0, 100);
35+
}
36+
else {
37+
fill(255, 0, 0, 100);
38+
}
39+
ellipse(16+i*32, 140, 24, 24);
40+
}
41+
42+
if (frameCount % 30 == 0) {
43+
// Pick a new lottery number!
44+
if (results.size() < 5) {
45+
int val = lottery.get(0);
46+
lottery.remove(0);
47+
results.append(val);
48+
} else {
49+
// Ok we picked five numbers, let's reset
50+
for (int i = 0; i < results.size(); i++) {
51+
lottery.append(results.get(i));
52+
}
53+
results.clear();
54+
}
55+
}
56+
}
57+
58+
void showList(IntList list, float x, float y) {
59+
for (int i = 0; i < list.size(); i++) {
60+
int val = list.get(i);
61+
stroke(255);
62+
noFill();
63+
ellipse(x+i*32, y, 24, 24);
64+
textAlign(CENTER);
65+
fill(255);
66+
text(val, x+i*32, y+6);
67+
}
68+
}
69+

java/keywords.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ getString FUNCTION2 JSONObject_getString_
563563
setBoolean FUNCTION2 JSONObject_setBoolean_
564564
setFloat FUNCTION2 JSONObject_setFloat_
565565
setInt FUNCTION2 JSONObject_setInt_
566-
getJSONArrayFUNCTION2 JSONObject_setJSONArray_
567-
getJSONObjectFUNCTION2 JSONObject_setJSONObject_
566+
setJSONArrayFUNCTION2 JSONObject_setJSONArray_
567+
setJSONObjectFUNCTION2 JSONObject_setJSONObject_
568568
setString FUNCTION2 JSONObject_setString_
569569
key KEYWORD4 key
570570
keyCode KEYWORD4 keyCode
@@ -610,6 +610,7 @@ mouseMoved FUNCTION4 mouseMoved
610610
mousePressed FUNCTION4 mousePressed
611611
mousePressed KEYWORD4 mousePressed
612612
mouseReleased FUNCTION1 mouseReleased_
613+
mouseWheel FUNCTION4 mouseWheel
613614
mouseX KEYWORD4 mouseX
614615
mouseY KEYWORD4 mouseY
615616
nf FUNCTION1 nf_
@@ -674,6 +675,7 @@ enableStyle FUNCTION2 PShape_enableStyle_
674675
endContour FUNCTION2 PShape_endContour_
675676
endShape FUNCTION2 PShape_endShape_
676677
getChild FUNCTION2 PShape_getChild_
678+
getChildCount FUNCTION2 PShape_getChildCount_
677679
getVertex FUNCTION2 PShape_getVertex_
678680
getVertexCount FUNCTION2 PShape_getVertexCount_
679681
isVisible FUNCTION2 PShape_isVisible_
@@ -695,6 +697,7 @@ array FUNCTION2 PVector_array_
695697
copy FUNCTION2 PVector_copy_
696698
cross FUNCTION2 PVector_cross_
697699
dist FUNCTION2 PVector_dist_
700+
div FUNCTION2 PVector_div_
698701
dot FUNCTION2 PVector_dot_
699702
fromAngle FUNCTION2 PVector_fromAngle_
700703
get FUNCTION2 PVector_get_
@@ -703,6 +706,7 @@ lerp FUNCTION2 PVector_lerp_
703706
limit FUNCTION2 PVector_limit_
704707
mag FUNCTION2 PVector_mag_
705708
magSq FUNCTION2 PVector_magSq_
709+
mult FUNCTION2 PVector_mult_
706710
normalize FUNCTION2 PVector_normalize_
707711
random2D FUNCTION2 PVector_random2D_
708712
random3D FUNCTION2 PVector_random3D_
@@ -812,15 +816,21 @@ clearRows FUNCTION2 Table_clearRows_
812816
findRow FUNCTION2 Table_findRow_
813817
findRows FUNCTION2 Table_findRows_
814818
getColumnCount FUNCTION2 Table_getColumnCount_
819+
getFloat FUNCTION2 Table_getFloat_
820+
getInt FUNCTION2 Table_getInt_
815821
getRow FUNCTION2 Table_getRow_
816822
getRowCount FUNCTION2 Table_getRowCount_
823+
getString FUNCTION2 Table_getString_
817824
getStringColumn FUNCTION2 Table_getStringColumn_
818825
matchRow FUNCTION2 Table_matchRow_
819826
matchRows FUNCTION2 Table_matchRows_
820827
removeColumn FUNCTION2 Table_removeColumn_
821828
removeRow FUNCTION2 Table_removeRow_
822829
removeTokens FUNCTION2 Table_removeTokens_
823830
rows FUNCTION2 Table_rows_
831+
setFloat FUNCTION2 Table_setFloat_
832+
setInt FUNCTION2 Table_setInt_
833+
setString FUNCTION2 Table_setString_
824834
trim FUNCTION2 Table_trim_
825835
TableRow KEYWORD5 TableRow
826836
getFloat FUNCTION2 TableRow_getFloat_
@@ -860,7 +870,9 @@ getChild FUNCTION2 XML_getChild_
860870
getChildren FUNCTION2 XML_getChildren_
861871
getContent FUNCTION2 XML_getContent_
862872
getFloat FUNCTION2 XML_getFloat_
873+
getContent FUNCTION2 XML_getFloatContent_
863874
getInt FUNCTION2 XML_getInt_
875+
getContent FUNCTION2 XML_getIntContent_
864876
getName FUNCTION2 XML_getName_
865877
getParent FUNCTION2 XML_getParent_
866878
getString FUNCTION2 XML_getString_

0 commit comments

Comments
 (0)