picrate 0.3.0-java → 0.4.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/CHANGELOG.md +1 -2
  4. data/README.md +1 -1
  5. data/Rakefile +2 -2
  6. data/lib/picrate.rb +1 -0
  7. data/lib/picrate/app.rb +4 -4
  8. data/lib/picrate/helper_methods.rb +0 -4
  9. data/lib/picrate/version.rb +1 -1
  10. data/library/color_group/color_group.rb +27 -0
  11. data/picrate.gemspec +1 -1
  12. data/pom.rb +5 -5
  13. data/pom.xml +5 -5
  14. data/src/main/java/monkstone/ColorUtil.java +57 -32
  15. data/src/main/java/processing/awt/PShapeJava2D.java +33 -9
  16. data/src/main/java/processing/awt/PSurfaceAWT.java +169 -76
  17. data/src/main/java/processing/core/PApplet.java +15921 -13981
  18. data/src/main/java/processing/core/PConstants.java +981 -475
  19. data/src/main/java/processing/core/PFont.java +202 -50
  20. data/src/main/java/processing/core/PGraphics.java +8470 -7323
  21. data/src/main/java/processing/core/PImage.java +212 -42
  22. data/src/main/java/processing/core/PMatrix.java +160 -21
  23. data/src/main/java/processing/core/PMatrix2D.java +178 -18
  24. data/src/main/java/processing/core/PMatrix3D.java +324 -48
  25. data/src/main/java/processing/core/PShape.java +42 -20
  26. data/src/main/java/processing/core/PShapeOBJ.java +91 -16
  27. data/src/main/java/processing/core/PShapeSVG.java +253 -53
  28. data/src/main/java/processing/core/PStyle.java +179 -34
  29. data/src/main/java/processing/core/PSurface.java +94 -13
  30. data/src/main/java/processing/core/PSurfaceNone.java +140 -35
  31. data/src/main/java/processing/core/PVector.java +87 -10
  32. data/src/main/java/processing/data/JSONObject.java +2 -2
  33. data/src/main/java/processing/event/Event.java +69 -86
  34. data/src/main/java/processing/event/MouseEvent.java +102 -102
  35. data/src/main/java/processing/opengl/PJOGL.java +3 -0
  36. data/test/color_group_test.rb +33 -0
  37. data/vendors/Rakefile +1 -1
  38. metadata +7 -4
@@ -2040,7 +2040,7 @@ public class PShape implements PConstants {
2040
2040
  parent.addName(nom, shape);
2041
2041
  } else {
2042
2042
  if (nameTable == null) {
2043
- nameTable = new HashMap<String,PShape>();
2043
+ nameTable = new HashMap<>();
2044
2044
  }
2045
2045
  nameTable.put(nom, shape);
2046
2046
  }
@@ -2387,14 +2387,14 @@ public class PShape implements PConstants {
2387
2387
  /**
2388
2388
  * ( begin auto-generated from PShape_setFill.xml )
2389
2389
  *
2390
- * The <b>setFill()</b> method defines the fill color of a <b>PShape</b>.
2391
- * This method is used after shapes are created or when a shape is defined explicitly
2392
- * (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>) as shown in the above example.
2393
- * When a shape is created with <b>beginShape()</b> and <b>endShape()</b>, its
2394
- * attributes may be changed with <b>fill()</b> and <b>stroke()</b> within
2395
- * <b>beginShape()</b> and <b>endShape()</b>. However, after the shape is
2396
- * created, only the <b>setFill()</b> method can define a new fill value for
2397
- * the <b>PShape</b>.
2390
+ * The <b>setFill()</b> method defines the fill color of a <b>PShape</b>.
2391
+ * This method is used after shapes are created or when a shape is defined explicitly
2392
+ * (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>) as shown in the above example.
2393
+ * When a shape is created with <b>beginShape()</b> and <b>endShape()</b>, its
2394
+ * attributes may be changed with <b>fill()</b> and <b>stroke()</b> within
2395
+ * <b>beginShape()</b> and <b>endShape()</b>. However, after the shape is
2396
+ * created, only the <b>setFill()</b> method can define a new fill value for
2397
+ * the <b>PShape</b>.
2398
2398
  *
2399
2399
  * ( end auto-generated )
2400
2400
  *
@@ -2543,14 +2543,14 @@ public class PShape implements PConstants {
2543
2543
  /**
2544
2544
  * ( begin auto-generated from PShape_setStroke.xml )
2545
2545
  *
2546
- * The <b>setStroke()</b> method defines the outline color of a <b>PShape</b>.
2547
- * This method is used after shapes are created or when a shape is defined
2548
- * explicitly (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>) as shown in
2549
- * the above example. When a shape is created with <b>beginShape()</b> and
2550
- * <b>endShape()</b>, its attributes may be changed with <b>fill()</b> and
2551
- * <b>stroke()</b> within <b>beginShape()</b> and <b>endShape()</b>.
2552
- * However, after the shape is created, only the <b>setStroke()</b> method
2553
- * can define a new stroke value for the <b>PShape</b>.
2546
+ * The <b>setStroke()</b> method defines the outline color of a <b>PShape</b>.
2547
+ * This method is used after shapes are created or when a shape is defined
2548
+ * explicitly (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>) as shown in
2549
+ * the above example. When a shape is created with <b>beginShape()</b> and
2550
+ * <b>endShape()</b>, its attributes may be changed with <b>fill()</b> and
2551
+ * <b>stroke()</b> within <b>beginShape()</b> and <b>endShape()</b>.
2552
+ * However, after the shape is created, only the <b>setStroke()</b> method
2553
+ * can define a new stroke value for the <b>PShape</b>.
2554
2554
  *
2555
2555
  * ( end auto-generated )
2556
2556
  *
@@ -2891,13 +2891,24 @@ public class PShape implements PConstants {
2891
2891
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2892
2892
 
2893
2893
 
2894
- // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
2894
+ /**
2895
+ * Return true if this x, y coordinate is part of this shape. Only works
2896
+ * with PATH shapes or GROUP shapes that contain other GROUPs or PATHs.
2897
+ */
2895
2898
  public boolean contains(float x, float y) {
2896
2899
  if (family == PATH) {
2900
+ // apply the inverse transformation matrix to the point coordinates
2901
+ PMatrix inverseCoords = matrix.get();
2902
+ inverseCoords.invert(); // maybe cache this?
2903
+ inverseCoords.invert(); // maybe cache this?
2904
+ PVector p = new PVector();
2905
+ inverseCoords.mult(new PVector(x,y),p);
2906
+
2907
+ // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
2897
2908
  boolean c = false;
2898
2909
  for (int i = 0, j = vertexCount-1; i < vertexCount; j = i++) {
2899
- if (((vertices[i][Y] > y) != (vertices[j][Y] > y)) &&
2900
- (x <
2910
+ if (((vertices[i][Y] > p.y) != (vertices[j][Y] > p.y)) &&
2911
+ (p.x <
2901
2912
  (vertices[j][X]-vertices[i][X]) *
2902
2913
  (y-vertices[i][Y]) /
2903
2914
  (vertices[j][1]-vertices[i][Y]) +
@@ -2906,7 +2917,18 @@ public class PShape implements PConstants {
2906
2917
  }
2907
2918
  }
2908
2919
  return c;
2920
+
2921
+ } else if (family == GROUP) {
2922
+ // If this is a group, loop through children until we find one that
2923
+ // contains the supplied coordinates. If a child does not support
2924
+ // contains() throw a warning and continue.
2925
+ for (int i = 0; i < childCount; i++) {
2926
+ if (children[i].contains(x, y)) return true;
2927
+ }
2928
+ return false;
2929
+
2909
2930
  } else {
2931
+ // https://github.com/processing/processing/issues/1280
2910
2932
  throw new IllegalArgumentException("The contains() method is only implemented for paths.");
2911
2933
  }
2912
2934
  }
@@ -22,16 +22,29 @@ public class PShapeOBJ extends PShape {
22
22
 
23
23
  /**
24
24
  * Initializes a new OBJ Object with the given filename.
25
+ * @param parent
26
+ * @param filename
25
27
  */
26
28
  public PShapeOBJ(PApplet parent, String filename) {
27
29
  this(parent, parent.createReader(filename), getBasePath(parent, filename));
28
30
  }
29
31
 
30
- public PShapeOBJ(PApplet parent, BufferedReader reader) {
32
+ /**
33
+ *
34
+ * @param parent
35
+ * @param reader
36
+ */
37
+ public PShapeOBJ(PApplet parent, BufferedReader reader) {
31
38
  this(parent, reader, "");
32
39
  }
33
40
 
34
- public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
41
+ /**
42
+ *
43
+ * @param parent
44
+ * @param reader
45
+ * @param basePath
46
+ */
47
+ public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
35
48
  ArrayList<OBJFace> faces = new ArrayList<OBJFace>();
36
49
  ArrayList<OBJMaterial> materials = new ArrayList<OBJMaterial>();
37
50
  ArrayList<PVector> coords = new ArrayList<PVector>();
@@ -46,8 +59,15 @@ public class PShapeOBJ extends PShape {
46
59
  addChildren(faces, materials, coords, normals, texcoords);
47
60
  }
48
61
 
49
-
50
- protected PShapeOBJ(OBJFace face, OBJMaterial mtl,
62
+ /**
63
+ *
64
+ * @param face
65
+ * @param mtl
66
+ * @param coords
67
+ * @param normals
68
+ * @param texcoords
69
+ */
70
+ protected PShapeOBJ(OBJFace face, OBJMaterial mtl,
51
71
  ArrayList<PVector> coords,
52
72
  ArrayList<PVector> normals,
53
73
  ArrayList<PVector> texcoords) {
@@ -125,8 +145,15 @@ public class PShapeOBJ extends PShape {
125
145
  }
126
146
  }
127
147
 
128
-
129
- protected void addChildren(ArrayList<OBJFace> faces,
148
+ /**
149
+ *
150
+ * @param faces
151
+ * @param materials
152
+ * @param coords
153
+ * @param normals
154
+ * @param texcoords
155
+ */
156
+ protected void addChildren(ArrayList<OBJFace> faces,
130
157
  ArrayList<OBJMaterial> materials,
131
158
  ArrayList<PVector> coords,
132
159
  ArrayList<PVector> normals,
@@ -149,8 +176,18 @@ public class PShapeOBJ extends PShape {
149
176
  }
150
177
  }
151
178
 
152
-
153
- static protected void parseOBJ(PApplet parent, String path,
179
+ /**
180
+ *
181
+ * @param parent
182
+ * @param path
183
+ * @param reader
184
+ * @param faces
185
+ * @param materials
186
+ * @param coords
187
+ * @param normals
188
+ * @param texcoords
189
+ */
190
+ static protected void parseOBJ(PApplet parent, String path,
154
191
  BufferedReader reader,
155
192
  ArrayList<OBJFace> faces,
156
193
  ArrayList<OBJMaterial> materials,
@@ -316,8 +353,16 @@ public class PShapeOBJ extends PShape {
316
353
  }
317
354
  }
318
355
 
319
-
320
- static protected void parseMTL(PApplet parent, String mtlfn, String path,
356
+ /**
357
+ *
358
+ * @param parent
359
+ * @param mtlfn
360
+ * @param path
361
+ * @param reader
362
+ * @param materials
363
+ * @param materialsHash
364
+ */
365
+ static protected void parseMTL(PApplet parent, String mtlfn, String path,
321
366
  BufferedReader reader,
322
367
  ArrayList<OBJMaterial> materials,
323
368
  Map<String, Integer> materialsHash) {
@@ -388,7 +433,14 @@ public class PShapeOBJ extends PShape {
388
433
  }
389
434
  }
390
435
 
391
- protected static OBJMaterial addMaterial(String mtlname,
436
+ /**
437
+ *
438
+ * @param mtlname
439
+ * @param materials
440
+ * @param materialsHash
441
+ * @return
442
+ */
443
+ protected static OBJMaterial addMaterial(String mtlname,
392
444
  ArrayList<OBJMaterial> materials,
393
445
  Map<String, Integer> materialsHash) {
394
446
  OBJMaterial currentMtl = new OBJMaterial(mtlname);
@@ -397,14 +449,24 @@ public class PShapeOBJ extends PShape {
397
449
  return currentMtl;
398
450
  }
399
451
 
400
- protected static int rgbaValue(PVector color) {
452
+ /**
453
+ *
454
+ * @param color
455
+ * @return
456
+ */
457
+ protected static int rgbaValue(PVector color) {
401
458
  return 0xFF000000 | ((int)(color.x * 255) << 16) |
402
459
  ((int)(color.y * 255) << 8) |
403
460
  (int)(color.z * 255);
404
461
  }
405
462
 
406
-
407
- protected static int rgbaValue(PVector color, float alpha) {
463
+ /**
464
+ *
465
+ * @param color
466
+ * @param alpha
467
+ * @return
468
+ */
469
+ protected static int rgbaValue(PVector color, float alpha) {
408
470
  return ((int)(alpha * 255) << 24) |
409
471
  ((int)(color.x * 255) << 16) |
410
472
  ((int)(color.y * 255) << 8) |
@@ -413,6 +475,10 @@ public class PShapeOBJ extends PShape {
413
475
 
414
476
 
415
477
  // Stores a face from an OBJ file
478
+
479
+ /**
480
+ *
481
+ */
416
482
  static protected class OBJFace {
417
483
  ArrayList<Integer> vertIdx;
418
484
  ArrayList<Integer> texIdx;
@@ -429,8 +495,13 @@ public class PShapeOBJ extends PShape {
429
495
  }
430
496
  }
431
497
 
432
-
433
- static protected String getBasePath(PApplet parent, String filename) {
498
+ /**
499
+ *
500
+ * @param parent
501
+ * @param filename
502
+ * @return
503
+ */
504
+ static protected String getBasePath(PApplet parent, String filename) {
434
505
  // Obtaining the path
435
506
  File file = new File(parent.dataPath(filename));
436
507
  if (!file.exists()) {
@@ -443,6 +514,10 @@ public class PShapeOBJ extends PShape {
443
514
 
444
515
 
445
516
  // Stores a material defined in an MTL file.
517
+
518
+ /**
519
+ *
520
+ */
446
521
  static protected class OBJMaterial {
447
522
  String name;
448
523
  PVector ka;
@@ -89,6 +89,10 @@ public class PShapeSVG extends PShape {
89
89
  XML element;
90
90
 
91
91
  /// Values between 0 and 1.
92
+
93
+ /**
94
+ *
95
+ */
92
96
  protected float opacity;
93
97
  float strokeOpacity;
94
98
  float fillOpacity;
@@ -102,15 +106,22 @@ public class PShapeSVG extends PShape {
102
106
  /** √((w² + h²)/2) of containing SVG (used for percentages). */
103
107
  protected float svgSizeXY;
104
108
 
105
- protected Gradient strokeGradient;
109
+ /**
110
+ *
111
+ */
112
+ protected Gradient strokeGradient;
106
113
  String strokeName; // id of another object, gradients only?
107
114
 
108
- protected Gradient fillGradient;
115
+ /**
116
+ *
117
+ */
118
+ protected Gradient fillGradient;
109
119
  String fillName; // id of another object
110
120
 
111
121
 
112
122
  /**
113
123
  * Initializes a new SVG object from the given XML object.
124
+ * @param svg
114
125
  */
115
126
  public PShapeSVG(XML svg) {
116
127
  this(null, svg, true);
@@ -125,8 +136,13 @@ public class PShapeSVG extends PShape {
125
136
  }
126
137
  }
127
138
 
128
-
129
- protected PShapeSVG(PShapeSVG parent, XML properties, boolean parseKids) {
139
+ /**
140
+ *
141
+ * @param parent
142
+ * @param properties
143
+ * @param parseKids
144
+ */
145
+ protected PShapeSVG(PShapeSVG parent, XML properties, boolean parseKids) {
130
146
  setParent(parent);
131
147
 
132
148
  // Need to get width/height in early.
@@ -213,6 +229,11 @@ public class PShapeSVG extends PShape {
213
229
 
214
230
  // Broken out so that subclasses can copy any additional variables
215
231
  // (i.e. fillGradientPaint and strokeGradientPaint)
232
+
233
+ /**
234
+ *
235
+ * @param parent
236
+ */
216
237
  protected void setParent(PShapeSVG parent) {
217
238
  // Need to set this so that findChild() works.
218
239
  // Otherwise 'parent' is null until addChild() is called later.
@@ -274,13 +295,20 @@ public class PShapeSVG extends PShape {
274
295
  }
275
296
 
276
297
 
277
- /** Factory method for subclasses. */
298
+ /** Factory method for subclasses.
299
+ * @param parent
300
+ * @param properties
301
+ * @param parseKids
302
+ * @return */
278
303
  protected PShapeSVG createShape(PShapeSVG parent, XML properties, boolean parseKids) {
279
304
  return new PShapeSVG(parent, properties, parseKids);
280
305
  }
281
306
 
282
-
283
- protected void parseChildren(XML graphics) {
307
+ /**
308
+ *
309
+ * @param graphics
310
+ */
311
+ protected void parseChildren(XML graphics) {
284
312
  XML[] elements = graphics.getChildren();
285
313
  children = new PShape[elements.length];
286
314
  childCount = 0;
@@ -296,6 +324,8 @@ public class PShapeSVG extends PShape {
296
324
  /**
297
325
  * Parse a child XML element.
298
326
  * Override this method to add parsing for more SVG elements.
327
+ * @param elem
328
+ * @return
299
329
  */
300
330
  protected PShape parseChild(XML elem) {
301
331
  // System.err.println("parsing child in pshape " + elem.getName());
@@ -389,8 +419,10 @@ public class PShapeSVG extends PShape {
389
419
  return shape;
390
420
  }
391
421
 
392
-
393
- protected void parseLine() {
422
+ /**
423
+ *
424
+ */
425
+ protected void parseLine() {
394
426
  kind = LINE;
395
427
  family = PRIMITIVE;
396
428
  params = new float[] {
@@ -428,8 +460,10 @@ public class PShapeSVG extends PShape {
428
460
  params[3] = ry*2;
429
461
  }
430
462
 
431
-
432
- protected void parseRect() {
463
+ /**
464
+ *
465
+ */
466
+ protected void parseRect() {
433
467
  kind = RECT;
434
468
  family = PRIMITIVE;
435
469
  params = new float[] {
@@ -463,8 +497,10 @@ public class PShapeSVG extends PShape {
463
497
  }
464
498
  }
465
499
 
466
-
467
- protected void parsePath() {
500
+ /**
501
+ *
502
+ */
503
+ protected void parsePath() {
468
504
  family = PATH;
469
505
  kind = 0;
470
506
 
@@ -1037,8 +1073,12 @@ public class PShapeSVG extends PShape {
1037
1073
  return outgoing;
1038
1074
  }
1039
1075
 
1040
-
1041
- static protected PMatrix2D parseSingleTransform(String matrixStr) {
1076
+ /**
1077
+ *
1078
+ * @param matrixStr
1079
+ * @return
1080
+ */
1081
+ static protected PMatrix2D parseSingleTransform(String matrixStr) {
1042
1082
  //String[] pieces = PApplet.match(matrixStr, "^\\s*(\\w+)\\((.*)\\)\\s*$");
1043
1083
  String[] pieces = PApplet.match(matrixStr, "[,\\s]*(\\w+)\\((.*)\\)");
1044
1084
  if (pieces == null) {
@@ -1084,8 +1124,11 @@ public class PShapeSVG extends PShape {
1084
1124
  return null;
1085
1125
  }
1086
1126
 
1087
-
1088
- protected void parseColors(XML properties) {
1127
+ /**
1128
+ *
1129
+ * @param properties
1130
+ */
1131
+ protected void parseColors(XML properties) {
1089
1132
  if (properties.hasAttribute("opacity")) {
1090
1133
  String opacityText = properties.getString("opacity");
1091
1134
  setOpacity(opacityText);
@@ -1273,6 +1316,7 @@ public class PShapeSVG extends PShape {
1273
1316
  /**
1274
1317
  * Parses the "color" datatype only, and prints an error if it is not of this form.
1275
1318
  * http://www.w3.org/TR/SVG/types.html#DataTypeColor
1319
+ * @param colorText
1276
1320
  * @return 0xRRGGBB (no alpha). Zero on error.
1277
1321
  */
1278
1322
  static protected int parseSimpleColor(String colorText) {
@@ -1344,6 +1388,13 @@ public class PShapeSVG extends PShape {
1344
1388
  }
1345
1389
  */
1346
1390
 
1391
+ /**
1392
+ *
1393
+ * @param what
1394
+ * @return
1395
+ */
1396
+
1397
+
1347
1398
  static protected int parseRGB(String what) {
1348
1399
  int leftParen = what.indexOf('(') + 1;
1349
1400
  int rightParen = what.indexOf(')');
@@ -1367,6 +1418,12 @@ public class PShapeSVG extends PShape {
1367
1418
 
1368
1419
 
1369
1420
  //static protected Map<String, String> parseStyleAttributes(String style) {
1421
+
1422
+ /**
1423
+ *
1424
+ * @param style
1425
+ * @return
1426
+ */
1370
1427
  static protected StringDict parseStyleAttributes(String style) {
1371
1428
  //Map<String, String> table = new HashMap<String, String>();
1372
1429
  StringDict table = new StringDict();
@@ -1410,9 +1467,11 @@ public class PShapeSVG extends PShape {
1410
1467
  * <LI>"1cm" equals "35.43307px" (and therefore 35.43307 user units)
1411
1468
  * <LI>"1in" equals "90px" (and therefore 90 user units)
1412
1469
  * </UL>
1470
+ * @param text
1413
1471
  * @param relativeTo (float) Used for %. When relative to viewbox, should
1414
1472
  * be svgWidth for horizontal dimentions, svgHeight for vertical, and
1415
1473
  * svgXYSize for anything else.
1474
+ * @return
1416
1475
  */
1417
1476
  static protected float parseUnitSize(String text, float relativeTo) {
1418
1477
  int len = text.length() - 2;
@@ -1436,8 +1495,12 @@ public class PShapeSVG extends PShape {
1436
1495
  }
1437
1496
  }
1438
1497
 
1439
-
1440
- static protected float parseFloatOrPercent(String text) {
1498
+ /**
1499
+ *
1500
+ * @param text
1501
+ * @return
1502
+ */
1503
+ static protected float parseFloatOrPercent(String text) {
1441
1504
  text = text.trim();
1442
1505
  if (text.endsWith("%")) {
1443
1506
  return Float.parseFloat(text.substring(0, text.length() - 1)) / 100.0f;
@@ -1449,15 +1512,35 @@ public class PShapeSVG extends PShape {
1449
1512
 
1450
1513
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1451
1514
 
1515
+ /**
1516
+ *
1517
+ */
1518
+
1452
1519
 
1453
1520
  static public class Gradient extends PShapeSVG {
1454
1521
  AffineTransform transform;
1455
1522
 
1456
- public float[] offset;
1457
- public int[] color;
1458
- public int count;
1459
-
1460
- public Gradient(PShapeSVG parent, XML properties) {
1523
+ /**
1524
+ *
1525
+ */
1526
+ public float[] offset;
1527
+
1528
+ /**
1529
+ *
1530
+ */
1531
+ public int[] color;
1532
+
1533
+ /**
1534
+ *
1535
+ */
1536
+ public int count;
1537
+
1538
+ /**
1539
+ *
1540
+ * @param parent
1541
+ * @param properties
1542
+ */
1543
+ public Gradient(PShapeSVG parent, XML properties) {
1461
1544
  super(parent, properties, true);
1462
1545
 
1463
1546
  XML elements[] = properties.getChildren();
@@ -1497,11 +1580,37 @@ public class PShapeSVG extends PShape {
1497
1580
  }
1498
1581
  }
1499
1582
 
1500
-
1501
- public class LinearGradient extends Gradient {
1502
- public float x1, y1, x2, y2;
1503
-
1504
- public LinearGradient(PShapeSVG parent, XML properties) {
1583
+ /**
1584
+ *
1585
+ */
1586
+ public class LinearGradient extends Gradient {
1587
+
1588
+ /**
1589
+ *
1590
+ */
1591
+ public float x1,
1592
+
1593
+ /**
1594
+ *
1595
+ */
1596
+ y1,
1597
+
1598
+ /**
1599
+ *
1600
+ */
1601
+ x2,
1602
+
1603
+ /**
1604
+ *
1605
+ */
1606
+ y2;
1607
+
1608
+ /**
1609
+ *
1610
+ * @param parent
1611
+ * @param properties
1612
+ */
1613
+ public LinearGradient(PShapeSVG parent, XML properties) {
1505
1614
  super(parent, properties);
1506
1615
 
1507
1616
  this.x1 = getFloatWithUnit(properties, "x1", svgWidth);
@@ -1527,11 +1636,32 @@ public class PShapeSVG extends PShape {
1527
1636
  }
1528
1637
  }
1529
1638
 
1530
-
1531
- public class RadialGradient extends Gradient {
1532
- public float cx, cy, r;
1533
-
1534
- public RadialGradient(PShapeSVG parent, XML properties) {
1639
+ /**
1640
+ *
1641
+ */
1642
+ public class RadialGradient extends Gradient {
1643
+
1644
+ /**
1645
+ *
1646
+ */
1647
+ public float cx,
1648
+
1649
+ /**
1650
+ *
1651
+ */
1652
+ cy,
1653
+
1654
+ /**
1655
+ *
1656
+ */
1657
+ r;
1658
+
1659
+ /**
1660
+ *
1661
+ * @param parent
1662
+ * @param properties
1663
+ */
1664
+ public RadialGradient(PShapeSVG parent, XML properties) {
1535
1665
  super(parent, properties);
1536
1666
 
1537
1667
  this.cx = getFloatWithUnit(properties, "cx", svgWidth);
@@ -1558,21 +1688,51 @@ public class PShapeSVG extends PShape {
1558
1688
 
1559
1689
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1560
1690
 
1691
+ /**
1692
+ *
1693
+ */
1694
+
1561
1695
 
1562
1696
  public static class Font extends PShapeSVG {
1563
- public FontFace face;
1564
1697
 
1565
- public Map<String, FontGlyph> namedGlyphs;
1566
- public Map<Character, FontGlyph> unicodeGlyphs;
1698
+ /**
1699
+ *
1700
+ */
1701
+ public FontFace face;
1567
1702
 
1568
- public int glyphCount;
1569
- public FontGlyph[] glyphs;
1570
- public FontGlyph missingGlyph;
1703
+ /**
1704
+ *
1705
+ */
1706
+ public Map<String, FontGlyph> namedGlyphs;
1571
1707
 
1572
- int horizAdvX;
1708
+ /**
1709
+ *
1710
+ */
1711
+ public Map<Character, FontGlyph> unicodeGlyphs;
1573
1712
 
1713
+ /**
1714
+ *
1715
+ */
1716
+ public int glyphCount;
1717
+
1718
+ /**
1719
+ *
1720
+ */
1721
+ public FontGlyph[] glyphs;
1722
+
1723
+ /**
1724
+ *
1725
+ */
1726
+ public FontGlyph missingGlyph;
1727
+
1728
+ int horizAdvX;
1574
1729
 
1575
- public Font(PShapeSVG parent, XML properties) {
1730
+ /**
1731
+ *
1732
+ * @param parent
1733
+ * @param properties
1734
+ */
1735
+ public Font(PShapeSVG parent, XML properties) {
1576
1736
  super(parent, properties, false);
1577
1737
  // handle(parent, properties);
1578
1738
 
@@ -1613,13 +1773,22 @@ public class PShapeSVG extends PShape {
1613
1773
  }
1614
1774
  }
1615
1775
 
1616
-
1617
- protected void drawShape() {
1776
+ /**
1777
+ *
1778
+ */
1779
+ protected void drawShape() {
1618
1780
  // does nothing for fonts
1619
1781
  }
1620
1782
 
1621
-
1622
- public void drawString(PGraphics g, String str, float x, float y, float size) {
1783
+ /**
1784
+ *
1785
+ * @param g
1786
+ * @param str
1787
+ * @param x
1788
+ * @param y
1789
+ * @param size
1790
+ */
1791
+ public void drawString(PGraphics g, String str, float x, float y, float size) {
1623
1792
  // 1) scale by the 1.0/unitsPerEm
1624
1793
  // 2) scale up by a font size
1625
1794
  g.pushMatrix();
@@ -1643,8 +1812,15 @@ public class PShapeSVG extends PShape {
1643
1812
  g.popMatrix();
1644
1813
  }
1645
1814
 
1646
-
1647
- public void drawChar(PGraphics g, char c, float x, float y, float size) {
1815
+ /**
1816
+ *
1817
+ * @param g
1818
+ * @param c
1819
+ * @param x
1820
+ * @param y
1821
+ * @param size
1822
+ */
1823
+ public void drawChar(PGraphics g, char c, float x, float y, float size) {
1648
1824
  g.pushMatrix();
1649
1825
  float s = size / face.unitsPerEm;
1650
1826
  g.translate(x, y);
@@ -1654,8 +1830,13 @@ public class PShapeSVG extends PShape {
1654
1830
  g.popMatrix();
1655
1831
  }
1656
1832
 
1657
-
1658
- public float textWidth(String str, float size) {
1833
+ /**
1834
+ *
1835
+ * @param str
1836
+ * @param size
1837
+ * @return
1838
+ */
1839
+ public float textWidth(String str, float size) {
1659
1840
  float w = 0;
1660
1841
  char[] c = str.toCharArray();
1661
1842
  for (int i = 0; i < c.length; i++) {
@@ -1709,13 +1890,27 @@ public class PShapeSVG extends PShape {
1709
1890
 
1710
1891
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1711
1892
 
1893
+ /**
1894
+ *
1895
+ */
1896
+
1712
1897
 
1713
1898
  public static class FontGlyph extends PShapeSVG { // extends Path
1899
+
1900
+ /**
1901
+ *
1902
+ */
1714
1903
  public String name;
1715
1904
  char unicode;
1716
1905
  int horizAdvX;
1717
1906
 
1718
- public FontGlyph(PShapeSVG parent, XML properties, Font font) {
1907
+ /**
1908
+ *
1909
+ * @param parent
1910
+ * @param properties
1911
+ * @param font
1912
+ */
1913
+ public FontGlyph(PShapeSVG parent, XML properties, Font font) {
1719
1914
  super(parent, properties, true);
1720
1915
  super.parsePath(); // ??
1721
1916
 
@@ -1738,8 +1933,11 @@ public class PShapeSVG extends PShape {
1738
1933
  }
1739
1934
  }
1740
1935
 
1741
-
1742
- protected boolean isLegit() { // TODO need a better way to handle this...
1936
+ /**
1937
+ *
1938
+ * @return
1939
+ */
1940
+ protected boolean isLegit() { // TODO need a better way to handle this...
1743
1941
  return vertexCount != 0;
1744
1942
  }
1745
1943
  }
@@ -1758,6 +1956,8 @@ public class PShapeSVG extends PShape {
1758
1956
  * // This code grabs "Layer 3" and the shapes beneath it.
1759
1957
  * PShape layer3 = svg.getChild("Layer 3");
1760
1958
  * </PRE>
1959
+ * @param name
1960
+ * @return
1761
1961
  */
1762
1962
  @Override
1763
1963
  public PShape getChild(String name) {