Skip to content

Commit 252b3ea

Browse files
Artur-sissbruecker
andauthored
fix!: Use double instead of float in map API (#4567)
* fix!: Use double instead of float in map API Java numbers like 1.2 are by default doubles and having floats in the API only makes it harder to use * adapt remaining code to use double Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent b9ba2ae commit 252b3ea

12 files changed

Lines changed: 62 additions & 62 deletions

File tree

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/MarkerFeaturePage.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ private static Icon createCustomIcon() {
6161
Icon.Options options = new Icon.Options();
6262
options.setSrc("assets/custom-marker.png");
6363
options.setColor("blue");
64-
options.setOpacity(0.8f);
65-
options.setScale(2f);
66-
options.setRotation((float) Math.PI);
64+
options.setOpacity(0.8);
65+
options.setScale(2);
66+
options.setRotation(Math.PI);
6767
return new Icon(options);
6868
}
6969
}

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/test/java/com/vaadin/flow/components/map/MapEventsIT.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public void changeViewPort_viewStateUpdated() {
4040
String[] parts = viewStateDiv.getText().split(";");
4141
double centerX = Double.parseDouble(parts[0]);
4242
double centerY = Double.parseDouble(parts[1]);
43-
float rotation = Float.parseFloat(parts[2]);
44-
float zoom = Float.parseFloat(parts[3]);
43+
double rotation = Double.parseDouble(parts[2]);
44+
double zoom = Double.parseDouble(parts[3]);
4545

4646
Assert.assertEquals(43.5627725, centerX, 0.1);
4747
Assert.assertEquals(44.1428164, centerY, 0.1);
@@ -63,8 +63,8 @@ public void changeViewPort_correctEventDataReceived() {
6363
String[] parts = eventDataDiv.getText().split(";");
6464
double centerX = Double.parseDouble(parts[0]);
6565
double centerY = Double.parseDouble(parts[1]);
66-
float rotation = Float.parseFloat(parts[2]);
67-
float zoom = Float.parseFloat(parts[3]);
66+
double rotation = Double.parseDouble(parts[2]);
67+
double zoom = Double.parseDouble(parts[3]);
6868

6969
Assert.assertEquals(43.5627725, centerX, 0.1);
7070
Assert.assertEquals(44.1428164, centerY, 0.1);

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/Map.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public void setCenter(Coordinate center) {
299299
*
300300
* @return current zoom level
301301
*/
302-
public float getZoom() {
302+
public double getZoom() {
303303
return getView().getZoom();
304304
}
305305

@@ -318,7 +318,7 @@ public float getZoom() {
318318
* @param zoom
319319
* new zoom level
320320
*/
321-
public void setZoom(float zoom) {
321+
public void setZoom(double zoom) {
322322
getView().setZoom(zoom);
323323
}
324324
}

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/MapBase.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ private void registerEventListeners() {
134134
// move end event to update view state to the latest values received
135135
// from the client
136136
addViewMoveEndEventListener(event -> {
137-
float rotation = event.getRotation();
138-
float zoom = event.getZoom();
137+
double rotation = event.getRotation();
138+
double zoom = event.getZoom();
139139
Coordinate center = event.getCenter();
140140
Extent extent = event.getExtent();
141141
getView().updateInternalViewState(center, rotation, zoom, extent);

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/configuration/AbstractConfigurationObject.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ protected void removePropertyChangeListener(
232232
* and mark the object as dirty. This can be useful to prevent change events
233233
* and resulting synchronizations when updating the server-side with state
234234
* from the client. See
235-
* {@link View#updateInternalViewState(Coordinate, float, float, Extent)}
235+
* {@link View#updateInternalViewState(Coordinate, double, double, Extent)}
236236
* for an example.
237237
*
238238
* @param updater

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/configuration/View.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
public class View extends AbstractConfigurationObject {
2222

2323
private Coordinate center;
24-
private float rotation;
25-
private float zoom;
24+
private double rotation;
25+
private double zoom;
2626
private Extent extent;
2727
private final String projection;
2828

@@ -94,7 +94,7 @@ public void setCenter(Coordinate center) {
9494
*
9595
* @return current rotation in radians
9696
*/
97-
public float getRotation() {
97+
public double getRotation() {
9898
return rotation;
9999
}
100100

@@ -104,7 +104,7 @@ public float getRotation() {
104104
* @param rotation
105105
* the rotation in radians format
106106
*/
107-
public void setRotation(float rotation) {
107+
public void setRotation(double rotation) {
108108
this.rotation = rotation;
109109
markAsDirty();
110110
}
@@ -114,7 +114,7 @@ public void setRotation(float rotation) {
114114
*
115115
* @return current zoom level
116116
*/
117-
public float getZoom() {
117+
public double getZoom() {
118118
return zoom;
119119
}
120120

@@ -129,7 +129,7 @@ public float getZoom() {
129129
* @param zoom
130130
* new zoom level
131131
*/
132-
public void setZoom(float zoom) {
132+
public void setZoom(double zoom) {
133133
this.zoom = zoom;
134134
markAsDirty();
135135
}
@@ -173,8 +173,8 @@ public Extent getExtent() {
173173
* @param extent
174174
* the updated extent
175175
*/
176-
public void updateInternalViewState(Coordinate center, float rotation,
177-
float zoom, Extent extent) {
176+
public void updateInternalViewState(Coordinate center, double rotation,
177+
double zoom, Extent extent) {
178178
update(() -> {
179179
this.center = center;
180180
this.rotation = rotation;

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/configuration/layer/Layer.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* Abstract base class for all map layers
1515
*/
1616
public abstract class Layer extends AbstractConfigurationObject {
17-
private float opacity = 1;
17+
private double opacity = 1;
1818
private boolean visible = true;
1919
private Integer zIndex;
20-
private Float minZoom;
21-
private Float maxZoom;
20+
private Double minZoom;
21+
private Double maxZoom;
2222
private String background;
2323

2424
/**
2525
* @return opacity of the layer
2626
*/
27-
public float getOpacity() {
27+
public double getOpacity() {
2828
return opacity;
2929
}
3030

@@ -35,7 +35,7 @@ public float getOpacity() {
3535
* @param opacity
3636
* new opacity of the layer
3737
*/
38-
public void setOpacity(float opacity) {
38+
public void setOpacity(double opacity) {
3939
this.opacity = opacity;
4040
markAsDirty();
4141
}
@@ -83,7 +83,7 @@ public void setzIndex(Integer zIndex) {
8383
* @return the minimum zoom level at which this layer will be visible, or
8484
* null if not defined
8585
*/
86-
public Float getMinZoom() {
86+
public Double getMinZoom() {
8787
return minZoom;
8888
}
8989

@@ -93,7 +93,7 @@ public Float getMinZoom() {
9393
* @param minZoom
9494
* the new minimum zoom level, or null to remove it
9595
*/
96-
public void setMinZoom(Float minZoom) {
96+
public void setMinZoom(Double minZoom) {
9797
this.minZoom = minZoom;
9898
markAsDirty();
9999
}
@@ -102,7 +102,7 @@ public void setMinZoom(Float minZoom) {
102102
* @return the maximum zoom level at which this layer will be visible, or
103103
* null if not defined
104104
*/
105-
public Float getMaxZoom() {
105+
public Double getMaxZoom() {
106106
return maxZoom;
107107
}
108108

@@ -112,7 +112,7 @@ public Float getMaxZoom() {
112112
* @param maxZoom
113113
* the new maximum zoom level, or null to remove it
114114
*/
115-
public void setMaxZoom(Float maxZoom) {
115+
public void setMaxZoom(Double maxZoom) {
116116
this.maxZoom = maxZoom;
117117
markAsDirty();
118118
}

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/configuration/source/ImageWMSSource.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ImageWMSSource extends ImageSource {
2222
private final Map<String, Object> params;
2323
private final String serverType;
2424
private final String crossOrigin;
25-
private final float ratio;
25+
private final double ratio;
2626

2727
public ImageWMSSource(Options options) {
2828
super(options);
@@ -116,7 +116,7 @@ public String getCrossOrigin() {
116116
*
117117
* @return the ratio
118118
*/
119-
public float getRatio() {
119+
public double getRatio() {
120120
return ratio;
121121
}
122122

@@ -125,7 +125,7 @@ public static class Options extends ImageSource.Options {
125125
private Map<String, Object> params;
126126
private String serverType;
127127
private String crossOrigin;
128-
private float ratio = 1.5f;
128+
private double ratio = 1.5;
129129

130130
/**
131131
* @see ImageWMSSource#getUrl()
@@ -158,7 +158,7 @@ public void setCrossOrigin(String crossOrigin) {
158158
/**
159159
* @see ImageWMSSource#getRatio()
160160
*/
161-
public void setRatio(float ratio) {
161+
public void setRatio(double ratio) {
162162
this.ratio = ratio;
163163
}
164164
}

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/configuration/style/Icon.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,21 @@ public void setImgSize(ImageSize imgSize) {
216216
}
217217

218218
public static class Anchor implements Serializable {
219-
private float x = 0.5f;
220-
private float y = 0.5f;
219+
private double x = 0.5;
220+
private double y = 0.5;
221221

222-
public float getX() {
222+
public double getX() {
223223
return x;
224224
}
225225

226-
public float getY() {
226+
public double getY() {
227227
return y;
228228
}
229229

230230
public Anchor() {
231231
}
232232

233-
public Anchor(float x, float y) {
233+
public Anchor(double x, double y) {
234234
this.x = x;
235235
this.y = y;
236236
}

‎vaadin-map-flow-parent/vaadin-map-flow/src/main/java/com/vaadin/flow/component/map/configuration/style/ImageStyle.java‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
*/
1616
public abstract class ImageStyle extends AbstractConfigurationObject {
1717

18-
private float opacity;
18+
private double opacity;
1919
private boolean rotateWithView;
20-
private float rotation;
21-
private float scale;
20+
private double rotation;
21+
private double scale;
2222

2323
/**
2424
* The opacity of the image. Value values range from {@code 0} to {@code 1}.
2525
* Defaults to {@code 1}.
2626
*
2727
* @return the current opacity
2828
*/
29-
public float getOpacity() {
29+
public double getOpacity() {
3030
return opacity;
3131
}
3232

@@ -36,7 +36,7 @@ public float getOpacity() {
3636
* @param opacity
3737
* the new opacity
3838
*/
39-
public void setOpacity(float opacity) {
39+
public void setOpacity(double opacity) {
4040
this.opacity = opacity;
4141
markAsDirty();
4242
}
@@ -62,7 +62,7 @@ public void setRotateWithView(boolean rotateWithView) {
6262
*
6363
* @return the current rotation
6464
*/
65-
public float getRotation() {
65+
public double getRotation() {
6666
return rotation;
6767
}
6868

@@ -72,7 +72,7 @@ public float getRotation() {
7272
* @param rotation
7373
* the new rotation
7474
*/
75-
public void setRotation(float rotation) {
75+
public void setRotation(double rotation) {
7676
this.rotation = rotation;
7777
markAsDirty();
7878
}
@@ -82,7 +82,7 @@ public void setRotation(float rotation) {
8282
*
8383
* @return the current scaling
8484
*/
85-
public float getScale() {
85+
public double getScale() {
8686
return scale;
8787
}
8888

@@ -92,7 +92,7 @@ public float getScale() {
9292
* @param scale
9393
* the new scaling
9494
*/
95-
public void setScale(float scale) {
95+
public void setScale(double scale) {
9696
this.scale = scale;
9797
markAsDirty();
9898
}
@@ -105,15 +105,15 @@ public ImageStyle(Options options) {
105105
}
106106

107107
protected static abstract class Options {
108-
private float opacity = 1;
108+
private double opacity = 1;
109109
private boolean rotateWithView = false;
110-
private float rotation = 0;
111-
private float scale = 1;
110+
private double rotation = 0;
111+
private double scale = 1;
112112

113113
/**
114114
* @see ImageStyle#getOpacity()
115115
*/
116-
public void setOpacity(float opacity) {
116+
public void setOpacity(double opacity) {
117117
this.opacity = opacity;
118118
}
119119

@@ -127,14 +127,14 @@ public void setRotateWithView(boolean rotateWithView) {
127127
/**
128128
* @see ImageStyle#getRotation()
129129
*/
130-
public void setRotation(float rotation) {
130+
public void setRotation(double rotation) {
131131
this.rotation = rotation;
132132
}
133133

134134
/**
135135
* @see ImageStyle#getScale()
136136
*/
137-
public void setScale(float scale) {
137+
public void setScale(double scale) {
138138
this.scale = scale;
139139
}
140140
}

0 commit comments

Comments
 (0)