From eb326b712583e0aaa8d065a94f2075c48f3afdf6 Mon Sep 17 00:00:00 2001 From: REAS Date: Sat, 18 May 2013 22:01:26 -0700 Subject: [PATCH] Modifications to Data classes for Reference entries --- core/src/processing/core/PApplet.java | 21 ++++--- core/src/processing/data/FloatDict.java | 2 + core/src/processing/data/FloatList.java | 3 + core/src/processing/data/IntDict.java | 2 + core/src/processing/data/IntList.java | 1 + core/src/processing/data/JSONArray.java | 55 ++++++++++++++++-- core/src/processing/data/JSONObject.java | 48 ++++++++++++---- core/src/processing/data/StringDict.java | 2 + core/src/processing/data/StringList.java | 4 +- core/src/processing/data/Table.java | 72 +++++++++++++++++++----- core/src/processing/data/TableRow.java | 37 +++++++++++- java/keywords.txt | 16 +++++- 12 files changed, 222 insertions(+), 41 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 92d8d8013..388ea6530 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -6037,7 +6037,6 @@ public class PApplet extends Applet * @webref input:files * @param filename name of a file in the data folder or a URL. * @see XML - * @see PApplet#createXML(String) * @see PApplet#parseXML(String) * @see PApplet#saveXML(XML, String) * @see PApplet#loadBytes(String) @@ -6069,7 +6068,6 @@ public class PApplet extends Applet * @param data the content to be parsed as XML * @return an XML object, or null * @see XML - * @see PApplet#createXML(String) * @see PApplet#loadXML(String) * @see PApplet#saveXML(XML, String) */ @@ -6093,7 +6091,6 @@ public class PApplet extends Applet * @param xml the XML object to save to disk * @param filename name of the file to write to * @see XML - * @see PApplet#createXML(String) * @see PApplet#loadXML(String) * @see PApplet#parseXML(String) */ @@ -6111,12 +6108,16 @@ public class PApplet extends Applet return new JSONObject(new StringReader(input)); } - + /** + * @webref output:files + */ public JSONObject loadJSONObject(String filename) { return new JSONObject(createReader(filename)); } - + /** + * @webref output:files + */ public boolean saveJSONObject(JSONObject json, String filename) { return saveJSONObject(json, filename, null); } @@ -6131,12 +6132,16 @@ public class PApplet extends Applet return new JSONArray(new StringReader(input)); } - + /** + * @webref output:files + */ public JSONArray loadJSONArray(String filename) { return new JSONArray(createReader(filename)); } - + /** + * @webref output:files + */ public boolean saveJSONArray(JSONArray json, String filename) { return saveJSONArray(json, filename); } @@ -6163,7 +6168,6 @@ public class PApplet extends Applet * @webref input:files * @param filename name of a file in the data folder or a URL. * @see Table - * @see PApplet#createTable() * @see PApplet#saveTable(Table, String) * @see PApplet#loadBytes(String) * @see PApplet#loadStrings(String) @@ -6204,7 +6208,6 @@ public class PApplet extends Applet * @param table the Table object to save to a file * @param filename the filename to which the Table should be saved * @see Table - * @see PApplet#createTable() * @see PApplet#loadTable(String) */ public boolean saveTable(Table table, String filename) { diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index 7d0f91c7b..c2d02cdfc 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -9,6 +9,8 @@ import processing.core.PApplet; /** * A simple table class to use a String as a lookup for an float value. + * + * @webref data:composite */ public class FloatDict { diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 8a34c2511..79c54f214 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -7,6 +7,9 @@ import java.util.Random; import processing.core.PApplet; +/** + * @webref data:composite + */ public class FloatList implements Iterable { int count; float[] data; diff --git a/core/src/processing/data/IntDict.java b/core/src/processing/data/IntDict.java index 424aaf7ad..72105d26b 100644 --- a/core/src/processing/data/IntDict.java +++ b/core/src/processing/data/IntDict.java @@ -9,6 +9,8 @@ import processing.core.PApplet; /** * A simple class to use a String as a lookup for an int value. + * + * @webref data:composite */ public class IntDict { diff --git a/core/src/processing/data/IntList.java b/core/src/processing/data/IntList.java index a833d23db..c4c726bfc 100644 --- a/core/src/processing/data/IntList.java +++ b/core/src/processing/data/IntList.java @@ -16,6 +16,7 @@ import processing.core.PApplet; * Helper class for a list of ints. By design (for efficiency), functions like * sort() and shuffle() always act on the list itself. To get a sorted copy, * use list.copy().sort(). + * @webref data:composite */ public class IntList implements Iterable { protected int count; diff --git a/core/src/processing/data/JSONArray.java b/core/src/processing/data/JSONArray.java index 349704599..2d74ef602 100644 --- a/core/src/processing/data/JSONArray.java +++ b/core/src/processing/data/JSONArray.java @@ -91,6 +91,7 @@ import processing.core.PApplet; * * @author JSON.org * @version 2012-11-13 + * @webref data:composite */ public class JSONArray { @@ -258,6 +259,8 @@ public class JSONArray { * @param index The index must be between 0 and length() - 1. * @return A string value. * @throws JSONException If there is no string value for the index. + * @webref jsonarray:method + * @brief Get the string associated with an index */ public String getString(int index) { Object object = this.get(index); @@ -274,6 +277,8 @@ public class JSONArray { * @param index The index must be between 0 and length() - 1. * @return The value. * @throws JSONException If the key is not found or if the value is not a number. + * @webref jsonarray:method + * @brief Get the int value associated with an index */ public int getInt(int index) { Object object = this.get(index); @@ -310,6 +315,9 @@ public class JSONArray { /** * Get a value from an index as a float. JSON uses 'double' values * internally, so this is simply getDouble() cast to a float. + * + * @webref jsonarray:method + * @brief To come... */ public float getFloat(int index) { return (float) getDouble(index); @@ -344,6 +352,8 @@ public class JSONArray { * @return The truth. * @throws JSONException If there is no value for the index or if the * value is not convertible to boolean. + * @webref jsonarray:method + * @brief Get the boolean value associated with an index */ public boolean getBoolean(int index) { Object object = this.get(index); @@ -362,10 +372,13 @@ public class JSONArray { /** * Get the JSONArray associated with an index. + * * @param index The index must be between 0 and length() - 1. * @return A JSONArray value. * @throws JSONException If there is no value for the index. or if the * value is not a JSONArray + * @webref jsonarray:method + * @brief Get the JSONArray associated with an index */ public JSONArray getJSONArray(int index) { Object object = this.get(index); @@ -378,10 +391,13 @@ public class JSONArray { /** * Get the JSONObject associated with an index. + * * @param index subscript * @return A JSONObject value. * @throws JSONException If there is no value for the index or if the * value is not a JSONObject + * @webref jsonarray:method + * @brief Get the JSONObject associated with an index */ public JSONObject getJSONObject(int index) { Object object = this.get(index); @@ -392,7 +408,12 @@ public class JSONArray { } - /** Get this entire array as a String array. */ + /** + * Get this entire array as a String array. + * + * @webref jsonarray:method + * @brief Get this entire array as a String array + */ public String[] getStringArray() { String[] outgoing = new String[size()]; for (int i = 0; i < size(); i++) { @@ -402,7 +423,12 @@ public class JSONArray { } - /** Get this entire array as an int array. Everything must be an int. */ + /** + * Get this entire array as an int array. Everything must be an int. + * + * @webref jsonarray:method + * @brief Get this entire array as an int array + */ public int[] getIntArray() { int[] outgoing = new int[size()]; for (int i = 0; i < size(); i++) { @@ -634,6 +660,8 @@ public class JSONArray { * * @param value A String value. * @return this. + * @webref jsonarray:method + * @brief Append an String value. This increases the array's length by one. */ public JSONArray append(String value) { this.append((Object)value); @@ -777,6 +805,8 @@ public class JSONArray { * @param value A String value. * @return this. * @throws JSONException If the index is negative. + * @webref jsonarray:method + * @brief Put or replace a String value */ public JSONArray setString(int index, String value) { this.set(index, value); @@ -792,6 +822,8 @@ public class JSONArray { * @param value An int value. * @return this. * @throws JSONException If the index is negative. + * @webref jsonarray:method + * @brief Put or replace an int value */ public JSONArray setInt(int index, int value) { this.set(index, new Integer(value)); @@ -823,6 +855,8 @@ public class JSONArray { * @return this. * @throws RuntimeException If the index is negative or if the value is * not finite. + * @webref jsonarray:method + * @brief Put or replace a float value */ public JSONArray setFloat(int index, float value) { return setDouble(index, value); @@ -852,6 +886,8 @@ public class JSONArray { * @param value A boolean value. * @return this. * @throws JSONException If the index is negative. + * @webref jsonarray:method + * @brief Put or replace a boolean value */ public JSONArray setBoolean(int index, boolean value) { return set(index, value ? Boolean.TRUE : Boolean.FALSE); @@ -872,13 +908,19 @@ public class JSONArray { // return this; // } - + /** + * @webref jsonarray:method + * @brief To come... + */ public JSONArray setJSONArray(int index, JSONArray value) { set(index, value); return this; } - + /** + * @webref jsonarray:method + * @brief To come... + */ public JSONArray setJSONObject(int index, JSONObject value) { set(index, value); return this; @@ -918,6 +960,8 @@ public class JSONArray { * Get the number of elements in the JSONArray, included nulls. * * @return The length (or size). + * @webref jsonarray:method + * @brief Get the number of elements in the JSONArray, included nulls */ public int size() { return myArrayList.size(); @@ -937,9 +981,12 @@ public class JSONArray { /** * Remove an index and close the hole. + * * @param index The index of the element to be removed. * @return The value that was associated with the index, * or null if there was no value. + * @webref jsonarray:method + * @brief Remove an index and close the hole */ public Object remove(int index) { Object o = this.opt(index); diff --git a/core/src/processing/data/JSONObject.java b/core/src/processing/data/JSONObject.java index 02d18b77b..589066d8b 100644 --- a/core/src/processing/data/JSONObject.java +++ b/core/src/processing/data/JSONObject.java @@ -103,6 +103,7 @@ import processing.core.PApplet; * * @author JSON.org * @version 2012-12-01 + * @webref data:composite */ public class JSONObject { /** @@ -539,6 +540,8 @@ public class JSONObject { * @param key A key string. * @return A string which is the value. * @throws JSONException if there is no string value for the key. + * @webref jsonobject:method + * @brief Get the string associated with a key */ public String getString(String key) { Object object = this.get(key); @@ -556,6 +559,8 @@ public class JSONObject { * @return The integer value. * @throws JSONException if the key is not found or if the value cannot * be converted to an integer. + * @webref jsonobject:method + * @brief Get the int value associated with a key */ public int getInt(String key) { Object object = this.get(key); @@ -588,7 +593,10 @@ public class JSONObject { } } - + /** + * @webref jsonobject:method + * @brief To come... + */ public float getFloat(String key) { return (float) getDouble(key); } @@ -618,8 +626,9 @@ public class JSONObject { * * @param key A key string. * @return The truth. - * @throws JSONException - * if the value is not a Boolean or the String "true" or "false". + * @throws JSONException if the value is not a Boolean or the String "true" or "false". + * @webref jsonobject:method + * @brief Get the boolean value associated with a key */ public boolean getBoolean(String key) { Object object = this.get(key); @@ -641,8 +650,9 @@ public class JSONObject { * * @param key A key string. * @return A JSONArray which is the value. - * @throws JSONException if the key is not found or - * if the value is not a JSONArray. + * @throws JSONException if the key is not found or if the value is not a JSONArray. + * @webref jsonobject:method + * @brief Get the JSONArray value associated with a key */ public JSONArray getJSONArray(String key) { Object object = this.get(key); @@ -658,8 +668,9 @@ public class JSONObject { * * @param key A key string. * @return A JSONObject which is the value. - * @throws JSONException if the key is not found or - * if the value is not a JSONObject. + * @throws JSONException if the key is not found or if the value is not a JSONObject. + * @webref jsonobject:method + * @brief Get the JSONObject value associated with a key */ public JSONObject getJSONObject(String key) { Object object = this.get(key); @@ -1082,6 +1093,10 @@ public class JSONObject { } + /** + * @webref jsonobject:method + * @brief To come... + */ public JSONObject setString(String key, String value) { return put(key, value); } @@ -1094,6 +1109,8 @@ public class JSONObject { * @param value An int which is the value. * @return this. * @throws JSONException If the key is null. + * @webref jsonobject:method + * @brief Put a key/int pair in the JSONObject */ public JSONObject setInt(String key, int value) { this.put(key, new Integer(value)); @@ -1114,7 +1131,10 @@ public class JSONObject { return this; } - + /** + * @webref jsonobject:method + * @brief To come... + */ public JSONObject setFloat(String key, float value) { this.put(key, new Double(value)); return this; @@ -1142,18 +1162,26 @@ public class JSONObject { * @param value A boolean which is the value. * @return this. * @throws JSONException If the key is null. + * @webref jsonobject:method + * @brief Put a key/boolean pair in the JSONObject */ public JSONObject setBoolean(String key, boolean value) { this.put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** + * @webref jsonobject:method + * @brief To come... + */ public JSONObject setJSONObject(String key, JSONObject value) { return put(key, value); } - + /** + * @webref jsonobject:method + * @brief To come... + */ public JSONObject setJSONArray(String key, JSONArray value) { return put(key, value); } diff --git a/core/src/processing/data/StringDict.java b/core/src/processing/data/StringDict.java index 93c3dce54..de71e84bb 100644 --- a/core/src/processing/data/StringDict.java +++ b/core/src/processing/data/StringDict.java @@ -9,6 +9,8 @@ import processing.core.PApplet; /** * A simple table class to use a String as a lookup for another String value. + * + * @webref data:composite */ public class StringDict { diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index 228ffc0f2..4cf685b7b 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -6,7 +6,9 @@ import java.util.Random; import processing.core.PApplet; - +/** + * @webref data:composite + */ public class StringList implements Iterable { int count; String[] data; diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index d6e9f9a1f..b84ad37cb 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -1294,12 +1294,14 @@ public class Table { } } - + /** + * @webref table:method + * @brief Removes a column from the table + */ public void removeColumn(String columnName) { removeColumn(getColumnIndex(columnName)); } - public void removeColumn(int column) { int newCount = columns.length - 1; @@ -1331,7 +1333,10 @@ public class Table { } } - + /** + * @webref table:method + * @brief To come... + */ public int getColumnCount() { return columns.length; } @@ -1655,7 +1660,10 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** + * @webref table:method + * @brief To come... + */ public int getRowCount() { return rowCount; } @@ -1665,7 +1673,10 @@ public class Table { return getRowCount() - 1; } - + /** + * @webref table:method + * @brief Removes all rows from a table + */ public void clearRows() { setRowCount(0); } @@ -1702,7 +1713,10 @@ public class Table { rowCount = newCount; } - + /** + * @webref table:method + * @brief Adds a row to the table + */ public TableRow addRow() { setRowCount(rowCount + 1); return new RowPointer(this, rowCount - 1); @@ -1791,7 +1805,10 @@ public class Table { rowCount++; } - + /** + * @webref table:method + * @brief Removes a row from the table + */ public void removeRow(int row) { for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { @@ -1986,7 +2003,10 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** + * @webref table:method + * @brief Gets a row from the table + */ public TableRow getRow(int row) { return new RowPointer(this, row); } @@ -1996,6 +2016,9 @@ public class Table { * Note that this one iterator instance is shared by any calls to iterate * the rows of this table. This is very efficient, but not thread-safe. * If you want to iterate in a multi-threaded manner, don't use the iterator. + * + * @webref table:method + * @brief To come... */ public Iterable rows() { return new Iterable() { @@ -2751,7 +2774,10 @@ public class Table { setString(row, column, value); } - + /** + * @webref table:method + * @brief To come... + */ public String[] getStringColumn(String name) { int col = getColumnIndex(name); return (col == -1) ? null : getStringColumn(col); @@ -2880,7 +2906,10 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** + * @webref table:method + * @brief To come... + */ public TableRow findRow(String value, int column) { int row = findRowIndex(value, column); return (row == -1) ? null : new RowPointer(this, row); @@ -2891,7 +2920,10 @@ public class Table { return findRow(value, getColumnIndex(columnName)); } - + /** + * @webref table:method + * @brief To come... + */ public Iterator findRows(String value, int column) { return new RowIndexIterator(this, findRowIndices(value, column)); } @@ -2988,7 +3020,10 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** + * @webref table:method + * @brief To come... + */ public TableRow matchRow(String regexp, int column) { int row = matchRowIndex(regexp, column); return (row == -1) ? null : new RowPointer(this, row); @@ -2999,7 +3034,10 @@ public class Table { return matchRow(regexp, getColumnIndex(columnName)); } - + /** + * @webref table:method + * @brief To come... + */ public Iterator matchRows(String value, int column) { return new RowIndexIterator(this, matchRowIndices(value, column)); } @@ -3085,6 +3123,9 @@ public class Table { /** * Remove any of the specified characters from the entire table. + * + * @webref table:method + * @brief Remove characters from the entire table */ public void removeTokens(String tokens) { for (int col = 0; col < getColumnCount(); col++) { @@ -3129,7 +3170,10 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** + * @webref table:method + * @brief To come... + */ public void trim() { for (int col = 0; col < getColumnCount(); col++) { trim(col); diff --git a/core/src/processing/data/TableRow.java b/core/src/processing/data/TableRow.java index 82b191a8e..d5b65cee3 100644 --- a/core/src/processing/data/TableRow.java +++ b/core/src/processing/data/TableRow.java @@ -1,26 +1,61 @@ package processing.data; - +/** + * @webref data:composite + */ public interface TableRow { + + /** + * @webref tablerow:method + * @brief Get the String value from a column + */ public String getString(int column); public String getString(String columnName); + + /** + * @webref tablerow:method + * @brief Get the int value from a column + */ public int getInt(int column); public int getInt(String columnName); + public long getLong(int column); public long getLong(String columnName); + + /** + * @webref tablerow:method + * @brief Get the float value from a column + */ public float getFloat(int column); public float getFloat(String columnName); + public double getDouble(int column); public double getDouble(String columnName); + /** + * @webref tablerow:method + * @brief Set the String value in a column + */ public void setString(int column, String value); public void setString(String columnName, String value); + + /** + * @webref tablerow:method + * @brief Set the int value in a column + */ public void setInt(int column, int value); public void setInt(String columnName, int value); + public void setLong(int column, long value); public void setLong(String columnName, long value); + + /** + * @webref tablerow:method + * @brief Set the float value in a column + */ public void setFloat(int column, float value); public void setFloat(String columnName, float value); + public void setDouble(int column, double value); public void setDouble(String columnName, double value); diff --git a/java/keywords.txt b/java/keywords.txt index 4cf38720c..3c2fa7f69 100644 --- a/java/keywords.txt +++ b/java/keywords.txt @@ -443,6 +443,8 @@ exp FUNCTION1 exp_ expand FUNCTION1 expand_ fill FUNCTION1 fill_ filter FUNCTION1 filter_ +FloatDict KEYWORD5 FloatDict +FloatList KEYWORD5 FloatList floor FUNCTION1 floor_ focused KEYWORD4 focused frameCount KEYWORD4 frameCount @@ -458,7 +460,11 @@ hour FUNCTION1 hour_ hue FUNCTION1 hue_ image FUNCTION1 image_ imageMode FUNCTION1 imageMode_ +IntDict KEYWORD5 IntDict +IntList KEYWORD5 IntList join FUNCTION1 join_ +JSONArray KEYWORD5 JSONArray +JSONObject KEYWORD5 JSONObject key KEYWORD4 key keyCode KEYWORD4 keyCode keyPressed FUNCTION4 keyPressed @@ -474,6 +480,8 @@ line FUNCTION1 line_ loadBytes FUNCTION1 loadBytes_ loadFont FUNCTION1 loadFont_ loadImage FUNCTION1 loadImage_ +loadJSONArray FUNCTION1 loadJSONArray_ +loadJSONObject FUNCTION1 loadJSONObject_ loadPixels FUNCTION1 loadPixels_ loadShader FUNCTION1 loadShader_ loadShape FUNCTION1 loadShape_ @@ -586,7 +594,6 @@ array FUNCTION2 PVector_array_ copy FUNCTION2 PVector_copy_ cross FUNCTION2 PVector_cross_ dist FUNCTION2 PVector_dist_ -div FUNCTION2 PVector_div_ dot FUNCTION2 PVector_dot_ fromAngle FUNCTION2 PVector_fromAngle_ get FUNCTION2 PVector_get_ @@ -595,7 +602,6 @@ lerp FUNCTION2 PVector_lerp_ limit FUNCTION2 PVector_limit_ mag FUNCTION2 PVector_mag_ magSq FUNCTION2 PVector_magSq_ -mult FUNCTION2 PVector_mult_ normalize FUNCTION2 PVector_normalize_ random2D FUNCTION2 PVector_random2D_ random3D FUNCTION2 PVector_random3D_ @@ -627,6 +633,8 @@ saturation FUNCTION1 saturation_ save FUNCTION1 save_ saveBytes FUNCTION1 saveBytes_ saveFrame FUNCTION1 saveFrame_ +saveJSONArray FUNCTION1 saveJSONArray_ +saveJSONObject FUNCTION1 saveJSONObject_ saveStream FUNCTION1 saveStream_ saveStrings FUNCTION1 saveStrings_ loadTable FUNCTION1 saveTable_ @@ -661,12 +669,16 @@ splitTokens FUNCTION1 splitTokens_ spotLight FUNCTION1 spotLight_ sq FUNCTION1 sq_ sqrt FUNCTION1 sqrt_ +StringDict KEYWORD5 StringDict +StringList KEYWORD5 StringList stroke FUNCTION1 stroke_ strokeCap FUNCTION1 strokeCap_ strokeJoin FUNCTION1 strokeJoin_ strokeWeight FUNCTION1 strokeWeight_ subset FUNCTION1 subset_ Table KEYWORD5 Table +addColumn FUNCTION2 Table_addColumn_ +TableRow KEYWORD5 TableRow tan FUNCTION1 tan_ TAU LITERAL2 TAU text FUNCTION1 text_