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
|
@@ -14,6 +14,7 @@ import java.io.PrintWriter;
|
|
|
14
14
|
public interface TableRow {
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
+
* @return
|
|
17
18
|
* @webref tablerow:method
|
|
18
19
|
* @brief Get an String value from the specified column
|
|
19
20
|
* @param column ID number of the column to reference
|
|
@@ -24,10 +25,12 @@ public interface TableRow {
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* @param columnName title of the column to reference
|
|
28
|
+
* @return
|
|
27
29
|
*/
|
|
28
30
|
public String getString(String columnName);
|
|
29
31
|
|
|
30
32
|
/**
|
|
33
|
+
* @return
|
|
31
34
|
* @webref tablerow:method
|
|
32
35
|
* @brief Get an integer value from the specified column
|
|
33
36
|
* @param column ID number of the column to reference
|
|
@@ -38,10 +41,12 @@ public interface TableRow {
|
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
* @param columnName title of the column to reference
|
|
44
|
+
* @return
|
|
41
45
|
*/
|
|
42
46
|
public int getInt(String columnName);
|
|
43
47
|
|
|
44
48
|
/**
|
|
49
|
+
* @return
|
|
45
50
|
* @brief Get a long value from the specified column
|
|
46
51
|
* @param column ID number of the column to reference
|
|
47
52
|
* @see TableRow#getFloat(int)
|
|
@@ -52,10 +57,12 @@ public interface TableRow {
|
|
|
52
57
|
|
|
53
58
|
/**
|
|
54
59
|
* @param columnName title of the column to reference
|
|
60
|
+
* @return
|
|
55
61
|
*/
|
|
56
62
|
public long getLong(String columnName);
|
|
57
63
|
|
|
58
64
|
/**
|
|
65
|
+
* @return
|
|
59
66
|
* @webref tablerow:method
|
|
60
67
|
* @brief Get a float value from the specified column
|
|
61
68
|
* @param column ID number of the column to reference
|
|
@@ -66,10 +73,12 @@ public interface TableRow {
|
|
|
66
73
|
|
|
67
74
|
/**
|
|
68
75
|
* @param columnName title of the column to reference
|
|
76
|
+
* @return
|
|
69
77
|
*/
|
|
70
78
|
public float getFloat(String columnName);
|
|
71
79
|
|
|
72
80
|
/**
|
|
81
|
+
* @return
|
|
73
82
|
* @brief Get a double value from the specified column
|
|
74
83
|
* @param column ID number of the column to reference
|
|
75
84
|
* @see TableRow#getInt(int)
|
|
@@ -79,6 +88,7 @@ public interface TableRow {
|
|
|
79
88
|
|
|
80
89
|
/**
|
|
81
90
|
* @param columnName title of the column to reference
|
|
91
|
+
* @return
|
|
82
92
|
*/
|
|
83
93
|
public double getDouble(String columnName);
|
|
84
94
|
|
|
@@ -93,6 +103,7 @@ public interface TableRow {
|
|
|
93
103
|
public void setString(int column, String value);
|
|
94
104
|
/**
|
|
95
105
|
* @param columnName title of the target column
|
|
106
|
+
* @param value
|
|
96
107
|
*/
|
|
97
108
|
public void setString(String columnName, String value);
|
|
98
109
|
|
|
@@ -108,6 +119,7 @@ public interface TableRow {
|
|
|
108
119
|
|
|
109
120
|
/**
|
|
110
121
|
* @param columnName title of the target column
|
|
122
|
+
* @param value
|
|
111
123
|
*/
|
|
112
124
|
public void setInt(String columnName, int value);
|
|
113
125
|
|
|
@@ -122,6 +134,7 @@ public interface TableRow {
|
|
|
122
134
|
|
|
123
135
|
/**
|
|
124
136
|
* @param columnName title of the target column
|
|
137
|
+
* @param value
|
|
125
138
|
*/
|
|
126
139
|
public void setLong(String columnName, long value);
|
|
127
140
|
|
|
@@ -137,6 +150,7 @@ public interface TableRow {
|
|
|
137
150
|
|
|
138
151
|
/**
|
|
139
152
|
* @param columnName title of the target column
|
|
153
|
+
* @param value
|
|
140
154
|
*/
|
|
141
155
|
public void setFloat(String columnName, float value);
|
|
142
156
|
|
|
@@ -151,6 +165,7 @@ public interface TableRow {
|
|
|
151
165
|
|
|
152
166
|
/**
|
|
153
167
|
* @param columnName title of the target column
|
|
168
|
+
* @param value
|
|
154
169
|
*/
|
|
155
170
|
public void setDouble(String columnName, double value);
|
|
156
171
|
|
|
@@ -170,6 +185,7 @@ public interface TableRow {
|
|
|
170
185
|
|
|
171
186
|
/**
|
|
172
187
|
* @param column ID number of the target column
|
|
188
|
+
* @return
|
|
173
189
|
*/
|
|
174
190
|
public int getColumnType(int column);
|
|
175
191
|
|
|
@@ -193,6 +209,14 @@ public interface TableRow {
|
|
|
193
209
|
*/
|
|
194
210
|
public String[] getColumnTitles();
|
|
195
211
|
|
|
196
|
-
|
|
197
|
-
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
* @param writer
|
|
215
|
+
*/
|
|
216
|
+
public void write(PrintWriter writer);
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
*/
|
|
221
|
+
public void print();
|
|
198
222
|
}
|
|
@@ -84,10 +84,14 @@ public class XML implements Serializable {
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Advanced users only; use loadXML() in PApplet.
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
* Advanced users only; use loadXML() in PApplet.This is not a supported
|
|
88
|
+
function and is subject to change.It is available simply for users that
|
|
89
|
+
would like to handle the exceptions in a particular way.
|
|
90
90
|
*
|
|
91
|
+
* @param file
|
|
92
|
+
* @throws java.io.IOException
|
|
93
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
94
|
+
* @throws org.xml.sax.SAXException
|
|
91
95
|
* @nowebref
|
|
92
96
|
*/
|
|
93
97
|
public XML(File file) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -98,6 +102,11 @@ public class XML implements Serializable {
|
|
|
98
102
|
/**
|
|
99
103
|
* Advanced users only; use loadXML() in PApplet.
|
|
100
104
|
*
|
|
105
|
+
* @param file
|
|
106
|
+
* @param options
|
|
107
|
+
* @throws java.io.IOException
|
|
108
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
109
|
+
* @throws org.xml.sax.SAXException
|
|
101
110
|
* @nowebref
|
|
102
111
|
*/
|
|
103
112
|
public XML(File file, String options) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -105,6 +114,10 @@ public class XML implements Serializable {
|
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
/**
|
|
117
|
+
* @param input
|
|
118
|
+
* @throws java.io.IOException
|
|
119
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
120
|
+
* @throws org.xml.sax.SAXException
|
|
108
121
|
* @nowebref
|
|
109
122
|
*/
|
|
110
123
|
public XML(InputStream input) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -116,6 +129,11 @@ public class XML implements Serializable {
|
|
|
116
129
|
* Unlike the loadXML() method in PApplet, this version works with files
|
|
117
130
|
* that are not in UTF-8 format.
|
|
118
131
|
*
|
|
132
|
+
* @param input
|
|
133
|
+
* @param options
|
|
134
|
+
* @throws java.io.IOException
|
|
135
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
136
|
+
* @throws org.xml.sax.SAXException
|
|
119
137
|
* @nowebref
|
|
120
138
|
*/
|
|
121
139
|
public XML(InputStream input, String options) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -139,6 +157,10 @@ public class XML implements Serializable {
|
|
|
139
157
|
/**
|
|
140
158
|
* Advanced users only; use loadXML() in PApplet.
|
|
141
159
|
*
|
|
160
|
+
* @param reader
|
|
161
|
+
* @throws java.io.IOException
|
|
162
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
163
|
+
* @throws org.xml.sax.SAXException
|
|
142
164
|
* @nowebref
|
|
143
165
|
*/
|
|
144
166
|
public XML(Reader reader) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -147,14 +169,17 @@ public class XML implements Serializable {
|
|
|
147
169
|
|
|
148
170
|
|
|
149
171
|
/**
|
|
150
|
-
* Advanced users only; use loadXML() in PApplet.Added extra code to handle
(Unicode NLF), which is sometimes
|
|
172
|
+
* Advanced users only; use loadXML() in PApplet.Added extra code to handle
(Unicode NLF), which is sometimes
|
|
173
|
+
inserted by web browsers (Safari?) and not distinguishable from a "real"
|
|
174
|
+
LF (or CRLF) in some text editors (i.e.TextEdit on OS X).Only doing
|
|
175
|
+
this for XML (and not all Reader objects) because LFs are essential.https://github.com/processing/processing/issues/2100
|
|
151
176
|
*
|
|
152
|
-
* Added extra code to handle \u2028 (Unicode NLF), which is sometimes
|
|
153
|
-
* inserted by web browsers (Safari?) and not distinguishable from a "real"
|
|
154
|
-
* LF (or CRLF) in some text editors (i.e. TextEdit on OS X). Only doing
|
|
155
|
-
* this for XML (and not all Reader objects) because LFs are essential.
|
|
156
|
-
* https://github.com/processing/processing/issues/2100
|
|
157
177
|
*
|
|
178
|
+
* @param reader
|
|
179
|
+
* @param options
|
|
180
|
+
* @throws java.io.IOException
|
|
181
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
182
|
+
* @throws org.xml.sax.SAXException
|
|
158
183
|
* @nowebref
|
|
159
184
|
*/
|
|
160
185
|
public XML(final Reader reader, String options) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -226,6 +251,8 @@ public class XML implements Serializable {
|
|
|
226
251
|
}
|
|
227
252
|
|
|
228
253
|
/**
|
|
254
|
+
* @param parent
|
|
255
|
+
* @param node
|
|
229
256
|
* @nowebref
|
|
230
257
|
*/
|
|
231
258
|
protected XML(XML parent, Node node) {
|
|
@@ -261,6 +288,12 @@ public class XML implements Serializable {
|
|
|
261
288
|
}
|
|
262
289
|
|
|
263
290
|
/**
|
|
291
|
+
* @param data
|
|
292
|
+
* @param options
|
|
293
|
+
* @return
|
|
294
|
+
* @throws java.io.IOException
|
|
295
|
+
* @throws javax.xml.parsers.ParserConfigurationException
|
|
296
|
+
* @throws org.xml.sax.SAXException
|
|
264
297
|
* @nowebref
|
|
265
298
|
*/
|
|
266
299
|
static public XML parse(String data, String options) throws IOException, ParserConfigurationException, SAXException {
|
|
@@ -272,13 +305,24 @@ public class XML implements Serializable {
|
|
|
272
305
|
// return write(PApplet.createWriter(output));
|
|
273
306
|
// }
|
|
274
307
|
|
|
308
|
+
/**
|
|
309
|
+
*
|
|
310
|
+
* @param file
|
|
311
|
+
* @return
|
|
312
|
+
*/
|
|
313
|
+
|
|
275
314
|
|
|
276
315
|
public boolean save(File file) {
|
|
277
316
|
return save(file, null);
|
|
278
317
|
}
|
|
279
318
|
|
|
280
|
-
|
|
281
|
-
|
|
319
|
+
/**
|
|
320
|
+
*
|
|
321
|
+
* @param file
|
|
322
|
+
* @param options
|
|
323
|
+
* @return
|
|
324
|
+
*/
|
|
325
|
+
public boolean save(File file, String options) {
|
|
282
326
|
PrintWriter writer = PApplet.createWriter(file);
|
|
283
327
|
boolean result = write(writer);
|
|
284
328
|
writer.flush();
|
|
@@ -289,6 +333,12 @@ public class XML implements Serializable {
|
|
|
289
333
|
|
|
290
334
|
// Sends this object and its kids to a Writer with an indent of 2 spaces,
|
|
291
335
|
// including the declaration at the top so that the output will be valid XML.
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
*
|
|
339
|
+
* @param output
|
|
340
|
+
* @return
|
|
341
|
+
*/
|
|
292
342
|
public boolean write(PrintWriter output) {
|
|
293
343
|
output.print(format(2));
|
|
294
344
|
output.flush();
|
|
@@ -297,9 +347,10 @@ public class XML implements Serializable {
|
|
|
297
347
|
|
|
298
348
|
|
|
299
349
|
/**
|
|
300
|
-
* Returns the parent element.
|
|
301
|
-
|
|
350
|
+
* Returns the parent element.This method returns null for the root
|
|
351
|
+
element.
|
|
302
352
|
*
|
|
353
|
+
* @return
|
|
303
354
|
* @webref xml:method
|
|
304
355
|
* @brief Gets a copy of the element's parent
|
|
305
356
|
*/
|
|
@@ -309,6 +360,7 @@ public class XML implements Serializable {
|
|
|
309
360
|
|
|
310
361
|
/**
|
|
311
362
|
* Internal function; not included in reference.
|
|
363
|
+
* @return
|
|
312
364
|
*/
|
|
313
365
|
protected Object getNative() {
|
|
314
366
|
return node;
|
|
@@ -329,6 +381,7 @@ public class XML implements Serializable {
|
|
|
329
381
|
}
|
|
330
382
|
|
|
331
383
|
/**
|
|
384
|
+
* @param newName
|
|
332
385
|
* @webref xml:method
|
|
333
386
|
* @brief Sets the element's name
|
|
334
387
|
*/
|
|
@@ -340,9 +393,9 @@ public class XML implements Serializable {
|
|
|
340
393
|
|
|
341
394
|
|
|
342
395
|
/**
|
|
343
|
-
* Returns the name of the element (without namespace prefix).
|
|
396
|
+
* Returns the name of the element (without namespace prefix).Internal function; not included in reference.
|
|
344
397
|
*
|
|
345
|
-
|
|
398
|
+
* @return
|
|
346
399
|
*/
|
|
347
400
|
public String getLocalName() {
|
|
348
401
|
return node.getLocalName();
|
|
@@ -382,6 +435,7 @@ public class XML implements Serializable {
|
|
|
382
435
|
/**
|
|
383
436
|
* Returns a boolean of whether or not there are children.
|
|
384
437
|
*
|
|
438
|
+
* @return
|
|
385
439
|
* @webref xml:method
|
|
386
440
|
* @brief Checks whether or not an element has any children
|
|
387
441
|
*/
|
|
@@ -392,9 +446,10 @@ public class XML implements Serializable {
|
|
|
392
446
|
|
|
393
447
|
|
|
394
448
|
/**
|
|
395
|
-
* Put the names of all children into an array.
|
|
396
|
-
|
|
449
|
+
* Put the names of all children into an array.Same as looping through
|
|
450
|
+
each child and calling getName() on each XMLElement.
|
|
397
451
|
*
|
|
452
|
+
* @return
|
|
398
453
|
* @webref xml:method
|
|
399
454
|
* @brief Returns the names of all children as an array
|
|
400
455
|
*/
|
|
@@ -420,6 +475,7 @@ public class XML implements Serializable {
|
|
|
420
475
|
/**
|
|
421
476
|
* Returns an array containing all the child elements.
|
|
422
477
|
*
|
|
478
|
+
* @return
|
|
423
479
|
* @webref xml:method
|
|
424
480
|
* @brief Returns an array containing all child elements
|
|
425
481
|
*/
|
|
@@ -440,6 +496,8 @@ public class XML implements Serializable {
|
|
|
440
496
|
/**
|
|
441
497
|
* Quick accessor for an element at a particular index.
|
|
442
498
|
*
|
|
499
|
+
* @param index
|
|
500
|
+
* @return
|
|
443
501
|
* @webref xml:method
|
|
444
502
|
* @brief Returns the child element with the specified index value or path
|
|
445
503
|
*/
|
|
@@ -541,8 +599,13 @@ public class XML implements Serializable {
|
|
|
541
599
|
return (XML[]) PApplet.subset(matches, 0, matchCount);
|
|
542
600
|
}
|
|
543
601
|
|
|
544
|
-
|
|
545
|
-
|
|
602
|
+
/**
|
|
603
|
+
*
|
|
604
|
+
* @param items
|
|
605
|
+
* @param offset
|
|
606
|
+
* @return
|
|
607
|
+
*/
|
|
608
|
+
protected XML[] getChildrenRecursive(String[] items, int offset) {
|
|
546
609
|
if (offset == items.length-1) {
|
|
547
610
|
return getChildren(items[offset]);
|
|
548
611
|
}
|
|
@@ -557,6 +620,8 @@ public class XML implements Serializable {
|
|
|
557
620
|
|
|
558
621
|
|
|
559
622
|
/**
|
|
623
|
+
* @param tag
|
|
624
|
+
* @return
|
|
560
625
|
* @webref xml:method
|
|
561
626
|
* @brief Appends a new child to the element
|
|
562
627
|
*/
|
|
@@ -566,15 +631,21 @@ public class XML implements Serializable {
|
|
|
566
631
|
return appendChild(newChild);
|
|
567
632
|
}
|
|
568
633
|
|
|
569
|
-
|
|
570
|
-
|
|
634
|
+
/**
|
|
635
|
+
*
|
|
636
|
+
* @param child
|
|
637
|
+
* @return
|
|
638
|
+
*/
|
|
639
|
+
public XML addChild(XML child) {
|
|
571
640
|
Document document = node.getOwnerDocument();
|
|
572
641
|
Node newChild = document.importNode((Node) child.getNative(), true);
|
|
573
642
|
return appendChild(newChild);
|
|
574
643
|
}
|
|
575
644
|
|
|
576
645
|
|
|
577
|
-
/** Internal handler to add the node structure.
|
|
646
|
+
/** Internal handler to add the node structure.
|
|
647
|
+
* @param newNode
|
|
648
|
+
* @return */
|
|
578
649
|
protected XML appendChild(Node newNode) {
|
|
579
650
|
node.appendChild(newNode);
|
|
580
651
|
XML newbie = new XML(this, newNode);
|
|
@@ -586,6 +657,7 @@ public class XML implements Serializable {
|
|
|
586
657
|
|
|
587
658
|
|
|
588
659
|
/**
|
|
660
|
+
* @param kid
|
|
589
661
|
* @webref xml:method
|
|
590
662
|
* @brief Removes the specified child
|
|
591
663
|
*/
|
|
@@ -594,8 +666,10 @@ public class XML implements Serializable {
|
|
|
594
666
|
children = null; // TODO not efficient
|
|
595
667
|
}
|
|
596
668
|
|
|
597
|
-
|
|
598
|
-
|
|
669
|
+
/**
|
|
670
|
+
*
|
|
671
|
+
*/
|
|
672
|
+
public void trim() {
|
|
599
673
|
try {
|
|
600
674
|
XPathFactory xpathFactory = XPathFactory.newInstance();
|
|
601
675
|
XPathExpression xpathExp =
|
|
@@ -666,6 +740,7 @@ public class XML implements Serializable {
|
|
|
666
740
|
/**
|
|
667
741
|
* Returns the number of attributes.
|
|
668
742
|
*
|
|
743
|
+
* @return
|
|
669
744
|
* @webref xml:method
|
|
670
745
|
* @brief Counts the specified element's number of attributes
|
|
671
746
|
*/
|
|
@@ -677,6 +752,7 @@ public class XML implements Serializable {
|
|
|
677
752
|
/**
|
|
678
753
|
* Get a list of the names for all of the attributes for this node.
|
|
679
754
|
*
|
|
755
|
+
* @return
|
|
680
756
|
* @webref xml:method
|
|
681
757
|
* @brief Returns a list of names of all attributes as an array
|
|
682
758
|
*/
|
|
@@ -692,6 +768,8 @@ public class XML implements Serializable {
|
|
|
692
768
|
/**
|
|
693
769
|
* Returns whether an attribute exists.
|
|
694
770
|
*
|
|
771
|
+
* @param name
|
|
772
|
+
* @return
|
|
695
773
|
* @webref xml:method
|
|
696
774
|
* @brief Checks whether or not an element has the specified attribute
|
|
697
775
|
*/
|
|
@@ -725,6 +803,8 @@ public class XML implements Serializable {
|
|
|
725
803
|
|
|
726
804
|
|
|
727
805
|
/**
|
|
806
|
+
* @param name
|
|
807
|
+
* @return
|
|
728
808
|
* @webref xml:method
|
|
729
809
|
* @brief Gets the content of an attribute as a String
|
|
730
810
|
*/
|
|
@@ -732,8 +812,13 @@ public class XML implements Serializable {
|
|
|
732
812
|
return getString(name, null);
|
|
733
813
|
}
|
|
734
814
|
|
|
735
|
-
|
|
736
|
-
|
|
815
|
+
/**
|
|
816
|
+
*
|
|
817
|
+
* @param name
|
|
818
|
+
* @param defaultValue
|
|
819
|
+
* @return
|
|
820
|
+
*/
|
|
821
|
+
public String getString(String name, String defaultValue) {
|
|
737
822
|
NamedNodeMap attrs = node.getAttributes();
|
|
738
823
|
if (attrs != null) {
|
|
739
824
|
Node attr = attrs.getNamedItem(name);
|
|
@@ -746,6 +831,8 @@ public class XML implements Serializable {
|
|
|
746
831
|
|
|
747
832
|
|
|
748
833
|
/**
|
|
834
|
+
* @param name
|
|
835
|
+
* @param value
|
|
749
836
|
* @webref xml:method
|
|
750
837
|
* @brief Sets the content of an attribute as a String
|
|
751
838
|
*/
|
|
@@ -755,6 +842,8 @@ public class XML implements Serializable {
|
|
|
755
842
|
|
|
756
843
|
|
|
757
844
|
/**
|
|
845
|
+
* @param name
|
|
846
|
+
* @return
|
|
758
847
|
* @webref xml:method
|
|
759
848
|
* @brief Gets the content of an attribute as an int
|
|
760
849
|
*/
|
|
@@ -764,6 +853,8 @@ public class XML implements Serializable {
|
|
|
764
853
|
|
|
765
854
|
|
|
766
855
|
/**
|
|
856
|
+
* @param name
|
|
857
|
+
* @param value
|
|
767
858
|
* @webref xml:method
|
|
768
859
|
* @brief Sets the content of an attribute as an int
|
|
769
860
|
*/
|
|
@@ -786,6 +877,8 @@ public class XML implements Serializable {
|
|
|
786
877
|
|
|
787
878
|
|
|
788
879
|
/**
|
|
880
|
+
* @param name
|
|
881
|
+
* @param value
|
|
789
882
|
* @webref xml:method
|
|
790
883
|
* @brief Sets the content of an element as an int
|
|
791
884
|
*/
|
|
@@ -810,6 +903,8 @@ public class XML implements Serializable {
|
|
|
810
903
|
/**
|
|
811
904
|
* Returns the value of an attribute, or zero if not present.
|
|
812
905
|
*
|
|
906
|
+
* @param name
|
|
907
|
+
* @return
|
|
813
908
|
* @webref xml:method
|
|
814
909
|
* @brief Gets the content of an attribute as a float
|
|
815
910
|
*/
|
|
@@ -832,6 +927,8 @@ public class XML implements Serializable {
|
|
|
832
927
|
|
|
833
928
|
|
|
834
929
|
/**
|
|
930
|
+
* @param name
|
|
931
|
+
* @param value
|
|
835
932
|
* @webref xml:method
|
|
836
933
|
* @brief Sets the content of an attribute as a float
|
|
837
934
|
*/
|
|
@@ -839,8 +936,12 @@ public class XML implements Serializable {
|
|
|
839
936
|
setString(name, String.valueOf(value));
|
|
840
937
|
}
|
|
841
938
|
|
|
842
|
-
|
|
843
|
-
|
|
939
|
+
/**
|
|
940
|
+
*
|
|
941
|
+
* @param name
|
|
942
|
+
* @return
|
|
943
|
+
*/
|
|
944
|
+
public double getDouble(String name) {
|
|
844
945
|
return getDouble(name, 0);
|
|
845
946
|
}
|
|
846
947
|
|
|
@@ -857,8 +958,12 @@ public class XML implements Serializable {
|
|
|
857
958
|
return (value == null) ? defaultValue : Double.parseDouble(value);
|
|
858
959
|
}
|
|
859
960
|
|
|
860
|
-
|
|
861
|
-
|
|
961
|
+
/**
|
|
962
|
+
*
|
|
963
|
+
* @param name
|
|
964
|
+
* @param value
|
|
965
|
+
*/
|
|
966
|
+
public void setDouble(String name, double value) {
|
|
862
967
|
setString(name, String.valueOf(value));
|
|
863
968
|
}
|
|
864
969
|
|
|
@@ -879,8 +984,12 @@ public class XML implements Serializable {
|
|
|
879
984
|
return node.getTextContent();
|
|
880
985
|
}
|
|
881
986
|
|
|
882
|
-
|
|
883
|
-
|
|
987
|
+
/**
|
|
988
|
+
*
|
|
989
|
+
* @param defaultValue
|
|
990
|
+
* @return
|
|
991
|
+
*/
|
|
992
|
+
public String getContent(String defaultValue) {
|
|
884
993
|
String s = node.getTextContent();
|
|
885
994
|
return (s != null) ? s : defaultValue;
|
|
886
995
|
}
|
|
@@ -900,6 +1009,7 @@ public class XML implements Serializable {
|
|
|
900
1009
|
|
|
901
1010
|
/**
|
|
902
1011
|
* @param defaultValue the default value of the attribute
|
|
1012
|
+
* @return
|
|
903
1013
|
*/
|
|
904
1014
|
public int getIntContent(int defaultValue) {
|
|
905
1015
|
return PApplet.parseInt(node.getTextContent(), defaultValue);
|
|
@@ -920,18 +1030,26 @@ public class XML implements Serializable {
|
|
|
920
1030
|
|
|
921
1031
|
/**
|
|
922
1032
|
* @param defaultValue the default value of the attribute
|
|
1033
|
+
* @return
|
|
923
1034
|
*/
|
|
924
1035
|
public float getFloatContent(float defaultValue) {
|
|
925
1036
|
return PApplet.parseFloat(node.getTextContent(), defaultValue);
|
|
926
1037
|
}
|
|
927
1038
|
|
|
928
|
-
|
|
929
|
-
|
|
1039
|
+
/**
|
|
1040
|
+
*
|
|
1041
|
+
* @return
|
|
1042
|
+
*/
|
|
1043
|
+
public long getLongContent() {
|
|
930
1044
|
return getLongContent(0);
|
|
931
1045
|
}
|
|
932
1046
|
|
|
933
|
-
|
|
934
|
-
|
|
1047
|
+
/**
|
|
1048
|
+
*
|
|
1049
|
+
* @param defaultValue
|
|
1050
|
+
* @return
|
|
1051
|
+
*/
|
|
1052
|
+
public long getLongContent(long defaultValue) {
|
|
935
1053
|
String c = node.getTextContent();
|
|
936
1054
|
if (c != null) {
|
|
937
1055
|
try {
|
|
@@ -941,13 +1059,20 @@ public class XML implements Serializable {
|
|
|
941
1059
|
return defaultValue;
|
|
942
1060
|
}
|
|
943
1061
|
|
|
944
|
-
|
|
945
|
-
|
|
1062
|
+
/**
|
|
1063
|
+
*
|
|
1064
|
+
* @return
|
|
1065
|
+
*/
|
|
1066
|
+
public double getDoubleContent() {
|
|
946
1067
|
return getDoubleContent(0);
|
|
947
1068
|
}
|
|
948
1069
|
|
|
949
|
-
|
|
950
|
-
|
|
1070
|
+
/**
|
|
1071
|
+
*
|
|
1072
|
+
* @param defaultValue
|
|
1073
|
+
* @return
|
|
1074
|
+
*/
|
|
1075
|
+
public double getDoubleContent(double defaultValue) {
|
|
951
1076
|
String c = node.getTextContent();
|
|
952
1077
|
if (c != null) {
|
|
953
1078
|
try {
|
|
@@ -959,6 +1084,7 @@ public class XML implements Serializable {
|
|
|
959
1084
|
|
|
960
1085
|
|
|
961
1086
|
/**
|
|
1087
|
+
* @param text
|
|
962
1088
|
* @webref xml:method
|
|
963
1089
|
* @brief Sets the content of an element
|
|
964
1090
|
*/
|
|
@@ -966,23 +1092,35 @@ public class XML implements Serializable {
|
|
|
966
1092
|
node.setTextContent(text);
|
|
967
1093
|
}
|
|
968
1094
|
|
|
969
|
-
|
|
970
|
-
|
|
1095
|
+
/**
|
|
1096
|
+
*
|
|
1097
|
+
* @param value
|
|
1098
|
+
*/
|
|
1099
|
+
public void setIntContent(int value) {
|
|
971
1100
|
setContent(String.valueOf(value));
|
|
972
1101
|
}
|
|
973
1102
|
|
|
974
|
-
|
|
975
|
-
|
|
1103
|
+
/**
|
|
1104
|
+
*
|
|
1105
|
+
* @param value
|
|
1106
|
+
*/
|
|
1107
|
+
public void setFloatContent(float value) {
|
|
976
1108
|
setContent(String.valueOf(value));
|
|
977
1109
|
}
|
|
978
1110
|
|
|
979
|
-
|
|
980
|
-
|
|
1111
|
+
/**
|
|
1112
|
+
*
|
|
1113
|
+
* @param value
|
|
1114
|
+
*/
|
|
1115
|
+
public void setLongContent(long value) {
|
|
981
1116
|
setContent(String.valueOf(value));
|
|
982
1117
|
}
|
|
983
1118
|
|
|
984
|
-
|
|
985
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
*
|
|
1121
|
+
* @param value
|
|
1122
|
+
*/
|
|
1123
|
+
public void setDoubleContent(double value) {
|
|
986
1124
|
setContent(String.valueOf(value));
|
|
987
1125
|
}
|
|
988
1126
|
|
|
@@ -1125,8 +1263,10 @@ public class XML implements Serializable {
|
|
|
1125
1263
|
return null;
|
|
1126
1264
|
}
|
|
1127
1265
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1266
|
+
/**
|
|
1267
|
+
*
|
|
1268
|
+
*/
|
|
1269
|
+
public void print() {
|
|
1130
1270
|
PApplet.println(format(2));
|
|
1131
1271
|
}
|
|
1132
1272
|
|