3030import de .bluecolored .bluemap .api .math .Color ;
3131import de .bluecolored .bluemap .api .math .Shape ;
3232
33+ import java .util .ArrayList ;
34+ import java .util .Arrays ;
35+ import java .util .Collection ;
3336import java .util .Objects ;
3437
38+ @ SuppressWarnings ("FieldMayBeFinal" )
3539@ DebugDump
3640public class ExtrudeMarker extends ObjectMarker {
3741 private static final Shape DEFAULT_SHAPE = Shape .createRect (0 , 0 , 1 , 1 );
3842
3943 private Shape shape ;
44+ private Collection <Shape > holes = new ArrayList <>();
4045 private float shapeMinY , shapeMaxY ;
4146 private boolean depthTest = true ;
4247 private int lineWidth = 2 ;
@@ -138,6 +143,15 @@ public void setShape(Shape shape, float minY, float maxY) {
138143 this .shapeMaxY = maxY ;
139144 }
140145
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+
141155 /**
142156 * Sets the position of this {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
143157 * <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>
272286
273287 Shape shape ;
274288 float shapeMinY , shapeMaxY ;
289+ Collection <Shape > holes = new ArrayList <>();
275290 Boolean depthTest ;
276291 Integer lineWidth ;
277292 Color lineColor ;
@@ -294,6 +309,25 @@ public Builder shape(Shape shape, float minY, float maxY) {
294309 return this ;
295310 }
296311
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+
297331 /**
298332 * Sets the position of the {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
299333 * @return this builder for chaining
@@ -361,6 +395,7 @@ public ExtrudeMarker build() {
361395 shapeMinY ,
362396 shapeMaxY
363397 );
398+ marker .getHoles ().addAll (holes );
364399 if (depthTest != null ) marker .setDepthTestEnabled (depthTest );
365400 if (lineWidth != null ) marker .setLineWidth (lineWidth );
366401 if (lineColor != null ) marker .setLineColor (lineColor );
0 commit comments