Skip to content

Commit 722f146

Browse files
committed
removed index.html file and generated the page using j2html library. added JLMapRenderer to define the map js and html inside the code. code cleanup.
Signed-off-by: makbn <[email protected]>
1 parent d5982e3 commit 722f146

File tree

19 files changed

+238
-465
lines changed

19 files changed

+238
-465
lines changed

jlmap-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<dependency>
6565
<groupId>com.google.code.gson</groupId>
6666
<artifactId>gson</artifactId>
67-
<version>2.10.1</version>
67+
<version>2.13.1</version>
6868
</dependency>
6969
<dependency>
7070
<groupId>com.fasterxml.jackson.core</groupId>

jlmap-api/src/main/java/io/github/makbn/jlmap/JLMapCallbackHandler.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,43 @@ private void initClassMap() {
4747

4848
/**
4949
* @param functionName name of source function from js
50-
* @param param1 name of object class
51-
* @param param2 id of object
50+
* @param jlType name of object class
51+
* @param uuid id of object
52+
* @param param1 additional param
53+
* @param param2 additional param
5254
* @param param3 additional param
53-
* @param param4 additional param
54-
* @param param5 additional param
5555
*/
5656
@SuppressWarnings("all")
57-
public void functionCalled(Object mapView, String functionName, Object param1, Object param2,
58-
Object param3, Object param4, Object param5) {
59-
log.debug("function: {} param1: {} param2: {} param3: {} param4: {} param5: {}",
60-
functionName, param1, param2, param3, param4, param5);
57+
public void functionCalled(Object mapView, String functionName, Object jlType, Object uuid,
58+
Object param1, Object param2, Object param3) {
59+
log.debug("function: {} jlType: {} uuid: {} param1: {} param2: {} param3: {}",
60+
functionName, jlType, uuid, param1, param2, param3);
6161
try {
6262
//get target class of Leaflet layer in JL Application
63-
Class<?>[] targetClasses = classMap.get(param1);
63+
Class<?>[] targetClasses = classMap.get(jlType);
6464
if (targetClasses == null) {
65-
targetClasses = classMap.get(param1.toString().replace("jl", ""));
65+
targetClasses = classMap.get(jlType.toString().replace("jl", ""));
6666
}
6767
//function called by an known class
6868
if (targetClasses != null) {
6969
//one Leaflet class may map to multiple class in JL Application
7070
// like ployLine mapped to JLPolyline and JLMultiPolyline
7171
Arrays.stream(targetClasses)
7272
.filter(jlObjects::containsKey)
73-
.map(targetClass -> jlObjects.get(targetClass).get(String.valueOf(param2)))
73+
.map(targetClass -> jlObjects.get(targetClass).get(String.valueOf(uuid)))
7474
.filter(Objects::nonNull)
7575
.filter(jlObject -> Objects.nonNull(jlObject.getOnActionListener()))
7676
.forEach(jlObject -> {
7777
eventHandlers.stream()
7878
.filter(hadler -> hadler.canHandle(functionName))
7979
.forEach(hadler -> hadler.handle(jlObject, functionName,
80-
jlObject.getOnActionListener(), param1, param2, param3, param4, param5));
80+
jlObject.getOnActionListener(), jlType, uuid, param1, param2, param3));
8181
});
82-
} else if (param1.equals("main_map") && getMapListener().isPresent()) {
82+
} else if (jlType.equals("main_map") && getMapListener().isPresent()) {
8383
eventHandlers.stream()
8484
.filter(hadler -> hadler.canHandle(functionName))
8585
.forEach(hadler -> hadler.handle(mapView, functionName, getMapListener().get(),
86-
param1, param2, param3, param4, param5));
86+
jlType, uuid, param1, param2, param3));
8787
}
8888
} catch (Exception e) {
8989
log.error(e.getMessage(), e);
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package io.github.makbn.jlmap;
22

3+
import lombok.NoArgsConstructor;
4+
35
/**
46
* @author Matt Akbarian (@makbn)
57
*/
6-
public class JLProperties {
8+
@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
9+
public final class JLProperties {
710
public static final int INIT_MIN_WIDTH = 1024;
811
public static final int INIT_MIN_HEIGHT = 576;
912
public static final int EARTH_RADIUS = 6367;
@@ -13,6 +16,4 @@ public class JLProperties {
1316
public static final int INIT_MIN_WIDTH_STAGE = INIT_MIN_WIDTH;
1417
public static final int INIT_MIN_HEIGHT_STAGE = INIT_MIN_HEIGHT;
1518
public static final double START_ANIMATION_RADIUS = 10;
16-
17-
1819
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.github.makbn.jlmap.map;
2+
3+
import io.github.makbn.jlmap.model.JLMapOption;
4+
import lombok.NonNull;
5+
6+
public interface JLMapRenderer {
7+
8+
@NonNull
9+
String render(@NonNull JLMapOption option);
10+
}

jlmap-api/src/main/java/io/github/makbn/jlmap/model/JLGeoJson.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
import lombok.AccessLevel;
55
import lombok.Builder;
66
import lombok.Getter;
7-
import lombok.Setter;
87
import lombok.experimental.FieldDefaults;
98
import lombok.experimental.NonFinal;
109

1110
/**
1211
* @author Matt Akbarian (@makbn)
1312
*/
1413
@Getter
15-
@Setter
1614
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
1715
public final class JLGeoJson extends JLObject<JLGeoJson> {
1816
@NonFinal

jlmap-api/src/main/java/io/github/makbn/jlmap/model/JLLatLng.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,34 @@
88

99
/**
1010
* Represents a geographical point with a certain latitude and longitude.
11+
*
1112
* @author Matt Akbarian (@makbn)
1213
*/
13-
@Getter
1414
@Setter
15+
@Getter
1516
@Builder
1617
@AllArgsConstructor
17-
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
18+
@NoArgsConstructor(force = true)
19+
@FieldDefaults(level = AccessLevel.PRIVATE)
1820
public class JLLatLng {
19-
/** geographical given latitude in degrees */
21+
/**
22+
* geographical given latitude in degrees
23+
*/
2024
double lat;
21-
/** geographical given longitude in degrees */
25+
/**
26+
* geographical given longitude in degrees
27+
*/
2228
double lng;
2329

2430
/**
2531
* Calculate distance between two points in latitude and longitude taking
2632
* into account height difference.Uses Haversine method as its base.
33+
*
2734
* @param dest Destination coordinate {{@link JLLatLng}}
2835
* @return Distance in Meters
2936
* @author David George
3037
*/
31-
public double distanceTo(JLLatLng dest){
38+
public double distanceTo(JLLatLng dest) {
3239
double latDistance = Math.toRadians(dest.getLat() - lat);
3340
double lonDistance = Math.toRadians(dest.getLng() - lng);
3441
double a = Math.sin(latDistance / 2)
@@ -60,7 +67,7 @@ public boolean equals(Object o) {
6067

6168
/**
6269
*
63-
* @param o The given point
70+
* @param o The given point
6471
* @param maxMargin The margin of error
6572
* @return Returns true if the given {{@link JLLatLng}} point is at the
6673
* same position (within a small margin of error).

jlmap-api/src/main/java/io/github/makbn/jlmap/model/JLMapOption.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import java.util.HashSet;
1010
import java.util.Set;
11-
import java.util.stream.Collectors;
12-
import java.util.stream.Stream;
1311

1412
/**
1513
* The {@code JLMapOption} class represents options for configuring a Leaflet
@@ -46,21 +44,6 @@ public class JLMapOption {
4644
@NonNull
4745
JLMapProvider jlMapProvider = JLMapProvider.getDefault();
4846

49-
/**
50-
* Converts the map options to a query string format, including both
51-
* map-specific parameters and additional parameters.
52-
*
53-
* @return The map options as a query string.
54-
*/
55-
@NonNull
56-
public String toQueryString() {
57-
return Stream.concat(
58-
getParameters().stream(), additionalParameter.stream())
59-
.map(Parameter::toString)
60-
.collect(Collectors.joining("&",
61-
String.format("?mapid=%s&", getJlMapProvider().getName()), ""));
62-
}
63-
6447
/**
6548
* Additional parameters to include in the map configuration.
6649
*/

jlmap-api/src/main/java/io/github/makbn/jlmap/model/JLPoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@Setter
1313
@Builder
1414
@AllArgsConstructor
15-
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
15+
@FieldDefaults(level = AccessLevel.PRIVATE)
1616
public class JLPoint {
1717
double x;
1818
double y;

jlmap-api/src/main/java/io/github/makbn/jlmap/model/JLPolygon.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.github.makbn.jlmap.model;
22

33
import io.github.makbn.jlmap.engine.JLTransporter;
4-
import lombok.*;
4+
import lombok.AccessLevel;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.ToString;
58
import lombok.experimental.FieldDefaults;
69

710
/**
@@ -12,7 +15,6 @@
1215
* @author Matt Akbarian (@makbn)
1316
*/
1417
@Getter
15-
@Setter
1618
@ToString
1719
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
1820
public final class JLPolygon extends JLObject<JLPolygon> {

jlmap-api/src/main/java/module-info.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@
2525
exports io.github.makbn.jlmap.exception;
2626
exports io.github.makbn.jlmap.geojson;
2727
exports io.github.makbn.jlmap.engine;
28+
29+
opens io.github.makbn.jlmap.model to com.google.gson;
2830
}

0 commit comments

Comments
 (0)