30
30
import de .bluecolored .bluemap .api .math .Color ;
31
31
import de .bluecolored .bluemap .api .math .Shape ;
32
32
33
+ import java .util .ArrayList ;
34
+ import java .util .Arrays ;
35
+ import java .util .Collection ;
33
36
import java .util .Objects ;
34
37
38
+ @ SuppressWarnings ("FieldMayBeFinal" )
35
39
@ DebugDump
36
40
public class ExtrudeMarker extends ObjectMarker {
37
41
private static final Shape DEFAULT_SHAPE = Shape .createRect (0 , 0 , 1 , 1 );
38
42
39
43
private Shape shape ;
44
+ private Collection <Shape > holes = new ArrayList <>();
40
45
private float shapeMinY , shapeMaxY ;
41
46
private boolean depthTest = true ;
42
47
private int lineWidth = 2 ;
@@ -138,6 +143,15 @@ public void setShape(Shape shape, float minY, float maxY) {
138
143
this .shapeMaxY = maxY ;
139
144
}
140
145
146
+ /**
147
+ * Getter for the <b>mutable</b> collection of holes in this {@link ExtrudeMarker}.
148
+ * <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
149
+ * @return A <b>mutable</b> collection of hole-shapes
150
+ */
151
+ public Collection <Shape > getHoles () {
152
+ return holes ;
153
+ }
154
+
141
155
/**
142
156
* Sets the position of this {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
143
157
* <p><i>(Invoke this after changing the {@link Shape} to make sure the markers position gets updated as well)</i></p>
@@ -272,6 +286,7 @@ public static class Builder extends ObjectMarker.Builder<ExtrudeMarker, Builder>
272
286
273
287
Shape shape ;
274
288
float shapeMinY , shapeMaxY ;
289
+ Collection <Shape > holes = new ArrayList <>();
275
290
Boolean depthTest ;
276
291
Integer lineWidth ;
277
292
Color lineColor ;
@@ -294,6 +309,25 @@ public Builder shape(Shape shape, float minY, float maxY) {
294
309
return this ;
295
310
}
296
311
312
+ /**
313
+ * <b>Adds</b> some hole-{@link Shape}s.
314
+ * @param holes the additional holes
315
+ * @return this builder for chaining
316
+ */
317
+ public Builder holes (Shape ... holes ) {
318
+ this .holes .addAll (Arrays .asList (holes ));
319
+ return this ;
320
+ }
321
+
322
+ /**
323
+ * Removes all hole-shapes from this Builder.
324
+ * @return this builder for chaining
325
+ */
326
+ public Builder clearHoles () {
327
+ this .holes .clear ();
328
+ return this ;
329
+ }
330
+
297
331
/**
298
332
* Sets the position of the {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
299
333
* @return this builder for chaining
@@ -361,6 +395,7 @@ public ExtrudeMarker build() {
361
395
shapeMinY ,
362
396
shapeMaxY
363
397
);
398
+ marker .getHoles ().addAll (holes );
364
399
if (depthTest != null ) marker .setDepthTestEnabled (depthTest );
365
400
if (lineWidth != null ) marker .setLineWidth (lineWidth );
366
401
if (lineColor != null ) marker .setLineColor (lineColor );
0 commit comments