diff --git a/src/main/java/io/github/makbn/jlmap/layer/JLVectorLayer.java b/src/main/java/io/github/makbn/jlmap/layer/JLVectorLayer.java index a979784..e5e88a5 100644 --- a/src/main/java/io/github/makbn/jlmap/layer/JLVectorLayer.java +++ b/src/main/java/io/github/makbn/jlmap/layer/JLVectorLayer.java @@ -2,15 +2,16 @@ import io.github.makbn.jlmap.JLMapCallbackHandler; import io.github.makbn.jlmap.JLProperties; +import io.github.makbn.jlmap.layer.leaflet.LeafletVectorLayerInt; import io.github.makbn.jlmap.model.*; import javafx.scene.paint.Color; import javafx.scene.web.WebEngine; /** * Represents the Vector layer on Leaflet map. - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ -public class JLVectorLayer extends JLLayer { +public class JLVectorLayer extends JLLayer implements LeafletVectorLayerInt { public JLVectorLayer(WebEngine engine, JLMapCallbackHandler callbackHandler) { super(engine, callbackHandler); @@ -19,18 +20,21 @@ public JLVectorLayer(WebEngine engine, JLMapCallbackHandler callbackHandler) { /** * Drawing polyline overlays on the map with {{@link JLOptions#DEFAULT}} options * - * @see {{@link JLVectorLayer#addPolyline(JLLatLng[], JLOptions)}} + * @see JLVectorLayer#addPolyline(JLLatLng[], JLOptions) */ + @Override public JLPolyline addPolyline(JLLatLng[] vertices) { return addPolyline(vertices, JLOptions.DEFAULT); } /** * Drawing polyline overlays on the map. + * * @param vertices arrays of LatLng points - * @param options see {{@link JLOptions}} for customizing - * @return the added {{@link JLPolyline}} to map + * @param options see {@link JLOptions} for customizing + * @return the added {@link JLPolyline} to map */ + @Override public JLPolyline addPolyline(JLLatLng[] vertices, JLOptions options) { String latlngs = convertJLLatLngToString(vertices); String hexColor = convertColorToString(options.getColor()); @@ -45,9 +49,11 @@ public JLPolyline addPolyline(JLLatLng[] vertices, JLOptions options) { /** * Remove a polyline from the map by id. + * * @param id of polyline - * @return {{@link Boolean#TRUE}} if removed successfully + * @return {@link Boolean#TRUE} if removed successfully */ + @Override public boolean removePolyline(int id) { String result = engine.executeScript(String.format("removePolyLine(%d)", id)) .toString(); @@ -59,20 +65,24 @@ public boolean removePolyline(int id) { } /** - * Drawing multi polyline overlays on the map with {{@link JLOptions#DEFAULT}} options. - * @see {{@link JLVectorLayer#addMultiPolyline(JLLatLng[][], JLOptions)}} - * @return the added {{@link JLMultiPolyline}} to map + * Drawing multi polyline overlays on the map with {@link JLOptions#DEFAULT} options. + * + * @return the added {@link JLMultiPolyline} to map + * @see JLVectorLayer#addMultiPolyline(JLLatLng[][], JLOptions) */ - public JLMultiPolyline addMultiPolyline(JLLatLng[][] vertices){ + @Override + public JLMultiPolyline addMultiPolyline(JLLatLng[][] vertices) { return addMultiPolyline(vertices, JLOptions.DEFAULT); } /** * Drawing MultiPolyline shape overlays on the map with multi-dimensional array. + * * @param vertices arrays of LatLng points - * @param options see {{@link JLOptions}} for customizing - * @return the added {{@link JLMultiPolyline}} to map + * @param options see {@link JLOptions} for customizing + * @return the added {@link JLMultiPolyline} to map */ + @Override public JLMultiPolyline addMultiPolyline(JLLatLng[][] vertices, JLOptions options) { String latlngs = convertJLLatLngToString(vertices); String hexColor = convertColorToString(options.getColor()); @@ -87,9 +97,10 @@ public JLMultiPolyline addMultiPolyline(JLLatLng[][] vertices, JLOptions options /** - * @see {{@link JLVectorLayer#removePolyline(int)}} + * @see JLVectorLayer#removePolyline(int) */ - public boolean removeMultiPolyline(int id){ + @Override + public boolean removeMultiPolyline(int id) { return removePolyline(id); } @@ -101,17 +112,19 @@ public boolean removeMultiPolyline(int id){ * with the first dimension representing the outer shape and the other * dimension representing holes in the outer shape! * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape! + * * @param vertices array of {{@link JLLatLng}} points - * @param options see {{@link JLOptions}} + * @param options see {{@link JLOptions}} * @return Instance of the created {{@link JLPolygon}} */ + @Override public JLPolygon addPolygon(JLLatLng[][][] vertices, JLOptions options) { String latlngs = convertJLLatLngToString(vertices); String result = engine.executeScript(String.format("addPolygon(%s, '%s', '%s', %d, %b, %b, %f, %f, %f)", - latlngs, convertColorToString(options.getColor()), convertColorToString(options.getFillColor()), - options.getWeight(), options.isStroke(), options.isFill(), options.getOpacity(), - options.getFillOpacity(), options.getSmoothFactor())) + latlngs, convertColorToString(options.getColor()), convertColorToString(options.getFillColor()), + options.getWeight(), options.isStroke(), options.isFill(), options.getOpacity(), + options.getFillOpacity(), options.getSmoothFactor())) .toString(); int index = Integer.parseInt(result); @@ -122,18 +135,22 @@ latlngs, convertColorToString(options.getColor()), convertColorToString(options. /** * Drawing polygon overlays on the map with {{@link JLOptions#DEFAULT}} option. - * @see {{@link JLVectorLayer#addMultiPolyline(JLLatLng[][], JLOptions)}} + * + * @see JLVectorLayer#addMultiPolyline(JLLatLng[][], JLOptions) */ - public JLPolygon addPolygon(JLLatLng[][][] vertices){ + @Override + public JLPolygon addPolygon(JLLatLng[][][] vertices) { return addPolygon(vertices, JLOptions.DEFAULT); } /** * Remove a {{@link JLPolygon}} from the map by id. + * * @param id of Polygon * @return {{@link Boolean#TRUE}} if removed successfully */ - public boolean removePolygon(int id){ + @Override + public boolean removePolygon(int id) { String result = engine.executeScript(String.format("removePolygon(%d)", id)) .toString(); callbackHandler.remove(JLPolygon.class, id); @@ -141,17 +158,19 @@ public boolean removePolygon(int id){ } /** - * Add a {{@link JLCircle}} to the map; - * @param center coordinate of the circle. - * @param radius radius of circle in meter. - * @param options see {{@link JLOptions}} - * @return the instance of created {{@link JLCircle}} + * Add a {@link JLCircle} to the map; + * + * @param center coordinate of the circle. + * @param radius radius of circle in meter. + * @param options see {@link JLOptions} + * @return the instance of created {@link JLCircle} */ + @Override public JLCircle addCircle(JLLatLng center, int radius, JLOptions options) { String result = engine.executeScript(String.format("addCircle([%f, %f], %d, '%s', '%s', %d, %b, %b, %f, %f, %f)", - center.getLat(), center.getLng(), radius, convertColorToString(options.getColor()), convertColorToString(options.getFillColor()), - options.getWeight(), options.isStroke(), options.isFill(), options.getOpacity(), - options.getFillOpacity(), options.getSmoothFactor())) + center.getLat(), center.getLng(), radius, convertColorToString(options.getColor()), convertColorToString(options.getFillColor()), + options.getWeight(), options.isStroke(), options.isFill(), options.getOpacity(), + options.getFillOpacity(), options.getSmoothFactor())) .toString(); int index = Integer.parseInt(result); @@ -161,20 +180,24 @@ public JLCircle addCircle(JLLatLng center, int radius, JLOptions options) { } /** - * Add {{@link JLCircle}} to the map with {{@link JLOptions#DEFAULT}} options. - * Default value for radius is {{@link JLProperties#DEFAULT_CIRCLE_RADIUS}} - * @see {{@link JLVectorLayer#addCircle(JLLatLng, int, JLOptions)}} + * Add {{@link JLCircle}} to the map with {@link JLOptions#DEFAULT} options. + * Default value for radius is {@link JLProperties#DEFAULT_CIRCLE_RADIUS} + * + * @see JLVectorLayer#addCircle(JLLatLng, int, JLOptions) */ - public JLCircle addCircle(JLLatLng center){ + @Override + public JLCircle addCircle(JLLatLng center) { return addCircle(center, JLProperties.DEFAULT_CIRCLE_RADIUS, JLOptions.DEFAULT); } /** - * Remove a {{@link JLCircle}} from the map by id. + * Remove a {@link JLCircle} from the map by id. + * * @param id of Circle - * @return {{@link Boolean#TRUE}} if removed successfully + * @return {@link Boolean#TRUE} if removed successfully */ - public boolean removeCircle(int id){ + @Override + public boolean removeCircle(int id) { String result = engine.executeScript(String.format("removeCircle(%d)", id)) .toString(); callbackHandler.remove(JLCircle.class, id); @@ -182,17 +205,19 @@ public boolean removeCircle(int id){ } /** - * Add a {{@link JLCircleMarker}} to the map; - * @param center coordinate of the circle. - * @param radius radius of circle in meter. - * @param options see {{@link JLOptions}} - * @return the instance of created {{@link JLCircleMarker}} + * Add a {@link JLCircleMarker} to the map; + * + * @param center coordinate of the circle. + * @param radius radius of circle in meter. + * @param options see {@link JLOptions} + * @return the instance of created {@link JLCircleMarker} */ + @Override public JLCircleMarker addCircleMarker(JLLatLng center, int radius, JLOptions options) { String result = engine.executeScript(String.format("addCircleMarker([%f, %f], %d, '%s', '%s', %d, %b, %b, %f, %f, %f)", - center.getLat(), center.getLng(), radius, convertColorToString(options.getColor()), convertColorToString(options.getFillColor()), - options.getWeight(), options.isStroke(), options.isFill(), options.getOpacity(), - options.getFillOpacity(), options.getSmoothFactor())) + center.getLat(), center.getLng(), radius, convertColorToString(options.getColor()), convertColorToString(options.getFillColor()), + options.getWeight(), options.isStroke(), options.isFill(), options.getOpacity(), + options.getFillOpacity(), options.getSmoothFactor())) .toString(); int index = Integer.parseInt(result); @@ -202,22 +227,24 @@ public JLCircleMarker addCircleMarker(JLLatLng center, int radius, JLOptions opt } /** - * Add {{@link JLCircleMarker}} to the map with {{@link JLOptions#DEFAULT}} options. - * Default value for radius is {{@link JLProperties#DEFAULT_CIRCLE_MARKER_RADIUS}} + * Add {@link JLCircleMarker} to the map with {@link JLOptions#DEFAULT} options. + * Default value for radius is {@link JLProperties#DEFAULT_CIRCLE_MARKER_RADIUS} * - * @see {{@link JLVectorLayer#addCircle(JLLatLng, int, JLOptions)}} + * @see JLVectorLayer#addCircle(JLLatLng, int, JLOptions) */ + @Override public JLCircleMarker addCircleMarker(JLLatLng center) { return addCircleMarker(center, JLProperties.DEFAULT_CIRCLE_MARKER_RADIUS, JLOptions.DEFAULT); } /** - * Remove a {{@link JLCircleMarker}} from the map by id. + * Remove a {@link JLCircleMarker} from the map by id. * * @param id of Circle - * @return {{@link Boolean#TRUE}} if removed successfully + * @return {@link Boolean#TRUE} if removed successfully */ + @Override public boolean removeCircleMarker(int id) { String result = engine.executeScript(String.format("removeCircleMarker(%d)", id)) .toString(); @@ -229,37 +256,37 @@ private String convertJLLatLngToString(JLLatLng[] latLngs) { StringBuilder sb = new StringBuilder(); sb.append("["); for (JLLatLng latLng : latLngs) { - sb.append(String.format("[%f, %f], ", latLng.getLat(), latLng.getLng())); + sb.append(String.format("%s, ", latLng.toString())); } sb.append("]"); return sb.toString(); } - private String convertJLLatLngToString(JLLatLng[][] latLngsList){ + private String convertJLLatLngToString(JLLatLng[][] latLngsList) { StringBuilder sb = new StringBuilder(); sb.append("["); - for (JLLatLng[] latLngs : latLngsList){ + for (JLLatLng[] latLngs : latLngsList) { sb.append(convertJLLatLngToString(latLngs)).append(","); } sb.append("]"); return sb.toString(); } - private String convertJLLatLngToString(JLLatLng[][][] latLngsList){ + private String convertJLLatLngToString(JLLatLng[][][] latLngList) { StringBuilder sb = new StringBuilder(); sb.append("["); - for (JLLatLng[][] latLngs : latLngsList){ - sb.append(convertJLLatLngToString(latLngs)).append(","); + for (JLLatLng[][] latLng2DArray : latLngList) { + sb.append(convertJLLatLngToString(latLng2DArray)).append(","); } sb.append("]"); return sb.toString(); } - private String convertColorToString(Color c){ - int r = (int)Math.round(c.getRed() * 255.0); - int g = (int)Math.round(c.getGreen() * 255.0); - int b = (int)Math.round(c.getBlue() * 255.0); - int a = (int)Math.round(c.getOpacity() * 255.0); + private String convertColorToString(Color c) { + int r = (int) Math.round(c.getRed() * 255.0); + int g = (int) Math.round(c.getGreen() * 255.0); + int b = (int) Math.round(c.getBlue() * 255.0); + int a = (int) Math.round(c.getOpacity() * 255.0); return String.format("#%02x%02x%02x%02x", r, g, b, a); } } diff --git a/src/main/java/io/github/makbn/jlmap/model/JLCircle.java b/src/main/java/io/github/makbn/jlmap/model/JLCircle.java index 1c09453..5581ff3 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLCircle.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLCircle.java @@ -4,7 +4,7 @@ /** * A class for drawing circle overlays on a map - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLCircleMarker.java b/src/main/java/io/github/makbn/jlmap/model/JLCircleMarker.java index 9edf2af..6b4b709 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLCircleMarker.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLCircleMarker.java @@ -4,7 +4,7 @@ /** * A circle of a fixed size with radius specified in pixels. - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLMarker.java b/src/main/java/io/github/makbn/jlmap/model/JLMarker.java index e5c2d0a..68cc368 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLMarker.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLMarker.java @@ -5,7 +5,7 @@ /** * JLMarker is used to display clickable/draggable icons on the map! - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLMultiPolyline.java b/src/main/java/io/github/makbn/jlmap/model/JLMultiPolyline.java index 4da9ef7..e704902 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLMultiPolyline.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLMultiPolyline.java @@ -4,7 +4,7 @@ /** * A class for drawing polyline overlays on a map - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLObject.java b/src/main/java/io/github/makbn/jlmap/model/JLObject.java index 4c283ed..0c85e8c 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLObject.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLObject.java @@ -3,9 +3,10 @@ import io.github.makbn.jlmap.listener.OnJLObjectActionListener; /** - * by: Mehdi Akbarian Rastaghi (@makbn) + * Represents basic object classes for interacting with Leaflet + * @author Mehdi Akbarian Rastaghi (@makbn) */ -public abstract class JLObject { +public abstract class JLObject> { private OnJLObjectActionListener listener; public OnJLObjectActionListener getOnActionListener() { diff --git a/src/main/java/io/github/makbn/jlmap/model/JLOptions.java b/src/main/java/io/github/makbn/jlmap/model/JLOptions.java index 7df53fc..c42b7ec 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLOptions.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLOptions.java @@ -10,7 +10,7 @@ * Optional value for theming objects inside the map! * Note that all options are not available for all objects! * Read more at Leaflet Official Docs. - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter @@ -19,52 +19,52 @@ public class JLOptions { /** Default value for theming options. */ - public final static JLOptions DEFAULT = JLOptions.builder().build(); + public static final JLOptions DEFAULT = JLOptions.builder().build(); - @Builder.Default /** Stroke color. Default is {{@link Color#BLUE}} */ + @Builder.Default private Color color = Color.BLUE; - @Builder.Default /** Fill color. Default is {{@link Color#BLUE}} */ + @Builder.Default private Color fillColor = Color.BLUE; - @Builder.Default /** Stroke width in pixels. Default is 3 */ + @Builder.Default private int weight = 3; + /** Whether to draw stroke along the path. Set it to false for disabling borders on polygons or circles. */ @Builder.Default - /** Whether to draw stroke along the path. Set it to false to disable borders on polygons or circles. */ private boolean stroke = true; + /** Whether to fill the path with color. Set it to false fo disabling filling on polygons or circles. */ @Builder.Default - /** Whether to fill the path with color. Set it to false to disable filling on polygons or circles. */ private boolean fill = true; - @Builder.Default /** Stroke opacity */ + @Builder.Default private double opacity = 1.0; - @Builder.Default /** Fill opacity. */ + @Builder.Default private double fillOpacity = 0.2; - @Builder.Default /** How much to simplify the polyline on each zoom level. - * More means better performance and smoother look, and less means more accurate representation. + * greater value means better performance and smoother look, and smaller value means more accurate representation. */ + @Builder.Default private double smoothFactor = 1.0; - @Builder.Default /** Controls the presence of a close button in the popup. */ + @Builder.Default private boolean closeButton = true; - @Builder.Default /** Set it to false if you want to override the default behavior of the popup closing when another popup is opened. */ + @Builder.Default private boolean autoClose = true; - @Builder.Default /** Whether the marker is draggable with mouse/touch or not. */ + @Builder.Default private boolean draggable = false; } diff --git a/src/main/java/io/github/makbn/jlmap/model/JLPolygon.java b/src/main/java/io/github/makbn/jlmap/model/JLPolygon.java index 1dbfed5..2dd0c7d 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLPolygon.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLPolygon.java @@ -6,7 +6,7 @@ * A class for drawing polygon overlays on the map. * Note that points you pass when creating a polygon shouldn't * have an additional last point equal to the first one. - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLPolyline.java b/src/main/java/io/github/makbn/jlmap/model/JLPolyline.java index 554e66d..c546188 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLPolyline.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLPolyline.java @@ -4,7 +4,7 @@ /** * A class for drawing polyline overlays on the map. - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLPopup.java b/src/main/java/io/github/makbn/jlmap/model/JLPopup.java index 57b5293..dce4212 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLPopup.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLPopup.java @@ -4,7 +4,7 @@ /** * Used to open popups in certain places of the map. - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ @Getter @Setter diff --git a/src/main/java/io/github/makbn/jlmap/model/JLSvg.java b/src/main/java/io/github/makbn/jlmap/model/JLSvg.java index 05965cc..f18a11e 100644 --- a/src/main/java/io/github/makbn/jlmap/model/JLSvg.java +++ b/src/main/java/io/github/makbn/jlmap/model/JLSvg.java @@ -1,7 +1,7 @@ package io.github.makbn.jlmap.model; /** - * by: Mehdi Akbarian Rastaghi (@makbn) + * @author Mehdi Akbarian Rastaghi (@makbn) */ class JLSvg {