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.debug.DebugDump;
|
||||||
import de.bluecolored.bluemap.api.math.Color;
|
import de.bluecolored.bluemap.api.math.Color;
|
||||||
import de.bluecolored.bluemap.api.math.Shape;
|
import de.bluecolored.bluemap.api.math.Shape;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
@DebugDump
|
@DebugDump
|
||||||
public class ExtrudeMarker extends ObjectMarker {
|
public class ExtrudeMarker extends ObjectMarker {
|
||||||
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
|
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
|
||||||
|
|
||||||
private Shape shape;
|
private Shape shape;
|
||||||
|
private Collection<Shape> holes = new ArrayList<>();
|
||||||
private float shapeMinY, shapeMaxY;
|
private float shapeMinY, shapeMaxY;
|
||||||
private boolean depthTest = true;
|
private boolean depthTest = true;
|
||||||
private int lineWidth = 2;
|
private int lineWidth = 2;
|
||||||
|
@ -138,6 +143,15 @@ public class ExtrudeMarker extends ObjectMarker {
|
||||||
this.shapeMaxY = 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).
|
* 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>
|
* <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 class ExtrudeMarker extends ObjectMarker {
|
||||||
|
|
||||||
Shape shape;
|
Shape shape;
|
||||||
float shapeMinY, shapeMaxY;
|
float shapeMinY, shapeMaxY;
|
||||||
|
Collection<Shape> holes = new ArrayList<>();
|
||||||
Boolean depthTest;
|
Boolean depthTest;
|
||||||
Integer lineWidth;
|
Integer lineWidth;
|
||||||
Color lineColor;
|
Color lineColor;
|
||||||
|
@ -294,6 +309,25 @@ public class ExtrudeMarker extends ObjectMarker {
|
||||||
return this;
|
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).
|
* Sets the position of the {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
|
||||||
* @return this builder for chaining
|
* @return this builder for chaining
|
||||||
|
@ -361,6 +395,7 @@ public class ExtrudeMarker extends ObjectMarker {
|
||||||
shapeMinY,
|
shapeMinY,
|
||||||
shapeMaxY
|
shapeMaxY
|
||||||
);
|
);
|
||||||
|
marker.getHoles().addAll(holes);
|
||||||
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
|
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
|
||||||
if (lineWidth != null) marker.setLineWidth(lineWidth);
|
if (lineWidth != null) marker.setLineWidth(lineWidth);
|
||||||
if (lineColor != null) marker.setLineColor(lineColor);
|
if (lineColor != null) marker.setLineColor(lineColor);
|
||||||
|
|
|
@ -31,13 +31,18 @@ import de.bluecolored.bluemap.api.debug.DebugDump;
|
||||||
import de.bluecolored.bluemap.api.math.Color;
|
import de.bluecolored.bluemap.api.math.Color;
|
||||||
import de.bluecolored.bluemap.api.math.Shape;
|
import de.bluecolored.bluemap.api.math.Shape;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
@DebugDump
|
@DebugDump
|
||||||
public class ShapeMarker extends ObjectMarker {
|
public class ShapeMarker extends ObjectMarker {
|
||||||
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
|
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
|
||||||
|
|
||||||
private Shape shape;
|
private Shape shape;
|
||||||
|
private Collection<Shape> holes = new ArrayList<>();
|
||||||
private float shapeY;
|
private float shapeY;
|
||||||
private boolean depthTest = true;
|
private boolean depthTest = true;
|
||||||
private int lineWidth = 2;
|
private int lineWidth = 2;
|
||||||
|
@ -119,6 +124,15 @@ public class ShapeMarker extends ObjectMarker {
|
||||||
this.shapeY = 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).
|
* 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>
|
* <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 class ShapeMarker extends ObjectMarker {
|
||||||
|
|
||||||
Shape shape;
|
Shape shape;
|
||||||
float shapeY;
|
float shapeY;
|
||||||
|
Collection<Shape> holes = new ArrayList<>();
|
||||||
Boolean depthTest;
|
Boolean depthTest;
|
||||||
Integer lineWidth;
|
Integer lineWidth;
|
||||||
Color lineColor;
|
Color lineColor;
|
||||||
|
@ -269,6 +284,25 @@ public class ShapeMarker extends ObjectMarker {
|
||||||
return this;
|
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).
|
* Sets the position of the {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
|
||||||
* @return this builder for chaining
|
* @return this builder for chaining
|
||||||
|
@ -334,6 +368,7 @@ public class ShapeMarker extends ObjectMarker {
|
||||||
checkNotNull(shape, "shape"),
|
checkNotNull(shape, "shape"),
|
||||||
shapeY
|
shapeY
|
||||||
);
|
);
|
||||||
|
marker.getHoles().addAll(holes);
|
||||||
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
|
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
|
||||||
if (lineWidth != null) marker.setLineWidth(lineWidth);
|
if (lineWidth != null) marker.setLineWidth(lineWidth);
|
||||||
if (lineColor != null) marker.setLineColor(lineColor);
|
if (lineColor != null) marker.setLineColor(lineColor);
|
||||||
|
|
Loading…
Reference in New Issue