diff --git a/src/Map.java b/src/Map.java index 4d07aba..6c91085 100644 --- a/src/Map.java +++ b/src/Map.java @@ -9,7 +9,7 @@ this.longitude = new Longitude(mapLongitude); this.mapLatitude = new MapLatitude(); this.latitude = new Latitude(mapLatitude); - this.presenter = new Presenter(mapLongitude, mapLatitude); // Presenter�������� + this.presenter = new Presenter(mapLongitude, mapLatitude, longitude, latitude); } public double getMapLongitude() { return mapLongitude.getValue(); @@ -18,8 +18,6 @@ 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() { @@ -34,7 +32,7 @@ } // �蓮�X�V�̂��߂̃��\�b�h - public void manualUpdate(double lat, double lon) { - presenter.manualUpdate(lat, lon); + public void manualUpdate() { + presenter.manualUpdate(); } } \ No newline at end of file diff --git a/src/Presenter.java b/src/Presenter.java index 5e3bb9c..36a5287 100644 --- a/src/Presenter.java +++ b/src/Presenter.java @@ -1,29 +1,43 @@ -// �V���� Presenter �N���X��lj����܂��B public class Presenter { + private boolean autoUpdateEnabled; private MapLongitude mapLongitude; private MapLatitude mapLatitude; - private boolean autoUpdateEnabled; + private Longitude longitude; + private Latitude latitude; - public Presenter(MapLongitude mapLongitude, MapLatitude mapLatitude) { - this.mapLongitude = mapLongitude; - this.mapLatitude = mapLatitude; - this.autoUpdateEnabled = true; // �f�t�H���g�ł͎����X�V��ON�ł��B + 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 void updateGPS(double lat, double lon) { + 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) { - mapLatitude.updateLatitude(lat); - mapLongitude.updateLongitude(lon); + mapLongitude.updateLongitude(long2); + mapLatitude.updateLatitude(lat2); } } - // �蓮�Œn�}�̕\���ʒu���X�V���郁�\�b�h��lj����܂��B - public void manualUpdate(double lat, double lon) { - mapLatitude.updateLatitude(lat); - mapLongitude.updateLongitude(lon); + // 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