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 Bounds slippyMapBounds; 018 private final boolean downloadAsNewLayer; 019 private final boolean zoomToDownloadedData; 020 021 /** 022 * Initializes a new instance of {@code DownloadSettings}. 023 * @param bbox The bounding box 024 * @param slippyMapBounds The bounds of the {@link SlippyMapChooser}/{@link org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser} 025 * @param downloadAsNewLayer The flag defining if a new layer must be created for the downloaded data. 026 * @param zoomToDownloadedData The flag defining if the map view, see {@link SlippyMapChooser}, 027 */ 028 public DownloadSettings(Bounds bbox, Bounds slippyMapBounds, boolean downloadAsNewLayer, boolean zoomToDownloadedData) { 029 this.downloadBounds = bbox; 030 this.slippyMapBounds = slippyMapBounds; 031 this.downloadAsNewLayer = downloadAsNewLayer; 032 this.zoomToDownloadedData = zoomToDownloadedData; 033 } 034 035 /** 036 * Gets the flag defining if a new layer must be created for the downloaded data. 037 * @return {@code true} if a new layer must be created, {@code false} otherwise. 038 */ 039 public boolean asNewLayer() { 040 return this.downloadAsNewLayer; 041 } 042 043 /** 044 * Gets the flag defining if the map view must zoom to the downloaded data. 045 * @return {@code true} if the view must zoom, {@code false} otherwise. 046 */ 047 public boolean zoomToData() { 048 return this.zoomToDownloadedData; 049 } 050 051 /** 052 * Gets the download bounds that are requested 053 * @return The bounds or an empty {@link Optional} if no bounds are selected 054 */ 055 public Optional<Bounds> getDownloadBounds() { 056 return Optional.ofNullable(downloadBounds); 057 } 058 059 /** 060 * Gets the slippy map bounds 061 * @return the slippy map bounds or an empty {@link Optional} if no slippy map was used to select the download bounds 062 */ 063 public Optional<Bounds> getSlippyMapBounds() { 064 return Optional.ofNullable(slippyMapBounds); 065 } 066}