001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.download; 003 004import java.util.Optional; 005 006import org.openstreetmap.josm.data.Bounds; 007 008/** 009 * The global settings of {@link DownloadDialog}. 010 * <p> 011 * This class is immutable 012 * @since 12652 013 */ 014public final class DownloadSettings { 015 016 private final Bounds downloadBounds; 017 private final boolean downloadAsNewLayer; 018 private final boolean zoomToDownloadedData; 019 020 /** 021 * Initializes a new instance of {@code DownloadSettings}. 022 * @param bbox The bounding box 023 * @param downloadAsNewLayer The flag defining if a new layer must be created for the downloaded data. 024 * @param zoomToDownloadedData The flag defining if the map view, see {@link SlippyMapChooser}, 025 * must zoom to the downloaded data. 026 */ 027 public DownloadSettings(Bounds bbox, boolean downloadAsNewLayer, boolean zoomToDownloadedData) { 028 this.downloadBounds = bbox; 029 this.downloadAsNewLayer = downloadAsNewLayer; 030 this.zoomToDownloadedData = zoomToDownloadedData; 031 } 032 033 /** 034 * Gets the flag defining if a new layer must be created for the downloaded data. 035 * @return {@code true} if a new layer must be created, {@code false} otherwise. 036 */ 037 public boolean asNewLayer() { 038 return this.downloadAsNewLayer; 039 } 040 041 /** 042 * Gets the flag defining if the map view must zoom to the downloaded data. 043 * @return {@code true} if the view must zoom, {@code false} otherwise. 044 */ 045 public boolean zoomToData() { 046 return this.zoomToDownloadedData; 047 } 048 049 /** 050 * Gets the download bounds that are requested 051 * @return The bounds or an empty {@link Optional} if no bounds are selected 052 */ 053 public Optional<Bounds> getDownloadBounds() { 054 return Optional.ofNullable(downloadBounds); 055 } 056}