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 {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
......
......@@ -12,7 +12,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Optional;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
......@@ -73,7 +72,7 @@ public class FxAppController {
private MapBase mapView;
private MapItemsControl<MapNode> markersParent;
private Optional<MapMarker> marker = Optional.empty();
private MapMarker marker = null;
private DraggableNodeController draggableMapController = null;
private DraggableNodeController draggableMarkerController = null;
......@@ -107,7 +106,7 @@ public class FxAppController {
private void handleMarkerDragged(final Node node, final double dx, final double dy) {
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));
getLatLongs().setLatLong(locationListView.getSelectionModel().getSelectedIndex(),
location2LatLong(newLocation));
......@@ -123,23 +122,22 @@ public class FxAppController {
if (num < 0 || num >= getLatLongs().getLatLongCount()) {
markersParent.getItems().clear();
if (draggableMarkerController != null) {
draggableMarkerController.detach(marker.get());
draggableMarkerController.detach(marker);
}
marker = Optional.empty();
marker = null;
} else {
final LatLong latLong = getLatLongs().getLatLong(num);
if (marker.isEmpty()) {
final MapMarker aMarker = new MapMarker(latLong);
markersParent.getItems().add(aMarker);
if (marker == null) {
marker = new MapMarker(latLong);
markersParent.getItems().add(marker);
if (draggableMarkerController != null) {
draggableMarkerController.attach(aMarker);
draggableMarkerController.attach(marker);
}
marker = Optional.of(aMarker);
} else {
marker.get().setLocation(latLong);
marker.setLocation(latLong);
}
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.
Finish editing this message first!
Please register or to comment