geomerative 1.1.0-java → 2.0.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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.mvn/extensions.xml +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  5. data/CHANGELOG.md +3 -0
  6. data/COPYING.md +1 -1
  7. data/README.md +0 -1
  8. data/Rakefile +2 -15
  9. data/docs/_includes/header.html +6 -6
  10. data/docs/_includes/icon-github.svg +3 -1
  11. data/docs/_includes/icon-twitter.svg +3 -1
  12. data/docs/_includes/navigation.html +18 -18
  13. data/docs/_sass/_base.scss +79 -79
  14. data/docs/_sass/_layout.scss +137 -137
  15. data/docs/_sass/_syntax-highlighting.scss +64 -64
  16. data/docs/index.html +18 -18
  17. data/examples/data/bot1.svg +1 -1
  18. data/examples/data/lion.svg +156 -156
  19. data/examples/data/ruby.svg +1 -1
  20. data/geomerative.gemspec +1 -2
  21. data/lib/geomerative/version.rb +1 -1
  22. data/mvnw +234 -0
  23. data/mvnw.cmd +145 -0
  24. data/pom.rb +14 -13
  25. data/pom.xml +14 -13
  26. data/src/geomerative/FastRClip.java +2149 -2156
  27. data/src/geomerative/RClip.java +2237 -2539
  28. data/src/geomerative/RClosest.java +33 -31
  29. data/src/geomerative/RCommand.java +1750 -1758
  30. data/src/geomerative/RContour.java +290 -292
  31. data/src/geomerative/RFont.java +277 -246
  32. data/src/geomerative/RG.java +722 -727
  33. data/src/geomerative/RGeomElem.java +967 -960
  34. data/src/geomerative/RGroup.java +508 -467
  35. data/src/geomerative/RMatrix.java +304 -289
  36. data/src/geomerative/RMesh.java +241 -229
  37. data/src/geomerative/RPath.java +924 -925
  38. data/src/geomerative/RPoint.java +391 -391
  39. data/src/geomerative/RPolygon.java +998 -988
  40. data/src/geomerative/RRectangle.java +43 -52
  41. data/src/geomerative/RSVG.java +480 -516
  42. data/src/geomerative/RShape.java +1767 -1777
  43. data/src/geomerative/RStrip.java +173 -176
  44. data/src/geomerative/RStyle.java +197 -194
  45. data/src/org/apache/batik/svggen/font/Font.java +141 -142
  46. data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
  47. data/src/org/apache/batik/svggen/font/Point.java +12 -12
  48. data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
  49. data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
  50. data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
  51. data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
  52. data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
  53. data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
  54. data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
  55. data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
  56. data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
  57. data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
  58. data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
  59. data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
  60. data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
  61. data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
  62. data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
  63. data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
  64. data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
  65. data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
  66. data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
  67. data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
  68. data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
  69. data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
  70. data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
  71. data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
  72. data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
  73. data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
  74. data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
  75. data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
  76. data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
  77. data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
  78. data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
  79. data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
  80. data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
  81. data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
  82. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
  83. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
  84. data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
  85. data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
  86. data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
  87. data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
  88. data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
  89. data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
  90. data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
  91. data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
  92. data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
  93. data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
  94. data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
  95. data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
  96. data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
  97. data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
  98. data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
  99. data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
  100. data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
  101. data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
  102. data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
  103. data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
  104. data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
  105. data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
  106. data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
  107. data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
  108. data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
  109. data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
  110. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
  111. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
  112. data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
  113. data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
  114. data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
  115. metadata +10 -11
  116. data/.travis.yml +0 -9
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
3
3
  *
4
- This file is part of Geomerative.
4
+ * This file is part of Geomerative.
5
5
  *
6
6
  * Geomerative is free software: you can redistribute it and/or modify it under
7
7
  * the terms of the GNU General Public License as published by the Free Software
@@ -18,208 +18,205 @@
18
18
  */
19
19
  package geomerative;
20
20
 
21
-
22
-
23
21
  import processing.core.PConstants;
24
22
  import processing.core.PGraphics;
25
23
 
26
-
27
24
  /**
28
25
  * RStrip is a reduced interface for creating, holding and drawing triangle
29
26
  * strips. Triangle strips are ordered lists of points (RPoint) which define the
30
27
  * vertices of a mesh.
31
28
  *
32
- * @eexample RStrip
33
- * @usage Geometry
34
- * @related RPoint
35
- * @related RMesh
36
- * @extended
29
+ RStrip
30
+ * Geometry
31
+ * RPoint
32
+ * RMesh
33
+
37
34
  */
38
35
  public class RStrip {
39
36
 
40
- /**
41
- * @invisible
42
- */
43
- public int type = RGeomElem.TRISTRIP;
44
-
45
- /**
46
- * Array of RPoint objects holding the vertices of the strip.
47
- *
48
- * @eexample vertices
49
- * @related RPoint
50
- * @related countVertices ( )
51
- * @related addVertex ( )
52
- */
53
- public RPoint vertices[];
54
-
55
- // ----------------------
56
- // --- Public Methods ---
57
- // ----------------------
58
- /**
59
- * Use this method to create a new strip.
60
- *
61
- * @eexample RStrip ( )
62
- * @related addVertex ( )
63
- * @param s the object of which to make a copy
64
- */
65
- public RStrip(RStrip s) {
66
- for (int i = 0; i < s.countVertices(); i++) {
67
- this.append(new RPoint(s.vertices[i]));
68
- }
69
- }
70
-
71
- public RStrip() {
72
- vertices = null;
73
- }
37
+ /**
38
+ *
39
+ */
40
+ public int type = RGeomElem.TRISTRIP;
74
41
 
75
- /**
76
- * Use this method to count the number of vertices in the strip.
77
- *
78
- * @eexample countVertices
79
- * @return int, the number vertices in the strip
80
- */
81
- public int countVertices() {
82
- if (this.vertices == null) {
83
- return 0;
84
- }
85
-
86
- return this.vertices.length;
87
- }
42
+ /**
43
+ * Array of RPoint objects holding the vertices of the strip.
44
+ *
45
+ vertices
46
+ * RPoint
47
+ * countVertices ( )
48
+ * addVertex ( )
49
+ */
50
+ public RPoint vertices[];
88
51
 
89
- /**
90
- * Use this method to draw the strip.
91
- *
92
- * @eexample drawStrip
93
- * @param g PGraphics, the graphics object on which to draw the strip
94
- */
95
- public void draw(PGraphics g) {
96
- int numVertices = countVertices();
97
- g.beginShape(PConstants.TRIANGLE_STRIP);
98
- for (int i = 0; i < numVertices; i++) {
99
- g.vertex(vertices[i].x, vertices[i].y);
100
- }
101
- g.endShape();
52
+ // ----------------------
53
+ // --- Public Methods ---
54
+ // ----------------------
55
+ /**
56
+ * Use this method to create a new strip.
57
+ *
58
+ RStrip ( )
59
+ * addVertex ( )
60
+ * @param s the object of which to make a copy
61
+ */
62
+ public RStrip(RStrip s) {
63
+ for (int i = 0; i < s.countVertices(); i++) {
64
+ this.append(new RPoint(s.vertices[i]));
102
65
  }
66
+ }
103
67
 
104
- /**
105
- * Use this method to add new vertices to the strip.
106
- *
107
- * @param p
108
- * @eexample addVertex ( )
109
- */
110
- public void addVertex(RPoint p) {
111
- this.append(p);
112
- }
68
+ public RStrip() {
69
+ vertices = null;
70
+ }
113
71
 
114
- public void addVertex(float x, float y) {
115
- this.append(new RPoint(x, y));
72
+ /**
73
+ * Use this method to count the number of vertices in the strip.
74
+ *
75
+ countVertices
76
+ * @return int, the number vertices in the strip
77
+ */
78
+ public int countVertices() {
79
+ if (this.vertices == null) {
80
+ return 0;
116
81
  }
117
82
 
118
- /**
119
- * Use this method to get the bounding box of the strip.
120
- *
121
- * @eexample getBounds
122
- * @return RContour, the bounding box of the strip in the form of a
123
- * four-point contour
124
- * @related draw ( )
125
- */
126
- public RContour getBounds() {
127
- float xmin = Float.MAX_VALUE;
128
- float ymin = Float.MAX_VALUE;
129
- float xmax = -Float.MAX_VALUE;
130
- float ymax = -Float.MAX_VALUE;
131
-
132
- for (int i = 0; i < this.countVertices(); i++) {
133
- float x = this.vertices[i].x;
134
- float y = this.vertices[i].y;
135
- if (x < xmin) {
136
- xmin = x;
137
- }
138
- if (x > xmax) {
139
- xmax = x;
140
- }
141
- if (y < ymin) {
142
- ymin = y;
143
- }
144
- if (y > ymax) {
145
- ymax = y;
146
- }
147
- }
148
-
149
- RContour c = new RContour();
150
- c.addPoint(xmin, ymin);
151
- c.addPoint(xmin, ymax);
152
- c.addPoint(xmax, ymax);
153
- c.addPoint(xmax, ymin);
154
- return c;
155
- }
83
+ return this.vertices.length;
84
+ }
156
85
 
157
- /**
158
- * Use this to get the vertices of the strip. It returns the points as an
159
- * array of RPoint.
160
- *
161
- * @eexample RStrip_getHandles
162
- * @return RPoint[], the vertices returned in an array.
86
+ /**
87
+ * Use this method to draw the strip.
163
88
  *
164
- */
165
- public RPoint[] getHandles() {
166
- return vertices;
89
+ drawStrip
90
+ * @param g PGraphics, the graphics object on which to draw the strip
91
+ */
92
+ public void draw(PGraphics g) {
93
+ int numVertices = countVertices();
94
+ g.beginShape(PConstants.TRIANGLE_STRIP);
95
+ for (int i = 0; i < numVertices; i++) {
96
+ g.vertex(vertices[i].x, vertices[i].y);
167
97
  }
98
+ g.endShape();
99
+ }
168
100
 
169
- /**
170
- * Use this to get the vertices of the strip. It returns the points as an
171
- * array of RPoint.
172
- *
173
- * @eexample RStrip_getPoints
174
- * @return RPoint[], the vertices returned in an array.
101
+ /**
102
+ * Use this method to add new vertices to the strip.
175
103
  *
176
- */
177
- public RPoint[] getPoints() {
178
- return vertices;
179
- }
180
-
181
- /**
182
- * Use this method to transform the strip.
183
- *
184
- * @eexample transformStrip
185
- * @param m RMatrix, the matrix of the affine transformation to apply to the
186
- * strip
187
- */
188
- public void transform(RMatrix m) {
189
- int numVertices = countVertices();
190
- if (numVertices != 0) {
191
- for (int i = 0; i < numVertices; i++) {
192
- vertices[i].transform(m);
193
- }
194
- }
195
- }
196
-
197
- void add(RPoint p) {
198
- this.append(p);
104
+ * @param p
105
+ addVertex ( )
106
+ */
107
+ public void addVertex(RPoint p) {
108
+ this.append(p);
109
+ }
110
+
111
+ public void addVertex(float x, float y) {
112
+ this.append(new RPoint(x, y));
113
+ }
114
+
115
+ /**
116
+ * Use this method to get the bounding box of the strip.
117
+ *
118
+ getBounds
119
+ * @return RContour, the bounding box of the strip in the form of a four-point
120
+ * contour
121
+ * draw ( )
122
+ */
123
+ public RContour getBounds() {
124
+ float xmin = Float.MAX_VALUE;
125
+ float ymin = Float.MAX_VALUE;
126
+ float xmax = -Float.MAX_VALUE;
127
+ float ymax = -Float.MAX_VALUE;
128
+
129
+ for (int i = 0; i < this.countVertices(); i++) {
130
+ float x = this.vertices[i].x;
131
+ float y = this.vertices[i].y;
132
+ if (x < xmin) {
133
+ xmin = x;
134
+ }
135
+ if (x > xmax) {
136
+ xmax = x;
137
+ }
138
+ if (y < ymin) {
139
+ ymin = y;
140
+ }
141
+ if (y > ymax) {
142
+ ymax = y;
143
+ }
199
144
  }
200
145
 
201
- void add(float x, float y) {
202
- this.append(new RPoint(x, y));
203
- }
146
+ RContour c = new RContour();
147
+ c.addPoint(xmin, ymin);
148
+ c.addPoint(xmin, ymax);
149
+ c.addPoint(xmax, ymax);
150
+ c.addPoint(xmax, ymin);
151
+ return c;
152
+ }
153
+
154
+ /**
155
+ * Use this to get the vertices of the strip. It returns the points as an
156
+ * array of RPoint.
157
+ *
158
+ RStrip_getHandles
159
+ * @return RPoint[], the vertices returned in an array.
160
+ *
161
+ */
162
+ public RPoint[] getHandles() {
163
+ return vertices;
164
+ }
165
+
166
+ /**
167
+ * Use this to get the vertices of the strip. It returns the points as an
168
+ * array of RPoint.
169
+ *
170
+ RStrip_getPoints
171
+ * @return RPoint[], the vertices returned in an array.
172
+ *
173
+ */
174
+ public RPoint[] getPoints() {
175
+ return vertices;
176
+ }
204
177
 
205
- /**
206
- * Remove all of the points. Creates an empty polygon.
207
- */
208
- void clear() {
209
- this.vertices = null;
178
+ /**
179
+ * Use this method to transform the strip.
180
+ *
181
+ transformStrip
182
+ * @param m RMatrix, the matrix of the affine transformation to apply to the
183
+ * strip
184
+ */
185
+ public void transform(RMatrix m) {
186
+ int numVertices = countVertices();
187
+ if (numVertices != 0) {
188
+ for (int i = 0; i < numVertices; i++) {
189
+ vertices[i].transform(m);
190
+ }
210
191
  }
211
-
212
- final void append(RPoint nextvertex) {
213
- RPoint[] newvertices;
214
- if (vertices == null) {
215
- newvertices = new RPoint[1];
216
- newvertices[0] = nextvertex;
217
- } else {
218
- newvertices = new RPoint[this.vertices.length + 1];
219
- System.arraycopy(this.vertices, 0, newvertices, 0, this.vertices.length);
220
- newvertices[this.vertices.length] = nextvertex;
221
- }
222
- this.vertices = newvertices;
192
+ }
193
+
194
+ void add(RPoint p) {
195
+ this.append(p);
196
+ }
197
+
198
+ void add(float x, float y) {
199
+ this.append(new RPoint(x, y));
200
+ }
201
+
202
+ /**
203
+ * Remove all of the points. Creates an empty polygon.
204
+ */
205
+ void clear() {
206
+ this.vertices = null;
207
+ }
208
+
209
+ final void append(RPoint nextvertex) {
210
+ RPoint[] newvertices;
211
+ if (vertices == null) {
212
+ newvertices = new RPoint[1];
213
+ newvertices[0] = nextvertex;
214
+ } else {
215
+ newvertices = new RPoint[this.vertices.length + 1];
216
+ System.arraycopy(this.vertices, 0, newvertices, 0, this.vertices.length);
217
+ newvertices[this.vertices.length] = nextvertex;
223
218
  }
219
+ this.vertices = newvertices;
220
+ }
224
221
 
225
222
  }
@@ -1,23 +1,22 @@
1
1
  /**
2
- Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
3
-
4
- This file is part of Geomerative.
5
-
6
- Geomerative is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- Geomerative is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU General Public License for more details.
15
-
16
- You should have received a copy of the GNU General Public License
17
- along with Geomerative. If not, see <http://www.gnu.org/licenses/>.
18
- */
19
-
20
- package geomerative ;
2
+ * Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
3
+ *
4
+ * This file is part of Geomerative.
5
+ *
6
+ * Geomerative is free software: you can redistribute it and/or modify it under
7
+ * the terms of the GNU General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later
9
+ * version.
10
+ *
11
+ * Geomerative is distributed in the hope that it will be useful, but WITHOUT
12
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
+ * details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License along with
17
+ * Geomerative. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ package geomerative;
21
20
 
22
21
  import processing.core.PApplet;
23
22
  import processing.core.PConstants;
@@ -25,11 +24,12 @@ import processing.core.PGraphics;
25
24
  import processing.core.PImage;
26
25
 
27
26
  /**
28
- * @extended
29
- */
30
- public class RStyle{
27
+
28
+ */
29
+ public class RStyle {
30
+
31
31
  public PImage texture = null;
32
-
32
+
33
33
  public boolean fillDef = false;
34
34
  public boolean fill = false;
35
35
  public int fillColor = 0xff000000;
@@ -43,7 +43,7 @@ public class RStyle{
43
43
 
44
44
  public boolean strokeAlphaDef = false;
45
45
  public int strokeAlpha = 0xff000000;
46
-
46
+
47
47
  public boolean strokeWeightDef = false;
48
48
  public float strokeWeight = 1F;
49
49
 
@@ -55,24 +55,25 @@ public class RStyle{
55
55
 
56
56
  private boolean oldFill = false;
57
57
  private int oldFillColor = 0;
58
-
58
+
59
59
  private boolean oldStroke = false;
60
60
  private int oldStrokeColor = 0;
61
61
  private float oldStrokeWeight = 1F;
62
62
  private int oldStrokeCap = PConstants.PROJECT;
63
63
  private int oldStrokeJoin = PConstants.MITER;
64
64
 
65
- public RStyle(){}
65
+ public RStyle() {
66
+ }
66
67
 
67
- public RStyle(RStyle p){
68
+ public RStyle(RStyle p) {
68
69
  texture = p.texture;
69
-
70
+
70
71
  fillDef = p.fillDef;
71
72
  fill = p.fill;
72
73
  fillColor = p.fillColor;
73
74
  fillAlphaDef = p.fillAlphaDef;
74
75
  fillAlpha = p.fillAlpha;
75
-
76
+
76
77
  strokeDef = p.strokeDef;
77
78
  stroke = p.stroke;
78
79
  strokeColor = p.strokeColor;
@@ -89,173 +90,172 @@ public class RStyle{
89
90
  strokeJoin = p.strokeJoin;
90
91
  }
91
92
 
92
- protected void setStyle(String styleString){
93
+ protected void setStyle(String styleString) {
93
94
  //RG.parent().println("Style parsing: " + styleString);
94
95
  String[] styleTokens = PApplet.splitTokens(styleString, ";");
95
-
96
- for (String styleToken : styleTokens) {
97
- String[] tokens = PApplet.splitTokens(styleToken, ":");
98
- tokens[0] = PApplet.trim(tokens[0]);
99
- switch (tokens[0]) {
100
- case "fill":
101
- setFill(tokens[1]);
102
- break;
103
- case "fill-opacity":
104
- setFillAlpha(tokens[1]);
105
- break;
106
- case "stroke":
107
- setStroke(tokens[1]);
108
- break;
109
- case "stroke-width":
110
- setStrokeWeight(tokens[1]);
111
- break;
112
- case "stroke-linecap":
113
- setStrokeCap(tokens[1]);
114
- break;
115
- case "stroke-linejoin":
116
- setStrokeJoin(tokens[1]);
117
- break;
118
- case "stroke-opacity":
119
- setStrokeAlpha(tokens[1]);
120
- break;
121
- case "opacity":
122
- setAlpha(tokens[1]);
123
- break;
124
- default:
125
- PApplet.println("Attribute '" + tokens[0] + "' not known. Ignoring it.");
126
- break;
127
- }
96
+
97
+ for (String styleToken : styleTokens) {
98
+ String[] tokens = PApplet.splitTokens(styleToken, ":");
99
+ tokens[0] = PApplet.trim(tokens[0]);
100
+ switch (tokens[0]) {
101
+ case "fill":
102
+ setFill(tokens[1]);
103
+ break;
104
+ case "fill-opacity":
105
+ setFillAlpha(tokens[1]);
106
+ break;
107
+ case "stroke":
108
+ setStroke(tokens[1]);
109
+ break;
110
+ case "stroke-width":
111
+ setStrokeWeight(tokens[1]);
112
+ break;
113
+ case "stroke-linecap":
114
+ setStrokeCap(tokens[1]);
115
+ break;
116
+ case "stroke-linejoin":
117
+ setStrokeJoin(tokens[1]);
118
+ break;
119
+ case "stroke-opacity":
120
+ setStrokeAlpha(tokens[1]);
121
+ break;
122
+ case "opacity":
123
+ setAlpha(tokens[1]);
124
+ break;
125
+ default:
126
+ PApplet.println("Attribute '" + tokens[0] + "' not known. Ignoring it.");
127
+ break;
128
128
  }
129
+ }
129
130
  }
130
131
 
131
- public void setFill(boolean _fill){
132
+ public void setFill(boolean _fill) {
132
133
  fillDef = true;
133
134
  fill = _fill;
134
135
  }
135
136
 
136
- public void setFill(int _fillColor){
137
+ public void setFill(int _fillColor) {
137
138
  //RG.parent().println("Setting fill by int: " + RG.parent().hex(_fillColor));
138
139
  setFill(true);
139
140
  fillColor = (fillColor & 0xff000000) | (_fillColor & 0x00ffffff);
140
141
  }
141
142
 
142
- public void setFill(String str){
143
+ public void setFill(String str) {
143
144
  //RG.parent().println("id: " + id);
144
145
  //RG.parent().println(" set fill: " + str);
145
- if(str.equals("none")){
146
+ if (str.equals("none")) {
146
147
  setFill(false);
147
148
 
148
- }else{
149
+ } else {
149
150
  setFill(getColor(str));
150
151
 
151
152
  }
152
153
  //RG.parent().println(" fillColor after: " + RG.parent().hex(fillColor));
153
154
  }
154
155
 
155
- public void setStroke(boolean _stroke){
156
+ public void setStroke(boolean _stroke) {
156
157
  strokeDef = true;
157
158
  stroke = _stroke;
158
159
  }
159
160
 
160
- public void setStroke(int _strokeColor){
161
+ public void setStroke(int _strokeColor) {
161
162
  setStroke(true);
162
163
  strokeColor = (strokeColor & 0xff000000) | (_strokeColor & 0x00ffffff);
163
164
  }
164
165
 
165
- public void setStroke(String str){
166
+ public void setStroke(String str) {
166
167
  //RG.parent().println(" set stroke: " + str);
167
- if(str.equals("none")){
168
+ if (str.equals("none")) {
168
169
  setStroke(false);
169
170
 
170
- }else{
171
+ } else {
171
172
  setStroke(getColor(str));
172
-
173
+
173
174
  }
174
175
  }
175
176
 
176
- public void setStrokeWeight(float value){
177
+ public void setStrokeWeight(float value) {
177
178
  //RG.parent().println(" set strokeWeight by float: " + value);
178
179
  strokeWeightDef = true;
179
180
  strokeWeight = value;
180
181
  }
181
182
 
182
- public void setStrokeWeight(String str){
183
+ public void setStrokeWeight(String str) {
183
184
  //RG.parent().println(" set strokeWeight by String: " + str);
184
- if(str.endsWith("px")){
185
+ if (str.endsWith("px")) {
185
186
  setStrokeWeight(PApplet.parseFloat(str.substring(0, str.length() - 2)));
186
- }else{
187
+ } else {
187
188
  setStrokeWeight(PApplet.parseFloat(str));
188
189
  }
189
190
 
190
-
191
191
  }
192
192
 
193
- public void setStrokeCap(String str){
193
+ public void setStrokeCap(String str) {
194
194
  //RG.parent().println(" set stroke-cap: " + str);
195
195
  strokeCapDef = true;
196
196
 
197
- switch (str) {
198
- case "butt":
199
- strokeCap = PConstants.PROJECT;
200
- break;
201
- case "round":
202
- strokeCap = PConstants.ROUND;
203
- break;
204
- case "square":
205
- strokeCap = PConstants.SQUARE;
206
- break;
207
- }
197
+ switch (str) {
198
+ case "butt":
199
+ strokeCap = PConstants.PROJECT;
200
+ break;
201
+ case "round":
202
+ strokeCap = PConstants.ROUND;
203
+ break;
204
+ case "square":
205
+ strokeCap = PConstants.SQUARE;
206
+ break;
207
+ }
208
208
  }
209
209
 
210
- public void setStrokeJoin(String str){
210
+ public void setStrokeJoin(String str) {
211
211
  //RG.parent().println(" set stroke-cap: " + str);
212
212
  strokeJoinDef = true;
213
213
 
214
- switch (str) {
215
- case "miter":
216
- strokeJoin = PConstants.MITER;
217
- break;
218
- case "round":
219
- strokeJoin = PConstants.ROUND;
220
- break;
221
- case "bevel":
222
- strokeJoin = PConstants.BEVEL;
223
- break;
224
- }
214
+ switch (str) {
215
+ case "miter":
216
+ strokeJoin = PConstants.MITER;
217
+ break;
218
+ case "round":
219
+ strokeJoin = PConstants.ROUND;
220
+ break;
221
+ case "bevel":
222
+ strokeJoin = PConstants.BEVEL;
223
+ break;
224
+ }
225
225
  }
226
226
 
227
- public void setStrokeAlpha(int opacity){
227
+ public void setStrokeAlpha(int opacity) {
228
228
  strokeAlphaDef = true;
229
229
  strokeAlpha = opacity;
230
230
  }
231
231
 
232
- public void setStrokeAlpha(String str){
233
- setStrokeAlpha((int)(PApplet.parseFloat(str) * 255F));
232
+ public void setStrokeAlpha(String str) {
233
+ setStrokeAlpha((int) (PApplet.parseFloat(str) * 255F));
234
234
  }
235
235
 
236
- public void setFillAlpha(int opacity){
236
+ public void setFillAlpha(int opacity) {
237
237
  fillAlphaDef = true;
238
238
  fillAlpha = opacity;
239
239
  }
240
240
 
241
- public void setFillAlpha(String str){
241
+ public void setFillAlpha(String str) {
242
242
  //RG.parent().println(" set fillOpacity: " + str);
243
- setFillAlpha((int)(PApplet.parseFloat(str) * 255F));
243
+ setFillAlpha((int) (PApplet.parseFloat(str) * 255F));
244
244
  //RG.parent().println(" fillColor after: " + RG.parent().hex(fillColor));
245
- }
245
+ }
246
246
 
247
- public void setAlpha(float opacity){
247
+ public void setAlpha(float opacity) {
248
248
  //RG.parent().println("Setting float opacity: " + opacity);
249
- setAlpha((int)(opacity * 100F));
249
+ setAlpha((int) (opacity * 100F));
250
250
  }
251
251
 
252
- public void setAlpha(int opacity){
252
+ public void setAlpha(int opacity) {
253
253
  /*
254
254
  RG.parent().println("setting opacity: " + RG.parent().hex(opacity));
255
255
 
256
256
  RG.parent().println(" fillColor before: " + RG.parent().hex(fillColor));
257
257
  RG.parent().println(" strokeColor before: " + RG.parent().hex(fillColor));
258
- */
258
+ */
259
259
 
260
260
  setFillAlpha(opacity);
261
261
  setStrokeAlpha(opacity);
@@ -266,15 +266,15 @@ public class RStyle{
266
266
  /*
267
267
  RG.parent().println(" fillColor now: " + RG.parent().hex(fillColor));
268
268
  RG.parent().println(" strokeColor now: " + RG.parent().hex(fillColor));
269
- */
269
+ */
270
270
  }
271
271
 
272
- public void setAlpha(String str){
272
+ public void setAlpha(String str) {
273
273
  //RG.parent().println("Setting string opacity: " + str);
274
274
  setAlpha(PApplet.parseFloat(str));
275
275
  }
276
276
 
277
- protected void saveContext(PGraphics g){
277
+ protected void saveContext(PGraphics g) {
278
278
  oldFill = g.fill;
279
279
  oldFillColor = g.fillColor;
280
280
  oldStroke = g.stroke;
@@ -284,189 +284,192 @@ public class RStyle{
284
284
  oldStrokeJoin = g.strokeJoin;
285
285
  }
286
286
 
287
- protected void saveContext(PApplet p){
287
+ protected void saveContext(PApplet p) {
288
288
  oldFill = p.g.fill;
289
289
  oldFillColor = p.g.fillColor;
290
290
  oldStroke = p.g.stroke;
291
291
  oldStrokeColor = p.g.strokeColor;
292
- oldStrokeWeight = p.g.strokeWeight;
292
+ oldStrokeWeight = p.g.strokeWeight;
293
293
  oldStrokeCap = p.g.strokeCap;
294
294
  oldStrokeJoin = p.g.strokeJoin;
295
295
  }
296
296
 
297
- protected void saveContext(){
297
+ protected void saveContext() {
298
298
  saveContext(RG.parent());
299
299
  }
300
300
 
301
- protected void restoreContext(PGraphics g){
301
+ protected void restoreContext(PGraphics g) {
302
302
  g.fill(oldFillColor);
303
- if(!oldFill){
303
+ if (!oldFill) {
304
304
  g.noFill();
305
305
  }
306
306
 
307
307
  g.stroke(oldStrokeColor);
308
308
  g.strokeWeight(oldStrokeWeight);
309
309
 
310
- try{
310
+ try {
311
311
  g.strokeCap(oldStrokeCap);
312
312
  g.strokeJoin(oldStrokeJoin);
313
- }catch(RuntimeException e){}
313
+ } catch (RuntimeException e) {
314
+ }
314
315
 
315
- if(!oldStroke){
316
+ if (!oldStroke) {
316
317
  g.noStroke();
317
318
  }
318
319
  }
319
320
 
320
- protected void restoreContext(PApplet p){
321
+ protected void restoreContext(PApplet p) {
321
322
  p.fill(oldFillColor);
322
- if(!oldFill){
323
+ if (!oldFill) {
323
324
  p.noFill();
324
325
  }
325
326
 
326
327
  p.stroke(oldStrokeColor);
327
328
  p.strokeWeight(oldStrokeWeight);
328
329
 
329
- try{
330
+ try {
330
331
  p.strokeCap(oldStrokeCap);
331
332
  p.strokeJoin(oldStrokeJoin);
332
- }catch(RuntimeException e){}
333
+ } catch (RuntimeException e) {
334
+ }
333
335
 
334
- if(!oldStroke){
336
+ if (!oldStroke) {
335
337
  p.noStroke();
336
- }
338
+ }
337
339
  }
338
340
 
339
- protected void restoreContext(){
341
+ protected void restoreContext() {
340
342
  restoreContext(RG.parent());
341
343
  }
342
344
 
343
- protected void setContext(PGraphics g){
344
- if(fillAlphaDef){
345
- if(fillDef){
345
+ protected void setContext(PGraphics g) {
346
+ if (fillAlphaDef) {
347
+ if (fillDef) {
346
348
  fillColor = ((fillAlpha << 24) & 0xff000000) | (fillColor & 0x00ffffff);
347
- }else{
348
- if(g.fill){
349
+ } else {
350
+ if (g.fill) {
349
351
  g.fill(((fillAlpha << 24) & 0xff000000) | (g.fillColor & 0x00ffffff));
350
352
  }
351
353
  }
352
354
  }
353
355
 
354
- if(fillDef){
356
+ if (fillDef) {
355
357
  g.fill(fillColor);
356
- if(!fill){
358
+ if (!fill) {
357
359
  g.noFill();
358
360
  }
359
361
  }
360
362
 
361
- if(strokeWeightDef){
363
+ if (strokeWeightDef) {
362
364
  g.strokeWeight(strokeWeight);
363
365
  }
364
366
 
365
- try{
366
- if(strokeCapDef){
367
+ try {
368
+ if (strokeCapDef) {
367
369
  g.strokeCap(strokeCap);
368
370
  }
369
-
370
- if(strokeJoinDef){
371
+
372
+ if (strokeJoinDef) {
371
373
  g.strokeJoin(strokeJoin);
372
374
  }
373
- }catch(RuntimeException e){}
375
+ } catch (RuntimeException e) {
376
+ }
374
377
 
375
- if(strokeAlphaDef){
376
- if(strokeDef){
378
+ if (strokeAlphaDef) {
379
+ if (strokeDef) {
377
380
  strokeColor = ((strokeAlpha << 24) & 0xff000000) | (strokeColor & 0x00ffffff);
378
- }else{
379
- if(g.stroke){
381
+ } else {
382
+ if (g.stroke) {
380
383
  g.stroke(((strokeAlpha << 24) & 0xff000000) | (g.strokeColor & 0x00ffffff));
381
384
  }
382
385
  }
383
386
  }
384
-
385
- if(strokeDef){
387
+
388
+ if (strokeDef) {
386
389
  g.stroke(strokeColor);
387
- if(!stroke){
390
+ if (!stroke) {
388
391
  g.noStroke();
389
392
  }
390
393
  }
391
394
  }
392
395
 
393
- protected void setContext(PApplet p){
394
-
395
- if(fillAlphaDef){
396
- if(fillDef){
396
+ protected void setContext(PApplet p) {
397
+
398
+ if (fillAlphaDef) {
399
+ if (fillDef) {
397
400
  fillColor = ((fillAlpha << 24) & 0xff000000) | (fillColor & 0x00ffffff);
398
- }else{
399
- if(p.g.fill){
401
+ } else {
402
+ if (p.g.fill) {
400
403
  p.fill(((fillAlpha << 24) & 0xff000000) | (p.g.fillColor & 0x00ffffff));
401
404
  }
402
405
  }
403
406
  }
404
-
405
- if(fillDef){
407
+
408
+ if (fillDef) {
406
409
  p.fill(fillColor);
407
- if(!fill){
410
+ if (!fill) {
408
411
  p.noFill();
409
412
  }
410
413
  }
411
414
 
412
- if(strokeWeightDef){
415
+ if (strokeWeightDef) {
413
416
  p.strokeWeight(strokeWeight);
414
417
  }
415
418
 
416
- try{
417
- if(strokeCapDef){
419
+ try {
420
+ if (strokeCapDef) {
418
421
  p.strokeCap(strokeCap);
419
422
  }
420
-
421
- if(strokeJoinDef){
423
+
424
+ if (strokeJoinDef) {
422
425
  p.strokeJoin(strokeJoin);
423
426
  }
424
- }catch(RuntimeException e){}
427
+ } catch (RuntimeException e) {
428
+ }
425
429
 
426
- if(strokeAlphaDef){
427
- if(strokeDef){
430
+ if (strokeAlphaDef) {
431
+ if (strokeDef) {
428
432
  strokeColor = ((strokeAlpha << 24) & 0xff000000) | (strokeColor & 0x00ffffff);
429
- }else{
430
- if(p.g.stroke){
433
+ } else {
434
+ if (p.g.stroke) {
431
435
  p.stroke(((strokeAlpha << 24) & 0xff000000) | (p.g.strokeColor & 0x00ffffff));
432
436
  }
433
437
  }
434
438
  }
435
439
 
436
- if(strokeDef){
440
+ if (strokeDef) {
437
441
  p.stroke(strokeColor);
438
- if(!stroke){
442
+ if (!stroke) {
439
443
  p.noStroke();
440
444
  }
441
445
  }
442
446
  }
443
447
 
444
- protected void setContext(){
448
+ protected void setContext() {
445
449
  setContext(RG.parent());
446
450
  }
447
451
 
448
-
449
- private int getColor(String colorString){
452
+ private int getColor(String colorString) {
450
453
  colorString = PApplet.trim(colorString);
451
-
452
- if(colorString.startsWith("#")){
453
- return PApplet.unhex("FF"+colorString.substring(1));
454
- }else if(colorString.startsWith("rgb")){
454
+
455
+ if (colorString.startsWith("#")) {
456
+ return PApplet.unhex("FF" + colorString.substring(1));
457
+ } else if (colorString.startsWith("rgb")) {
455
458
  String[] rgb = PApplet.splitTokens(colorString, "rgb( , )");
456
- return (int)RG.parent().color(PApplet.parseInt(rgb[0]), PApplet.parseInt(rgb[1]), PApplet.parseInt(rgb[2]));
457
- }else{
458
- switch (colorString) {
459
- case "black":
460
- return 0;
461
- case "red":
462
- return RG.parent().color(255, 0, 0);
463
- case "green":
464
- return RG.parent().color(0, 255, 0);
465
- case "blue":
466
- return RG.parent().color(0, 0, 255);
467
- case "yellow":
468
- return RG.parent().color(0, 255, 255);
469
- }
459
+ return (int) RG.parent().color(PApplet.parseInt(rgb[0]), PApplet.parseInt(rgb[1]), PApplet.parseInt(rgb[2]));
460
+ } else {
461
+ switch (colorString) {
462
+ case "black":
463
+ return 0;
464
+ case "red":
465
+ return RG.parent().color(255, 0, 0);
466
+ case "green":
467
+ return RG.parent().color(0, 255, 0);
468
+ case "blue":
469
+ return RG.parent().color(0, 0, 255);
470
+ case "yellow":
471
+ return RG.parent().color(0, 255, 255);
472
+ }
470
473
  }
471
474
  return 0;
472
475
  }