mirror of
https://github.com/BlueMap-Minecraft/BlueMapAPI.git
synced 2024-11-23 10:45:47 +01:00
Add methods to add holes to shape and extrude markers
This commit is contained in:
parent
942cec6571
commit
ad77b492dd
@ -30,13 +30,18 @@
|
||||
import de.bluecolored.bluemap.api.math.Color;
|
||||
import de.bluecolored.bluemap.api.math.Shape;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
@DebugDump
|
||||
public class ExtrudeMarker extends ObjectMarker {
|
||||
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
|
||||
|
||||
private Shape shape;
|
||||
private Collection<Shape> holes = new ArrayList<>();
|
||||
private float shapeMinY, shapeMaxY;
|
||||
private boolean depthTest = true;
|
||||
private int lineWidth = 2;
|
||||
@ -138,6 +143,15 @@ public void setShape(Shape shape, float minY, float maxY) {
|
||||
this.shapeMaxY = maxY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the <b>mutable</b> collection of holes in this {@link ExtrudeMarker}.
|
||||
* <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
|
||||
* @return A <b>mutable</b> collection of hole-shapes
|
||||
*/
|
||||
public Collection<Shape> getHoles() {
|
||||
return holes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position of this {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
|
||||
* <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>
|
||||
|
||||
Shape shape;
|
||||
float shapeMinY, shapeMaxY;
|
||||
Collection<Shape> holes = new ArrayList<>();
|
||||
Boolean depthTest;
|
||||
Integer lineWidth;
|
||||
Color lineColor;
|
||||
@ -294,6 +309,25 @@ public Builder shape(Shape shape, float minY, float maxY) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>Adds</b> some hole-{@link Shape}s.
|
||||
* @param holes the additional holes
|
||||
* @return this builder for chaining
|
||||
*/
|
||||
public Builder holes(Shape... holes) {
|
||||
this.holes.addAll(Arrays.asList(holes));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all hole-shapes from this Builder.
|
||||
* @return this builder for chaining
|
||||
*/
|
||||
public Builder clearHoles() {
|
||||
this.holes.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position of the {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
|
||||
* @return this builder for chaining
|
||||
@ -361,6 +395,7 @@ public ExtrudeMarker build() {
|
||||
shapeMinY,
|
||||
shapeMaxY
|
||||
);
|
||||
marker.getHoles().addAll(holes);
|
||||
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
|
||||
if (lineWidth != null) marker.setLineWidth(lineWidth);
|
||||
if (lineColor != null) marker.setLineColor(lineColor);
|
||||
|
@ -31,13 +31,18 @@
|
||||
import de.bluecolored.bluemap.api.math.Color;
|
||||
import de.bluecolored.bluemap.api.math.Shape;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
@DebugDump
|
||||
public class ShapeMarker extends ObjectMarker {
|
||||
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
|
||||
|
||||
private Shape shape;
|
||||
private Collection<Shape> holes = new ArrayList<>();
|
||||
private float shapeY;
|
||||
private boolean depthTest = true;
|
||||
private int lineWidth = 2;
|
||||
@ -119,6 +124,15 @@ public void setShape(Shape shape, float y) {
|
||||
this.shapeY = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the <b>mutable</b> collection of holes in this {@link ShapeMarker}.
|
||||
* <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
|
||||
* @return A <b>mutable</b> collection of hole-shapes
|
||||
*/
|
||||
public Collection<Shape> getHoles() {
|
||||
return holes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position of this {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
|
||||
* <p><i>(Invoke this after changing the {@link Shape} to make sure the markers position gets updated as well)</i></p>
|
||||
@ -250,6 +264,7 @@ public static class Builder extends ObjectMarker.Builder<ShapeMarker, Builder> {
|
||||
|
||||
Shape shape;
|
||||
float shapeY;
|
||||
Collection<Shape> holes = new ArrayList<>();
|
||||
Boolean depthTest;
|
||||
Integer lineWidth;
|
||||
Color lineColor;
|
||||
@ -269,6 +284,25 @@ public Builder shape(Shape shape, float y) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>Adds</b> some hole-{@link Shape}s.
|
||||
* @param holes the additional holes
|
||||
* @return this builder for chaining
|
||||
*/
|
||||
public Builder holes(Shape... holes) {
|
||||
this.holes.addAll(Arrays.asList(holes));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all hole-shapes from this Builder.
|
||||
* @return this builder for chaining
|
||||
*/
|
||||
public Builder clearHoles() {
|
||||
this.holes.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position of the {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
|
||||
* @return this builder for chaining
|
||||
@ -334,6 +368,7 @@ public ShapeMarker build() {
|
||||
checkNotNull(shape, "shape"),
|
||||
shapeY
|
||||
);
|
||||
marker.getHoles().addAll(holes);
|
||||
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
|
||||
if (lineWidth != null) marker.setLineWidth(lineWidth);
|
||||
if (lineColor != null) marker.setLineColor(lineColor);
|
||||
|
Loading…
Reference in New Issue
Block a user