diff --git a/src/Map.java b/src/Map.java index abfd465..6c91085 100644 --- a/src/Map.java +++ b/src/Map.java @@ -1,15 +1,15 @@ -import java.util.*; - public class Map { private MapLongitude mapLongitude; private Longitude longitude; private MapLatitude mapLatitude; private Latitude latitude; + private Presenter presenter; public Map() { this.mapLongitude = new MapLongitude(); this.longitude = new Longitude(mapLongitude); this.mapLatitude = new MapLatitude(); this.latitude = new Latitude(mapLatitude); + this.presenter = new Presenter(mapLongitude, mapLatitude, longitude, latitude); } public double getMapLongitude() { return mapLongitude.getValue(); @@ -18,8 +18,7 @@ return longitude.getValue(); } public void updateGPS(double lat2, double long2) { - this.longitude.updateGPS(lat2, long2); - this.latitude.updateGPS(lat2, long2); + this.presenter.updateGPS(lat2, long2); } public double getMapLatitude() { return mapLatitude.getValue(); @@ -27,4 +26,13 @@ public double getLatitude() { return latitude.getValue(); } + // �����X�V��ON/OFF��؂�ւ��郁�\�b�h + public void setAutoUpdateEnabled(boolean enabled) { + presenter.setAutoUpdateEnabled(enabled); + } + + // �蓮�X�V�̂��߂̃��\�b�h + public void manualUpdate() { + presenter.manualUpdate(); + } } \ No newline at end of file diff --git a/src/Presenter.java b/src/Presenter.java new file mode 100644 index 0000000..36a5287 --- /dev/null +++ b/src/Presenter.java @@ -0,0 +1,43 @@ +public class Presenter { + private boolean autoUpdateEnabled; + private MapLongitude mapLongitude; + private MapLatitude mapLatitude; + private Longitude longitude; + private Latitude latitude; + + public Presenter(MapLongitude mapLong, MapLatitude mapLat, Longitude longi, Latitude lati) { + this.mapLongitude = mapLong; + this.mapLatitude = mapLat; + this.longitude = longi; + this.latitude = lati; + this.autoUpdateEnabled = true; // default is auto-update enabled + } + + public void setAutoUpdateEnabled(boolean enabled) { + this.autoUpdateEnabled = enabled; + } + + public boolean isAutoUpdateEnabled() { + return this.autoUpdateEnabled; + } + + public void updateGPS(double lat2, double long2) { + // Update GPS coordinates + longitude.updateGPS(lat2, long2); + latitude.updateGPS(lat2, long2); + + // If auto-update is enabled, also update map coordinates + if (autoUpdateEnabled) { + mapLongitude.updateLongitude(long2); + mapLatitude.updateLatitude(lat2); + } + } + + // Method to manually trigger a map update + public void manualUpdate() { + if (!autoUpdateEnabled) { + mapLongitude.updateLongitude(longitude.getValue()); + mapLatitude.updateLatitude(latitude.getValue()); + } + } +} \ No newline at end of file