diff --git a/src/Latitude.java b/src/Latitude.java index d9f9f3b..f971552 100644 --- a/src/Latitude.java +++ b/src/Latitude.java @@ -1,11 +1,12 @@ -import java.util.*; - public class Latitude { private MapLatitude mapLatitude; private double value; public Latitude(MapLatitude mapLatitude) { this.mapLatitude = mapLatitude; } + public void updateValue(double lat2) { + this.value = lat2; + } public double getValue() { return this.value; } diff --git a/src/Longitude.java b/src/Longitude.java index b533c8a..4287b14 100644 --- a/src/Longitude.java +++ b/src/Longitude.java @@ -1,11 +1,12 @@ -import java.util.*; - public class Longitude { private MapLongitude mapLongitude; private double value; public Longitude(MapLongitude mapLongitude) { this.mapLongitude = mapLongitude; } + public void updateValue(double long2) { + this.value = long2; + } public double getValue() { return this.value; } diff --git a/src/Map.java b/src/Map.java index abfd465..1abf7c6 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(this.longitude, this.latitude, this.mapLongitude, this.mapLatitude); } 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); + presenter.updateGPS(lat2, long2); } public double getMapLatitude() { return mapLatitude.getValue(); @@ -27,4 +26,12 @@ public double getLatitude() { return latitude.getValue(); } + // �����X�V��ON/OFF���\�b�h�Ǝ蓮�X�V���\�b�h��Map�N���X�ŌĂяo����悤�ɂ��� + public void setAutoUpdateEnabled(boolean enabled) { + presenter.setAutoUpdateEnabled(enabled); + } + + 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..a65c61d --- /dev/null +++ b/src/Presenter.java @@ -0,0 +1,37 @@ +public class Presenter { + private boolean autoUpdateEnabled = true; // ������Ԃł͎����X�V��ON�ɂ��܂� + private Longitude longitude; + private Latitude latitude; + private MapLongitude mapLongitude; + private MapLatitude mapLatitude; + + public Presenter(Longitude longitude, Latitude latitude, MapLongitude mapLongitude, MapLatitude mapLatitude) { + this.longitude = longitude; + this.latitude = latitude; + this.mapLongitude = mapLongitude; + this.mapLatitude = mapLatitude; + } + + public void updateGPS(double lat2, double long2) { + // GPS�̏�Ԃ��X�V���܂� + longitude.updateValue(long2); + latitude.updateValue(lat2); + + // �����X�V���L���ȏꍇ�̂ݒn�}�̒��S�ʒu���X�V���܂� + if (autoUpdateEnabled) { + mapLongitude.updateLongitude(long2); + mapLatitude.updateLatitude(lat2); + } + } + + // �����X�V��ON/OFF��؂�ւ��郁�\�b�h + public void setAutoUpdateEnabled(boolean enabled) { + this.autoUpdateEnabled = enabled; + } + + // �蓮�X�V���s�����\�b�h + public void manualUpdate() { + mapLongitude.updateLongitude(longitude.getValue()); + mapLatitude.updateLatitude(latitude.getValue()); + } +} \ No newline at end of file