Skip to content

Commit 4897db9

Browse files
committed
improved documentation
Signed-off-by: makbn <mehdi74akbarian@gmail.com>
1 parent 69ea3a8 commit 4897db9

File tree

5 files changed

+102
-8
lines changed

5 files changed

+102
-8
lines changed

jlmap-vaadin/src/main/java/io/github/makbn/jlmap/vaadin/JLMapView.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ protected void onAttach(AttachEvent attachEvent) {
110110
}
111111
}
112112

113-
113+
/**
114+
* Generates the JavaScript function call to initialize the map.
115+
*
116+
* @return the JavaScript initialization string
117+
*/
114118
@SuppressWarnings("all")
115119
private String generateInitializeFunctionCall() {
116120
String call = """
@@ -141,8 +145,15 @@ private void initializeLayers() {
141145
}
142146

143147
/**
144-
* Called when the map is loaded successfully.
145-
* This method is called from JavaScript.
148+
* Called when the map is loaded successfully from JavaScript.
149+
* Handles events from the client side.
150+
*
151+
* @param function the function name
152+
* @param jlType the JL type
153+
* @param uuid the unique identifier
154+
* @param additionalParam1 additional parameter 1
155+
* @param additionalParam2 additional parameter 2
156+
* @param additionalParam3 additional parameter 3
146157
*/
147158
@ClientCallable
148159
@SuppressWarnings("unused")
@@ -152,18 +163,15 @@ public void eventHandler(String function, String jlType, String uuid, String add
152163
}
153164

154165
/**
155-
* Gets the JLWebEngine used by this map view.
156-
*
157-
* @return the JLWebEngine
166+
* {@inheritDoc}
158167
*/
159168
@Override
160169
public JLWebEngine<PendingJavaScriptResult> getJLEngine() {
161170
return jlWebEngine;
162171
}
163172

164173
/**
165-
* Adds the controller to the document.
166-
* This method is called automatically when the component is attached.
174+
* {@inheritDoc}
167175
*/
168176
@Override
169177
public void addControllerToDocument() {
@@ -193,6 +201,8 @@ public void setMapViewListener(OnJLMapViewListener listener) {
193201
}
194202

195203
/**
204+
* Gets the GeoJson layer for this map view.
205+
*
196206
* @return JLVaadinGeoJsonLayer
197207
*/
198208
public JLVaadinGeoJsonLayer getGeoJsonLayer() {

jlmap-vaadin/src/main/java/io/github/makbn/jlmap/vaadin/engine/JLVaadinTransporter.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,26 @@
88

99
import java.util.concurrent.CompletableFuture;
1010

11+
/**
12+
* JLVaadinTransporter is an abstract implementation of JLTransporter for Vaadin,
13+
* handling the conversion of JavaScript results to Java objects using Gson.
14+
*
15+
* <p>This class is used to bridge between JavaScript execution results (PendingJavaScriptResult)
16+
* and Java model objects, providing a generic conversion mechanism for Vaadin-based JLMap integrations.</p>
17+
*
18+
* @author Matt Akbarian (@makbn)
19+
*/
1120
public abstract class JLVaadinTransporter implements JLTransporter<PendingJavaScriptResult> {
1221

1322
Gson gson = new Gson();
1423

24+
/**
25+
* Converts a PendingJavaScriptResult to a Java object of type M using Gson.
26+
*
27+
* @param result the PendingJavaScriptResult from Vaadin
28+
* @param <M> the type of the result object
29+
* @return the converted Java object
30+
*/
1531
@Override
1632
@SneakyThrows
1733
public <M> M covertResult(PendingJavaScriptResult result) {

jlmap-vaadin/src/main/java/io/github/makbn/jlmap/vaadin/layer/JLVaadinControlLayer.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,80 +17,122 @@ public JLVaadinControlLayer(JLWebEngine<PendingJavaScriptResult> engine, JLMapCa
1717
super(engine, callbackHandler);
1818
}
1919

20+
/**
21+
* {@inheritDoc}
22+
*/
2023
@Override
2124
public void zoomIn(int delta) {
2225
engine.executeScript(String.format("this.map.zoomIn(%d)", delta));
2326
}
2427

28+
/**
29+
* {@inheritDoc}
30+
*/
2531
@Override
2632
public void zoomOut(int delta) {
2733
engine.executeScript(String.format("this.map.zoomOut(%d)", delta));
2834
}
2935

36+
/**
37+
* {@inheritDoc}
38+
*/
3039
@Override
3140
public void setZoom(int level) {
3241
engine.executeScript(String.format("this.map.setZoom(%d)", level));
3342
}
3443

44+
/**
45+
* {@inheritDoc}
46+
*/
3547
@Override
3648
public void setZoomAround(JLLatLng latLng, int zoom) {
3749
engine.executeScript(
3850
String.format("this.map.setZoomAround(L.latLng(%f, %f), %d)",
3951
latLng.getLat(), latLng.getLng(), zoom));
4052
}
4153

54+
/**
55+
* {@inheritDoc}
56+
*/
4257
@Override
4358
public void fitBounds(JLBounds bounds) {
4459
engine.executeScript(String.format("this.map.fitBounds(%s)",
4560
bounds.toString()));
4661
}
4762

63+
/**
64+
* {@inheritDoc}
65+
*/
4866
@Override
4967
public void fitWorld() {
5068
engine.executeScript("this.map.fitWorld()");
5169
}
5270

71+
/**
72+
* {@inheritDoc}
73+
*/
5374
@Override
5475
public void panTo(JLLatLng latLng) {
5576
engine.executeScript(String.format("this.map.panTo(L.latLng(%f, %f))",
5677
latLng.getLat(), latLng.getLng()));
5778
}
5879

80+
/**
81+
* {@inheritDoc}
82+
*/
5983
@Override
6084
public void flyTo(JLLatLng latLng, int zoom) {
6185
engine.executeScript(
6286
String.format("this.map.flyTo(L.latLng(%f, %f), %d)",
6387
latLng.getLat(), latLng.getLng(), zoom));
6488
}
6589

90+
/**
91+
* {@inheritDoc}
92+
*/
6693
@Override
6794
public void flyToBounds(JLBounds bounds) {
6895
engine.executeScript(String.format("this.map.flyToBounds(%s)",
6996
bounds.toString()));
7097
}
7198

99+
/**
100+
* {@inheritDoc}
101+
*/
72102
@Override
73103
public void setMaxBounds(JLBounds bounds) {
74104
engine.executeScript(String.format("this.map.setMaxBounds(%s)",
75105
bounds.toString()));
76106
}
77107

108+
/**
109+
* {@inheritDoc}
110+
*/
78111
@Override
79112
public void setMinZoom(int zoom) {
80113
engine.executeScript(String.format("this.map.setMinZoom(%d)", zoom));
81114
}
82115

116+
/**
117+
* {@inheritDoc}
118+
*/
83119
@Override
84120
public void setMaxZoom(int zoom) {
85121
engine.executeScript(String.format("this.map.setMaxZoom(%d)", zoom));
86122
}
87123

124+
/**
125+
* {@inheritDoc}
126+
*/
88127
@Override
89128
public void panInsideBounds(JLBounds bounds) {
90129
engine.executeScript(String.format("this.map.panInsideBounds(%s)",
91130
bounds.toString()));
92131
}
93132

133+
/**
134+
* {@inheritDoc}
135+
*/
94136
@Override
95137
public void panInside(JLLatLng latLng) {
96138
engine.executeScript(

jlmap-vaadin/src/main/java/io/github/makbn/jlmap/vaadin/layer/JLVaadinGeoJsonLayer.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,37 @@ public JLVaadinGeoJsonLayer(JLWebEngine<PendingJavaScriptResult> engine,
4141
this.idGenerator = new AtomicInteger();
4242
}
4343

44+
/**
45+
* {@inheritDoc}
46+
*/
4447
@Override
4548
public JLGeoJson addFromFile(@NonNull File file) throws JLException {
4649
String json = fromFile.load(file);
4750
return addGeoJson(json);
4851
}
4952

53+
/**
54+
* {@inheritDoc}
55+
*/
5056
@Override
5157
public JLGeoJson addFromUrl(@NonNull String url) throws JLException {
5258
String json = fromUrl.load(url);
5359
return addGeoJson(json);
5460
}
5561

62+
/**
63+
* {@inheritDoc}
64+
*/
5665
@Override
5766
public JLGeoJson addFromContent(@NonNull String content)
5867
throws JLException {
5968
String json = fromContent.load(content);
6069
return addGeoJson(json);
6170
}
6271

72+
/**
73+
* {@inheritDoc}
74+
*/
6375
@Override
6476
public boolean removeGeoJson(@NonNull String id) {
6577
try {
@@ -72,6 +84,12 @@ public boolean removeGeoJson(@NonNull String id) {
7284
}
7385
}
7486

87+
/**
88+
* Adds a GeoJSON object to the map from a JSON string.
89+
*
90+
* @param geoJson the GeoJSON string
91+
* @return the added JLGeoJson object
92+
*/
7593
private JLGeoJson addGeoJson(String geoJson) {
7694
String elementUniqueName = getElementUniqueName(JLGeoJson.class, idGenerator.incrementAndGet());
7795
JLGeoJsonObjectBuilder builder = new JLGeoJsonObjectBuilder()

jlmap-vaadin/src/main/java/io/github/makbn/jlmap/vaadin/layer/JLVaadinLayer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,12 @@ public Function<JLTransport, PendingJavaScriptResult> clientToServerTransport()
4949
}
5050
};
5151
}
52+
53+
/**
54+
* {@inheritDoc}
55+
*/
56+
@Override
57+
public String toString() {
58+
return super.toString();
59+
}
5260
}

0 commit comments

Comments
 (0)