geomerative 0.4.3-java → 2.1.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +19 -1
- data/COPYING.md +1 -1
- data/README.md +2 -2
- data/Rakefile +2 -15
- data/docs/_config.yml +8 -0
- data/docs/_includes/head.html +7 -6
- data/docs/_includes/header.html +6 -6
- data/docs/_includes/icon-github.svg +3 -1
- data/docs/_includes/icon-twitter.svg +3 -1
- data/docs/_includes/navigation.html +24 -0
- data/docs/_sass/_base.scss +79 -79
- data/docs/_sass/_layout.scss +137 -137
- data/docs/_sass/_syntax-highlighting.scss +64 -64
- data/docs/index.html +18 -18
- data/examples/README.md +1 -1
- data/examples/data/bot1.svg +1 -1
- data/examples/data/lion.svg +156 -156
- data/examples/data/ruby.svg +1 -1
- data/examples/jruby_merge.rb +1 -1
- data/examples/{f_agent.rb → library/f_agent/f_agent.rb} +0 -0
- data/examples/{font_agent.rb → library/font_agent/font_agent.rb} +2 -1
- data/examples/text_on_geomerative_path.rb +3 -2
- data/examples/typo_deform.rb +2 -2
- data/examples/typo_extra_bright.rb +1 -1
- data/geomerative.gemspec +3 -6
- data/lib/geomerative/version.rb +1 -1
- data/lib/geomerative.jar +0 -0
- data/lib/geomerative.rb +10 -10
- data/mvnw +234 -0
- data/mvnw.cmd +145 -0
- data/pom.rb +14 -16
- data/pom.xml +13 -19
- data/src/geomerative/FastRClip.java +2050 -2334
- data/src/geomerative/RClip.java +2237 -2539
- data/src/geomerative/RClosest.java +33 -31
- data/src/geomerative/RCommand.java +1750 -1758
- data/src/geomerative/RContour.java +290 -292
- data/src/geomerative/RFont.java +277 -246
- data/src/geomerative/RG.java +722 -727
- data/src/geomerative/RGeomElem.java +967 -962
- data/src/geomerative/RGroup.java +508 -467
- data/src/geomerative/RMatrix.java +304 -289
- data/src/geomerative/RMesh.java +241 -229
- data/src/geomerative/RPath.java +924 -926
- data/src/geomerative/RPoint.java +391 -391
- data/src/geomerative/RPolygon.java +1017 -1013
- data/src/geomerative/RRectangle.java +43 -52
- data/src/geomerative/RSVG.java +480 -516
- data/src/geomerative/RShape.java +1767 -1777
- data/src/geomerative/RStrip.java +173 -176
- data/src/geomerative/RStyle.java +197 -194
- data/src/module-info.java +4 -0
- data/src/org/apache/batik/svggen/font/Font.java +141 -142
- data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
- data/src/org/apache/batik/svggen/font/Point.java +12 -12
- data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
- data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
- data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
- data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
- data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
- data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
- data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
- data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
- data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
- data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
- data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
- data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
- data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
- data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
- data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
- data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
- data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
- data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
- data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
- data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
- data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
- data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
- data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
- data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
- data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
- data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
- data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
- data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
- data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
- data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
- data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
- data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
- data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
- data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
- data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
- data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
- data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
- data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
- data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
- data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
- data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
- data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
- data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
- data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
- data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
- data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
- data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
- data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
- data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
- data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
- data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
- data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
- data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
- data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
- data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
- data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
- data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
- data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
- data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
- data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
- data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
- data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
- data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
- data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
- data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
- data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
- data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
- metadata +18 -19
- data/.travis.yml +0 -10
- 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
|
-
|
|
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,8 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
package geomerative;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
21
|
import java.util.List;
|
|
24
22
|
import processing.core.PApplet;
|
|
25
23
|
import processing.core.PConstants;
|
|
@@ -30,326 +28,326 @@ import processing.core.PGraphics;
|
|
|
30
28
|
* Contours are ordered lists of points (RPoint) which define the outlines of
|
|
31
29
|
* polygons. Contours can be self-intersecting.
|
|
32
30
|
*
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
31
|
+
RContour
|
|
32
|
+
* Geometry
|
|
33
|
+
* RPoint
|
|
34
|
+
* RPolygon
|
|
35
|
+
|
|
38
36
|
*/
|
|
39
37
|
public class RContour extends RGeomElem {
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Array of RPoint objects holding the points of the contour.
|
|
48
|
-
*
|
|
49
|
-
* @eexample points
|
|
50
|
-
* @related RPoint
|
|
51
|
-
* @related countPoints ( )
|
|
52
|
-
* @related addPoint ( )
|
|
53
|
-
*/
|
|
54
|
-
public RPoint[] points;
|
|
55
|
-
boolean isContributing = true;
|
|
56
|
-
boolean isHole = false;
|
|
57
|
-
boolean closed = true;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Use this method to count the number of points in the contour.
|
|
61
|
-
*
|
|
62
|
-
* @eexample countPoints
|
|
63
|
-
* @return int, the number points in the contour
|
|
64
|
-
*/
|
|
65
|
-
public int countPoints() {
|
|
66
|
-
if (this.points == null) {
|
|
67
|
-
return 0;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return this.points.length;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Create a countour given an array of points.
|
|
75
|
-
*
|
|
76
|
-
* @param contourpoints the points of the new contour
|
|
77
|
-
* @invisible
|
|
78
|
-
*/
|
|
79
|
-
public RContour(RPoint[] contourpoints) {
|
|
80
|
-
this.points = contourpoints;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public RContour() {
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public RContour(RContour c) {
|
|
87
|
-
for (int i = 0; i < c.countPoints(); i++) {
|
|
88
|
-
this.append(new RPoint(c.points[i]));
|
|
89
|
-
}
|
|
90
|
-
isHole = c.isHole;
|
|
91
|
-
isContributing = c.isContributing;
|
|
92
|
-
|
|
93
|
-
setStyle(c);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Use this method to draw the contour.
|
|
98
|
-
*
|
|
99
|
-
* @eexample drawContour
|
|
100
|
-
* @param g PGraphics, the graphics object on which to draw the contour
|
|
101
|
-
*/
|
|
102
|
-
@Override
|
|
103
|
-
public void draw(PGraphics g) {
|
|
104
|
-
int numPoints = countPoints();
|
|
105
|
-
boolean beforeFill = g.fill;
|
|
106
|
-
g.noFill();
|
|
107
|
-
g.beginShape();
|
|
108
|
-
for (int i = 0; i < numPoints; i++) {
|
|
109
|
-
g.vertex(points[i].x, points[i].y);
|
|
110
|
-
}
|
|
111
|
-
g.endShape(closed ? PConstants.CLOSE : PConstants.OPEN);
|
|
112
|
-
if (beforeFill) {
|
|
113
|
-
g.fill(g.fillColor);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
*
|
|
119
|
-
* @param g
|
|
120
|
-
*/
|
|
121
|
-
@Override
|
|
122
|
-
public void draw(PApplet g) {
|
|
123
|
-
int numPoints = countPoints();
|
|
124
|
-
boolean beforeFill = g.g.fill;
|
|
125
|
-
g.noFill();
|
|
126
|
-
g.beginShape();
|
|
127
|
-
for (int i = 0; i < numPoints; i++) {
|
|
128
|
-
g.vertex(points[i].x, points[i].y);
|
|
129
|
-
}
|
|
130
|
-
g.endShape(closed ? PConstants.CLOSE : PConstants.OPEN);
|
|
131
|
-
if (beforeFill) {
|
|
132
|
-
g.fill(g.g.fillColor);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Use this method to add new points to the contour.
|
|
138
|
-
*
|
|
139
|
-
* @param p
|
|
140
|
-
* @eexample addPoint ( )
|
|
141
|
-
*/
|
|
142
|
-
public void addPoint(RPoint p) {
|
|
143
|
-
this.append(p);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public void addPoint(float x, float y) {
|
|
147
|
-
this.append(new RPoint(x, y));
|
|
148
|
-
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
public int type = RGeomElem.CONTOUR;
|
|
149
43
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Array of RPoint objects holding the points of the contour.
|
|
46
|
+
*
|
|
47
|
+
points
|
|
48
|
+
* RPoint
|
|
49
|
+
* countPoints ( )
|
|
50
|
+
* addPoint ( )
|
|
51
|
+
*/
|
|
52
|
+
public RPoint[] points;
|
|
53
|
+
boolean isContributing = true;
|
|
54
|
+
boolean isHole = false;
|
|
55
|
+
boolean closed = true;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Use this method to count the number of points in the contour.
|
|
59
|
+
*
|
|
60
|
+
countPoints
|
|
61
|
+
* @return int, the number points in the contour
|
|
62
|
+
*/
|
|
63
|
+
public int countPoints() {
|
|
64
|
+
if (this.points == null) {
|
|
65
|
+
return 0;
|
|
164
66
|
}
|
|
165
67
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
*
|
|
169
|
-
* @param morePoints
|
|
170
|
-
*/
|
|
171
|
-
public void addPoints(List<RPoint> morePoints) {
|
|
172
|
-
int start = 0;
|
|
173
|
-
if (points == null) {
|
|
174
|
-
this.points = new RPoint[morePoints.size()];
|
|
175
|
-
} else {
|
|
176
|
-
RPoint[] newPoints = new RPoint[this.points.length + morePoints.size()];
|
|
177
|
-
System.arraycopy(this.points, 0, newPoints, 0, this.points.length);
|
|
178
|
-
this.points = newPoints;
|
|
179
|
-
start = morePoints.size();
|
|
180
|
-
}
|
|
181
|
-
// it would be nice to be able to access the ArrayList's internal array!
|
|
182
|
-
for (int i = start, j = 0; i < points.length; i++) {
|
|
183
|
-
points[i] = morePoints.get(j);
|
|
184
|
-
j++;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
68
|
+
return this.points.length;
|
|
69
|
+
}
|
|
187
70
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
* the way of an array of RPoint.
|
|
191
|
-
*
|
|
192
|
-
* @eexample RContour_getHandles
|
|
193
|
-
* @return RPoint[], the points returned in an array.
|
|
71
|
+
/**
|
|
72
|
+
* Create a countour given an array of points.
|
|
194
73
|
*
|
|
195
|
-
|
|
196
|
-
@Override
|
|
197
|
-
public RPoint[] getHandles() {
|
|
198
|
-
return points;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Use this to return the points of the contour. It returns the points in
|
|
203
|
-
* the way of an array of RPoint.
|
|
204
|
-
*
|
|
205
|
-
* @eexample RContour_getPoints
|
|
206
|
-
* @return RPoint[], the points returned in an array.
|
|
74
|
+
* @param contourpoints the points of the new contour
|
|
207
75
|
*
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
76
|
+
*/
|
|
77
|
+
public RContour(RPoint[] contourpoints) {
|
|
78
|
+
this.points = contourpoints;
|
|
79
|
+
}
|
|
213
80
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @param t
|
|
217
|
-
* @return
|
|
218
|
-
*/
|
|
219
|
-
@Override
|
|
220
|
-
public RPoint getPoint(float t) {
|
|
221
|
-
PApplet.println("Feature not yet implemented for this class.");
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
81
|
+
public RContour() {
|
|
82
|
+
}
|
|
224
83
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return null;
|
|
84
|
+
public RContour(RContour c) {
|
|
85
|
+
for (int i = 0; i < c.countPoints(); i++) {
|
|
86
|
+
this.append(new RPoint(c.points[i]));
|
|
229
87
|
}
|
|
88
|
+
isHole = c.isHole;
|
|
89
|
+
isContributing = c.isContributing;
|
|
230
90
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
PApplet.println("Feature not yet implemented for this class.");
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
91
|
+
setStyle(c);
|
|
92
|
+
}
|
|
236
93
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Use this method to draw the contour.
|
|
96
|
+
*
|
|
97
|
+
drawContour
|
|
98
|
+
* @param g PGraphics, the graphics object on which to draw the contour
|
|
99
|
+
*/
|
|
100
|
+
@Override
|
|
101
|
+
public void draw(PGraphics g) {
|
|
102
|
+
int numPoints = countPoints();
|
|
103
|
+
boolean beforeFill = g.fill;
|
|
104
|
+
g.noFill();
|
|
105
|
+
g.beginShape();
|
|
106
|
+
for (int i = 0; i < numPoints; i++) {
|
|
107
|
+
g.vertex(points[i].x, points[i].y);
|
|
241
108
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
* @return
|
|
246
|
-
*/
|
|
247
|
-
@Override
|
|
248
|
-
public RPoint[][] getHandlesInPaths() {
|
|
249
|
-
PApplet.println("Feature not yet implemented for this class.");
|
|
250
|
-
return null;
|
|
109
|
+
g.endShape(closed ? PConstants.CLOSE : PConstants.OPEN);
|
|
110
|
+
if (beforeFill) {
|
|
111
|
+
g.fill(g.fillColor);
|
|
251
112
|
}
|
|
113
|
+
}
|
|
252
114
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param g
|
|
118
|
+
*/
|
|
119
|
+
@Override
|
|
120
|
+
public void draw(PApplet g) {
|
|
121
|
+
int numPoints = countPoints();
|
|
122
|
+
boolean beforeFill = g.g.fill;
|
|
123
|
+
g.noFill();
|
|
124
|
+
g.beginShape();
|
|
125
|
+
for (int i = 0; i < numPoints; i++) {
|
|
126
|
+
g.vertex(points[i].x, points[i].y);
|
|
257
127
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
* @param p
|
|
262
|
-
* @return
|
|
263
|
-
*/
|
|
264
|
-
@Override
|
|
265
|
-
public boolean contains(RPoint p) {
|
|
266
|
-
PApplet.println("Feature not yet implemented for this class.");
|
|
267
|
-
return false;
|
|
128
|
+
g.endShape(closed ? PConstants.CLOSE : PConstants.OPEN);
|
|
129
|
+
if (beforeFill) {
|
|
130
|
+
g.fill(g.g.fillColor);
|
|
268
131
|
}
|
|
132
|
+
}
|
|
269
133
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Use this method to add new points to the contour.
|
|
136
|
+
*
|
|
137
|
+
* @param p
|
|
138
|
+
addPoint ( )
|
|
139
|
+
*/
|
|
140
|
+
public void addPoint(RPoint p) {
|
|
141
|
+
this.append(p);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public void addPoint(float x, float y) {
|
|
145
|
+
this.append(new RPoint(x, y));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Efficiently add an array of points to the contour.
|
|
150
|
+
*
|
|
151
|
+
* @param morePoints
|
|
152
|
+
*/
|
|
153
|
+
public void addPoints(RPoint[] morePoints) {
|
|
154
|
+
if (points == null) {
|
|
155
|
+
this.points = morePoints;
|
|
156
|
+
} else {
|
|
157
|
+
RPoint[] newPoints = new RPoint[this.points.length + morePoints.length];
|
|
158
|
+
System.arraycopy(this.points, 0, newPoints, 0, this.points.length);
|
|
159
|
+
System.arraycopy(morePoints, 0, newPoints, this.points.length, morePoints.length);
|
|
160
|
+
this.points = newPoints;
|
|
280
161
|
}
|
|
162
|
+
}
|
|
281
163
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Efficiently add a list of points to the contour.
|
|
166
|
+
*
|
|
167
|
+
* @param morePoints
|
|
168
|
+
*/
|
|
169
|
+
public void addPoints(List<RPoint> morePoints) {
|
|
170
|
+
int start = 0;
|
|
171
|
+
if (points == null) {
|
|
172
|
+
this.points = new RPoint[morePoints.size()];
|
|
173
|
+
} else {
|
|
174
|
+
RPoint[] newPoints = new RPoint[this.points.length + morePoints.size()];
|
|
175
|
+
System.arraycopy(this.points, 0, newPoints, 0, this.points.length);
|
|
176
|
+
this.points = newPoints;
|
|
177
|
+
start = morePoints.size();
|
|
293
178
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if ((points[0].x == points[points.length - 1].x) && (points[0].y == points[points.length - 1].y)) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
addPoint(new RPoint(points[0].x, points[0].y));
|
|
305
|
-
closed = true;
|
|
179
|
+
// it would be nice to be able to access the ArrayList's internal array!
|
|
180
|
+
for (int i = start, j = 0; i < points.length; i++) {
|
|
181
|
+
points[i] = morePoints.get(j);
|
|
182
|
+
j++;
|
|
306
183
|
}
|
|
184
|
+
}
|
|
307
185
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Use this to return the points of the contour. It returns the points in the
|
|
188
|
+
* way of an array of RPoint.
|
|
189
|
+
*
|
|
190
|
+
RContour_getHandles
|
|
191
|
+
* @return RPoint[], the points returned in an array.
|
|
192
|
+
*
|
|
193
|
+
*/
|
|
194
|
+
@Override
|
|
195
|
+
public RPoint[] getHandles() {
|
|
196
|
+
return points;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Use this to return the points of the contour. It returns the points in the
|
|
201
|
+
* way of an array of RPoint.
|
|
202
|
+
*
|
|
203
|
+
RContour_getPoints
|
|
204
|
+
* @return RPoint[], the points returned in an array.
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
@Override
|
|
208
|
+
public RPoint[] getPoints() {
|
|
209
|
+
return points;
|
|
210
|
+
}
|
|
315
211
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
* @param t
|
|
215
|
+
* @return
|
|
216
|
+
*/
|
|
217
|
+
@Override
|
|
218
|
+
public RPoint getPoint(float t) {
|
|
219
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@Override
|
|
224
|
+
public RPoint getTangent(float t) {
|
|
225
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@Override
|
|
230
|
+
public RPoint[] getTangents() {
|
|
231
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@Override
|
|
236
|
+
public RPoint[][] getPointsInPaths() {
|
|
237
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
*
|
|
243
|
+
* @return
|
|
244
|
+
*/
|
|
245
|
+
@Override
|
|
246
|
+
public RPoint[][] getHandlesInPaths() {
|
|
247
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@Override
|
|
252
|
+
public RPoint[][] getTangentsInPaths() {
|
|
253
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
*
|
|
259
|
+
* @param p
|
|
260
|
+
* @return
|
|
261
|
+
*/
|
|
262
|
+
@Override
|
|
263
|
+
public boolean contains(RPoint p) {
|
|
264
|
+
PApplet.println("Feature not yet implemented for this class.");
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Use this method to know if the contour is a hole. Remember to use the
|
|
270
|
+
* method update() on the polygon before using this method.
|
|
271
|
+
*
|
|
272
|
+
RPolygon_isHole
|
|
273
|
+
* @return boolean, true if it is a hole
|
|
274
|
+
* update ( )
|
|
275
|
+
*/
|
|
276
|
+
public boolean isHole() {
|
|
277
|
+
return isHole;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
*/
|
|
283
|
+
@Override
|
|
284
|
+
public void print() {
|
|
285
|
+
System.out.println("contour: ");
|
|
286
|
+
for (int i = 0; i < countPoints(); i++) {
|
|
287
|
+
System.out.println("--- point " + i + " ---");
|
|
288
|
+
points[i].print();
|
|
289
|
+
System.out.println("---------------");
|
|
322
290
|
}
|
|
291
|
+
}
|
|
323
292
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
@Override
|
|
328
|
-
public RMesh toMesh() {
|
|
329
|
-
return this.toPolygon().toMesh();
|
|
293
|
+
public void addClose() {
|
|
294
|
+
if (points == null) {
|
|
295
|
+
return;
|
|
330
296
|
}
|
|
331
297
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*
|
|
335
|
-
* @eexample RPolygon_getType
|
|
336
|
-
* @return int, will allways return RGeomElem.POLYGON
|
|
337
|
-
*/
|
|
338
|
-
@Override
|
|
339
|
-
public int getType() {
|
|
340
|
-
return type;
|
|
298
|
+
if ((points[0].x == points[points.length - 1].x) && (points[0].y == points[points.length - 1].y)) {
|
|
299
|
+
return;
|
|
341
300
|
}
|
|
342
301
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
302
|
+
addPoint(new RPoint(points[0].x, points[0].y));
|
|
303
|
+
closed = true;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @return
|
|
308
|
+
*/
|
|
309
|
+
@Override
|
|
310
|
+
public RPolygon toPolygon() {
|
|
311
|
+
return new RPolygon(this);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @return
|
|
316
|
+
*/
|
|
317
|
+
@Override
|
|
318
|
+
public RShape toShape() throws RuntimeException {
|
|
319
|
+
throw new RuntimeException("Transforming a Contour to a Shape is not yet implemented.");
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @return
|
|
324
|
+
*/
|
|
325
|
+
@Override
|
|
326
|
+
public RMesh toMesh() {
|
|
327
|
+
return this.toPolygon().toMesh();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Use this method to get the type of element this is.
|
|
332
|
+
*
|
|
333
|
+
RPolygon_getType
|
|
334
|
+
* @return int, will allways return RGeomElem.POLYGON
|
|
335
|
+
*/
|
|
336
|
+
@Override
|
|
337
|
+
public int getType() {
|
|
338
|
+
return type;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
final void append(RPoint nextpoint) {
|
|
342
|
+
RPoint[] newpoints;
|
|
343
|
+
if (points == null) {
|
|
344
|
+
newpoints = new RPoint[1];
|
|
345
|
+
newpoints[0] = nextpoint;
|
|
346
|
+
} else {
|
|
347
|
+
newpoints = new RPoint[this.points.length + 1];
|
|
348
|
+
System.arraycopy(this.points, 0, newpoints, 0, this.points.length);
|
|
349
|
+
newpoints[this.points.length] = nextpoint;
|
|
354
350
|
}
|
|
351
|
+
this.points = newpoints;
|
|
352
|
+
}
|
|
355
353
|
}
|