geomerative 1.1.0-java → 2.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
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,433 +1,471 @@
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
- */
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;
19
20
 
20
- package geomerative ;
21
- import processing.core.*;
21
+ import processing.core.PApplet;
22
+ import processing.core.PGraphics;
22
23
 
23
24
 
24
25
  /**
25
- * RGroup is a holder for a group of geometric elements that can be drawn and transformed, such as shapes, polygons or meshes.
26
- * @usage geometry
27
- * @extended
26
+ * RGroup is a holder for a group of geometric elements that can be drawn and
27
+ * transformed, such as shapes, polygons or meshes.
28
+ *
29
+ * geometry
30
+
28
31
  */
29
- public class RGroup extends RGeomElem
30
- {
32
+ public class RGroup extends RGeomElem {
33
+
31
34
  /**
32
- * @invisible
35
+ *
33
36
  */
34
37
  public int type = RGeomElem.GROUP;
35
-
38
+
36
39
  /**
37
- * Array of RGeomElem objects holding the elements of the group. When accessing theses elements we must cast them to their class in order to get all the functionalities of each representation. e.g. RShape s = group.elements[i].toShape() If the element cannot be converted to the target class it will throw a RuntimeException, to ignore these, use try-catch syntax.
38
- * @eexample RGroup_elements
39
- * @related RShape
40
- * @related RPolygon
41
- * @related RMesh
42
- * @related countElements ( )
43
- * @related addElement ( )
44
- * @related removeElement ( )
40
+ * Array of RGeomElem objects holding the elements of the group. When
41
+ * accessing theses elements we must cast them to their class in order to get
42
+ * all the functionalities of each representation. e.g. RShape s =
43
+ * group.elements[i].toShape() If the element cannot be converted to the
44
+ * target class it will throw a RuntimeException, to ignore these, use
45
+ * try-catch syntax.
46
+ *
47
+ RGroup_elements
48
+ * RShape
49
+ * RPolygon
50
+ * RMesh
51
+ * countElements ( )
52
+ * addElement ( )
53
+ * removeElement ( )
45
54
  */
46
55
  public RGeomElem[] elements;
47
-
56
+
48
57
  /**
49
58
  * Use this method to create a new empty group.
50
- * @eexample RGroup
59
+ *
60
+ RGroup
51
61
  */
52
- public RGroup(){
62
+ public RGroup() {
53
63
  elements = null;
54
64
  }
55
65
 
56
66
  /**
57
67
  * Use this method to create a copy of a group.
58
- * @param grp
59
- * @eexample RGroup
68
+ *
69
+ * @param grp
70
+ RGroup
60
71
  */
61
- public RGroup(RGroup grp){
62
- for(int i=0;i<grp.countElements();i++){
72
+ public RGroup(RGroup grp) {
73
+ for (int i = 0; i < grp.countElements(); i++) {
63
74
  //System.out.println(grp.elements[i].getType());
64
- switch(grp.elements[i].getType()){
65
- case RGeomElem.MESH:
66
- this.addElement(new RMesh((RMesh)grp.elements[i]));
67
- break;
68
-
69
- case RGeomElem.GROUP:
70
- this.addElement(new RGroup((RGroup)grp.elements[i]));
71
- break;
72
-
73
- case RGeomElem.POLYGON:
74
- this.addElement(new RPolygon((RPolygon)grp.elements[i]));
75
- break;
76
-
77
- case RGeomElem.SHAPE:
78
- this.addElement(new RShape((RShape)grp.elements[i]));
79
- break;
80
-
75
+ switch (grp.elements[i].getType()) {
76
+ case RGeomElem.MESH:
77
+ this.addElement(new RMesh((RMesh) grp.elements[i]));
78
+ break;
79
+
80
+ case RGeomElem.GROUP:
81
+ this.addElement(new RGroup((RGroup) grp.elements[i]));
82
+ break;
83
+
84
+ case RGeomElem.POLYGON:
85
+ this.addElement(new RPolygon((RPolygon) grp.elements[i]));
86
+ break;
87
+
88
+ case RGeomElem.SHAPE:
89
+ this.addElement(new RShape((RShape) grp.elements[i]));
90
+ break;
91
+
81
92
  }
82
93
  }
83
-
94
+
84
95
  setStyle(grp);
85
96
  }
86
-
87
-
97
+
88
98
  /**
89
99
  * Use this method to get the centroid of the element.
90
- * @eexample RGroup_getCentroid
100
+ *
101
+ RGroup_getCentroid
91
102
  * @return RPoint, the centroid point of the element
92
- * @related getBounds ( )
93
- * @related getCenter ( )
103
+ * getBounds ( )
104
+ * getCenter ( )
94
105
  */
95
106
  @Override
96
- public RPoint getCentroid(){
107
+ public RPoint getCentroid() {
97
108
  RPoint bestCentroid = new RPoint();
98
109
  float bestArea = Float.NEGATIVE_INFINITY;
99
- if(elements != null){
100
- for(int i=0;i<elements.length-1;i++)
101
- {
102
- float area = elements[i].getArea();
103
- if(area > bestArea){
104
- bestArea = area;
105
- bestCentroid = elements[i].getCentroid();
106
- }
110
+ if (elements != null) {
111
+ for (int i = 0; i < elements.length - 1; i++) {
112
+ float area = elements[i].getArea();
113
+ if (area > bestArea) {
114
+ bestArea = area;
115
+ bestCentroid = elements[i].getCentroid();
107
116
  }
117
+ }
108
118
  return bestCentroid;
109
119
  }
110
120
  return null;
111
121
  }
112
-
122
+
113
123
  /**
114
124
  * Use this method to count the number of elements in the group.
115
- * @eexample RGroup_countElements
125
+ *
126
+ RGroup_countElements
116
127
  * @return int, the number elements in the group.
117
- * @related addElement ( )
118
- * @related removeElement ( )
128
+ * addElement ( )
129
+ * removeElement ( )
119
130
  */
120
- public int countElements(){
121
- if(elements==null) return 0;
131
+ public int countElements() {
132
+ if (elements == null) {
133
+ return 0;
134
+ }
122
135
  return elements.length;
123
136
  }
124
-
137
+
125
138
  @Override
126
- public void print(){
139
+ public void print() {
127
140
  System.out.println("group: ");
128
- for(int i=0;i<countElements();i++)
129
- {
130
- System.out.println("--- "+i+" ---");
131
- elements[i].print();
132
- System.out.println("---------------");
133
- }
141
+ for (int i = 0; i < countElements(); i++) {
142
+ System.out.println("--- " + i + " ---");
143
+ elements[i].print();
144
+ System.out.println("---------------");
145
+ }
134
146
  }
135
-
147
+
136
148
  /**
137
- * Use this method to draw the group. This will draw each element at a time, without worrying about intersections or holes. This is the main difference between having a shape with multiple paths and having a group with multiple shapes.
138
- * @eexample RGroup_draw
149
+ * Use this method to draw the group. This will draw each element at a time,
150
+ * without worrying about intersections or holes. This is the main difference
151
+ * between having a shape with multiple paths and having a group with multiple
152
+ * shapes.
153
+ *
154
+ RGroup_draw
139
155
  * @param g PGraphics, the graphics object on which to draw the group
140
156
  */
141
157
  @Override
142
- public void draw(PGraphics g){
143
- if(!RG.ignoreStyles){
158
+ public void draw(PGraphics g) {
159
+ if (!RG.ignoreStyles) {
144
160
  saveContext(g);
145
161
  setContext(g);
146
162
  }
147
163
 
148
- for(int i=0; i<countElements(); i++){
164
+ for (int i = 0; i < countElements(); i++) {
149
165
  elements[i].draw(g);
150
166
  }
151
167
 
152
- if(!RG.ignoreStyles){
168
+ if (!RG.ignoreStyles) {
153
169
  restoreContext(g);
154
170
  }
155
171
  }
156
-
172
+
157
173
  @Override
158
- public void draw(PApplet a){
159
- if(!RG.ignoreStyles){
174
+ public void draw(PApplet a) {
175
+ if (!RG.ignoreStyles) {
160
176
  saveContext(a);
161
177
  setContext(a);
162
178
  }
163
179
 
164
- for(int i=0; i<countElements(); i++){
180
+ for (int i = 0; i < countElements(); i++) {
165
181
  elements[i].draw(a);
166
182
  }
167
-
168
- if(!RG.ignoreStyles){
183
+
184
+ if (!RG.ignoreStyles) {
169
185
  restoreContext(a);
170
186
  }
171
187
  }
172
-
188
+
173
189
  /**
174
190
  * Use this method to add a new element.
175
- * @eexample RGroup_addElement
176
- * @param elem RGeomElem, any kind of RGeomElem to add. It accepts the classes RShape, RPolygon and RMesh.
177
- * @related removeElement ( )
191
+ *
192
+ RGroup_addElement
193
+ * @param elem RGeomElem, any kind of RGeomElem to add. It accepts the classes
194
+ * RShape, RPolygon and RMesh.
195
+ * removeElement ( )
178
196
  */
179
- public final void addElement(RGeomElem elem){
197
+ public final void addElement(RGeomElem elem) {
180
198
  this.append(elem);
181
199
  }
182
-
200
+
183
201
  /**
184
202
  * Use this method to add a new element.
185
- * @eexample RGroup_addGroup
203
+ *
204
+ RGroup_addGroup
186
205
  * @param grupo RGroup, A group of elements to add to this group.
187
- * @related removeElement ( )
206
+ * removeElement ( )
188
207
  */
189
- public void addGroup(RGroup grupo){
190
- for(int i=0;i<grupo.countElements();i++){
208
+ public void addGroup(RGroup grupo) {
209
+ for (int i = 0; i < grupo.countElements(); i++) {
191
210
  this.addElement(grupo.elements[i]);
192
211
  }
193
212
  }
194
-
213
+
195
214
  /**
196
215
  * Use this method to remove an element.
197
- * @eexample RGroup_removeElement
216
+ *
217
+ RGroup_removeElement
198
218
  * @param i int, the index of the element to remove from the group.
199
- * @related addElement ( )
219
+ * addElement ( )
200
220
  */
201
- public void removeElement(int i) throws RuntimeException{
221
+ public void removeElement(int i) throws RuntimeException {
202
222
  this.extract(i);
203
223
  }
204
-
224
+
205
225
  /**
206
- * Use this method to get a new group whose elements are the corresponding meshes of the elements in the current group. This can be used for increasing performance in exchange of losing abstraction.
207
- * @eexample RGroup_toMeshGroup
226
+ * Use this method to get a new group whose elements are the corresponding
227
+ * meshes of the elements in the current group. This can be used for
228
+ * increasing performance in exchange of losing abstraction.
229
+ *
230
+ RGroup_toMeshGroup
208
231
  * @return RGroup, the new group made of RMeshes
209
- * @related toPolygonGroup ( )
210
- * @related toShapeGroup ( )
232
+ * toPolygonGroup ( )
233
+ * toShapeGroup ( )
211
234
  */
212
- public RGroup toMeshGroup() throws RuntimeException{
235
+ public RGroup toMeshGroup() throws RuntimeException {
213
236
  RGroup result = new RGroup();
214
- for(int i=0;i<countElements();i++){
237
+ for (int i = 0; i < countElements(); i++) {
215
238
  result.addElement(elements[i].toMesh());
216
239
  }
217
240
  return result;
218
241
  }
219
-
242
+
220
243
  /**
221
- * Use this method to get a new group whose elements are the corresponding polygons of the elements in the current group. At this moment there is no implementation for transforming a mesh to a polygon so applying this method to groups holding mesh elements will generate an exception.
222
- * @eexample RGroup_toPolygonGroup
244
+ * Use this method to get a new group whose elements are the corresponding
245
+ * polygons of the elements in the current group. At this moment there is no
246
+ * implementation for transforming a mesh to a polygon so applying this method
247
+ * to groups holding mesh elements will generate an exception.
248
+ *
249
+ RGroup_toPolygonGroup
223
250
  * @return RGroup, the new group made of RPolygons
224
- * @related toMeshGroup ( )
225
- * @related toShapeGroup ( )
251
+ * toMeshGroup ( )
252
+ * toShapeGroup ( )
226
253
  */
227
- public RGroup toPolygonGroup() throws RuntimeException{
254
+ public RGroup toPolygonGroup() throws RuntimeException {
228
255
  RGroup result = new RGroup();
229
- for(int i=0;i<countElements();i++){
256
+ for (int i = 0; i < countElements(); i++) {
230
257
  RGeomElem element = elements[i];
231
- if(element.getType() == RGeomElem.GROUP){
232
- RGeomElem newElement = ((RGroup)(element)).toPolygonGroup();
258
+ if (element.getType() == RGeomElem.GROUP) {
259
+ RGeomElem newElement = ((RGroup) (element)).toPolygonGroup();
233
260
  result.addElement(newElement);
234
- }else{
261
+ } else {
235
262
  result.addElement(element.toPolygon());
236
263
  }
237
264
  }
238
265
  result.setStyle(this);
239
266
  return result;
240
267
  }
241
-
268
+
242
269
  /**
243
- * Use this method to get a new group whose elements are all the corresponding shapes of the elements in the current group. At this moment there is no implementation for transforming a mesh or a polygon to a shape so applying this method to groups holding mesh or polygon elements will generate an exception.
244
- * @eexample RGroup_toShapeGroup
270
+ * Use this method to get a new group whose elements are all the corresponding
271
+ * shapes of the elements in the current group. At this moment there is no
272
+ * implementation for transforming a mesh or a polygon to a shape so applying
273
+ * this method to groups holding mesh or polygon elements will generate an
274
+ * exception.
275
+ *
276
+ RGroup_toShapeGroup
245
277
  * @return RGroup, the new group made of RShapes
246
- * @related toMeshGroup ( )
247
- * @related toPolygonGroup ( )
278
+ * toMeshGroup ( )
279
+ * toPolygonGroup ( )
248
280
  */
249
- public RGroup toShapeGroup() throws RuntimeException{
281
+ public RGroup toShapeGroup() throws RuntimeException {
250
282
  RGroup result = new RGroup();
251
- for(int i=0;i<countElements();i++){
283
+ for (int i = 0; i < countElements(); i++) {
252
284
  RGeomElem element = elements[i];
253
- if(element.getType() == RGeomElem.GROUP){
254
- RGeomElem newElement = ((RGroup)(element)).toShapeGroup();
285
+ if (element.getType() == RGeomElem.GROUP) {
286
+ RGeomElem newElement = ((RGroup) (element)).toShapeGroup();
255
287
  result.addElement(newElement);
256
- }else{
288
+ } else {
257
289
  result.addElement(element.toShape());
258
290
  }
259
291
  }
260
292
  result.setStyle(this);
261
293
  return result;
262
294
  }
263
-
295
+
264
296
  /**
265
- * @return
266
- * @invisible
297
+ * @return
267
298
  */
268
299
  @Override
269
- public RMesh toMesh() throws RuntimeException{
300
+ public RMesh toMesh() throws RuntimeException {
270
301
  //throw new RuntimeException("Transforming a Group to a Mesh is not yet implemented.");
271
302
  RGroup meshGroup = toMeshGroup();
272
303
  RMesh result = new RMesh();
273
- for(int i=0;i<countElements();i++){
274
- RMesh currentMesh = (RMesh)(meshGroup.elements[i]);
275
- for(int j=0;j<currentMesh.countStrips();j++){
304
+ for (int i = 0; i < countElements(); i++) {
305
+ RMesh currentMesh = (RMesh) (meshGroup.elements[i]);
306
+ for (int j = 0; j < currentMesh.countStrips(); j++) {
276
307
  result.addStrip(currentMesh.strips[j]);
277
308
  }
278
309
  }
279
310
  result.setStyle(this);
280
311
  return result;
281
312
  }
282
-
313
+
283
314
  /**
284
- * @return
285
- * @invisible
315
+ * @return
286
316
  */
287
317
  @Override
288
- public RPolygon toPolygon() throws RuntimeException{
318
+ public RPolygon toPolygon() throws RuntimeException {
289
319
  //throw new RuntimeException("Transforming a Group to a Polygon is not yet implemented.");
290
320
  //RGroup polygonGroup = toPolygonGroup();
291
321
  RPolygon result = new RPolygon();
292
- for(int i=0;i<countElements();i++){
322
+ for (int i = 0; i < countElements(); i++) {
293
323
  RPolygon currentPolygon = elements[i].toPolygon();
294
- for(int j=0;j<currentPolygon.countContours();j++){
324
+ for (int j = 0; j < currentPolygon.countContours(); j++) {
295
325
  result.addContour(currentPolygon.contours[j]);
296
326
  }
297
327
  }
298
328
  result.setStyle(this);
299
329
  return result;
300
330
  }
301
-
331
+
302
332
  /**
303
- * @return
304
- * @invisible
333
+ * @return
305
334
  */
306
335
  @Override
307
- public RShape toShape() throws RuntimeException{
336
+ public RShape toShape() throws RuntimeException {
308
337
  //throw new RuntimeException("Transforming a Group to a Shape is not yet implemented.");
309
338
  RShape result = new RShape();
310
- for(int i=0;i<countElements();i++){
339
+ for (int i = 0; i < countElements(); i++) {
311
340
  RShape currentShape = elements[i].toShape();
312
- for(int j=0;j<currentShape.countPaths();j++){
341
+ for (int j = 0; j < currentShape.countPaths(); j++) {
313
342
  result.addPath(currentShape.paths[j]);
314
343
  }
315
344
  }
316
345
  result.setStyle(this);
317
346
  return result;
318
347
  }
319
-
348
+
320
349
  /**
321
- * Use this to return the points of the group. It returns the points as an array of RPoint.
322
- * @eexample RGroup_getHandles
350
+ * Use this to return the points of the group. It returns the points as an
351
+ * array of RPoint.
352
+ *
353
+ RGroup_getHandles
323
354
  * @return RPoint[], the points returned in an array.
324
- * */
355
+ *
356
+ */
325
357
  @Override
326
- public RPoint[] getHandles(){
358
+ public RPoint[] getHandles() {
327
359
  int numElements = countElements();
328
- if(numElements == 0){
360
+ if (numElements == 0) {
329
361
  return null;
330
362
  }
331
-
332
- RPoint[] result=null;
363
+
364
+ RPoint[] result = null;
333
365
  RPoint[] newresult;
334
- for(int i=0;i<numElements;i++){
366
+ for (int i = 0; i < numElements; i++) {
335
367
  RPoint[] newPoints = elements[i].getHandles();
336
- if(newPoints!=null){
337
- if(result==null){
368
+ if (newPoints != null) {
369
+ if (result == null) {
338
370
  result = new RPoint[newPoints.length];
339
- System.arraycopy(newPoints,0,result,0,newPoints.length);
340
- }else{
371
+ System.arraycopy(newPoints, 0, result, 0, newPoints.length);
372
+ } else {
341
373
  newresult = new RPoint[result.length + newPoints.length];
342
- System.arraycopy(result,0,newresult,0,result.length);
343
- System.arraycopy(newPoints,0,newresult,result.length,newPoints.length);
374
+ System.arraycopy(result, 0, newresult, 0, result.length);
375
+ System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
344
376
  result = newresult;
345
377
  }
346
378
  }
347
379
  }
348
380
  return result;
349
- }
350
-
351
- /**
352
- *
353
- * @param t
354
- * @return
355
- */
356
- @Override
357
- public RPoint getPoint(float t){
381
+ }
382
+
383
+ /**
384
+ *
385
+ * @param t
386
+ * @return
387
+ */
388
+ @Override
389
+ public RPoint getPoint(float t) {
358
390
  float[] indAndAdv = indAndAdvAt(t);
359
- int indOfElement = (int)(indAndAdv[0]);
391
+ int indOfElement = (int) (indAndAdv[0]);
360
392
  float advOfElement = indAndAdv[1];
361
393
 
362
394
  return elements[indOfElement].getPoint(advOfElement);
363
395
  }
364
396
 
365
397
  /**
366
- * Use this to return the points of the group. It returns the points as an array of RPoint.
367
- * @eexample RGroup_getPoints
398
+ * Use this to return the points of the group. It returns the points as an
399
+ * array of RPoint.
400
+ *
401
+ RGroup_getPoints
368
402
  * @return RPoint[], the points returned in an array.
369
- * */
403
+ *
404
+ */
370
405
  @Override
371
- public RPoint[] getPoints(){
406
+ public RPoint[] getPoints() {
372
407
  int numElements = countElements();
373
- if(numElements == 0){
408
+ if (numElements == 0) {
374
409
  return null;
375
410
  }
376
411
 
377
- RCommand.segmentAccOffset = RCommand.segmentOffset;
378
- RPoint[] result=null;
412
+ RCommand.segmentAccOffset = RCommand.segmentOffset;
413
+ RPoint[] result = null;
379
414
  RPoint[] newresult;
380
- for(int i=0;i<numElements;i++){
415
+ for (int i = 0; i < numElements; i++) {
381
416
  RPoint[] newPoints = elements[i].getPoints();
382
- if(newPoints!=null){
383
- if(result==null){
417
+ if (newPoints != null) {
418
+ if (result == null) {
384
419
  result = new RPoint[newPoints.length];
385
- System.arraycopy(newPoints,0,result,0,newPoints.length);
386
- }else{
420
+ System.arraycopy(newPoints, 0, result, 0, newPoints.length);
421
+ } else {
387
422
  newresult = new RPoint[result.length + newPoints.length];
388
- System.arraycopy(result,0,newresult,0,result.length);
389
- System.arraycopy(newPoints,0,newresult,result.length,newPoints.length);
423
+ System.arraycopy(result, 0, newresult, 0, result.length);
424
+ System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
390
425
  result = newresult;
391
426
  }
392
427
  }
393
428
  }
394
-
429
+
395
430
  return result;
396
431
  }
397
432
 
398
433
  @Override
399
- public RPoint getTangent(float t){
434
+ public RPoint getTangent(float t) {
400
435
  float[] indAndAdv = indAndAdvAt(t);
401
- int indOfElement = (int)(indAndAdv[0]);
436
+ int indOfElement = (int) (indAndAdv[0]);
402
437
  float advOfElement = indAndAdv[1];
403
438
 
404
439
  return elements[indOfElement].getTangent(advOfElement);
405
440
  }
406
441
 
407
442
  /**
408
- * Use this to return the points of the group. It returns the points as an array of RPoint.
409
- * @eexample RGroup_getPoints
443
+ * Use this to return the points of the group. It returns the points as an
444
+ * array of RPoint.
445
+ *
446
+ RGroup_getPoints
410
447
  * @return RPoint[], the points returned in an array.
411
- * */
448
+ *
449
+ */
412
450
  @Override
413
- public RPoint[] getTangents(){
451
+ public RPoint[] getTangents() {
414
452
  int numElements = countElements();
415
- if(numElements == 0){
453
+ if (numElements == 0) {
416
454
  return null;
417
455
  }
418
-
419
- RPoint[] result=null;
456
+
457
+ RPoint[] result = null;
420
458
  RPoint[] newresult;
421
- for(int i=0;i<numElements;i++){
459
+ for (int i = 0; i < numElements; i++) {
422
460
  RPoint[] newPoints = elements[i].getTangents();
423
- if(newPoints!=null){
424
- if(result==null){
461
+ if (newPoints != null) {
462
+ if (result == null) {
425
463
  result = new RPoint[newPoints.length];
426
- System.arraycopy(newPoints,0,result,0,newPoints.length);
427
- }else{
464
+ System.arraycopy(newPoints, 0, result, 0, newPoints.length);
465
+ } else {
428
466
  newresult = new RPoint[result.length + newPoints.length];
429
- System.arraycopy(result,0,newresult,0,result.length);
430
- System.arraycopy(newPoints,0,newresult,result.length,newPoints.length);
467
+ System.arraycopy(result, 0, newresult, 0, result.length);
468
+ System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
431
469
  result = newresult;
432
470
  }
433
471
  }
@@ -436,93 +474,99 @@ public class RGroup extends RGeomElem
436
474
  }
437
475
 
438
476
  /**
439
- * Use this to return the points of each path of the group. It returns the points as an array of arrays of RPoint.
440
- * @eexample RGroup_getPoints
477
+ * Use this to return the points of each path of the group. It returns the
478
+ * points as an array of arrays of RPoint.
479
+ *
480
+ RGroup_getPoints
441
481
  * @return RPoint[], the points returned in an array.
442
- * */
482
+ *
483
+ */
443
484
  @Override
444
- public RPoint[][] getPointsInPaths(){
485
+ public RPoint[][] getPointsInPaths() {
445
486
  int numElements = countElements();
446
- if(numElements == 0){
487
+ if (numElements == 0) {
447
488
  return null;
448
489
  }
449
-
450
- RPoint[][] result=null;
490
+
491
+ RPoint[][] result = null;
451
492
  RPoint[][] newresult;
452
- for(int i=0;i<numElements;i++){
493
+ for (int i = 0; i < numElements; i++) {
453
494
  RPoint[][] newPointPaths = elements[i].getPointsInPaths();
454
- if(newPointPaths != null){
455
- if(result == null){
495
+ if (newPointPaths != null) {
496
+ if (result == null) {
456
497
  result = new RPoint[newPointPaths.length][];
457
- System.arraycopy(newPointPaths,0,result,0,newPointPaths.length);
458
- }else{
498
+ System.arraycopy(newPointPaths, 0, result, 0, newPointPaths.length);
499
+ } else {
459
500
  newresult = new RPoint[result.length + newPointPaths.length][];
460
- System.arraycopy(result,0,newresult,0,result.length);
461
- System.arraycopy(newPointPaths,0,newresult,result.length,newPointPaths.length);
501
+ System.arraycopy(result, 0, newresult, 0, result.length);
502
+ System.arraycopy(newPointPaths, 0, newresult, result.length, newPointPaths.length);
462
503
  result = newresult;
463
504
  }
464
505
  }
465
506
  }
466
- return result;
507
+ return result;
467
508
  }
468
509
 
469
510
  @Override
470
- public RPoint[][] getHandlesInPaths(){
511
+ public RPoint[][] getHandlesInPaths() {
471
512
  int numElements = countElements();
472
- if(numElements == 0){
513
+ if (numElements == 0) {
473
514
  return null;
474
- }
475
- RPoint[][] result=null;
515
+ }
516
+ RPoint[][] result = null;
476
517
  RPoint[][] newresult;
477
- for(int i=0;i<numElements;i++){
518
+ for (int i = 0; i < numElements; i++) {
478
519
  RPoint[][] newHandlePaths = elements[i].getHandlesInPaths();
479
- if(newHandlePaths != null){
480
- if(result == null){
520
+ if (newHandlePaths != null) {
521
+ if (result == null) {
481
522
  result = new RPoint[newHandlePaths.length][];
482
- System.arraycopy(newHandlePaths,0,result,0,newHandlePaths.length);
483
- }else{
523
+ System.arraycopy(newHandlePaths, 0, result, 0, newHandlePaths.length);
524
+ } else {
484
525
  newresult = new RPoint[result.length + newHandlePaths.length][];
485
- System.arraycopy(result,0,newresult,0,result.length);
486
- System.arraycopy(newHandlePaths,0,newresult,result.length,newHandlePaths.length);
526
+ System.arraycopy(result, 0, newresult, 0, result.length);
527
+ System.arraycopy(newHandlePaths, 0, newresult, result.length, newHandlePaths.length);
487
528
  result = newresult;
488
529
  }
489
530
  }
490
531
  }
491
- return result;
532
+ return result;
492
533
  }
493
534
 
494
535
  @Override
495
- public RPoint[][] getTangentsInPaths(){
536
+ public RPoint[][] getTangentsInPaths() {
496
537
  int numElements = countElements();
497
- if(numElements == 0){
538
+ if (numElements == 0) {
498
539
  return null;
499
- }
500
- RPoint[][] result=null;
540
+ }
541
+ RPoint[][] result = null;
501
542
  RPoint[][] newresult;
502
- for(int i=0;i<numElements;i++){
543
+ for (int i = 0; i < numElements; i++) {
503
544
  RPoint[][] newTangentPaths = elements[i].getTangentsInPaths();
504
- if(newTangentPaths != null){
505
- if(result == null){
545
+ if (newTangentPaths != null) {
546
+ if (result == null) {
506
547
  result = new RPoint[newTangentPaths.length][];
507
- System.arraycopy(newTangentPaths,0,result,0,newTangentPaths.length);
508
- }else{
548
+ System.arraycopy(newTangentPaths, 0, result, 0, newTangentPaths.length);
549
+ } else {
509
550
  newresult = new RPoint[result.length + newTangentPaths.length][];
510
- System.arraycopy(result,0,newresult,0,result.length);
511
- System.arraycopy(newTangentPaths,0,newresult,result.length,newTangentPaths.length);
551
+ System.arraycopy(result, 0, newresult, 0, result.length);
552
+ System.arraycopy(newTangentPaths, 0, newresult, result.length, newTangentPaths.length);
512
553
  result = newresult;
513
554
  }
514
555
  }
515
556
  }
516
- return result;
557
+ return result;
517
558
  }
518
559
 
519
560
  /**
520
- * Use this to return a specific tangent on the curve. It returns true if the point passed as a parameter is inside the group.
521
- * @param p the point for which to test containment..
561
+ * Use this to return a specific tangent on the curve. It returns true if the
562
+ * point passed as a parameter is inside the group.
563
+ *
564
+ * @param p the point for which to test containment..
522
565
  * @return boolean, true if the point is in the path.
523
- * */
566
+ *
567
+ */
524
568
  @Override
525
- public boolean contains(RPoint p){
569
+ public boolean contains(RPoint p) {
526
570
  float testx = p.x;
527
571
  float testy = p.y;
528
572
 
@@ -533,63 +577,62 @@ public class RGroup extends RGeomElem
533
577
 
534
578
  float ymin = bbox.getMinY();
535
579
  float ymax = bbox.getMaxY();
536
-
537
- if( (testx < xmin) || (testx > xmax) || (testy < ymin) || (testy > ymax)){
580
+
581
+ if ((testx < xmin) || (testx > xmax) || (testy < ymin) || (testy > ymax)) {
538
582
  return false;
539
583
  }
540
-
584
+
541
585
  // Test for containment in elements
542
586
  boolean result = false;
543
- for(int i = 0;i<countElements();i++){
587
+ for (int i = 0; i < countElements(); i++) {
544
588
  result |= elements[i].contains(p);
545
589
  }
546
590
  return result;
547
591
  }
548
592
 
549
-
550
593
  /**
551
594
  * Use this method to get the type of element this is.
552
- * @eexample RPolygon_getType
595
+ *
596
+ RPolygon_getType
553
597
  * @return int, will allways return RGeomElem.POLYGON
554
598
  */
555
599
  @Override
556
- public int getType(){
600
+ public int getType() {
557
601
  return type;
558
602
  }
559
603
 
560
- private float[] indAndAdvAt(float t){
604
+ private float[] indAndAdvAt(float t) {
561
605
  int indOfElement = 0;
562
606
  float[] lengthsCurves = getCurveLengths();
563
607
  float lengthCurve = getCurveLength();
564
608
 
565
609
  /* Calculate the amount of advancement t mapped to each command */
566
- /* We use a simple algorithm where we give to each command the same amount of advancement */
567
- /* A more useful way would be to give to each command an advancement proportional to the length of the command */
568
-
610
+ /* We use a simple algorithm where we give to each command the same amount of advancement */
611
+ /* A more useful way would be to give to each command an advancement proportional to the length of the command */
569
612
  float accumulatedAdvancement = lengthsCurves[indOfElement] / lengthCurve;
570
613
  float prevAccumulatedAdvancement = 0F;
571
-
614
+
572
615
  /* Find in what command the advancement point is */
573
- while(t > accumulatedAdvancement){
616
+ while (t > accumulatedAdvancement) {
574
617
  indOfElement++;
575
618
  prevAccumulatedAdvancement = accumulatedAdvancement;
576
619
  accumulatedAdvancement += (lengthsCurves[indOfElement] / lengthCurve);
577
620
  }
578
-
579
- float advOfElement = (t-prevAccumulatedAdvancement) / (lengthsCurves[indOfElement] / lengthCurve);
621
+
622
+ float advOfElement = (t - prevAccumulatedAdvancement) / (lengthsCurves[indOfElement] / lengthCurve);
580
623
 
581
624
  float[] indAndAdv = new float[2];
582
625
 
583
626
  indAndAdv[0] = indOfElement;
584
627
  indAndAdv[1] = advOfElement;
585
-
628
+
586
629
  return indAndAdv;
587
630
  }
588
631
 
589
- public RGroup[] split(float t){
632
+ public RGroup[] split(float t) {
590
633
  RGroup[] result = new RGroup[2];
591
634
 
592
- if(t == 0.0F){
635
+ if (t == 0.0F) {
593
636
  result[0] = new RGroup();
594
637
  result[1] = new RGroup(this);
595
638
  result[0].setStyle(this);
@@ -597,8 +640,8 @@ public class RGroup extends RGeomElem
597
640
 
598
641
  return result;
599
642
  }
600
-
601
- if(t == 1.0F){
643
+
644
+ if (t == 1.0F) {
602
645
  result[0] = new RGroup(this);
603
646
  result[1] = new RGroup();
604
647
  result[0].setStyle(this);
@@ -611,300 +654,298 @@ public class RGroup extends RGeomElem
611
654
  result[1] = new RGroup();
612
655
 
613
656
  float[] indAndAdv = indAndAdvAt(t);
614
- int indOfElement = (int)(indAndAdv[0]);
657
+ int indOfElement = (int) (indAndAdv[0]);
615
658
  float advOfElement = indAndAdv[1];
616
659
 
617
660
  // Add the elements before the cut point
618
- for(int i=0; i<indOfElement; i++){
619
- switch(elements[i].getType()){
620
- case RGeomElem.MESH:
621
- result[0].addElement(new RMesh((RMesh)elements[i]));
622
- break;
623
-
624
- case RGeomElem.GROUP:
625
- result[0].addElement(new RGroup((RGroup)elements[i]));
626
- break;
627
-
628
- case RGeomElem.POLYGON:
629
- result[0].addElement(new RPolygon((RPolygon)elements[i]));
630
- break;
631
-
632
- case RGeomElem.SHAPE:
633
- result[0].addElement(new RShape((RShape)elements[i]));
634
- break;
661
+ for (int i = 0; i < indOfElement; i++) {
662
+ switch (elements[i].getType()) {
663
+ case RGeomElem.MESH:
664
+ result[0].addElement(new RMesh((RMesh) elements[i]));
665
+ break;
666
+
667
+ case RGeomElem.GROUP:
668
+ result[0].addElement(new RGroup((RGroup) elements[i]));
669
+ break;
670
+
671
+ case RGeomElem.POLYGON:
672
+ result[0].addElement(new RPolygon((RPolygon) elements[i]));
673
+ break;
674
+
675
+ case RGeomElem.SHAPE:
676
+ result[0].addElement(new RShape((RShape) elements[i]));
677
+ break;
635
678
  }
636
679
  }
637
680
 
638
681
  // Add the cut point element cutted
639
682
  RGeomElem element = this.elements[indOfElement];
640
- switch(element.getType())
641
- {
683
+ switch (element.getType()) {
642
684
  case RGeomElem.GROUP:
643
- RGroup[] splittedGroups = ((RGroup)element).split(advOfElement);
644
- if( splittedGroups != null ){
685
+ RGroup[] splittedGroups = ((RGroup) element).split(advOfElement);
686
+ if (splittedGroups != null) {
645
687
  result[0].addElement(new RGroup(splittedGroups[0]));
646
688
  result[1].addElement(new RGroup(splittedGroups[1]));
647
689
  }
648
690
  break;
649
-
691
+
650
692
  case RGeomElem.SHAPE:
651
- RShape[] splittedShapes = ((RShape)element).split(advOfElement);
652
- if( splittedShapes != null ){
693
+ RShape[] splittedShapes = ((RShape) element).split(advOfElement);
694
+ if (splittedShapes != null) {
653
695
  result[0].addElement(new RShape(splittedShapes[0]));
654
696
  result[1].addElement(new RShape(splittedShapes[1]));
655
697
  }
656
698
  break;
657
- }
699
+ }
658
700
 
659
701
  // Add the elements after the cut point
660
- for(int i=indOfElement+1; i<countElements(); i++){
661
- switch(elements[i].getType()){
662
- case RGeomElem.MESH:
663
- result[1].addElement(new RMesh((RMesh)elements[i]));
664
- break;
665
-
666
- case RGeomElem.GROUP:
667
- result[1].addElement(new RGroup((RGroup)elements[i]));
668
- break;
669
-
670
- case RGeomElem.POLYGON:
671
- result[1].addElement(new RPolygon((RPolygon)elements[i]));
672
- break;
673
-
674
- case RGeomElem.SHAPE:
675
- result[1].addElement(new RShape((RShape)elements[i]));
676
- break;
702
+ for (int i = indOfElement + 1; i < countElements(); i++) {
703
+ switch (elements[i].getType()) {
704
+ case RGeomElem.MESH:
705
+ result[1].addElement(new RMesh((RMesh) elements[i]));
706
+ break;
707
+
708
+ case RGeomElem.GROUP:
709
+ result[1].addElement(new RGroup((RGroup) elements[i]));
710
+ break;
711
+
712
+ case RGeomElem.POLYGON:
713
+ result[1].addElement(new RPolygon((RPolygon) elements[i]));
714
+ break;
715
+
716
+ case RGeomElem.SHAPE:
717
+ result[1].addElement(new RShape((RShape) elements[i]));
718
+ break;
677
719
  }
678
720
  }
679
-
721
+
680
722
  result[0].setStyle(this);
681
723
  result[1].setStyle(this);
682
-
724
+
683
725
  return result;
684
726
  }
685
727
 
686
- public RGroup[] splitPaths(float t){
728
+ public RGroup[] splitPaths(float t) {
687
729
  RGroup[] result = new RGroup[2];
688
730
  result[0] = new RGroup();
689
731
  result[1] = new RGroup();
690
- for(int i = 0; i<this.countElements(); i++){
732
+ for (int i = 0; i < this.countElements(); i++) {
691
733
  RGeomElem element = this.elements[i];
692
-
693
- switch(element.getType())
694
- {
734
+
735
+ switch (element.getType()) {
695
736
  case RGeomElem.GROUP:
696
- RGroup[] splittedGroups = ((RGroup)element).splitPaths(t);
697
- if( splittedGroups != null ){
737
+ RGroup[] splittedGroups = ((RGroup) element).splitPaths(t);
738
+ if (splittedGroups != null) {
698
739
  result[0].addElement(splittedGroups[0]);
699
740
  result[1].addElement(splittedGroups[1]);
700
741
  }
701
742
  break;
702
-
743
+
703
744
  case RGeomElem.SHAPE:
704
- RShape[] splittedShapes = ((RShape)element).splitPaths(t);
705
- if( splittedShapes != null ){
745
+ RShape[] splittedShapes = ((RShape) element).splitPaths(t);
746
+ if (splittedShapes != null) {
706
747
  result[0].addElement(splittedShapes[0]);
707
748
  result[1].addElement(splittedShapes[1]);
708
749
  }
709
750
  break;
710
- }
751
+ }
711
752
  }
712
753
  result[0].setStyle(this);
713
754
  result[1].setStyle(this);
714
755
 
715
756
  return result;
716
757
  }
717
-
758
+
718
759
  /**
719
760
  * Use this to insert a split point into each command of the group.
720
- * @eexample insertHandleInPaths
721
- * @param t float, the parameter of advancement on the curve. t must have values between 0 and 1.
722
- * */
723
- public void insertHandleInPaths(float t){
724
- if((t == 0F) || (t == 1F)){
761
+ *
762
+ insertHandleInPaths
763
+ * @param t float, the parameter of advancement on the curve. t must have
764
+ * values between 0 and 1.
765
+ *
766
+ */
767
+ public void insertHandleInPaths(float t) {
768
+ if ((t == 0F) || (t == 1F)) {
725
769
  return;
726
770
  }
727
-
728
- for(int i = 0; i<this.countElements(); i++){
771
+
772
+ for (int i = 0; i < this.countElements(); i++) {
729
773
  RGeomElem element = this.elements[i];
730
-
731
- switch(element.getType())
732
- {
774
+
775
+ switch (element.getType()) {
733
776
  case RGeomElem.GROUP:
734
- ((RGroup)element).insertHandleInPaths(t);
777
+ ((RGroup) element).insertHandleInPaths(t);
735
778
  break;
736
-
779
+
737
780
  case RGeomElem.SHAPE:
738
- ((RShape)element).insertHandleInPaths(t);
781
+ ((RShape) element).insertHandleInPaths(t);
739
782
  break;
740
- }
741
- }
783
+ }
784
+ }
742
785
  }
743
-
744
-
786
+
745
787
  @Override
746
- protected void calculateCurveLengths(){
788
+ protected void calculateCurveLengths() {
747
789
  lenCurves = new float[countElements()];
748
790
  lenCurve = 0F;
749
- for(int i=0;i<countElements();i++){
750
- lenCurves[i] = elements[i].getCurveLength();
791
+ for (int i = 0; i < countElements(); i++) {
792
+ lenCurves[i] = elements[i].getCurveLength();
751
793
  lenCurve += lenCurves[i];
752
794
  }
753
795
  }
754
-
755
-
796
+
756
797
  /**
757
798
  * Use this method to adapt a group of of figures to a group.
758
- * @param wght
759
- * @param lngthOffset
760
- * @eexample RGroup_adapt
761
- * @param grp the path to which to adapt
799
+ *
800
+ * @param wght
801
+ * @param lngthOffset
802
+ RGroup_adapt
803
+ * @param grp the path to which to adapt
762
804
  */
763
- public void adapt(RGroup grp, float wght, float lngthOffset) throws RuntimeException{
805
+ public void adapt(RGroup grp, float wght, float lngthOffset) throws RuntimeException {
764
806
  RRectangle c = this.getBounds();
765
807
  float xmin = c.getMinX();
766
808
  float xmax = c.getMaxX();
767
809
  float ymax = c.getMaxY();
768
-
810
+
769
811
  int numElements = this.countElements();
770
-
771
- switch(RG.adaptorType){
772
- case RG.BYPOINT:
773
- for(int i=0;i<numElements;i++){
774
- RGeomElem elem = this.elements[i];
775
- RPoint[] ps = elem.getHandles();
776
- if(ps != null){
812
+
813
+ switch (RG.adaptorType) {
814
+ case RG.BYPOINT:
815
+ for (int i = 0; i < numElements; i++) {
816
+ RGeomElem elem = this.elements[i];
817
+ RPoint[] ps = elem.getHandles();
818
+ if (ps != null) {
777
819
  for (RPoint p1 : ps) {
778
- float px = p1.x;
779
- float py = p1.y;
780
- float t = ((px-xmin)/(xmax-xmin) + lngthOffset ) % 1.001F;
781
- float amp = (ymax-py);
782
- RPoint tg = grp.getTangent(t);
783
- RPoint p = grp.getPoint(t);
784
- float angle = (float)Math.atan2(tg.y, tg.x) - (float)Math.PI/2F;
785
- p1.x = p.x + wght*amp*(float)Math.cos(angle);
786
- p1.y = p.y + wght*amp*(float)Math.sin(angle);
820
+ float px = p1.x;
821
+ float py = p1.y;
822
+ float t = ((px - xmin) / (xmax - xmin) + lngthOffset) % 1.001F;
823
+ float amp = (ymax - py);
824
+ RPoint tg = grp.getTangent(t);
825
+ RPoint p = grp.getPoint(t);
826
+ float angle = (float) Math.atan2(tg.y, tg.x) - (float) Math.PI / 2F;
827
+ p1.x = p.x + wght * amp * (float) Math.cos(angle);
828
+ p1.y = p.y + wght * amp * (float) Math.sin(angle);
787
829
  }
830
+ }
788
831
  }
789
- }
790
- break;
791
- case RG.BYELEMENTPOSITION:
792
-
793
- for(int i=0;i<numElements;i++){
794
- RGeomElem elem = this.elements[i];
795
- RRectangle elemc = elem.getBounds();
796
-
797
- float px = (elemc.bottomRight.x + elemc.topLeft.x) / 2F;
798
- float py = (elemc.bottomRight.y - elemc.topLeft.y) / 2F;
799
- float t = ((px-xmin)/(xmax-xmin) + lngthOffset ) % 1F;
800
-
801
- RPoint tg = grp.getTangent(t);
802
- RPoint p = grp.getPoint(t);
803
- float angle = (float)Math.atan2(tg.y, tg.x);
804
-
805
- RPoint pletter = new RPoint(px,py);
806
- p.sub(pletter);
807
-
808
- RMatrix mtx = new RMatrix();
809
- mtx.translate(p);
810
- mtx.rotate(angle,pletter);
811
- mtx.scale(wght,pletter);
812
-
813
- elem.transform(mtx);
814
- }
815
- break;
816
-
817
- case RG.BYELEMENTINDEX:
818
-
819
- for(int i=0;i<numElements;i++){
820
- RGeomElem elem = this.elements[i];
821
- RRectangle elemc = elem.getBounds();
822
-
823
- float px = (elemc.bottomRight.x + elemc.topLeft.x) / 2F;
824
- float py = (elemc.bottomRight.y - elemc.topLeft.y) / 2F;
825
- float t = ((float)i/(float)numElements + lngthOffset ) % 1F;
826
-
827
- RPoint tg = grp.getTangent(t);
828
- RPoint p = grp.getPoint(t);
829
- float angle = (float)Math.atan2(tg.y, tg.x);
830
-
831
- RPoint pletter = new RPoint(px,py);
832
- p.sub(pletter);
833
-
834
- RMatrix mtx = new RMatrix();
835
- mtx.translate(p);
836
- mtx.rotate(angle,pletter);
837
- mtx.scale(wght,pletter);
838
-
839
- elem.transform(mtx);
840
- }
841
- break;
842
-
843
- default:
844
- throw new RuntimeException("Unknown adaptor type : "+RG.adaptorType+". The method RG.setAdaptor() only accepts RG.BYPOINT or RG.BYELEMENT as parameter values.");
832
+ break;
833
+ case RG.BYELEMENTPOSITION:
834
+
835
+ for (int i = 0; i < numElements; i++) {
836
+ RGeomElem elem = this.elements[i];
837
+ RRectangle elemc = elem.getBounds();
838
+
839
+ float px = (elemc.bottomRight.x + elemc.topLeft.x) / 2F;
840
+ float py = (elemc.bottomRight.y - elemc.topLeft.y) / 2F;
841
+ float t = ((px - xmin) / (xmax - xmin) + lngthOffset) % 1F;
842
+
843
+ RPoint tg = grp.getTangent(t);
844
+ RPoint p = grp.getPoint(t);
845
+ float angle = (float) Math.atan2(tg.y, tg.x);
846
+
847
+ RPoint pletter = new RPoint(px, py);
848
+ p.sub(pletter);
849
+
850
+ RMatrix mtx = new RMatrix();
851
+ mtx.translate(p);
852
+ mtx.rotate(angle, pletter);
853
+ mtx.scale(wght, pletter);
854
+
855
+ elem.transform(mtx);
856
+ }
857
+ break;
858
+
859
+ case RG.BYELEMENTINDEX:
860
+
861
+ for (int i = 0; i < numElements; i++) {
862
+ RGeomElem elem = this.elements[i];
863
+ RRectangle elemc = elem.getBounds();
864
+
865
+ float px = (elemc.bottomRight.x + elemc.topLeft.x) / 2F;
866
+ float py = (elemc.bottomRight.y - elemc.topLeft.y) / 2F;
867
+ float t = ((float) i / (float) numElements + lngthOffset) % 1F;
868
+
869
+ RPoint tg = grp.getTangent(t);
870
+ RPoint p = grp.getPoint(t);
871
+ float angle = (float) Math.atan2(tg.y, tg.x);
872
+
873
+ RPoint pletter = new RPoint(px, py);
874
+ p.sub(pletter);
875
+
876
+ RMatrix mtx = new RMatrix();
877
+ mtx.translate(p);
878
+ mtx.rotate(angle, pletter);
879
+ mtx.scale(wght, pletter);
880
+
881
+ elem.transform(mtx);
882
+ }
883
+ break;
884
+
885
+ default:
886
+ throw new RuntimeException("Unknown adaptor type : " + RG.adaptorType + ". The method RG.setAdaptor() only accepts RG.BYPOINT or RG.BYELEMENT as parameter values.");
845
887
  }
846
888
  }
847
-
848
- public void adapt(RGroup grp) throws RuntimeException{
889
+
890
+ public void adapt(RGroup grp) throws RuntimeException {
849
891
  adapt(grp, RG.adaptorScale, RG.adaptorLengthOffset);
850
892
  }
851
893
 
852
- public void adapt(RShape shp){
894
+ public void adapt(RShape shp) {
853
895
  RGroup grp = new RGroup();
854
896
  grp.addElement(shp);
855
897
  adapt(grp);
856
898
  }
857
899
 
858
- public void adapt(RShape shp, float wght, float lngthOffset){
900
+ public void adapt(RShape shp, float wght, float lngthOffset) {
859
901
  RGroup grp = new RGroup();
860
902
  grp.addElement(shp);
861
903
  adapt(grp, wght, lngthOffset);
862
904
  }
863
-
864
905
 
865
- public void polygonize(){
906
+ public void polygonize() {
866
907
  RGroup grp = toPolygonGroup().toShapeGroup();
867
908
  this.elements = grp.elements;
868
909
  }
869
910
 
870
- private void append(RGeomElem elem){
911
+ private void append(RGeomElem elem) {
871
912
  RGeomElem[] newelements;
872
- if(elements==null){
913
+ if (elements == null) {
873
914
  newelements = new RGeomElem[1];
874
915
  newelements[0] = elem;
875
- }else{
876
- newelements = new RGeomElem[this.elements.length+1];
877
- System.arraycopy(this.elements,0,newelements,0,this.elements.length);
878
- newelements[this.elements.length]=elem;
916
+ } else {
917
+ newelements = new RGeomElem[this.elements.length + 1];
918
+ System.arraycopy(this.elements, 0, newelements, 0, this.elements.length);
919
+ newelements[this.elements.length] = elem;
879
920
  }
880
- this.elements=newelements;
921
+ this.elements = newelements;
881
922
  }
882
-
883
- private void extract(int i) throws RuntimeException{
923
+
924
+ private void extract(int i) throws RuntimeException {
884
925
  RGeomElem[] newelements;
885
- if(elements==null){
926
+ if (elements == null) {
886
927
  throw new RuntimeException("The group is empty. No elements to remove.");
887
- }else{
888
- if(i<0){
928
+ } else {
929
+ if (i < 0) {
889
930
  throw new RuntimeException("Negative values for indexes are not valid.");
890
931
  }
891
- if(i>elements.length-1){
932
+ if (i > elements.length - 1) {
892
933
  throw new RuntimeException("Index out of the bounds of the group. You are trying to erase an element with an index higher than the number of elements in the group.");
893
934
  }
894
- if(elements.length==1){
935
+ if (elements.length == 1) {
895
936
  newelements = null;
896
- }else if(i==0){
897
- newelements = new RGeomElem[this.elements.length-1];
898
- System.arraycopy(this.elements,1,newelements,0,this.elements.length-1);
899
- }else if(i==elements.length-1){
900
- newelements = new RGeomElem[this.elements.length-1];
901
- System.arraycopy(this.elements,0,newelements,0,this.elements.length-1);
902
- }else{
903
- newelements = new RGeomElem[this.elements.length-1];
904
- System.arraycopy(this.elements,0,newelements,0,i);
905
- System.arraycopy(this.elements,i+1,newelements,i,this.elements.length-i-1);
937
+ } else if (i == 0) {
938
+ newelements = new RGeomElem[this.elements.length - 1];
939
+ System.arraycopy(this.elements, 1, newelements, 0, this.elements.length - 1);
940
+ } else if (i == elements.length - 1) {
941
+ newelements = new RGeomElem[this.elements.length - 1];
942
+ System.arraycopy(this.elements, 0, newelements, 0, this.elements.length - 1);
943
+ } else {
944
+ newelements = new RGeomElem[this.elements.length - 1];
945
+ System.arraycopy(this.elements, 0, newelements, 0, i);
946
+ System.arraycopy(this.elements, i + 1, newelements, i, this.elements.length - i - 1);
906
947
  }
907
948
  }
908
- this.elements=newelements;
949
+ this.elements = newelements;
909
950
  }
910
951
  }