|
| 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.util.Optional; |
| 28 | + |
| 29 | +import com.flowpowered.math.vector.Vector3d; |
| 30 | + |
| 31 | +import de.bluecolored.bluemap.api.renderer.BlueMapMap; |
| 32 | + |
| 33 | +/** |
| 34 | + * A marker that is displayed on one of the maps in the web-app. |
| 35 | + * <p>Each marker has an id that is unique in the {@link MarkerSet} that it is in.</p> |
| 36 | + */ |
| 37 | +public interface Marker { |
| 38 | + |
| 39 | + /** |
| 40 | + * Getter for the id of this {@link Marker}. |
| 41 | + * <p>The id is unique in the {@link MarkerSet} that this marker is in.</p> |
| 42 | + * @return the id of this {@link Marker} |
| 43 | + */ |
| 44 | + String getId(); |
| 45 | + |
| 46 | + /** |
| 47 | + * Getter for the {@link BlueMapMap} this {@link Marker} lives in. |
| 48 | + * @return the {@link BlueMapMap} this {@link Marker} lives in |
| 49 | + */ |
| 50 | + BlueMapMap getMap(); |
| 51 | + |
| 52 | + /** |
| 53 | + * Sets the {@link BlueMapMap} this {@link Marker} lives in |
| 54 | + * @param map the new {@link BlueMapMap} |
| 55 | + */ |
| 56 | + void setMap(BlueMapMap map); |
| 57 | + |
| 58 | + /** |
| 59 | + * Getter for the position of where this {@link Marker} lives on the map. |
| 60 | + * @return the position of this {@link Marker} |
| 61 | + */ |
| 62 | + Vector3d getPosition(); |
| 63 | + |
| 64 | + /** |
| 65 | + * Sets the position of where this {@link Marker} lives on the map. |
| 66 | + * @param position the new position |
| 67 | + */ |
| 68 | + void setPosition(Vector3d position); |
| 69 | + |
| 70 | + /** |
| 71 | + * Getter for the minimum distance of the camera to the position ({@link #getPosition()} of the {@link Marker} for it to be displayed.<br> |
| 72 | + * If the camera is closer to this {@link Marker} than this distance, it will be hidden! |
| 73 | + * |
| 74 | + * @return the minimum distance for this {@link Marker} to be displayed |
| 75 | + */ |
| 76 | + double getMinDistance(); |
| 77 | + |
| 78 | + /** |
| 79 | + * Sets the minimum distance of the camera to the position ({@link #getPosition()} of the {@link Marker} for it to be displayed.<br> |
| 80 | + * If the camera is closer to this {@link Marker} than this distance, it will be hidden! |
| 81 | + * |
| 82 | + * @param minDistance the new minimum distance |
| 83 | + */ |
| 84 | + void setMinDistance(double minDistance); |
| 85 | + |
| 86 | + /** |
| 87 | + * Getter for the maximum distance of the camera to the position ({@link #getPosition()} of the {@link Marker} for it to be displayed.<br> |
| 88 | + * If the camera is further to this {@link Marker} than this distance, it will be hidden! |
| 89 | + * |
| 90 | + * @return the maximum distance for this {@link Marker} to be displayed |
| 91 | + */ |
| 92 | + double getMaxDistance(); |
| 93 | + |
| 94 | + /** |
| 95 | + * Sets the maximum distance of the camera to the position ({@link #getPosition()} of the {@link Marker} for it to be displayed.<br> |
| 96 | + * If the camera is closer to this {@link Marker} than this distance, it will be hidden! |
| 97 | + * |
| 98 | + * @param maxDistance the new maximum distance |
| 99 | + */ |
| 100 | + void setMaxDistance(double maxDistance); |
| 101 | + |
| 102 | + /** |
| 103 | + * Getter for the label of this marker. The label can include html-tags. |
| 104 | + * @return the label of this |
| 105 | + */ |
| 106 | + String getLabel(); |
| 107 | + |
| 108 | + /** |
| 109 | + * Sets the label of this {@link Marker}. The label can include html-tags. |
| 110 | + * <p> |
| 111 | + * <b>Important:</b><br> |
| 112 | + * Html-tags in the label will not be escaped, so you can use them to style the {@link Marker}-labels.<br> |
| 113 | + * 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! |
| 114 | + * </p> |
| 115 | + * |
| 116 | + * @param label the new label for this {@link Marker} |
| 117 | + */ |
| 118 | + void setLabel(String label); |
| 119 | + |
| 120 | + /** |
| 121 | + * Gets the link-adress of this {@link Marker}.<br> |
| 122 | + * If a link is present, this link will be followed when the user clicks on the marker in the web-app. |
| 123 | + * |
| 124 | + * @return the {@link Optional} link |
| 125 | + */ |
| 126 | + Optional<String> getLink(); |
| 127 | + |
| 128 | + /** |
| 129 | + * If this is <code>true</code> the link ({@link #getLink()}) will be opened in a new tab. |
| 130 | + * @return whether the link will be opened in a new tab |
| 131 | + * @see #getLink() |
| 132 | + */ |
| 133 | + boolean isNewTab(); |
| 134 | + |
| 135 | + /** |
| 136 | + * Sets the link-adress of this {@link Marker}.<br> |
| 137 | + * If a link is present, this link will be followed when the user clicks on the marker in the web-app. |
| 138 | + * |
| 139 | + * @param link the link, or <code>null</code> to disable the link |
| 140 | + * @param newTab whether the link should be opened in a new tab |
| 141 | + */ |
| 142 | + void setLink(String link, boolean newTab); |
| 143 | + |
| 144 | +} |
0 commit comments