Skip to content
Snippets Groups Projects
Commit eb58c3f3 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Remove use of Optional and isEmpty

parent b5460e64
No related branches found
No related tags found
No related merge requests found
Pipeline #46705 passed
...@@ -13,7 +13,6 @@ public class LatLong { ...@@ -13,7 +13,6 @@ public class LatLong {
this.longitude = longitude; this.longitude = longitude;
} }
public double getLatitude() { public double getLatitude() {
return latitude; return latitude;
} }
......
...@@ -12,7 +12,6 @@ import java.io.FileOutputStream; ...@@ -12,7 +12,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Optional;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
...@@ -73,7 +72,7 @@ public class FxAppController { ...@@ -73,7 +72,7 @@ public class FxAppController {
private MapBase mapView; private MapBase mapView;
private MapItemsControl<MapNode> markersParent; private MapItemsControl<MapNode> markersParent;
private Optional<MapMarker> marker = Optional.empty(); private MapMarker marker = null;
private DraggableNodeController draggableMapController = null; private DraggableNodeController draggableMapController = null;
private DraggableNodeController draggableMarkerController = null; private DraggableNodeController draggableMarkerController = null;
...@@ -107,7 +106,7 @@ public class FxAppController { ...@@ -107,7 +106,7 @@ public class FxAppController {
private void handleMarkerDragged(final Node node, final double dx, final double dy) { private void handleMarkerDragged(final Node node, final double dx, final double dy) {
final MapProjection projection = mapView.getProjection(); final MapProjection projection = mapView.getProjection();
final Point2D point = projection.locationToViewportPoint(marker.get().getLocation()); final Point2D point = projection.locationToViewportPoint(marker.getLocation());
final Location newLocation = projection.viewportPointToLocation(point.add(dx, dy)); final Location newLocation = projection.viewportPointToLocation(point.add(dx, dy));
getLatLongs().setLatLong(locationListView.getSelectionModel().getSelectedIndex(), getLatLongs().setLatLong(locationListView.getSelectionModel().getSelectedIndex(),
location2LatLong(newLocation)); location2LatLong(newLocation));
...@@ -123,23 +122,22 @@ public class FxAppController { ...@@ -123,23 +122,22 @@ public class FxAppController {
if (num < 0 || num >= getLatLongs().getLatLongCount()) { if (num < 0 || num >= getLatLongs().getLatLongCount()) {
markersParent.getItems().clear(); markersParent.getItems().clear();
if (draggableMarkerController != null) { if (draggableMarkerController != null) {
draggableMarkerController.detach(marker.get()); draggableMarkerController.detach(marker);
} }
marker = Optional.empty(); marker = null;
} else { } else {
final LatLong latLong = getLatLongs().getLatLong(num); final LatLong latLong = getLatLongs().getLatLong(num);
if (marker.isEmpty()) { if (marker == null) {
final MapMarker aMarker = new MapMarker(latLong); marker = new MapMarker(latLong);
markersParent.getItems().add(aMarker); markersParent.getItems().add(marker);
if (draggableMarkerController != null) { if (draggableMarkerController != null) {
draggableMarkerController.attach(aMarker); draggableMarkerController.attach(marker);
} }
marker = Optional.of(aMarker);
} else { } else {
marker.get().setLocation(latLong); marker.setLocation(latLong);
} }
if (centerOnMarker) { if (centerOnMarker) {
mapView.setCenter(marker.get().getLocation()); mapView.setCenter(marker.getLocation());
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment