diff --git a/src/Map.java b/src/Map.java index abfd465..6ab2a7e 100644 --- a/src/Map.java +++ b/src/Map.java @@ -1,15 +1,16 @@ -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); + // Presenter�Ɉˑ��I�u�W�F�N�g��n�� + this.presenter = new Presenter(mapLongitude, longitude, mapLatitude, latitude); } public double getMapLongitude() { return mapLongitude.getValue(); @@ -18,8 +19,7 @@ return longitude.getValue(); } public void updateGPS(double lat2, double long2) { - this.longitude.updateGPS(lat2, long2); - this.latitude.updateGPS(lat2, long2); + presenter.updateGPS(lat2, long2); } public double getMapLatitude() { return mapLatitude.getValue(); @@ -27,4 +27,8 @@ public double getLatitude() { return latitude.getValue(); } + // �����X�V��ON/OFF��؂�ւ��郁�\�b�h��Map�N���X�ɒlj� + public void setAutoUpdateEnabled(boolean autoUpdate) { + presenter.setAutoUpdateEnabled(autoUpdate); + } } \ No newline at end of file diff --git a/src/Presenter.java b/src/Presenter.java new file mode 100644 index 0000000..2220064 --- /dev/null +++ b/src/Presenter.java @@ -0,0 +1,31 @@ +class Presenter { + private MapLongitude mapLongitude; + private Longitude longitude; + private MapLatitude mapLatitude; + private Latitude latitude; + private boolean autoUpdateEnabled; + + public Presenter(MapLongitude mapLong, Longitude longi, MapLatitude mapLat, Latitude lati) { + this.mapLongitude = mapLong; + this.longitude = longi; + this.mapLatitude = mapLat; + this.latitude = lati; + this.autoUpdateEnabled = true; // �f�t�H���g�ł͎����X�V��ON�� + } + + public void updateGPS(double lat, double lon) { + // Longitude��Latitude�̏�Ԃ��X�V + longitude.updateGPS(lat, lon); + latitude.updateGPS(lat, lon); + + // MapLongitude��MapLatitude�̏�Ԃ������ɉ����čX�V + if (autoUpdateEnabled) { + mapLongitude.updateLongitude(lon); + mapLatitude.updateLatitude(lat); + } + } + + public void setAutoUpdateEnabled(boolean autoUpdate) { + this.autoUpdateEnabled = autoUpdate; + } +} \ No newline at end of file