Changeset 6070 in josm for trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongPanel.java
- Timestamp:
- 2013-07-17T00:01:49+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongPanel.java
r6054 r6070 25 25 */ 26 26 public class DownloadAlongPanel extends JPanel { 27 28 29 30 31 32 33 34 35 27 28 // Preferences keys 29 private final String prefOsm; 30 private final String prefGps; 31 private final String prefDist; 32 private final String prefArea; 33 private final String prefNear; 34 35 // Data types to download 36 36 private final JCheckBox cbDownloadOsmData; 37 37 private final JCheckBox cbDownloadGpxData; 38 38 39 39 // Legacy list of values 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 40 private static final Integer dist[] = { 5000, 500, 50 }; 41 private static final Integer area[] = { 20, 10, 5, 1 }; 42 43 private final JList buffer; 44 private final JList maxRect; 45 private final JList downloadNear; 46 47 /** 48 * Constructs a new {@code DownloadPanel}. 49 * @param prefOsm Preference key determining if OSM data should be downloaded 50 * @param prefGps Preference key determining if GPS data should be downloaded 51 * @param prefDist Preference key determining maximum distance 52 * @param prefArea Preference key determining maximum area 53 * @param prefNear Preference key determining "near" parameter. Can be {@code null} 54 */ 55 public DownloadAlongPanel(String prefOsm, String prefGps, String prefDist, String prefArea, String prefNear) { 56 super(new GridBagLayout()); 57 58 this.prefOsm = prefOsm; 59 this.prefGps = prefGps; 60 this.prefDist = prefDist; 61 this.prefArea = prefArea; 62 this.prefNear = prefNear; 63 64 cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), Main.pref.getBoolean(prefOsm, true)); 65 65 cbDownloadOsmData.setToolTipText(tr("Select to download OSM data.")); 66 66 add(cbDownloadOsmData, GBC.std().insets(1,5,1,5)); … … 69 69 add(cbDownloadGpxData, GBC.eol().insets(5,5,1,5)); 70 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 71 add(new JLabel(tr("Download everything within:")), GBC.eol()); 72 String s[] = new String[dist.length]; 73 for (int i = 0; i < dist.length; ++i) { 74 s[i] = tr("{0} meters", dist[i]); 75 } 76 buffer = new JList(s); 77 78 double distanceValue = Main.pref.getDouble(prefDist, dist[0]); 79 int distanceLegacyIndex = 0; 80 for (int i = 0; i < dist.length; i++) { 81 if (dist[i] == (int)distanceValue) { 82 distanceLegacyIndex = i; 83 break; 84 } 85 } 86 87 buffer.setSelectedIndex(distanceLegacyIndex); 88 add(buffer, GBC.eol()); 89 90 add(new JLabel(tr("Maximum area per request:")), GBC.eol()); 91 s = new String[area.length]; 92 for (int i = 0; i < area.length; ++i) { 93 s[i] = tr("{0} sq km", area[i]); 94 } 95 maxRect = new JList(s); 96 97 double areaValue = Main.pref.getDouble(prefArea, area[0]); 98 int areaLegacyIndex = 0; 99 for (int i = 0; i < area.length; i++) { 100 if (area[i] == (int)areaValue) { 101 areaLegacyIndex = i; 102 break; 103 } 104 } 105 106 maxRect.setSelectedIndex(areaLegacyIndex); 107 add(maxRect, GBC.eol()); 108 109 if (prefNear != null) { 110 110 add(new JLabel(tr("Download near:")), GBC.eol()); 111 111 downloadNear = new JList(new String[]{tr("track only"), tr("waypoints only"), tr("track and waypoints")}); 112 112 downloadNear.setSelectedIndex(Main.pref.getInteger(prefNear, 0)); 113 113 add(downloadNear, GBC.eol()); 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 114 } else { 115 downloadNear = null; 116 } 117 } 118 119 /** 120 * Gets the maximum distance in meters 121 * @return The maximum distance, in meters 122 */ 123 public final double getDistance() { 124 return dist[buffer.getSelectedIndex()]; 125 } 126 127 /** 128 * Gets the maximum area in squared kilometers 129 * @return The maximum distance, in squared kilometers 130 */ 131 public final double getArea() { 132 return area[maxRect.getSelectedIndex()]; 133 } 134 135 /** 136 * Gets the "download near" choosen value 137 * @return the "download near" choosen value (0: track only, 1: waypoints only, 2: both) 138 */ 139 public final int getNear() { 140 return downloadNear.getSelectedIndex(); 141 } 142 143 143 /** 144 144 * Replies true if the user selected to download OSM data … … 158 158 return cbDownloadGpxData.isSelected(); 159 159 } 160 160 161 161 /** 162 162 * Remembers the current settings in the download panel 163 163 */ 164 164 protected final void rememberSettings() { 165 166 167 168 169 170 171 165 Main.pref.put(prefOsm, isDownloadOsmData()); 166 Main.pref.put(prefGps, isDownloadGpxData()); 167 Main.pref.putDouble(prefDist, getDistance()); 168 Main.pref.putDouble(prefArea, getArea()); 169 if (prefNear != null) { 170 Main.pref.putInteger(prefNear, getNear()); 171 } 172 172 } 173 173 … … 177 177 */ 178 178 protected final void addChangeListener(ChangeListener listener) { 179 180 179 cbDownloadGpxData.addChangeListener(listener); 180 cbDownloadOsmData.addChangeListener(listener); 181 181 } 182 182
Note:
See TracChangeset
for help on using the changeset viewer.