Skip to content

Commit 92948cf

Browse files
committed
First draft for the new marker-types
1 parent ea8d237 commit 92948cf

File tree

12 files changed

+692
-58
lines changed

12 files changed

+692
-58
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package de.bluecolored.bluemap.api.marker;
2+
3+
public interface DistanceRangedMarker extends Marker {
4+
5+
/**
6+
* Getter for the minimum distance of the camera to the position for this {@link Marker} to be displayed.<br>
7+
* If the camera is closer to this {@link Marker} than this distance, it will be hidden!
8+
*
9+
* @return the minimum distance for this {@link Marker} to be displayed
10+
*/
11+
double getMinDistance();
12+
13+
/**
14+
* Sets the minimum distance of the camera to the position of the {@link Marker} for it to be displayed.<br>
15+
* If the camera is closer to this {@link Marker} than this distance, it will be hidden!
16+
*
17+
* @param minDistance the new minimum distance
18+
*/
19+
void setMinDistance(double minDistance);
20+
21+
/**
22+
* Getter for the maximum distance of the camera to the position of the {@link Marker} for it to be displayed.<br>
23+
* If the camera is further to this {@link Marker} than this distance, it will be hidden!
24+
*
25+
* @return the maximum distance for this {@link Marker} to be displayed
26+
*/
27+
double getMaxDistance();
28+
29+
/**
30+
* Sets the maximum distance of the camera to the position of the {@link Marker} for it to be displayed.<br>
31+
* If the camera is further to this {@link Marker} than this distance, it will be hidden!
32+
*
33+
* @param maxDistance the new maximum distance
34+
*/
35+
void setMaxDistance(double maxDistance);
36+
37+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.api.marker;
26+
27+
import java.awt.*;
28+
29+
public interface ExtrudeMarker extends ObjectMarker, DistanceRangedMarker {
30+
31+
/**
32+
* Getter for {@link Shape} of this {@link ExtrudeMarker}.
33+
* <p>The shape is placed on the xz-plane of the map, so the y-coordinates of the {@link Shape}'s points are the z-coordinates in the map.</p>
34+
* @return the {@link Shape}
35+
*/
36+
Shape getShape();
37+
38+
/**
39+
* Getter for the minimum height (y-coordinate) of where the shape is displayed on the map.<br>
40+
* <i>(The shape will be extruded from this value to {@link #getShapeMaxY()} on the map)</i>
41+
* @return the min-height of the shape on the map
42+
*/
43+
float getShapeMinY();
44+
45+
/**
46+
* Getter for the maximum height (y-coordinate) of where the shape is displayed on the map.
47+
* <i>(The shape will be extruded from {@link #getShapeMinY()} to this value on the map)</i>
48+
* @return the max-height of the shape on the map
49+
*/
50+
float getShapeMaxY();
51+
52+
/**
53+
* Sets the {@link Shape} of this {@link ExtrudeMarker}.
54+
* <p>The shape is placed on the xz-plane of the map, so the y-coordinates of the {@link Shape}'s points will be the z-coordinates in the map.</p>
55+
* <i>(The shape will be extruded from minY to maxY on the map)</i>
56+
* @param shape the new {@link Shape}
57+
* @param minY the new min-height (y-coordinate) of the shape on the map
58+
* @param maxY the new max-height (y-coordinate) of the shape on the map
59+
*/
60+
void setShape(Shape shape, float minY, float maxY);
61+
62+
/**
63+
* If the depth-test is disabled, you can see the marker fully through all objects on the map. If it is enabled, you'll only see the marker when it is not behind anything.
64+
* @return <code>true</code> if the depthTest is enabled
65+
*/
66+
boolean isDepthTestEnabled();
67+
68+
/**
69+
* If the depth-test is disabled, you can see the marker fully through all objects on the map. If it is enabled, you'll only see the marker when it is not behind anything.
70+
* @param enabled if the depth-test should be enabled for this {@link ExtrudeMarker}
71+
*/
72+
void setDepthTestEnabled(boolean enabled);
73+
74+
/**
75+
* Getter for the width of the lines of this {@link ExtrudeMarker}.
76+
* @return the width of the lines in pixels
77+
*/
78+
int getLineWidth();
79+
80+
/**
81+
* Sets the width of the lines for this {@link ExtrudeMarker}.
82+
* @param width the new width in pixels
83+
*/
84+
void setLineWidth(int width);
85+
86+
/**
87+
* Getter for the {@link Color} of the border-line of the shape.
88+
* @return the line-color
89+
*/
90+
Color getLineColor();
91+
92+
/**
93+
* Sets the {@link Color} of the border-line of the shape.
94+
* @param color the new line-color
95+
*/
96+
void setLineColor(Color color);
97+
98+
/**
99+
* Getter for the fill-{@link Color} of the shape.
100+
* @return the fill-color
101+
*/
102+
Color getFillColor();
103+
104+
/**
105+
* Sets the fill-{@link Color} of the shape.
106+
* @param color the new fill-color
107+
*/
108+
void setFillColor(Color color);
109+
110+
/**
111+
* Sets the border- and fill- color.
112+
* @param lineColor the new border-color
113+
* @param fillColor the new fill-color
114+
* @see #setLineColor(Color)
115+
* @see #setFillColor(Color)
116+
*/
117+
default void setColors(Color lineColor, Color fillColor) {
118+
setLineColor(lineColor);
119+
setFillColor(fillColor);
120+
}
121+
122+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.api.marker;
26+
27+
import com.flowpowered.math.vector.Vector2i;
28+
import de.bluecolored.bluemap.api.BlueMapAPI;
29+
30+
public interface HtmlMarker extends Marker, DistanceRangedMarker {
31+
32+
/**
33+
* Getter for the position (in pixels) where the icon is anchored to the map.
34+
* @return the anchor-position in pixels
35+
*/
36+
Vector2i getAnchor();
37+
38+
/**
39+
* Sets the html for this {@link HtmlMarker}.
40+
*
41+
* <p>
42+
* <b>Important:</b><br>
43+
* Make sure you escape all html-tags from possible user inputs to prevent possible <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS-Attacks</a> on the web-client!
44+
* </p>
45+
*
46+
* @param html the html-element that will be inserted as the marker.
47+
*/
48+
void setHtml(String html);
49+
50+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.api.marker;
26+
27+
import com.flowpowered.math.vector.Vector3d;
28+
29+
import java.util.Arrays;
30+
31+
/**
32+
* A line consisting of 2 or more {@link Vector3d}-points.
33+
*/
34+
public class Line {
35+
36+
private final Vector3d[] points;
37+
private Vector3d min = null;
38+
private Vector3d max = null;
39+
40+
public Line(Vector3d... points) {
41+
if (points.length < 2) throw new IllegalArgumentException("A line has to have at least 2 points!");
42+
this.points = points;
43+
}
44+
45+
/**
46+
* Getter for the amount of points in this line.
47+
* @return the amount of points
48+
*/
49+
public int getPointCount() {
50+
return points.length;
51+
}
52+
53+
public Vector3d getPoint(int i) {
54+
return points[i];
55+
}
56+
57+
/**
58+
* Getter for <b>a copy</b> of the points array.<br>
59+
* <i>(A line is immutable once created)</i>
60+
* @return the points of this line
61+
*/
62+
public Vector3d[] getPoints() {
63+
return Arrays.copyOf(points, points.length);
64+
}
65+
66+
/**
67+
* Calculates and returns the minimum corner of the axis-aligned-bounding-box of this line.
68+
* @return the min of the AABB of this line
69+
*/
70+
public Vector3d getMin() {
71+
if (this.min == null) {
72+
Vector3d min = points[0];
73+
for (int i = 1; i < points.length; i++) {
74+
min = min.min(points[i]);
75+
}
76+
this.min = min;
77+
}
78+
return this.min;
79+
}
80+
81+
/**
82+
* Calculates and returns the maximum corner of the axis-aligned-bounding-box of this line.
83+
* @return the max of the AABB of this line
84+
*/
85+
public Vector3d getMax() {
86+
if (this.max == null) {
87+
Vector3d max = points[0];
88+
for (int i = 1; i < points.length; i++) {
89+
max = max.max(points[i]);
90+
}
91+
this.max = max;
92+
}
93+
return this.max;
94+
}
95+
96+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.api.marker;
26+
27+
import java.awt.*;
28+
29+
public interface LineMarker extends ObjectMarker, DistanceRangedMarker {
30+
31+
/**
32+
* Getter for {@link Line} of this {@link LineMarker}.
33+
* @return the {@link Line}
34+
*/
35+
Line getLine();
36+
37+
/**
38+
* Sets the {@link Line} of this {@link LineMarker}.
39+
* @param line the new {@link Line}
40+
*/
41+
void setLine(Line line);
42+
43+
/**
44+
* If the depth-test is disabled, you can see the marker fully through all objects on the map. If it is enabled, you'll only see the marker when it is not behind anything.
45+
* @return <code>true</code> if the depthTest is enabled
46+
*/
47+
boolean isDepthTestEnabled();
48+
49+
/**
50+
* If the depth-test is disabled, you can see the marker fully through all objects on the map. If it is enabled, you'll only see the marker when it is not behind anything.
51+
* @param enabled if the depth-test should be enabled for this {@link LineMarker}
52+
*/
53+
void setDepthTestEnabled(boolean enabled);
54+
55+
/**
56+
* Getter for the width of the lines of this {@link LineMarker}.
57+
* @return the width of the lines in pixels
58+
*/
59+
int getLineWidth();
60+
61+
/**
62+
* Sets the width of the lines for this {@link LineMarker}.
63+
* @param width the new width in pixels
64+
*/
65+
void setLineWidth(int width);
66+
67+
/**
68+
* Getter for the {@link Color} of the border-line of the shape.
69+
* @return the line-color
70+
*/
71+
Color getLineColor();
72+
73+
/**
74+
* Sets the {@link Color} of the border-line of the shape.
75+
* @param color the new line-color
76+
*/
77+
void setLineColor(Color color);
78+
79+
}

0 commit comments

Comments
 (0)