import java.util.*; public class Map { private MapLatitude mapLatitude; private Latitude latitude; private MapLongitude mapLongitude; private Longitude longitude; private Presenter presenter; private boolean autoUpdate; // 自動更新の状態を管理する変数 public Map() { this.mapLatitude = new MapLatitude(); this.latitude = new Latitude(); this.mapLongitude = new MapLongitude(); this.longitude = new Longitude(); this.presenter = new Presenter(longitude, latitude, mapLongitude, mapLatitude); this.autoUpdate = true; // デフォルトは自動更新ON } // 自動更新の状態を設定する public void setAutoUpdate(boolean autoUpdate) { this.autoUpdate = autoUpdate; } // 現在のGPS位置で手動更新を行う public void updateManually() { this.presenter.updateMapLocation(latitude.getValue(), longitude.getValue()); } // 以下のメソッドは変更なし public double getMapLatitude() { return mapLatitude.getValue(); } public double getLatitude() { return latitude.getValue(); } public double getMapLongitude() { return mapLongitude.getValue(); } public double getLongitude() { return longitude.getValue(); } // GPS位置が更新された時の処理 public void updateGPS(double lat2, double long2) { this.latitude.updateGPS(lat2, long2); this.longitude.updateGPS(lat2, long2); if (autoUpdate) { // 自動更新がONの時のみ地図位置を更新 this.presenter.updateMapLocation(lat2, long2); } } }