geomerative 0.4.3-java → 2.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.mvn/extensions.xml +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  5. data/CHANGELOG.md +19 -1
  6. data/COPYING.md +1 -1
  7. data/README.md +2 -2
  8. data/Rakefile +2 -15
  9. data/docs/_config.yml +8 -0
  10. data/docs/_includes/head.html +7 -6
  11. data/docs/_includes/header.html +6 -6
  12. data/docs/_includes/icon-github.svg +3 -1
  13. data/docs/_includes/icon-twitter.svg +3 -1
  14. data/docs/_includes/navigation.html +24 -0
  15. data/docs/_sass/_base.scss +79 -79
  16. data/docs/_sass/_layout.scss +137 -137
  17. data/docs/_sass/_syntax-highlighting.scss +64 -64
  18. data/docs/index.html +18 -18
  19. data/examples/README.md +1 -1
  20. data/examples/data/bot1.svg +1 -1
  21. data/examples/data/lion.svg +156 -156
  22. data/examples/data/ruby.svg +1 -1
  23. data/examples/jruby_merge.rb +1 -1
  24. data/examples/{f_agent.rb → library/f_agent/f_agent.rb} +0 -0
  25. data/examples/{font_agent.rb → library/font_agent/font_agent.rb} +2 -1
  26. data/examples/text_on_geomerative_path.rb +3 -2
  27. data/examples/typo_deform.rb +2 -2
  28. data/examples/typo_extra_bright.rb +1 -1
  29. data/geomerative.gemspec +3 -6
  30. data/lib/geomerative/version.rb +1 -1
  31. data/lib/geomerative.jar +0 -0
  32. data/lib/geomerative.rb +10 -10
  33. data/mvnw +234 -0
  34. data/mvnw.cmd +145 -0
  35. data/pom.rb +14 -16
  36. data/pom.xml +13 -19
  37. data/src/geomerative/FastRClip.java +2050 -2334
  38. data/src/geomerative/RClip.java +2237 -2539
  39. data/src/geomerative/RClosest.java +33 -31
  40. data/src/geomerative/RCommand.java +1750 -1758
  41. data/src/geomerative/RContour.java +290 -292
  42. data/src/geomerative/RFont.java +277 -246
  43. data/src/geomerative/RG.java +722 -727
  44. data/src/geomerative/RGeomElem.java +967 -962
  45. data/src/geomerative/RGroup.java +508 -467
  46. data/src/geomerative/RMatrix.java +304 -289
  47. data/src/geomerative/RMesh.java +241 -229
  48. data/src/geomerative/RPath.java +924 -926
  49. data/src/geomerative/RPoint.java +391 -391
  50. data/src/geomerative/RPolygon.java +1017 -1013
  51. data/src/geomerative/RRectangle.java +43 -52
  52. data/src/geomerative/RSVG.java +480 -516
  53. data/src/geomerative/RShape.java +1767 -1777
  54. data/src/geomerative/RStrip.java +173 -176
  55. data/src/geomerative/RStyle.java +197 -194
  56. data/src/module-info.java +4 -0
  57. data/src/org/apache/batik/svggen/font/Font.java +141 -142
  58. data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
  59. data/src/org/apache/batik/svggen/font/Point.java +12 -12
  60. data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
  61. data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
  62. data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
  63. data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
  64. data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
  65. data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
  66. data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
  67. data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
  68. data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
  69. data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
  70. data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
  71. data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
  72. data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
  73. data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
  74. data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
  75. data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
  76. data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
  77. data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
  78. data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
  79. data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
  80. data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
  81. data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
  82. data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
  83. data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
  84. data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
  85. data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
  86. data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
  87. data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
  88. data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
  89. data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
  90. data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
  91. data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
  92. data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
  93. data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
  94. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
  95. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
  96. data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
  97. data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
  98. data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
  99. data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
  100. data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
  101. data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
  102. data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
  103. data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
  104. data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
  105. data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
  106. data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
  107. data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
  108. data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
  109. data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
  110. data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
  111. data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
  112. data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
  113. data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
  114. data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
  115. data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
  116. data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
  117. data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
  118. data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
  119. data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
  120. data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
  121. data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
  122. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
  123. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
  124. data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
  125. data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
  126. data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
  127. metadata +18 -19
  128. data/.travis.yml +0 -10
  129. data/calculate_torsional_angle.rb +0 -17
@@ -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,11 +18,7 @@
18
18
  */
19
19
  package geomerative;
20
20
 
21
- //import processing.core.*;
22
-
23
- import processing.core.PApplet;
24
- import processing.core.PGraphics;
25
-
21
+ import processing.core.*;
26
22
 
27
23
  /**
28
24
  * RPolygon is a reduced interface for creating, holding and drawing complex
@@ -30,1085 +26,1093 @@ import processing.core.PGraphics;
30
26
  * interface allows us to perform binary operations (difference, xor, union and
31
27
  * intersection) on polygons.
32
28
  *
33
- * @eexample RPolygon
34
- * @usage Geometry
35
- * @related RContour
36
- * @related createCircle ( )
37
- * @related createRing ( )
38
- * @related createStar ( )
39
- * @related diff ( )
40
- * @related xor ( )
41
- * @related union ( )
42
- * @related intersection ( )
43
- * @extended
29
+ RPolygon
30
+ * Geometry
31
+ * RContour
32
+ * createCircle ( )
33
+ * createRing ( )
34
+ * createStar ( )
35
+ * diff ( )
36
+ * xor ( )
37
+ * union ( )
38
+ * intersection ( )
39
+
44
40
  */
45
41
  public class RPolygon extends RGeomElem {
46
42
 
47
- /**
48
- * @invisible
49
- */
50
- public int type = RGeomElem.POLYGON;
51
- public static int defaultDetail = 50;
52
-
53
- /**
54
- * Array of RContour objects holding the contours of the polygon.
55
- *
56
- * @eexample contours
57
- * @related RContour
58
- * @related countContours ( )
59
- * @related addContour ( )
60
- */
61
- public RContour[] contours;
62
- int currentContour = 0;
63
-
64
- // ----------------------
65
- // --- Public Methods ---
66
- // ----------------------
67
- /**
68
- * Make a copy of the given polygon.
69
- *
70
- * @eexample createPolygon
71
- * @param p the object of which to make a copy
72
- */
73
- public RPolygon(RPolygon p) {
74
- if (p == null) {
75
- return;
76
- }
77
-
78
- for (int i = 0; i < p.countContours(); i++) {
79
- this.append(new RContour(p.contours[i]));
80
- }
81
- type = RGeomElem.POLYGON;
82
-
83
- setStyle(p);
84
- }
85
-
86
- /**
87
- * Create a new polygon given an array of points.
88
- *
89
- * @eexample createPolygon
90
- * @param points the points for the new polygon.
91
- */
92
- public RPolygon(RPoint[] points) {
93
- this(new RContour(points));
94
- }
95
-
96
- /**
97
- * Create a new polygon given a contour.
98
- *
99
- * @param newcontour the contour for the new polygon.
100
- */
101
- public RPolygon(RContour newcontour) {
102
- this.append(newcontour);
103
- type = RGeomElem.POLYGON;
104
- }
105
-
106
- /**
107
- * Create an empty polygon.
108
- */
109
- public RPolygon() {
110
- contours = null;
111
- type = RGeomElem.POLYGON;
112
- }
113
-
114
- /**
115
- * Use this method to create a new circle polygon.
116
- *
117
- * @param x
118
- * @param y
119
- * @eexample createCircle
120
- * @param radius the radius of the circle
121
- * @param detail the number of vertices of the polygon
122
- * @return RPolygon, the circular polygon newly created
123
- */
124
- static public RPolygon createCircle(float x, float y, float radius, int detail) {
125
- RPoint[] points = new RPoint[detail];
126
- double radiansPerStep = 2 * Math.PI / detail;
127
- for (int i = 0; i < detail; i++) {
128
- points[i] = new RPoint(
129
- radius * Math.cos(i * radiansPerStep) + x,
130
- radius * Math.sin(i * radiansPerStep) + y
131
- );
132
- }
133
- return new RPolygon(points);
134
- }
135
-
136
- static public RPolygon createCircle(float radius, int detail) {
137
- return createCircle(0, 0, radius, detail);
138
- }
139
-
140
- static public RPolygon createCircle(float x, float y, float radius) {
141
- return createCircle(x, y, radius, defaultDetail);
142
- }
143
-
144
- static public RPolygon createCircle(float radius) {
145
- return createCircle(0, 0, radius, defaultDetail);
146
- }
43
+ /**
44
+ *
45
+ */
46
+ public int type = RGeomElem.POLYGON;
47
+ public static int defaultDetail = 50;
147
48
 
148
- /**
149
- * Use this method to create a new rectangle polygon.
150
- *
151
- * @eexample createRectangle
152
- * @param x the upper-left corner x coordinate
153
- * @param y the upper-left corner y coordinate
154
- * @param w the width
155
- * @param h the height
156
- * @return RPolygon, the circular polygon newly created
157
- */
158
- static public RPolygon createRectangle(float x, float y, float w, float h) {
159
- RPolygon rectangle = new RPolygon();
160
- rectangle.addPoint(x, y);
161
- rectangle.addPoint(x + w, y);
162
- rectangle.addPoint(x + w, y + h);
163
- rectangle.addPoint(x, y + h);
164
- rectangle.addPoint(x, y);
165
- return rectangle;
166
- }
49
+ /**
50
+ * Array of RContour objects holding the contours of the polygon.
51
+ *
52
+ contours
53
+ * RContour
54
+ * countContours ( )
55
+ * addContour ( )
56
+ */
57
+ public RContour[] contours;
58
+ int currentContour = 0;
167
59
 
168
- static public RPolygon createRectangle(float w, float h) {
169
- return createRectangle(0, 0, w, h);
60
+ // ----------------------
61
+ // --- Public Methods ---
62
+ // ----------------------
63
+ /**
64
+ * Make a copy of the given polygon.
65
+ *
66
+ createPolygon
67
+ * @param p the object of which to make a copy
68
+ */
69
+ public RPolygon(RPolygon p) {
70
+ if (p == null) {
71
+ return;
170
72
  }
171
73
 
172
- /**
173
- * Use this method to create a new starform polygon.
174
- *
175
- * @param x
176
- * @param y
177
- * @eexample createStar
178
- * @param radiusBig the outter radius of the star polygon
179
- * @param radiusSmall the inner radius of the star polygon
180
- * @param spikes the amount of spikes on the star polygon
181
- * @return RPolygon, the starform polygon newly created
182
- */
183
- static public RPolygon createStar(float x, float y, float radiusBig, float radiusSmall, int spikes) {
184
- int numPoints = spikes * 2;
185
- RPoint[] points = new RPoint[numPoints];
186
- double radiansPerStep = Math.PI / spikes;
187
- for (int i = 0; i < numPoints; i += 2) {
188
- points[i] = new RPoint(
189
- radiusBig * Math.cos(i * radiansPerStep) + x,
190
- radiusBig * Math.sin(i * radiansPerStep) + y
191
- );
192
- points[i + 1] = new RPoint(
193
- radiusSmall * Math.cos(i * radiansPerStep) + x,
194
- radiusSmall * Math.sin(i * radiansPerStep) + y
195
- );
196
- }
197
- return new RPolygon(points);
74
+ for (int i = 0; i < p.countContours(); i++) {
75
+ this.append(new RContour(p.contours[i]));
198
76
  }
77
+ type = RGeomElem.POLYGON;
199
78
 
200
- static public RPolygon createStar(float radiusBig, float radiusSmall, int spikes) {
201
- return createStar(0, 0, radiusBig, radiusSmall, spikes);
202
- }
79
+ setStyle(p);
80
+ }
203
81
 
204
- /**
205
- * Use this method to create a new ring polygon.
206
- *
207
- * @param x
208
- * @param y
209
- * @eexample createRing
210
- * @param radiusBig the outter radius of the ring polygon
211
- * @param radiusSmall the inner radius of the ring polygon
212
- * @param detail the number of vertices on each contour of the ring
213
- * @return RPolygon, the ring polygon newly created
214
- */
215
- static public RPolygon createRing(float x, float y, float radiusBig, float radiusSmall, int detail) {
216
- RPoint[] inner = new RPoint[detail];
217
- RPoint[] outer = new RPoint[detail];
218
- double radiansPerStep = 2 * Math.PI / detail;
219
- for (int i = 0; i < detail; i++) {
220
- inner[i] = new RPoint(
221
- radiusSmall * Math.cos(i * radiansPerStep) + x,
222
- radiusSmall * Math.sin(i * radiansPerStep) + y
223
- );
224
- outer[i] = new RPoint(
225
- radiusBig * Math.cos(i * radiansPerStep) + x,
226
- radiusBig * Math.sin(i * radiansPerStep) + y
227
- );
82
+ /**
83
+ * Create a new polygon given an array of points.
84
+ *
85
+ createPolygon
86
+ * @param points the points for the new polygon.
87
+ */
88
+ public RPolygon(RPoint[] points) {
89
+ this(new RContour(points));
90
+ }
91
+
92
+ /**
93
+ * Create a new polygon given a contour.
94
+ *
95
+ * @param newcontour the contour for the new polygon.
96
+ */
97
+ public RPolygon(RContour newcontour) {
98
+ this.append(newcontour);
99
+ type = RGeomElem.POLYGON;
100
+ }
101
+
102
+ /**
103
+ * Create an empty polygon.
104
+ */
105
+ public RPolygon() {
106
+ contours = null;
107
+ type = RGeomElem.POLYGON;
108
+ }
109
+
110
+ /**
111
+ * Use this method to create a new circle polygon.
112
+ *
113
+ * @param x
114
+ * @param y
115
+ createCircle
116
+ * @param radius the radius of the circle
117
+ * @param detail the number of vertices of the polygon
118
+ * @return RPolygon, the circular polygon newly created
119
+ */
120
+ static public RPolygon createCircle(float x, float y, float radius, int detail) {
121
+ RPoint[] points = new RPoint[detail];
122
+ double radiansPerStep = 2 * Math.PI / detail;
123
+ for (int i = 0; i < detail; i++) {
124
+ points[i] = new RPoint(
125
+ radius * Math.cos(i * radiansPerStep) + x,
126
+ radius * Math.sin(i * radiansPerStep) + y
127
+ );
128
+ }
129
+ return new RPolygon(points);
130
+ }
131
+
132
+ static public RPolygon createCircle(float radius, int detail) {
133
+ return createCircle(0, 0, radius, detail);
134
+ }
135
+
136
+ static public RPolygon createCircle(float x, float y, float radius) {
137
+ return createCircle(x, y, radius, defaultDetail);
138
+ }
139
+
140
+ static public RPolygon createCircle(float radius) {
141
+ return createCircle(0, 0, radius, defaultDetail);
142
+ }
143
+
144
+ /**
145
+ * Use this method to create a new rectangle polygon.
146
+ *
147
+ createRectangle
148
+ * @param x the upper-left corner x coordinate
149
+ * @param y the upper-left corner y coordinate
150
+ * @param w the width
151
+ * @param h the height
152
+ * @return RPolygon, the circular polygon newly created
153
+ */
154
+ static public RPolygon createRectangle(float x, float y, float w, float h) {
155
+ RPolygon rectangle = new RPolygon();
156
+ rectangle.addPoint(x, y);
157
+ rectangle.addPoint(x + w, y);
158
+ rectangle.addPoint(x + w, y + h);
159
+ rectangle.addPoint(x, y + h);
160
+ rectangle.addPoint(x, y);
161
+ return rectangle;
162
+ }
163
+
164
+ static public RPolygon createRectangle(float w, float h) {
165
+ return createRectangle(0, 0, w, h);
166
+ }
167
+
168
+ /**
169
+ * Use this method to create a new starform polygon.
170
+ *
171
+ * @param x
172
+ * @param y
173
+ createStar
174
+ * @param radiusBig the outter radius of the star polygon
175
+ * @param radiusSmall the inner radius of the star polygon
176
+ * @param spikes the amount of spikes on the star polygon
177
+ * @return RPolygon, the starform polygon newly created
178
+ */
179
+ static public RPolygon createStar(float x, float y, float radiusBig, float radiusSmall, int spikes) {
180
+ int numPoints = spikes * 2;
181
+ RPoint[] points = new RPoint[numPoints];
182
+ double radiansPerStep = Math.PI / spikes;
183
+ for (int i = 0; i < numPoints; i += 2) {
184
+ points[i] = new RPoint(
185
+ radiusBig * Math.cos(i * radiansPerStep) + x,
186
+ radiusBig * Math.sin(i * radiansPerStep) + y
187
+ );
188
+ points[i + 1] = new RPoint(
189
+ radiusSmall * Math.cos(i * radiansPerStep) + x,
190
+ radiusSmall * Math.sin(i * radiansPerStep) + y
191
+ );
192
+ }
193
+ return new RPolygon(points);
194
+ }
195
+
196
+ static public RPolygon createStar(float radiusBig, float radiusSmall, int spikes) {
197
+ return createStar(0, 0, radiusBig, radiusSmall, spikes);
198
+ }
199
+
200
+ /**
201
+ * Use this method to create a new ring polygon.
202
+ *
203
+ * @param x
204
+ * @param y
205
+ createRing
206
+ * @param radiusBig the outter radius of the ring polygon
207
+ * @param radiusSmall the inner radius of the ring polygon
208
+ * @param detail the number of vertices on each contour of the ring
209
+ * @return RPolygon, the ring polygon newly created
210
+ */
211
+ static public RPolygon createRing(float x, float y, float radiusBig, float radiusSmall, int detail) {
212
+ RPoint[] inner = new RPoint[detail];
213
+ RPoint[] outer = new RPoint[detail];
214
+ double radiansPerStep = 2 * Math.PI / detail;
215
+ for (int i = 0; i < detail; i++) {
216
+ inner[i] = new RPoint(
217
+ radiusSmall * Math.cos(i * radiansPerStep) + x,
218
+ radiusSmall * Math.sin(i * radiansPerStep) + y
219
+ );
220
+ outer[i] = new RPoint(
221
+ radiusBig * Math.cos(i * radiansPerStep) + x,
222
+ radiusBig * Math.sin(i * radiansPerStep) + y
223
+ );
224
+ }
225
+ RPolygon ring = new RPolygon();
226
+ ring.addContour(outer);
227
+ ring.addContour(inner);
228
+ return ring;
229
+ }
230
+
231
+ static public RPolygon createRing(float radiusBig, float radiusSmall, int detail) {
232
+ return createRing(0, 0, radiusBig, radiusSmall, detail);
233
+ }
234
+
235
+ static public RPolygon createRing(float x, float y, float radiusBig, float radiusSmall) {
236
+ return createRing(x, y, radiusBig, radiusSmall, defaultDetail);
237
+ }
238
+
239
+ static public RPolygon createRing(float radiusBig, float radiusSmall) {
240
+ return createRing(0, 0, radiusBig, radiusSmall, defaultDetail);
241
+ }
242
+
243
+ /**
244
+ * Use this method to get the centroid of the element.
245
+ *
246
+ RGroup_getCentroid
247
+ * @return RPo the centroid point of the element
248
+ * getBounds ( )
249
+ * getCenter ( )
250
+ */
251
+ @Override
252
+ public RPoint getCentroid() {
253
+ RPoint bestCentroid = new RPoint();
254
+ float bestArea = Float.NEGATIVE_INFINITY;
255
+ if (contours != null) {
256
+ for (RContour contour : contours) {
257
+ float area = Math.abs(contour.getArea());
258
+ if (area > bestArea) {
259
+ bestArea = area;
260
+ bestCentroid = contour.getCentroid();
228
261
  }
229
- RPolygon ring = new RPolygon();
230
- ring.addContour(outer);
231
- ring.addContour(inner);
232
- return ring;
262
+ }
263
+ return bestCentroid;
233
264
  }
265
+ return null;
266
+ }
234
267
 
235
- static public RPolygon createRing(float radiusBig, float radiusSmall, int detail) {
236
- return createRing(0, 0, radiusBig, radiusSmall, detail);
237
- }
238
-
239
- static public RPolygon createRing(float x, float y, float radiusBig, float radiusSmall) {
240
- return createRing(x, y, radiusBig, radiusSmall, defaultDetail);
241
- }
242
-
243
- static public RPolygon createRing(float radiusBig, float radiusSmall) {
244
- return createRing(0, 0, radiusBig, radiusSmall, defaultDetail);
268
+ /**
269
+ * Use this method to count the number of contours in the polygon.
270
+ *
271
+ countContours
272
+ * @return int the number contours in the polygon
273
+ * addContour ( )
274
+ */
275
+ public int countContours() {
276
+ if (this.contours == null) {
277
+ return 0;
245
278
  }
246
279
 
247
- /**
248
- * Use this method to get the centroid of the element.
249
- *
250
- * @eexample RGroup_getCentroid
251
- * @return RPo the centroid point of the element
252
- * @related getBounds ( )
253
- * @related getCenter ( )
254
- */
255
- @Override
256
- public RPoint getCentroid() {
257
- RPoint bestCentroid = new RPoint();
258
- float bestArea = Float.NEGATIVE_INFINITY;
259
- if (contours != null) {
260
- for (RContour contour : contours) {
261
- float area = Math.abs(contour.getArea());
262
- if (area > bestArea) {
263
- bestArea = area;
264
- bestCentroid = contour.getCentroid();
265
- }
266
- }
267
- return bestCentroid;
268
- }
269
- return null;
270
- }
280
+ return this.contours.length;
281
+ }
271
282
 
272
- /**
273
- * Use this method to count the number of contours in the polygon.
274
- *
275
- * @eexample countContours
276
- * @return int the number contours in the polygon
277
- * @related addContour ( )
278
- */
279
- public int countContours() {
280
- if (this.contours == null) {
281
- return 0;
283
+ /**
284
+ * Add a new contour to the polygon.
285
+ *
286
+ addContour
287
+ * @param c the contour to be added
288
+ * addPoint ( )
289
+ */
290
+ public void addContour(RContour c) {
291
+ this.append(c);
292
+ }
293
+
294
+ /**
295
+ * Add an empty contour to the polygon.
296
+ *
297
+ addContour
298
+ * addPoint ( )
299
+ */
300
+ public void addContour() {
301
+ this.append(new RContour());
302
+ }
303
+
304
+ /**
305
+ * Add a new contour to the polygon given an array of points.
306
+ *
307
+ addContour
308
+ * @param points the points of the new contour to be added
309
+ * addPoint ( )
310
+ */
311
+ public void addContour(RPoint[] points) {
312
+ this.append(new RContour(points));
313
+ }
314
+
315
+ /**
316
+ * Use this method to set the current contour to which append points.
317
+ *
318
+ * @param indContour
319
+ addContour
320
+ * addPoint ( )
321
+ */
322
+ public void setContour(int indContour) {
323
+ this.currentContour = indContour;
324
+ }
325
+
326
+ /**
327
+ * Add a new point to the current contour.
328
+ *
329
+ addPoint
330
+ * @param p the point to be added
331
+ * addContour ( )
332
+ * setCurrent ( )
333
+ */
334
+ public void addPoint(RPoint p) {
335
+ if (contours == null) {
336
+ this.append(new RContour());
337
+ }
338
+ this.contours[currentContour].append(p);
339
+ }
340
+
341
+ /**
342
+ * Add a new point to the current contour.
343
+ *
344
+ addPoint
345
+ * @param x the x coordinate of the point to be added
346
+ * @param y the y coordinate of the point to be added
347
+ * addContour ( )
348
+ * setCurrent ( )
349
+ */
350
+ public void addPoint(float x, float y) {
351
+ if (contours == null) {
352
+ this.append(new RContour());
353
+ }
354
+ this.contours[currentContour].append(new RPoint(x, y));
355
+ }
356
+
357
+ /**
358
+ * Add a new point to the selected contour.
359
+ *
360
+ addPoint
361
+ * @param indContour the index of the contour to which the point will be added
362
+ * @param p the point to be added
363
+ * addContour ( )
364
+ * setCurrent ( )
365
+ */
366
+ public void addPoint(int indContour, RPoint p) {
367
+ if (contours == null) {
368
+ this.append(new RContour());
369
+ }
370
+ this.contours[indContour].append(p);
371
+ }
372
+
373
+ /**
374
+ * Add a new point to the selected contour.
375
+ *
376
+ addPoint
377
+ * @param indContour the index of the contour to which the point will be added
378
+ * @param x the x coordinate of the point to be added
379
+ * @param y the y coordinate of the point to be added
380
+ * addContour ( )
381
+ * setCurrent ( )
382
+ */
383
+ public void addPoint(int indContour, float x, float y) {
384
+ if (contours == null) {
385
+ this.append(new RContour());
386
+ }
387
+ this.contours[indContour].append(new RPoint(x, y));
388
+ }
389
+
390
+ public void addClose() {
391
+ if (contours == null) {
392
+ return;
393
+ }
394
+
395
+ contours[contours.length - 1].addClose();
396
+ }
397
+
398
+ /**
399
+ * Use this method to create a new mesh from a given polygon.
400
+ *
401
+ toMesh
402
+ * @return RMesh, the mesh made of tristrips resulting of a tesselation of the
403
+ * polygon
404
+ * draw ( )
405
+ */
406
+ @Override
407
+ public RMesh toMesh() {
408
+ if (contours == null) {
409
+ return new RMesh();
410
+ }
411
+
412
+ RMesh mesh = RClip.polygonToMesh(this);
413
+ if (mesh == null) {
414
+ return null;
415
+ }
416
+
417
+ mesh.setStyle(this);
418
+ return mesh;
419
+ }
420
+
421
+ @Override
422
+ public void print() {
423
+ System.out.println("polygon: ");
424
+ for (int i = 0; i < countContours(); i++) {
425
+ System.out.println("--- contour " + i + " ---");
426
+ contours[i].print();
427
+ System.out.println("---------------");
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Removes contours with less than 3 points. These are contours that are open.
433
+ * Since close polygons have points[0] == points[-1] and two more points to
434
+ * form a triangle at least. This is useful to avoid the clipping algorithm
435
+ * from breaking.
436
+ *
437
+ * @return
438
+ *
439
+ */
440
+ protected RPolygon removeOpenContours() {
441
+ RPolygon clean = new RPolygon();
442
+ for (int i = 0; i < countContours(); i++) {
443
+ if (contours[i].countPoints() > 3) {
444
+ clean.addContour(contours[i]);
445
+ }
446
+ }
447
+ clean.setStyle(this);
448
+ return clean;
449
+ }
450
+
451
+ /**
452
+ * @return
453
+ */
454
+ @Override
455
+ public RPolygon toPolygon() {
456
+ return new RPolygon(this);
457
+ }
458
+
459
+ /**
460
+ * @return
461
+ */
462
+ @Override
463
+ public RShape toShape() {
464
+ int numContours = countContours();
465
+
466
+ RShape result = new RShape();
467
+ for (int i = 0; i < numContours; i++) {
468
+ RPoint[] newpoints = this.contours[i].getHandles();
469
+
470
+ if (newpoints != null) {
471
+ result.addMoveTo(newpoints[0]);
472
+
473
+ for (int j = 1; j < newpoints.length; j++) {
474
+ result.addLineTo(newpoints[j]);
282
475
  }
283
476
 
284
- return this.contours.length;
285
- }
286
-
287
- /**
288
- * Add a new contour to the polygon.
289
- *
290
- * @eexample addContour
291
- * @param c the contour to be added
292
- * @related addPoint ( )
293
- */
294
- public void addContour(RContour c) {
295
- this.append(c);
296
- }
297
-
298
- /**
299
- * Add an empty contour to the polygon.
300
- *
301
- * @eexample addContour
302
- * @related addPoint ( )
303
- */
304
- public void addContour() {
305
- this.append(new RContour());
306
- }
307
-
308
- /**
309
- * Add a new contour to the polygon given an array of points.
310
- *
311
- * @eexample addContour
312
- * @param points the points of the new contour to be added
313
- * @related addPoint ( )
314
- */
315
- public void addContour(RPoint[] points) {
316
- this.append(new RContour(points));
317
- }
318
-
319
- /**
320
- * Use this method to set the current contour to which append points.
321
- *
322
- * @param indContour
323
- * @eexample addContour
324
- * @related addPoint ( )
325
- */
326
- public void setContour(int indContour) {
327
- this.currentContour = indContour;
328
- }
329
-
330
- /**
331
- * Add a new point to the current contour.
332
- *
333
- * @eexample addPoint
334
- * @param p the point to be added
335
- * @related addContour ( )
336
- * @related setCurrent ( )
337
- */
338
- public void addPoint(RPoint p) {
339
- if (contours == null) {
340
- this.append(new RContour());
477
+ if (contours[i].closed) {
478
+ result.addClose();
341
479
  }
342
- this.contours[currentContour].append(p);
343
- }
344
480
 
345
- /**
346
- * Add a new point to the current contour.
347
- *
348
- * @eexample addPoint
349
- * @param x the x coordinate of the point to be added
350
- * @param y the y coordinate of the point to be added
351
- * @related addContour ( )
352
- * @related setCurrent ( )
353
- */
354
- public void addPoint(float x, float y) {
355
- if (contours == null) {
356
- this.append(new RContour());
357
- }
358
- this.contours[currentContour].append(new RPoint(x, y));
481
+ result.paths[i].setStyle(contours[i]);
482
+ }
359
483
  }
360
484
 
361
- /**
362
- * Add a new point to the selected contour.
363
- *
364
- * @eexample addPoint
365
- * @param indContour the index of the contour to which the point will be
366
- * added
367
- * @param p the point to be added
368
- * @related addContour ( )
369
- * @related setCurrent ( )
370
- */
371
- public void addPoint(int indContour, RPoint p) {
372
- if (contours == null) {
373
- this.append(new RContour());
374
- }
375
- this.contours[indContour].append(p);
376
- }
485
+ result.setStyle(this);
486
+ return result;
487
+ }
377
488
 
378
- /**
379
- * Add a new point to the selected contour.
380
- *
381
- * @eexample addPoint
382
- * @param indContour the index of the contour to which the point will be
383
- * added
384
- * @param x the x coordinate of the point to be added
385
- * @param y the y coordinate of the point to be added
386
- * @related addContour ( )
387
- * @related setCurrent ( )
388
- */
389
- public void addPoint(int indContour, float x, float y) {
390
- if (contours == null) {
391
- this.append(new RContour());
489
+ /**
490
+ * Use this to return the points of the polygon. It returns the points in the
491
+ * way of an array of RPoint.
492
+ *
493
+ RPolygon_getHandles
494
+ * @return RPoint[], the points returned in an array.
495
+ *
496
+ */
497
+ @Override
498
+ public RPoint[] getHandles() {
499
+ int numContours = countContours();
500
+ if (numContours == 0) {
501
+ return null;
502
+ }
503
+
504
+ RPoint[] result = null;
505
+ RPoint[] newresult = null;
506
+ for (int i = 0; i < numContours; i++) {
507
+ RPoint[] newPoints = contours[i].getHandles();
508
+ if (newPoints != null) {
509
+ if (result == null) {
510
+ result = new RPoint[newPoints.length];
511
+ System.arraycopy(newPoints, 0, result, 0, newPoints.length);
512
+ } else {
513
+ newresult = new RPoint[result.length + newPoints.length];
514
+ System.arraycopy(result, 0, newresult, 0, result.length);
515
+ System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
516
+ result = newresult;
392
517
  }
393
- this.contours[indContour].append(new RPoint(x, y));
518
+ }
394
519
  }
520
+ return result;
521
+ }
395
522
 
396
- public void addClose() {
397
- if (contours == null) {
398
- return;
523
+ /**
524
+ * Use this to return the points of the polygon. It returns the points in the
525
+ * way of an array of RPoint.
526
+ *
527
+ RPolygon_getPoints
528
+ * @return RPoint[], the points returned in an array.
529
+ *
530
+ */
531
+ @Override
532
+ public RPoint[] getPoints() {
533
+ int numContours = countContours();
534
+ if (numContours == 0) {
535
+ return null;
536
+ }
537
+
538
+ RPoint[] result = null;
539
+ RPoint[] newresult = null;
540
+ for (int i = 0; i < numContours; i++) {
541
+ RPoint[] newPoints = contours[i].getPoints();
542
+ if (newPoints != null) {
543
+ if (result == null) {
544
+ result = new RPoint[newPoints.length];
545
+ System.arraycopy(newPoints, 0, result, 0, newPoints.length);
546
+ } else {
547
+ newresult = new RPoint[result.length + newPoints.length];
548
+ System.arraycopy(result, 0, newresult, 0, result.length);
549
+ System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
550
+ result = newresult;
399
551
  }
400
-
401
- contours[contours.length - 1].addClose();
552
+ }
402
553
  }
554
+ return result;
555
+ }
403
556
 
404
- /**
405
- * Use this method to create a new mesh from a given polygon.
406
- *
407
- * @eexample toMesh
408
- * @return RMesh, the mesh made of tristrips resulting of a tesselation of
409
- * the polygon
410
- * @related draw ( )
411
- */
412
- @Override
413
- public RMesh toMesh() {
414
- if (contours == null) {
415
- return new RMesh();
557
+ /**
558
+ * Use this method to get the type of element this is.
559
+ *
560
+ RPolygon_getType
561
+ * @return int, will allways return RGeomElem.POLYGON
562
+ */
563
+ @Override
564
+ public int getType() {
565
+ return type;
566
+ }
567
+
568
+ /**
569
+ * Use this method to get the area covered by the polygon.
570
+ *
571
+ getArea
572
+ * @return float, the area covered by the polygon
573
+ * draw ( )
574
+ */
575
+ @Override
576
+ public float getArea() {
577
+ if (getNumPoints() < 3) {
578
+ return 0.0F;
579
+ }
580
+ float ax = getX(0);
581
+ float ay = getY(0);
582
+ float area = 0.0F;
583
+ for (int i = 1; i < (getNumPoints() - 1); i++) {
584
+ float bx = getX(i);
585
+ float by = getY(i);
586
+ float cx = getX(i + 1);
587
+ float cy = getY(i + 1);
588
+ float tarea = ((cx - bx) * (ay - by)) - ((ax - bx) * (cy - by));
589
+ area += tarea;
590
+ }
591
+ area = 0.5F * Math.abs(area);
592
+ return area;
593
+ }
594
+
595
+ /**
596
+ * Use this method to draw the polygon.
597
+ *
598
+ drawPolygon
599
+ * @param g PGraphics, the graphics object on which to draw the polygon
600
+ * draw ( )
601
+ */
602
+ @Override
603
+ public void draw(PGraphics g) {
604
+ int numContours = countContours();
605
+ if (numContours != 0) {
606
+ if (isIn(g)) {
607
+ if (!RG.ignoreStyles) {
608
+ saveContext(g);
609
+ setContext(g);
416
610
  }
417
611
 
418
- RMesh mesh = RClip.polygonToMesh(this);
419
- if (mesh == null) {
420
- return null;
421
- }
612
+ // Check whether to draw the fill or not
613
+ if (g.fill) {
614
+ // Since we are drawing the different tristrips we must turn off the stroke or make it the same color as the fill
615
+ // NOTE: there's currently no way of drawing the outline of a mesh, since no information is kept about what vertices are at the edge
422
616
 
423
- mesh.setStyle(this);
424
- return mesh;
425
- }
617
+ // Save the information about the current stroke color and turn off
618
+ boolean stroking = g.stroke;
619
+ g.noStroke();
426
620
 
427
- @Override
428
- public void print() {
429
- System.out.println("polygon: ");
430
- for (int i = 0; i < countContours(); i++) {
431
- System.out.println("--- contour " + i + " ---");
432
- contours[i].print();
433
- System.out.println("---------------");
434
- }
435
- }
436
-
437
- /**
438
- * Removes contours with less than 3 points. These are contours that are
439
- * open. Since close polygons have points[0] == points[-1] and two more
440
- * points to form a triangle at least. This is useful to avoid the clipping
441
- * algorithm from breaking.
442
- *
443
- * @return
444
- * @invisible
445
- */
446
- protected RPolygon removeOpenContours() {
447
- RPolygon clean = new RPolygon();
448
- for (int i = 0; i < countContours(); i++) {
449
- if (contours[i].countPoints() > 3) {
450
- clean.addContour(contours[i]);
621
+ // Save smoothing state and turn off
622
+ int smoothing = g.smooth;
623
+ try {
624
+ if (smoothing > 0) {
625
+ g.noSmooth();
451
626
  }
452
- }
453
- clean.setStyle(this);
454
- return clean;
455
- }
627
+ } catch (Exception e) {
628
+ }
456
629
 
457
- /**
458
- * @return @invisible
459
- */
460
- @Override
461
- public RPolygon toPolygon() {
462
- return new RPolygon(this);
463
- }
630
+ RMesh tempMesh = this.toMesh();
631
+ tempMesh.draw(g);
464
632
 
465
- /**
466
- * @return @invisible
467
- */
468
- @Override
469
- public RShape toShape() {
470
- int numContours = countContours();
471
-
472
- RShape result = new RShape();
473
- for (int i = 0; i < numContours; i++) {
474
- RPoint[] newpoints = this.contours[i].getHandles();
475
-
476
- if (newpoints != null) {
477
- result.addMoveTo(newpoints[0]);
478
-
479
- for (int j = 1; j < newpoints.length; j++) {
480
- result.addLineTo(newpoints[j]);
481
- }
633
+ // Restore the old stroke color
634
+ if (stroking) {
635
+ g.stroke(g.strokeColor);
636
+ }
482
637
 
483
- if (contours[i].closed) {
484
- result.addClose();
485
- }
486
-
487
- result.paths[i].setStyle(contours[i]);
638
+ // Restore the old smoothing state
639
+ try {
640
+ if (smoothing > 0) {
641
+ g.smooth();
488
642
  }
643
+ } catch (Exception e) {
644
+ }
489
645
  }
490
646
 
491
- result.setStyle(this);
492
- return result;
493
- }
494
-
495
- /**
496
- * Use this to return the points of the polygon. It returns the points in
497
- * the way of an array of RPoint.
498
- *
499
- * @eexample RPolygon_getHandles
500
- * @return RPoint[], the points returned in an array.
501
- *
502
- */
503
- @Override
504
- public RPoint[] getHandles() {
505
- int numContours = countContours();
506
- if (numContours == 0) {
507
- return null;
647
+ // Check whether to draw the stroke or not
648
+ if (g.stroke) {
649
+ for (int i = 0; i < numContours; i++) {
650
+ contours[i].draw(g);
651
+ }
508
652
  }
509
653
 
510
- RPoint[] result = null;
511
- RPoint[] newresult;
512
- for (int i = 0; i < numContours; i++) {
513
- RPoint[] newPoints = contours[i].getHandles();
514
- if (newPoints != null) {
515
- if (result == null) {
516
- result = new RPoint[newPoints.length];
517
- System.arraycopy(newPoints, 0, result, 0, newPoints.length);
518
- } else {
519
- newresult = new RPoint[result.length + newPoints.length];
520
- System.arraycopy(result, 0, newresult, 0, result.length);
521
- System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
522
- result = newresult;
523
- }
524
- }
654
+ if (!RG.ignoreStyles) {
655
+ restoreContext(g);
525
656
  }
526
- return result;
527
- }
528
-
529
- /**
530
- * Use this to return the points of the polygon. It returns the points in
531
- * the way of an array of RPoint.
532
- *
533
- * @eexample RPolygon_getPoints
534
- * @return RPoint[], the points returned in an array.
535
- *
536
- */
537
- @Override
538
- public RPoint[] getPoints() {
539
- int numContours = countContours();
540
- if (numContours == 0) {
541
- return null;
657
+ }
658
+ }
659
+ }
660
+
661
+ @Override
662
+ public void draw(PApplet g) {
663
+ int numContours = countContours();
664
+ if (numContours != 0) {
665
+ if (isIn(g)) {
666
+ if (!RG.ignoreStyles) {
667
+ saveContext(g);
668
+ setContext(g);
542
669
  }
543
670
 
544
- RPoint[] result = null;
545
- RPoint[] newresult;
546
- for (int i = 0; i < numContours; i++) {
547
- RPoint[] newPoints = contours[i].getPoints();
548
- if (newPoints != null) {
549
- if (result == null) {
550
- result = new RPoint[newPoints.length];
551
- System.arraycopy(newPoints, 0, result, 0, newPoints.length);
552
- } else {
553
- newresult = new RPoint[result.length + newPoints.length];
554
- System.arraycopy(result, 0, newresult, 0, result.length);
555
- System.arraycopy(newPoints, 0, newresult, result.length, newPoints.length);
556
- result = newresult;
557
- }
558
- }
559
- }
560
- return result;
561
- }
562
-
563
- /**
564
- * Use this method to get the type of element this is.
565
- *
566
- * @eexample RPolygon_getType
567
- * @return int, will allways return RGeomElem.POLYGON
568
- */
569
- @Override
570
- public int getType() {
571
- return type;
572
- }
573
-
574
- /**
575
- * Use this method to get the area covered by the polygon.
576
- *
577
- * @eexample getArea
578
- * @return float, the area covered by the polygon
579
- * @related draw ( )
580
- */
581
- @Override
582
- public float getArea() {
583
- if (getNumPoints() < 3) {
584
- return 0.0F;
585
- }
586
- float ax = getX(0);
587
- float ay = getY(0);
588
- float area = 0.0F;
589
- for (int i = 1; i < (getNumPoints() - 1); i++) {
590
- float bx = getX(i);
591
- float by = getY(i);
592
- float cx = getX(i + 1);
593
- float cy = getY(i + 1);
594
- float tarea = ((cx - bx) * (ay - by)) - ((ax - bx) * (cy - by));
595
- area += tarea;
596
- }
597
- area = 0.5F * Math.abs(area);
598
- return area;
599
- }
600
-
601
- /**
602
- * Use this method to draw the polygon.
603
- *
604
- * @eexample drawPolygon
605
- * @param g PGraphics, the graphics object on which to draw the polygon
606
- * @related draw ( )
607
- */
608
- @Override
609
- public void draw(PGraphics g) {
610
- int numContours = countContours();
611
- if (numContours != 0) {
612
- if (isIn(g)) {
613
- if (!RG.ignoreStyles) {
614
- saveContext(g);
615
- setContext(g);
616
- }
617
-
618
- // Check whether to draw the fill or not
619
- if (g.fill) {
671
+ // Check whether to draw the fill or not
672
+ if (g.g.fill) {
620
673
  // Since we are drawing the different tristrips we must turn off the stroke or make it the same color as the fill
621
- // NOTE: there's currently no way of drawing the outline of a mesh, since no information is kept about what vertices are at the edge
674
+ // NOTE: there's currently no way of drawing the outline of a mesh, since no information is kept about what vertices are at the edge
622
675
 
623
- // Save the information about the current stroke color and turn off
624
- boolean stroking = g.stroke;
625
- g.noStroke();
676
+ // Save the information about the current stroke color and turn off
677
+ boolean stroking = g.g.stroke;
678
+ g.noStroke();
626
679
 
627
680
  // Save smoothing state and turn off
628
- // boolean smoothing = g.smooth;
629
- try {
630
-
631
- g.noSmooth();
632
-
633
- } catch (Exception e) {
634
- }
635
-
636
- RMesh tempMesh = this.toMesh();
637
- tempMesh.draw(g);
638
-
639
- // Restore the old stroke color
640
- if (stroking) {
641
- g.stroke(g.strokeColor);
642
- }
643
-
644
- }
645
-
646
- // Check whether to draw the stroke or not
647
- if (g.stroke) {
648
- for (int i = 0; i < numContours; i++) {
649
- contours[i].draw(g);
650
- }
651
- }
652
-
653
- if (!RG.ignoreStyles) {
654
- restoreContext(g);
655
- }
681
+ int smoothing = g.g.smooth;
682
+ try {
683
+ if (smoothing > 0) {
684
+ g.noSmooth();
656
685
  }
657
- }
658
- }
659
-
660
- /**
661
- *
662
- * @param g
663
- */
664
- @Override
665
- public void draw(PApplet g) {
666
- int numContours = countContours();
667
- if (numContours != 0) {
668
- if (isIn(g)) {
669
- if (!RG.ignoreStyles) {
670
- saveContext(g);
671
- setContext(g);
672
- }
673
-
674
- // Check whether to draw the fill or not
675
- if (g.g.fill) {
676
- // Since we are drawing the different tristrips we must turn off the stroke or make it the same color as the fill
677
- // NOTE: there's currently no way of drawing the outline of a mesh, since no information is kept about what vertices are at the edge
678
-
679
- // Save the information about the current stroke color and turn off
680
- boolean stroking = g.g.stroke;
681
- g.noStroke();
682
-
683
- RMesh tempMesh = this.toMesh();
684
- if (tempMesh != null) {
685
- tempMesh.draw(g);
686
- }
687
-
688
- // Restore the old stroke color
689
- if (stroking) {
690
- g.stroke(g.g.strokeColor);
691
- }
692
-
693
- }
694
-
695
- // Check whether to draws the stroke or not
696
- if (g.g.stroke) {
697
- for (int i = 0; i < numContours; i++) {
698
- contours[i].draw(g);
699
- }
700
- }
701
-
702
- if (!RG.ignoreStyles) {
703
- restoreContext(g);
704
- }
686
+ } catch (Exception e) {
687
+ }
688
+
689
+ RMesh tempMesh = this.toMesh();
690
+ if (tempMesh != null) {
691
+ tempMesh.draw(g);
692
+ }
693
+
694
+ // Restore the old stroke color
695
+ if (stroking) {
696
+ g.stroke(g.g.strokeColor);
697
+ }
698
+
699
+ // Restore the old smoothing state
700
+ try {
701
+ if (smoothing > 0) {
702
+ g.smooth();
705
703
  }
704
+ } catch (Exception e) {
705
+ }
706
706
  }
707
- }
708
-
709
- /**
710
- * Use this method to get the intersection of this polygon with the polygon
711
- * passed in as a parameter.
712
- *
713
- * @eexample intersection
714
- * @param p RPolygon, the polygon with which to perform the intersection
715
- * @return RPolygon, the intersection of the two polygons
716
- * @related union ( )
717
- * @related xor ( )
718
- * @related diff ( )
719
- */
720
- public RPolygon intersection(RPolygon p) {
721
- RPolygon res = RClip.intersection(p, this);
722
- res.setStyle(this.getStyle());
723
- return res;
724
- }
725
-
726
- /**
727
- * Use this method to get the union of this polygon with the polygon passed
728
- * in as a parameter.
729
- *
730
- * @eexample union
731
- * @param p RPolygon, the polygon with which to perform the union
732
- * @return RPolygon, the union of the two polygons
733
- * @related intersection ( )
734
- * @related xor ( )
735
- * @related diff ( )
736
- */
737
- public RPolygon union(RPolygon p) {
738
- RPolygon res = RClip.union(p, this);
739
- res.setStyle(this.getStyle());
740
- return res;
741
- }
742
-
743
- /**
744
- * Use this method to get the xor of this polygon with the polygon passed in
745
- * as a parameter.
746
- *
747
- * @eexample xor
748
- * @param p RPolygon, the polygon with which to perform the xor
749
- * @return RPolygon, the xor of the two polygons
750
- * @related union ( )
751
- * @related intersection ( )
752
- * @related diff ( )
753
- */
754
- public RPolygon xor(RPolygon p) {
755
- RPolygon res = RClip.xor(p, this);
756
- res.setStyle(this.getStyle());
757
- return res;
758
- }
759
707
 
760
- /**
761
- * Use this method to get the difference between this polygon and the
762
- * polygon passed in as a parameter.
763
- *
764
- * @eexample diff
765
- * @param p RPolygon, the polygon with which to perform the difference
766
- * @return RPolygon, the difference of the two polygons
767
- * @related union ( )
768
- * @related xor ( )
769
- * @related intersection ( )
770
- */
771
- public RPolygon diff(RPolygon p) {
772
- RPolygon res = RClip.diff(this, p);
773
- res.setStyle(this.getStyle());
774
- return res;
775
- }
776
-
777
- /**
778
- * Use this method to get a rebuilt version of a given polygon by removing
779
- * extra points and solving intersecting contours or holes.
780
- *
781
- * @eexample RPolygon_update
782
- * @return RPolygon, the updated polygon
783
- * @related diff ( )
784
- * @related union ( )
785
- * @related xor ( )
786
- * @related intersection ( )
787
- */
788
- public RPolygon update() {
789
- return RClip.update(this);
790
- }
791
-
792
- @Override
793
- public RPoint getPoint(float t) {
794
- PApplet.println("Feature not yet implemented for this class.");
795
- return null;
796
- }
797
-
798
- /**
799
- *
800
- * @param t
801
- * @return
802
- */
803
- @Override
804
- public RPoint getTangent(float t) {
805
- PApplet.println("Feature not yet implemented for this class.");
806
- return null;
807
- }
808
-
809
- /**
810
- *
811
- * @return
812
- */
813
- @Override
814
- public RPoint[] getTangents() {
815
- PApplet.println("Feature not yet implemented for this class.");
816
- return null;
817
- }
818
-
819
- /**
820
- *
821
- * @return
822
- */
823
- @Override
824
- public RPoint[][] getPointsInPaths() {
825
- PApplet.println("Feature not yet implemented for this class.");
826
- return null;
827
- }
828
-
829
- @Override
830
- public RPoint[][] getHandlesInPaths() {
831
- PApplet.println("Feature not yet implemented for this class.");
832
- return null;
833
- }
834
-
835
- @Override
836
- public RPoint[][] getTangentsInPaths() {
837
- PApplet.println("Feature not yet implemented for this class.");
838
- return null;
839
- }
840
-
841
- @Override
842
- public boolean contains(RPoint p) {
843
- PApplet.println("Feature not yet implemented for this class.");
844
- return false;
845
- }
846
-
847
- /**
848
- * Use this method to transform the polygon.
849
- *
850
- * @eexample RPolygon_transform
851
- * @param m RMatrix, the matrix of the affine transformation to apply to the
852
- * polygon
853
- */
854
- /*
855
- public void transform(RMatrix m){
856
- int numContours = countContours();
857
- if(numContours!=0){
858
- for(int i=0;i<numContours;i++){
859
- contours[i].transform(m);
860
- }
861
- }
862
- }
863
- */
864
- // ----------------------
865
- // --- Private Methods ---
866
- // ----------------------
867
- /**
868
- * Remove all of the points. Creates an empty polygon.
869
- */
870
- protected void clear() {
871
- this.contours = null;
872
- }
873
-
874
- /**
875
- * Add a point to the first inner polygon.
876
- *
877
- * @param x
878
- * @param y
879
- */
880
- protected void add(float x, float y) {
881
- if (contours == null) {
882
- this.append(new RContour());
708
+ // Check whether to draws the stroke or not
709
+ if (g.g.stroke) {
710
+ for (int i = 0; i < numContours; i++) {
711
+ contours[i].draw(g);
712
+ }
883
713
  }
884
- this.contours[0].append(new RPoint(x, y));
885
- }
886
714
 
887
- /**
888
- * Add a point to the first inner polygon.
889
- *
890
- * @param p
891
- */
892
- protected void add(RPoint p) {
893
- if (contours == null) {
894
- this.append(new RContour());
715
+ if (!RG.ignoreStyles) {
716
+ restoreContext(g);
895
717
  }
896
- this.contours[0].append(p);
718
+ }
897
719
  }
720
+ }
898
721
 
899
- /**
900
- * Add an inner polygon to this polygon - assumes that adding polygon does
901
- * not have any inner polygons.
902
- *
903
- * @param p
904
- */
905
- protected void add(RPolygon p) {
906
- /*if (this.contours.length > 0 && this.isHole){
907
- throw new IllegalStateException("Cannot add polys to something designated as a hole.");
908
- }*/
909
- RContour c = new RContour();
910
- for (int i = 0; i < p.getNumPoints(); i++) {
911
- c.addPoint(p.getX(i), p.getY(i));
912
- }
913
- this.append(c);
722
+ /**
723
+ * Use this method to get the intersection of this polygon with the polygon
724
+ * passed in as a parameter.
725
+ *
726
+ intersection
727
+ * @param p RPolygon, the polygon with which to perform the intersection
728
+ * @return RPolygon, the intersection of the two polygons
729
+ * union ( )
730
+ * xor ( )
731
+ * diff ( )
732
+ */
733
+ public RPolygon intersection(RPolygon p) {
734
+ RPolygon res = RClip.intersection(p, this);
735
+ res.setStyle(this.getStyle());
736
+ return res;
737
+ }
738
+
739
+ /**
740
+ * Use this method to get the union of this polygon with the polygon passed in
741
+ * as a parameter.
742
+ *
743
+ union
744
+ * @param p RPolygon, the polygon with which to perform the union
745
+ * @return RPolygon, the union of the two polygons
746
+ * intersection ( )
747
+ * xor ( )
748
+ * diff ( )
749
+ */
750
+ public RPolygon union(RPolygon p) {
751
+ RPolygon res = RClip.union(p, this);
752
+ res.setStyle(this.getStyle());
753
+ return res;
754
+ }
755
+
756
+ /**
757
+ * Use this method to get the xor of this polygon with the polygon passed in
758
+ * as a parameter.
759
+ *
760
+ xor
761
+ * @param p RPolygon, the polygon with which to perform the xor
762
+ * @return RPolygon, the xor of the two polygons
763
+ * union ( )
764
+ * intersection ( )
765
+ * diff ( )
766
+ */
767
+ public RPolygon xor(RPolygon p) {
768
+ RPolygon res = RClip.xor(p, this);
769
+ res.setStyle(this.getStyle());
770
+ return res;
771
+ }
772
+
773
+ /**
774
+ * Use this method to get the difference between this polygon and the polygon
775
+ * passed in as a parameter.
776
+ *
777
+ diff
778
+ * @param p RPolygon, the polygon with which to perform the difference
779
+ * @return RPolygon, the difference of the two polygons
780
+ * union ( )
781
+ * xor ( )
782
+ * intersection ( )
783
+ */
784
+ public RPolygon diff(RPolygon p) {
785
+ RPolygon res = RClip.diff(this, p);
786
+ res.setStyle(this.getStyle());
787
+ return res;
788
+ }
789
+
790
+ /**
791
+ * Use this method to get a rebuilt version of a given polygon by removing
792
+ * extra points and solving intersecting contours or holes.
793
+ *
794
+ RPolygon_update
795
+ * @return RPolygon, the updated polygon
796
+ * diff ( )
797
+ * union ( )
798
+ * xor ( )
799
+ * intersection ( )
800
+ */
801
+ public RPolygon update() {
802
+ return RClip.update(this);
803
+ }
804
+
805
+ @Override
806
+ public RPoint getPoint(float t) {
807
+ PApplet.println("Feature not yet implemented for this class.");
808
+ return null;
809
+ }
810
+
811
+ @Override
812
+ public RPoint getTangent(float t) {
813
+ PApplet.println("Feature not yet implemented for this class.");
814
+ return null;
815
+ }
816
+
817
+ /**
818
+ *
819
+ * @return
820
+ */
821
+ @Override
822
+ public RPoint[] getTangents() {
823
+ PApplet.println("Feature not yet implemented for this class.");
824
+ return null;
825
+ }
826
+
827
+ @Override
828
+ public RPoint[][] getPointsInPaths() {
829
+ PApplet.println("Feature not yet implemented for this class.");
830
+ return null;
831
+ }
832
+
833
+ @Override
834
+ public RPoint[][] getHandlesInPaths() {
835
+ PApplet.println("Feature not yet implemented for this class.");
836
+ return null;
837
+ }
838
+
839
+ @Override
840
+ public RPoint[][] getTangentsInPaths() {
841
+ PApplet.println("Feature not yet implemented for this class.");
842
+ return null;
843
+ }
844
+
845
+ @Override
846
+ public boolean contains(RPoint p) {
847
+ PApplet.println("Feature not yet implemented for this class.");
848
+ return false;
849
+ }
850
+
851
+ /**
852
+ * Use this method to transform the polygon.
853
+ *
854
+ RPolygon_transform
855
+ * @param m RMatrix, the matrix of the affine transformation to apply to the
856
+ * polygon
857
+ */
858
+ /*
859
+ public void transform(RMatrix m){
860
+ int numContours = countContours();
861
+ if(numContours!=0){
862
+ for(int i=0;i<numContours;i++){
863
+ contours[i].transform(m);
914
864
  }
915
-
916
- /**
917
- * Add an inner polygon to this polygon - assumes that adding polygon does
918
- * not have any inner polygons.
919
- *
920
- * @param c
921
- */
922
- protected void add(RContour c) {
923
- /*if (this.contours.length > 0 && this.isHole){
924
- throw new IllegalStateException("Cannot add polys to something designated as a hole.");
925
- }*/
926
- this.append(c);
927
865
  }
928
-
929
- /**
930
- * Return true if the polygon is empty
931
- *
932
- * @return
933
- */
934
- protected boolean isEmpty() {
935
- return (this.contours == null);
936
866
  }
937
-
938
- /**
939
- * Returns the bounding box of the polygon.
940
- *
941
- * @return
942
- */
943
- protected RRectangle getBBox() {
944
- if (this.contours == null) {
945
- return new RRectangle();
946
- } else if (this.contours.length == 1) {
947
-
948
- float xmin = Float.MAX_VALUE;
949
- float ymin = Float.MAX_VALUE;
950
- float xmax = -Float.MAX_VALUE;
951
- float ymax = -Float.MAX_VALUE;
952
-
953
- if (this.contours[0].points == null) {
954
- return new RRectangle();
955
- }
956
-
957
- for (RPoint point : this.contours[0].points) {
958
- float x = point.getX();
959
- float y = point.getY();
960
- if (x < xmin) {
961
- xmin = x;
962
- }
963
- if (x > xmax) {
964
- xmax = x;
965
- }
966
- if (y < ymin) {
967
- ymin = y;
968
- }
969
- if (y > ymax) {
970
- ymax = y;
971
- }
972
- }
973
-
974
- return new RRectangle(xmin, ymin, (xmax - xmin), (ymax - ymin));
975
- } else {
976
- throw new UnsupportedOperationException("getBounds not supported on complex poly.");
977
- }
978
- }
979
-
980
- /**
981
- * Returns the polygon at this index.
982
- *
983
- * @param polyIndex
984
- * @return
985
- */
986
- protected RPolygon getInnerPoly(int polyIndex) {
987
- return new RPolygon(this.contours[polyIndex]);
988
- }
989
-
990
- /**
991
- * Returns the number of inner polygons - inner polygons are assumed to
992
- * return one here.
993
- *
994
- * @return
995
- */
996
- protected int getNumInnerPoly() {
997
- if (this.contours == null) {
998
- return 0;
867
+ */
868
+ // ----------------------
869
+ // --- Private Methods ---
870
+ // ----------------------
871
+ /**
872
+ * Remove all of the points. Creates an empty polygon.
873
+ */
874
+ protected void clear() {
875
+ this.contours = null;
876
+ }
877
+
878
+ /**
879
+ * Add a point to the first inner polygon.
880
+ *
881
+ * @param x
882
+ * @param y
883
+ */
884
+ protected void add(float x, float y) {
885
+ if (contours == null) {
886
+ this.append(new RContour());
887
+ }
888
+ this.contours[0].append(new RPoint(x, y));
889
+ }
890
+
891
+ /**
892
+ * Add a point to the first inner polygon.
893
+ *
894
+ * @param p
895
+ */
896
+ protected void add(RPoint p) {
897
+ if (contours == null) {
898
+ this.append(new RContour());
899
+ }
900
+ this.contours[0].append(p);
901
+ }
902
+
903
+ /**
904
+ * Add an inner polygon to this polygon - assumes that adding polygon does not
905
+ * have any inner polygons.
906
+ *
907
+ * @param p
908
+ */
909
+ protected void add(RPolygon p) {
910
+ /*if (this.contours.length > 0 && this.isHole){
911
+ throw new IllegalStateException("Cannot add polys to something designated as a hole.");
912
+ }*/
913
+ RContour c = new RContour();
914
+ for (int i = 0; i < p.getNumPoints(); i++) {
915
+ c.addPoint(p.getX(i), p.getY(i));
916
+ }
917
+ this.append(c);
918
+ }
919
+
920
+ /**
921
+ * Add an inner polygon to this polygon - assumes that adding polygon does not
922
+ * have any inner polygons.
923
+ *
924
+ * @param c
925
+ */
926
+ protected void add(RContour c) {
927
+ /*if (this.contours.length > 0 && this.isHole){
928
+ throw new IllegalStateException("Cannot add polys to something designated as a hole.");
929
+ }*/
930
+ this.append(c);
931
+ }
932
+
933
+ /**
934
+ * Return true if the polygon is empty
935
+ *
936
+ * @return
937
+ */
938
+ protected boolean isEmpty() {
939
+ return (this.contours == null);
940
+ }
941
+
942
+ /**
943
+ * Returns the bounding box of the polygon.
944
+ *
945
+ * @return
946
+ */
947
+ protected RRectangle getBBox() {
948
+ if (this.contours == null) {
949
+ return new RRectangle();
950
+ } else if (this.contours.length == 1) {
951
+
952
+ float xmin = Float.MAX_VALUE;
953
+ float ymin = Float.MAX_VALUE;
954
+ float xmax = -Float.MAX_VALUE;
955
+ float ymax = -Float.MAX_VALUE;
956
+
957
+ if (this.contours[0].points == null) {
958
+ return new RRectangle();
959
+ }
960
+
961
+ for (RPoint point : this.contours[0].points) {
962
+ float x = point.getX();
963
+ float y = point.getY();
964
+ if (x < xmin) {
965
+ xmin = x;
999
966
  }
1000
- return this.contours.length;
1001
- }
1002
-
1003
- /**
1004
- * Return the number points of the first inner polygon
1005
- *
1006
- * @return
1007
- */
1008
- protected int getNumPoints() {
1009
- if (this.contours == null) {
1010
- return 0;
967
+ if (x > xmax) {
968
+ xmax = x;
1011
969
  }
1012
- if (this.contours[0].points == null) {
1013
- return 0;
970
+ if (y < ymin) {
971
+ ymin = y;
1014
972
  }
1015
- return this.contours[0].points.length;
1016
- }
1017
-
1018
- /**
1019
- * Return the X value of the point at the index in the first inner polygon
1020
- *
1021
- * @param index
1022
- * @return
1023
- */
1024
- protected float getX(int index) {
1025
- if (this.contours == null) {
1026
- return 0;
973
+ if (y > ymax) {
974
+ ymax = y;
1027
975
  }
1028
- return this.contours[0].points[index].x;
1029
- }
976
+ }
1030
977
 
1031
- /**
1032
- * Return the Y value of the point at the index in the first inner polygon
1033
- *
1034
- * @param index
1035
- * @return
1036
- */
1037
- protected float getY(int index) {
1038
- if (this.contours == null) {
1039
- return 0;
1040
- }
1041
- return this.contours[0].points[index].y;
978
+ return new RRectangle(xmin, ymin, (xmax - xmin), (ymax - ymin));
979
+ } else {
980
+ throw new UnsupportedOperationException("getBounds not supported on complex poly.");
1042
981
  }
982
+ }
1043
983
 
1044
- /**
1045
- * Return true if this polygon is a hole. Holes are assumed to be inner
1046
- * polygons of a more complex polygon.
1047
- *
1048
- * @return
1049
- * @throws IllegalStateException if called on a complex polygon.
1050
- */
1051
- public boolean isHole() {
1052
- if (this.contours == null || this.contours.length > 1) {
1053
- throw new IllegalStateException("Cannot call on a poly made up of more than one poly.");
1054
- }
1055
- return this.contours[0].isHole;
984
+ /**
985
+ * Returns the polygon at this index.
986
+ *
987
+ * @param polyIndex
988
+ * @return
989
+ */
990
+ protected RPolygon getInnerPoly(int polyIndex) {
991
+ return new RPolygon(this.contours[polyIndex]);
992
+ }
993
+
994
+ /**
995
+ * Returns the number of inner polygons - inner polygons are assumed to return
996
+ * one here.
997
+ *
998
+ * @return
999
+ */
1000
+ protected int getNumInnerPoly() {
1001
+ if (this.contours == null) {
1002
+ return 0;
1056
1003
  }
1004
+ return this.contours.length;
1005
+ }
1057
1006
 
1058
- /**
1059
- * Set whether or not this polygon is a hole. Cannot be called on a complex
1060
- * polygon.
1061
- *
1062
- * @param isHole
1063
- * @throws IllegalStateException if called on a complex polygon.
1064
- */
1065
- protected void setIsHole(boolean isHole) {
1066
- if (this.contours == null || this.contours.length > 1) {
1067
- throw new IllegalStateException("Cannot call on a poly made up of more than one poly.");
1068
- }
1069
- this.contours[0].isHole = isHole;
1007
+ /**
1008
+ * Return the number points of the first inner polygon
1009
+ *
1010
+ * @return
1011
+ */
1012
+ protected int getNumPoints() {
1013
+ if (this.contours == null) {
1014
+ return 0;
1070
1015
  }
1071
-
1072
- /**
1073
- * Return true if the given inner polygon is contributing to the set
1074
- * operation. This method should NOT be used outside the Clip algorithm.
1075
- *
1076
- * @param polyIndex
1077
- * @return
1078
- */
1079
- protected boolean isContributing(int polyIndex) {
1080
- return this.contours[polyIndex].isContributing;
1016
+ if (this.contours[0].points == null) {
1017
+ return 0;
1081
1018
  }
1019
+ return this.contours[0].points.length;
1020
+ }
1082
1021
 
1083
- /**
1084
- * Set whether or not this inner polygon is constributing to the set
1085
- * operation. This method should NOT be used outside the Clip algorithm.
1086
- *
1087
- * @param polyIndex
1088
- * @param contributes
1022
+ /**
1023
+ * Return the X value of the point at the index in the first inner polygon
1024
+ *
1025
+ * @param index
1026
+ * @return
1027
+ */
1028
+ protected float getX(int index) {
1029
+ if (this.contours == null) {
1030
+ return 0;
1031
+ }
1032
+ return this.contours[0].points[index].x;
1033
+ }
1034
+
1035
+ /**
1036
+ * Return the Y value of the point at the index in the first inner polygon
1037
+ *
1038
+ * @param index
1039
+ * @return
1040
+ */
1041
+ protected float getY(int index) {
1042
+ if (this.contours == null) {
1043
+ return 0;
1044
+ }
1045
+ return this.contours[0].points[index].y;
1046
+ }
1047
+
1048
+ /**
1049
+ * Return true if this polygon is a hole. Holes are assumed to be inner
1050
+ * polygons of a more complex polygon.
1051
+ *
1052
+ * @return
1053
+ * @throws IllegalStateException if called on a complex polygon.
1054
+ */
1055
+ public boolean isHole() {
1056
+ if (this.contours == null || this.contours.length > 1) {
1057
+ throw new IllegalStateException("Cannot call on a poly made up of more than one poly.");
1058
+ }
1059
+ return this.contours[0].isHole;
1060
+ }
1061
+
1062
+ /**
1063
+ * Set whether or not this polygon is a hole. Cannot be called on a complex
1064
+ * polygon.
1065
+ *
1066
+ * @param isHole
1067
+ * @throws IllegalStateException if called on a complex polygon.
1068
+ */
1069
+ protected void setIsHole(boolean isHole) {
1070
+ if (this.contours == null || this.contours.length > 1) {
1071
+ throw new IllegalStateException("Cannot call on a poly made up of more than one poly.");
1072
+ }
1073
+ this.contours[0].isHole = isHole;
1074
+ }
1075
+
1076
+ /**
1077
+ * Return true if the given inner polygon is contributing to the set
1078
+ * operation. This method should NOT be used outside the Clip algorithm.
1079
+ *
1080
+ * @param polyIndex
1081
+ * @return
1082
+ */
1083
+ protected boolean isContributing(int polyIndex) {
1084
+ return this.contours[polyIndex].isContributing;
1085
+ }
1086
+
1087
+ /**
1088
+ * Set whether or not this inner polygon is constributing to the set
1089
+ * operation. This method should NOT be used outside the Clip algorithm.
1090
+ *
1091
+ * @param polyIndex
1092
+ * @param contributes
1093
+ */
1094
+ protected void setContributing(int polyIndex, boolean contributes) {
1095
+ /*
1096
+ if( this.contours.length != 1 )
1097
+ {
1098
+ throw new IllegalStateException( "Only applies to polys of size 1" );
1099
+ }
1089
1100
  */
1090
- protected void setContributing(int polyIndex, boolean contributes) {
1091
- /*
1092
- if( this.contours.length != 1 )
1093
- {
1094
- throw new IllegalStateException( "Only applies to polys of size 1" );
1095
- }
1096
- */
1097
- this.contours[polyIndex].isContributing = contributes;
1098
- }
1099
-
1100
- private void append(RContour nextcontour) {
1101
- RContour[] newcontours;
1102
- if (contours == null) {
1103
- newcontours = new RContour[1];
1104
- newcontours[0] = nextcontour;
1105
- currentContour = 0;
1106
- } else {
1107
- newcontours = new RContour[this.contours.length + 1];
1108
- System.arraycopy(this.contours, 0, newcontours, 0, this.contours.length);
1109
- newcontours[this.contours.length] = nextcontour;
1110
- currentContour++;
1111
- }
1112
- this.contours = newcontours;
1113
- }
1101
+ this.contours[polyIndex].isContributing = contributes;
1102
+ }
1103
+
1104
+ private void append(RContour nextcontour) {
1105
+ RContour[] newcontours;
1106
+ if (contours == null) {
1107
+ newcontours = new RContour[1];
1108
+ newcontours[0] = nextcontour;
1109
+ currentContour = 0;
1110
+ } else {
1111
+ newcontours = new RContour[this.contours.length + 1];
1112
+ System.arraycopy(this.contours, 0, newcontours, 0, this.contours.length);
1113
+ newcontours[this.contours.length] = nextcontour;
1114
+ currentContour++;
1115
+ }
1116
+ this.contours = newcontours;
1117
+ }
1114
1118
  }