Ignore:
Timestamp:
2013-07-17T00:01:49+02:00 (11 years ago)
Author:
stoecker
Message:

see #8853 remove tabs, trailing spaces, windows line ends, strange characters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongPanel.java

    r6054 r6070  
    2525 */
    2626public class DownloadAlongPanel extends JPanel {
    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
     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
    3636    private final JCheckBox cbDownloadOsmData;
    3737    private final JCheckBox cbDownloadGpxData;
    3838
    3939    // Legacy list of values
    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));
     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));
    6565        cbDownloadOsmData.setToolTipText(tr("Select to download OSM data."));
    6666        add(cbDownloadOsmData,  GBC.std().insets(1,5,1,5));
     
    6969        add(cbDownloadGpxData,  GBC.eol().insets(5,5,1,5));
    7070       
    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) {
     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) {
    110110            add(new JLabel(tr("Download near:")), GBC.eol());
    111111            downloadNear = new JList(new String[]{tr("track only"), tr("waypoints only"), tr("track and waypoints")});
    112112            downloadNear.setSelectedIndex(Main.pref.getInteger(prefNear, 0));
    113113            add(downloadNear, GBC.eol());
    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        
     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   
    143143    /**
    144144     * Replies true if the user selected to download OSM data
     
    158158        return cbDownloadGpxData.isSelected();
    159159    }
    160        
     160   
    161161    /**
    162162     * Remembers the current settings in the download panel
    163163     */
    164164    protected final void rememberSettings() {
    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                 }
     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        }
    172172    }
    173173   
     
    177177     */
    178178    protected final void addChangeListener(ChangeListener listener) {
    179         cbDownloadGpxData.addChangeListener(listener);
    180         cbDownloadOsmData.addChangeListener(listener);
     179        cbDownloadGpxData.addChangeListener(listener);
     180        cbDownloadOsmData.addChangeListener(listener);
    181181    }
    182182
Note: See TracChangeset for help on using the changeset viewer.