1
2
3
4
5
6
7
8
9 package math.geom2d.circulinear;
10
11 import java.awt.Graphics2D;
12 import java.util.Collection;
13
14 import math.geom2d.AffineTransform2D;
15 import math.geom2d.domain.BoundaryPolyCurve2D;
16 import math.geom2d.domain.ContinuousOrientedCurve2D;
17 import math.geom2d.transform.CircleInversion2D;
18
19
20
21
22
23
24
25
26 public class GenericCirculinearRing2D
27 extends PolyCirculinearCurve2D<CirculinearElement2D>
28 implements CirculinearRing2D {
29
30
31
32
33
34 public GenericCirculinearRing2D() {
35 super();
36 this.closed = true;
37 }
38
39 public GenericCirculinearRing2D(int size) {
40 super(size);
41 this.closed = true;
42 }
43
44 public GenericCirculinearRing2D(CirculinearElement2D[] curves) {
45 super(curves);
46 this.closed = true;
47 }
48
49
50
51
52 @Deprecated
53 public GenericCirculinearRing2D(CirculinearElement2D[] curves,
54 boolean closed) {
55 super(curves, closed);
56 }
57
58 public GenericCirculinearRing2D(
59 Collection<? extends CirculinearElement2D> curves) {
60 super(curves);
61 this.closed = true;
62 }
63
64
65
66
67 @Deprecated
68 public GenericCirculinearRing2D(
69 Collection<? extends CirculinearElement2D> curves,
70 boolean closed) {
71 super(curves, closed);
72 }
73
74
75
76
77
78
79
80
81
82 public static <T extends CirculinearElement2D> GenericCirculinearRing2D
83 create(Collection<T> curves) {
84 return new GenericCirculinearRing2D(curves);
85 }
86
87
88
89
90
91
92 public static GenericCirculinearRing2D create(
93 CirculinearElement2D[] curves) {
94 return new GenericCirculinearRing2D(curves);
95 }
96
97
98
99
100
101
102
103
104 @Override
105 public CirculinearRing2D getParallel(double dist) {
106 return new GenericCirculinearRing2D(
107 CirculinearCurve2DUtils.createContinuousParallel(this, dist)
108 .getSmoothPieces());
109 }
110
111 public Collection<? extends GenericCirculinearRing2D> getContinuousCurves() {
112 return wrapCurve(this);
113 }
114
115 @Override
116 public GenericCirculinearRing2D transform(CircleInversion2D inv) {
117
118 GenericCirculinearRing2D result =
119 new GenericCirculinearRing2D(curves.size());
120
121
122 for (CirculinearElement2D element : curves)
123 result.addCurve((CirculinearElement2D)element.transform(inv));
124 return result;
125 }
126
127
128
129
130 public void fill(Graphics2D g2) {
131 g2.fill(this.getGeneralPath());
132 }
133
134
135
136
137 public Collection<? extends CirculinearContour2D> getBoundaryCurves() {
138 return wrapCurve(this);
139 }
140
141
142
143
144 public CirculinearDomain2D getDomain() {
145 return new GenericCirculinearDomain2D(this);
146 }
147
148 @Override
149 public GenericCirculinearRing2D getReverseCurve(){
150 int n = curves.size();
151
152 CirculinearElement2D[] curves2 = new CirculinearElement2D[n];
153
154
155 for (int i = 0; i<n; i++)
156 curves2[i] = (CirculinearElement2D)curves.get(n-1-i).getReverseCurve();
157
158
159 return new GenericCirculinearRing2D(curves2);
160 }
161
162 @Override
163 public BoundaryPolyCurve2D<ContinuousOrientedCurve2D>
164 transform(AffineTransform2D trans) {
165
166 int n = this.getCurveNumber();
167
168
169 BoundaryPolyCurve2D<ContinuousOrientedCurve2D> result =
170 new BoundaryPolyCurve2D<ContinuousOrientedCurve2D>(n);
171
172
173 for (ContinuousOrientedCurve2D curve : curves)
174 result.addCurve((ContinuousOrientedCurve2D)curve.transform(trans));
175 return result;
176 }
177
178 }