Changeset 2676 in josm


Ignore:
Timestamp:
Dec 24, 2009 8:48:40 AM (3 years ago)
Author:
jttt
Message:

Fix some of the warnings found by FindBugs

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r2637 r2676  
    329329                    && o.text.equals(this.text)); 
    330330        } 
     331 
     332        @Override 
     333        public int hashCode() { 
     334            return text.hashCode(); 
     335        } 
    331336    } 
    332337 
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java

    r2611 r2676  
    2323    private static class PrefixSuffixSwitcher { 
    2424 
     25        private static final String SEPARATOR = "[:_]?"; 
     26 
    2527        private final String a; 
    2628        private final String b; 
    2729        private final Pattern startPattern; 
    2830        private final Pattern endPattern; 
    29  
    30         private final String SEPARATOR = "[:_]?"; 
    3131 
    3232        public PrefixSuffixSwitcher(String a, String b) { 
  • trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java

    r2017 r2676  
    1313import java.util.Map; 
    1414import java.util.Set; 
     15import java.util.Map.Entry; 
    1516 
    1617import javax.swing.JLabel; 
     
    151152 
    152153            if (answer == JOptionPane.YES_OPTION) { 
    153                 for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) { 
    154                     List<TagCorrection> tagCorrections = 
    155                         tagCorrectionsMap.get(primitive); 
     154                for (Entry<OsmPrimitive, List<TagCorrection>> entry : tagCorrectionsMap.entrySet()) { 
     155                    List<TagCorrection> tagCorrections = entry.getValue(); 
     156                    OsmPrimitive primitive = entry.getKey(); 
    156157 
    157158                    // create the clone 
     
    186187                    } 
    187188                } 
    188                 for (OsmPrimitive primitive : roleCorrectionMap.keySet()) { 
    189                     List<RoleCorrection> roleCorrections = roleCorrectionMap 
    190                     .get(primitive); 
     189                for (Entry<OsmPrimitive, List<RoleCorrection>> entry : roleCorrectionMap.entrySet()) { 
     190                    OsmPrimitive primitive = entry.getKey(); 
     191                    List<RoleCorrection> roleCorrections = entry.getValue(); 
    191192 
    192193                    for (int i = 0; i < roleCorrections.size(); i++) { 
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r2613 r2676  
    230230    @Override 
    231231    public int hashCode() { 
    232         final int prime = 31; 
    233         int result = 1; 
    234         result = prime * result + (id ^ (id >>> 32)); 
    235232        if (id > 0) 
    236             return prime * result + getClass().hashCode(); 
     233            return id; 
    237234        else 
    238235            return super.hashCode(); 
  • trunk/src/org/openstreetmap/josm/data/osm/Filter.java

    r2512 r2676  
    11package org.openstreetmap.josm.data.osm; 
    22 
    3 import org.openstreetmap.josm.actions.search.SearchAction; 
     3import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 
    44import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 
    5 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 
    65 
    76/** 
     
    109 */ 
    1110public class Filter extends SearchSetting { 
    12    private final String version = "1"; 
    13    public Boolean enable = true; 
    14    public Boolean hide = false; 
    15    public Boolean inverted = false; 
    16    public Boolean applyForChildren = true; 
    17    public Filter() { 
    18        super("", SearchMode.add, false, false); 
    19    } 
    20    public Filter(String text, SearchMode mode, boolean caseSensitive, boolean regexSearch) { 
    21        super(text, mode, caseSensitive, regexSearch); 
    22    } 
     11    private static final String version = "1"; 
    2312 
    24    public Filter(String prefText){ 
    25       super("", SearchMode.add, false, false); 
    26       String[] prfs = prefText.split(";"); 
    27       if(prfs.length != 10 && !prfs[0].equals(version)) 
    28          throw new Error("Incompatible filter preferences"); 
    29       text = prfs[1]; 
    30       if(prfs[2].equals("replace")) mode = SearchMode.replace; 
    31       if(prfs[2].equals("add")) mode = SearchMode.add; 
    32       if(prfs[2].equals("remove")) mode = SearchMode.remove; 
    33       if(prfs[2].equals("in_selection")) mode = SearchMode.in_selection; 
    34       caseSensitive = Boolean.parseBoolean(prfs[3]); 
    35       regexSearch = Boolean.parseBoolean(prfs[4]); 
    36       enable = Boolean.parseBoolean(prfs[6]); 
    37       hide = Boolean.parseBoolean(prfs[7]); 
    38       inverted = Boolean.parseBoolean(prfs[8]); 
    39       applyForChildren = Boolean.parseBoolean(prfs[9]); 
     13    public Boolean enable = true; 
     14    public Boolean hide = false; 
     15    public Boolean inverted = false; 
     16    public Boolean applyForChildren = true; 
     17    public Filter() { 
     18        super("", SearchMode.add, false, false); 
     19    } 
     20    public Filter(String text, SearchMode mode, boolean caseSensitive, boolean regexSearch) { 
     21        super(text, mode, caseSensitive, regexSearch); 
     22    } 
    4023 
    41    } 
     24    public Filter(String prefText){ 
     25        super("", SearchMode.add, false, false); 
     26        String[] prfs = prefText.split(";"); 
     27        if(prfs.length != 10 && !prfs[0].equals(version)) 
     28            throw new Error("Incompatible filter preferences"); 
     29        text = prfs[1]; 
     30        if(prfs[2].equals("replace")) { 
     31            mode = SearchMode.replace; 
     32        } 
     33        if(prfs[2].equals("add")) { 
     34            mode = SearchMode.add; 
     35        } 
     36        if(prfs[2].equals("remove")) { 
     37            mode = SearchMode.remove; 
     38        } 
     39        if(prfs[2].equals("in_selection")) { 
     40            mode = SearchMode.in_selection; 
     41        } 
     42        caseSensitive = Boolean.parseBoolean(prfs[3]); 
     43        regexSearch = Boolean.parseBoolean(prfs[4]); 
     44        enable = Boolean.parseBoolean(prfs[6]); 
     45        hide = Boolean.parseBoolean(prfs[7]); 
     46        inverted = Boolean.parseBoolean(prfs[8]); 
     47        applyForChildren = Boolean.parseBoolean(prfs[9]); 
    4248 
    43    public String getPrefString(){ 
    44       return version + ";" + 
    45           text + ";" + mode + ";" + caseSensitive + ";" + regexSearch + ";" + 
    46           "legacy" + ";" + enable + ";" + hide + ";" + 
    47           inverted + ";" + applyForChildren; 
    48    } 
     49    } 
     50 
     51    public String getPrefString(){ 
     52        return version + ";" + 
     53        text + ";" + mode + ";" + caseSensitive + ";" + regexSearch + ";" + 
     54        "legacy" + ";" + enable + ";" + hide + ";" + 
     55        inverted + ";" + applyForChildren; 
     56    } 
    4957} 
  • trunk/src/org/openstreetmap/josm/data/projection/Puwg.java

    r2516 r2676  
    33package org.openstreetmap.josm.data.projection; 
    44 
     5import static org.openstreetmap.josm.tools.I18n.tr; 
     6 
     7import java.awt.GridBagLayout; 
    58import java.text.DecimalFormat; 
    6  
    7 import static org.openstreetmap.josm.tools.I18n.tr; 
    8  
    9 import java.awt.GridBagLayout; 
    109import java.util.Collection; 
    1110import java.util.Collections; 
     
    4039    private static DecimalFormat decFormatter = new DecimalFormat("###0"); 
    4140 
     41    @Override 
    4242    public EastNorth latlon2eastNorth(LatLon p) { 
    4343        PuwgData z = Zones[zone]; 
     
    5050    } 
    5151 
     52    @Override 
    5253    public LatLon eastNorth2latlon(EastNorth p) { 
    5354        PuwgData z = Zones[zone]; 
     
    6364    } 
    6465 
     66    @Override 
    6567    public String toCode() { 
    6668        return Zones[zone].toCode(); 
     
    7274    } 
    7375 
     76    @Override 
    7477    public String getCacheDirectoryName() { 
    7578        return Zones[zone].getCacheDirectoryName(); 
    7679    } 
    7780 
     81    @Override 
    7882    public Bounds getWorldBoundsLatLon() { 
    7983        return Zones[zone].getWorldBoundsLatLon(); 
    8084    } 
    8185 
     86    @Override 
    8287    public double getDefaultZoomInPPD() { 
    8388        // This will set the scale bar to about 100 km 
     
    9398    } 
    9499 
     100    @Override 
    95101    public void setupPreferencePanel(JPanel p) { 
    96102        JComboBox prefcb = new JComboBox(Puwg.Zones); 
     
    105111    } 
    106112 
     113    @Override 
    107114    public Collection<String> getPreferences(JPanel p) { 
    108     Object prefcb = p.getComponent(2); 
     115        Object prefcb = p.getComponent(2); 
    109116        if(!(prefcb instanceof JComboBox)) 
    110117            return null; 
     
    113120    } 
    114121 
     122    @Override 
    115123    public Collection<String> getPreferencesFromCode(String code) 
    116124    { 
     
    118126        { 
    119127            if(code.equals(p.toCode())) 
    120             return Collections.singleton(code); 
     128                return Collections.singleton(code); 
    121129        } 
    122130        return null; 
    123131    } 
    124132 
     133    @Override 
    125134    public void setPreferences(Collection<String> args) 
    126135    { 
     
    131140                for(String s : args) 
    132141                { 
    133                 for (int i=0; i < Puwg.Zones.length; ++i) 
    134                     if(s.equals(Zones[i].toCode())) 
    135                     zone = i; 
    136                 break; 
     142                    for (int i=0; i < Puwg.Zones.length; ++i) 
     143                        if(s.equals(Zones[i].toCode())) { 
     144                            zone = i; 
     145                        } 
     146                    break; 
    137147                } 
    138             } catch (NullPointerException e) {}; 
     148            } catch (NullPointerException e) {} 
    139149        } 
    140150    } 
     
    151161class Epsg2180 implements PuwgData { 
    152162 
    153     final private double Epsg2180FalseEasting = 500000.0; /* y */ 
    154     final private double Epsg2180FalseNorthing = -5300000.0; /* x */ 
    155     final private double Epsg2180ScaleFactor = 0.9993; 
    156     final private double Epsg2180CentralMeridian = 19.0; 
     163    private static final double Epsg2180FalseEasting = 500000.0; /* y */ 
     164    private static final double Epsg2180FalseNorthing = -5300000.0; /* x */ 
     165    private static final double Epsg2180ScaleFactor = 0.9993; 
     166    private static final double Epsg2180CentralMeridian = 19.0; 
    157167    private static DecimalFormat decFormatter = new DecimalFormat("###0"); 
    158168 
     
    202212abstract class Puwg2000 implements PuwgData { 
    203213 
    204     final private double PuwgFalseEasting = 500000.0; 
    205     final private double PuwgFalseNorthing = 0; 
    206     final private double PuwgScaleFactor = 0.999923; 
    207     final private double[] Puwg2000CentralMeridian = {15.0, 18.0, 21.0, 24.0}; 
     214    private static final double PuwgFalseEasting = 500000.0; 
     215    private static final double PuwgFalseNorthing = 0; 
     216    private static final double PuwgScaleFactor = 0.999923; 
     217    //final private double[] Puwg2000CentralMeridian = {15.0, 18.0, 21.0, 24.0}; 
    208218    final private String[] Puwg2000Code = { "EPSG:2176",  "EPSG:2177", "EPSG:2178", "EPSG:2179"}; 
    209219    final private String[] Puwg2000CDName = { "epsg2176",  "epsg2177", "epsg2178", "epsg2179"}; 
     
    258268 
    259269class Epsg2176 extends Puwg2000 implements Projection { 
    260     final private int PuwgZone = 5; 
    261  
     270    private static final int PuwgZone = 5; 
     271 
     272    @Override 
    262273    public int getZone() { return PuwgZone; } 
    263274} 
    264275 
    265276class Epsg2177 extends Puwg2000 implements Projection { 
    266     final private int PuwgZone = 6; 
    267  
     277    private static final int PuwgZone = 6; 
     278 
     279    @Override 
    268280    public int getZone() { return PuwgZone; } 
    269281} 
    270282 
    271283class Epsg2178 extends Puwg2000 implements Projection { 
    272     final private int PuwgZone = 7; 
    273  
     284    private static final int PuwgZone = 7; 
     285 
     286    @Override 
    274287    public int getZone() { return PuwgZone; } 
    275288} 
    276289 
    277290class Epsg2179 extends Puwg2000 implements Projection { 
    278     final private int PuwgZone = 8; 
    279  
    280     public int getZone() { return PuwgZone; } 
    281 } 
     291    private static final int PuwgZone = 8; 
     292 
     293    @Override 
     294    public int getZone() { return PuwgZone; } 
     295} 
  • trunk/src/org/openstreetmap/josm/gui/FileDrop.java

    r2626 r2676  
    320320 
    321321                    // Get a useful list 
    322                     List fileList = (java.util.List) 
    323                     tr.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor); 
     322                    List<?> fileList = (List<?>)tr.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor); 
    324323 
    325324                    // Convert list to array 
     
    429428        { 
    430429            boolean support = false; 
    431             try 
    432             {   Class arbitraryDndClass = Class.forName( "java.awt.dnd.DnDConstants" ); 
    433             support = true; 
    434             }   // end try 
    435             catch( Exception e ) 
    436             {   support = false; 
    437             }   // end catch 
     430            try { 
     431                Class.forName( "java.awt.dnd.DnDConstants" ); 
     432                support = true; 
     433            } catch( Exception e ) { 
     434                support = false; 
     435            } 
    438436            supportsDnD = support; 
    439437        }   // end if: first time through 
  • trunk/src/org/openstreetmap/josm/gui/ScrollViewport.java

    r2512 r2676  
    1313import java.awt.event.MouseAdapter; 
    1414import java.awt.event.MouseEvent; 
    15  
    1615import java.util.ArrayList; 
    1716import java.util.List; 
     
    145144        int direction = scrollDirection; 
    146145 
    147         if (component == null || direction == NO_SCROLL) { 
     146        if (component == null || direction == NO_SCROLL) 
    148147            return; 
    149         } 
    150  
    151         Dimension compSize = component.getSize(); 
     148 
    152149        Rectangle viewRect = vp.getViewRect(); 
    153150 
     
    162159 
    163160        switch (direction) { 
    164             case UP_DIRECTION : 
    165                 deltaY *= -1; 
    166                 break; 
    167             case LEFT_DIRECTION : 
    168                 deltaX *= -1; 
    169                 break; 
     161        case UP_DIRECTION : 
     162            deltaY *= -1; 
     163            break; 
     164        case LEFT_DIRECTION : 
     165            deltaX *= -1; 
     166            break; 
    170167        } 
    171168 
     
    173170    } 
    174171    public synchronized void scroll(int deltaX, int deltaY) { 
    175         if (component == null) { 
     172        if (component == null) 
    176173            return; 
    177         } 
    178174        Dimension compSize = component.getSize(); 
    179175        Rectangle viewRect = vp.getViewRect(); 
     
    204200    public void showOrHideButtons() { 
    205201        boolean needButtons = vp.getViewSize().height > vp.getViewRect().height || 
    206                               vp.getViewSize().width > vp.getViewRect().width; 
     202        vp.getViewSize().width > vp.getViewRect().width; 
    207203        for (JButton b : buttons) { 
    208204            b.setVisible(needButtons); 
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r2626 r2676  
    4747import org.openstreetmap.josm.data.Bounds; 
    4848import org.openstreetmap.josm.data.coor.LatLon; 
    49 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    5049import org.openstreetmap.josm.gui.ExceptionDialogUtil; 
    5150import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
     
    158157        public double lon; 
    159158        public int zoom; 
    160         public int osmId; 
    161         public OsmPrimitiveType type; 
    162159 
    163160        public Bounds getDownloadArea() { 
     
    200197                    currentResult.lon = Double.parseDouble(atts.getValue("lon")); 
    201198                    currentResult.zoom = Integer.parseInt(atts.getValue("zoom")); 
    202                     currentResult.osmId = Integer.parseInt(atts.getValue("id")); 
    203                     currentResult.type = OsmPrimitiveType.from(atts.getValue("type")); 
     199                    //currentResult.osmId = Integer.parseInt(atts.getValue("id")); 
     200                    //currentResult.type = OsmPrimitiveType.from(atts.getValue("type")); 
    204201                    data.add(currentResult); 
    205202                } else if (qName.equals("description") && (depth == 3)) { 
     
    383380    } 
    384381 
    385     class NamedResultTableColumnModel extends DefaultTableColumnModel { 
     382    static class NamedResultTableColumnModel extends DefaultTableColumnModel { 
    386383        protected void createColumns() { 
    387384            TableColumn col = null; 
  • trunk/src/org/openstreetmap/josm/gui/help/HelpApplication.java

    r2512 r2676  
    66import java.awt.Rectangle; 
    77import java.awt.Toolkit; 
    8 import java.io.IOException; 
    98import java.io.PrintWriter; 
    109import java.io.StringWriter; 
    1110import java.lang.Thread.UncaughtExceptionHandler; 
    12 import java.util.Arrays; 
    1311import java.util.Collection; 
    1412import java.util.HashMap; 
    1513import java.util.LinkedList; 
    16 import java.util.List; 
    1714import java.util.Map; 
    18 import java.util.logging.FileHandler; 
    1915import java.util.logging.Level; 
    20 import java.util.logging.LogManager; 
    2116import java.util.logging.Logger; 
    22 import java.util.logging.SimpleFormatter; 
    23  
    24 import javax.swing.JOptionPane; 
    2517 
    2618import org.openstreetmap.josm.Main; 
     
    6658 
    6759        // construct argument table 
    68         List<String> argList = Arrays.asList(argArray); 
    6960        final Map<String, Collection<String>> args = new HashMap<String, Collection<String>>(); 
    7061        for (String arg : argArray) { 
  • trunk/src/org/openstreetmap/josm/gui/io/UploadedObjectsSummaryPanel.java

    r2626 r2676  
    140140     * 
    141141     */ 
    142     class PrimitiveList extends JList { 
     142    static class PrimitiveList extends JList { 
    143143        public PrimitiveList() { 
    144144            super(new PrimitiveListModel()); 
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r2662 r2676  
    4040import javax.swing.AbstractListModel; 
    4141import javax.swing.BorderFactory; 
    42 import javax.swing.ButtonGroup; 
    4342import javax.swing.JButton; 
    4443import javax.swing.JCheckBox; 
     
    4948import javax.swing.JOptionPane; 
    5049import javax.swing.JPanel; 
    51 import javax.swing.JRadioButton; 
    5250import javax.swing.JScrollPane; 
    5351import javax.swing.JSeparator; 
     
    9088    double timezone; 
    9189    long delta; 
    92      
     90 
    9391    public CorrelateGpxWithImages(GeoImageLayer layer) { 
    9492        this.yLayer = layer; 
     
    123121    JLabel statusBarText; 
    124122    StatusBarListener statusBarListener; 
    125      
     123 
    126124    // remember the last number of matched photos 
    127125    int lastNumMatched = 0; 
     
    440438    public void actionPerformed(ActionEvent arg0) { 
    441439        // Construct the list of loaded GPX tracks 
    442         Collection<Layer> layerLst = Main.main.map.mapView.getAllLayers(); 
     440        Collection<Layer> layerLst = Main.map.mapView.getAllLayers(); 
    443441        GpxDataWrapper defaultItem = null; 
    444442        Iterator<Layer> iterLayer = layerLst.iterator(); 
     
    491489            timezone = 0; 
    492490        } 
    493          
     491 
    494492        tfTimezone = new JTextField(10); 
    495493        tfTimezone.setText(formatTimezone(timezone)); 
    496494 
    497495        try { 
    498         delta = parseOffset(Main.pref.get("geoimage.delta", "0")); 
     496            delta = parseOffset(Main.pref.get("geoimage.delta", "0")); 
    499497        } catch (ParseException e) { 
    500498            delta = 0; 
    501499        } 
    502500        delta = delta / 1000; 
    503          
     501 
    504502        tfOffset = new JTextField(10); 
    505503        tfOffset.setText(Long.toString(delta)); 
    506          
    507         JPanel panelBtn = new JPanel(); 
    508          
     504 
    509505        JButton buttonViewGpsPhoto = new JButton(tr("<html>Use photo of an accurate clock,<br>" 
    510506                + "e.g. GPS receiver display</html>")); 
     
    519515 
    520516        JLabel labelPosition = new JLabel(tr("Override position for: ")); 
    521   
     517 
    522518        int numAll = getSortedImgList(true, true).size(); 
    523519        int numExif = numAll - getSortedImgList(false, true).size(); 
     
    529525        cbTaggedImg = new JCheckBox(tr("Images that are already tagged ({0}/{1})", numTagged, numAll), true); 
    530526        cbTaggedImg.setEnabled(numTagged != 0); 
    531          
     527 
    532528        labelPosition.setEnabled(cbExifImg.isEnabled() || cbTaggedImg.isEnabled()); 
    533529 
     
    540536                    yLayer.loadThumbs(); 
    541537                } else { 
    542                 }         
     538                } 
    543539            } 
    544540        });*/ 
     
    549545        gbc.gridy = y++; 
    550546        panelTf.add(panelCb, gbc); 
    551          
    552          
     547 
     548 
    553549        gbc = GBC.eol().fill(GBC.HORIZONTAL).insets(0,0,0,12); 
    554550        gbc.gridx = 0; 
     
    578574        gbc.weightx = 1.; 
    579575        panelTf.add(tfOffset, gbc); 
    580          
     576 
    581577        gbc = GBC.std().insets(5,5,5,5); 
    582578        gbc.gridx = 2; 
     
    593589        gbc.weightx = 0.5; 
    594590        panelTf.add(buttonAutoGuess, gbc); 
    595          
     591 
    596592        gbc.gridx = 3; 
    597593        panelTf.add(buttonAdjust, gbc); 
     
    628624        statusBarText.setFont(statusBarText.getFont().deriveFont(8)); 
    629625        statusBar.add(statusBarText); 
    630          
     626 
    631627        statusBarListener = new StatusBarListener() { 
    632628            @Override 
     
    639635                    delta = parseOffset(tfOffset.getText().trim()); 
    640636                } catch (ParseException e) { 
    641                      return e.getMessage(); 
    642                 } 
    643                  
     637                    return e.getMessage(); 
     638                } 
     639 
    644640                // Construct a list of images that have a date, and sort them on the date. 
    645641                ArrayList<ImageEntry> dateImgLst = getSortedImgList(); 
     
    647643                    ie.cleanTmp(); 
    648644                } 
    649                  
     645 
    650646                GpxDataWrapper selGpx = selectedGPX(false); 
    651647                if (selGpx == null) 
    652648                    return tr("No gpx selected"); 
    653                      
     649 
    654650                lastNumMatched = matchGpxTrack(dateImgLst, selGpx.data, (long) (timezone * 3600) + delta); 
    655651 
     
    657653            } 
    658654        }; 
    659          
     655 
    660656        tfTimezone.getDocument().addDocumentListener(statusBarListener); 
    661657        tfOffset.getDocument().addDocumentListener(statusBarListener); 
    662658        cbExifImg.addItemListener(statusBarListener); 
    663659        cbTaggedImg.addItemListener(statusBarListener); 
    664          
     660 
    665661        statusBarListener.updateStatusBar(); 
    666662 
     
    683679        syncDialog.pack(); 
    684680        syncDialog.addWindowListener(new WindowAdapter() { 
    685             final int CANCEL = -1; 
    686             final int DONE = 0; 
    687             final int AGAIN = 1; 
    688             final int NOTHING = 2; 
     681            final static int CANCEL = -1; 
     682            final static int DONE = 0; 
     683            final static int AGAIN = 1; 
     684            final static int NOTHING = 2; 
    689685            private int checkAndSave() { 
    690                 if (syncDialog.isVisible()) { 
     686                if (syncDialog.isVisible()) 
    691687                    // nothing happened: JOSM was minimized or similar 
    692                     return NOTHING;              
    693                 } 
     688                    return NOTHING; 
    694689                int answer = syncDialog.getValue(); 
    695690                if(answer != 1) 
     
    704699                    return AGAIN; 
    705700                } 
    706                  
     701 
    707702                try { 
    708703                    delta = parseOffset(tfOffset.getText().trim()); 
    709704                } catch (ParseException e) { 
    710                         JOptionPane.showMessageDialog(Main.parent, e.getMessage(), 
    711                                 tr("Invalid offset"), JOptionPane.ERROR_MESSAGE); 
     705                    JOptionPane.showMessageDialog(Main.parent, e.getMessage(), 
     706                            tr("Invalid offset"), JOptionPane.ERROR_MESSAGE); 
    712707                    return AGAIN; 
    713708                } 
    714                  
     709 
    715710                if (lastNumMatched == 0) { 
    716711                    if (new ExtendedDialog( 
     
    718713                            tr("Correlate images with GPX track"), 
    719714                            new String[] { tr("OK"), tr("Try Again") }). 
    720                         setContent(tr("No images could be matched!")). 
    721                         setButtonIcons(new String[] { "ok.png", "dialogs/refresh.png"}). 
    722                         showDialog().getValue() == 2) 
    723                             return AGAIN; 
     715                            setContent(tr("No images could be matched!")). 
     716                            setButtonIcons(new String[] { "ok.png", "dialogs/refresh.png"}). 
     717                            showDialog().getValue() == 2) 
     718                        return AGAIN; 
    724719                } 
    725720                return DONE; 
    726721            } 
    727              
     722 
     723            @Override 
    728724            public void windowDeactivated(WindowEvent e) { 
    729725                int result = checkAndSave(); 
    730726                switch (result) { 
    731                     case NOTHING: 
    732                         break; 
    733                     case CANCEL: 
    734                     { 
    735                         for (ImageEntry ie : yLayer.data) { 
    736                             ie.tmp = null; 
    737                         } 
    738                         yLayer.updateBufferAndRepaint(); 
    739                         break; 
     727                case NOTHING: 
     728                    break; 
     729                case CANCEL: 
     730                { 
     731                    for (ImageEntry ie : yLayer.data) { 
     732                        ie.tmp = null; 
    740733                    } 
    741                     case AGAIN: 
    742                         actionPerformed(null); 
    743                         break; 
    744                     case DONE: 
    745                     { 
    746                         Main.pref.put("geoimage.timezone", formatTimezone(timezone)); 
    747                         Main.pref.put("geoimage.delta", Long.toString(delta * 1000)); 
    748                         Main.pref.put("geoimage.showThumbs", yLayer.useThumbs); 
    749  
    750                         yLayer.useThumbs = cbShowThumbs.isSelected();//FIXME 
    751                         yLayer.loadThumbs(); 
    752                          
    753                         // Search whether an other layer has yet defined some bounding box. 
    754                         // If none, we'll zoom to the bounding box of the layer with the photos. 
    755                         boolean boundingBoxedLayerFound = false; 
    756                         for (Layer l: Main.map.mapView.getAllLayers()) { 
    757                             if (l != yLayer) { 
    758                                 BoundingXYVisitor bbox = new BoundingXYVisitor(); 
    759                                 l.visitBoundingBox(bbox); 
    760                                 if (bbox.getBounds() != null) { 
    761                                     boundingBoxedLayerFound = true; 
    762                                     break; 
    763                                 } 
     734                    yLayer.updateBufferAndRepaint(); 
     735                    break; 
     736                } 
     737                case AGAIN: 
     738                    actionPerformed(null); 
     739                    break; 
     740                case DONE: 
     741                { 
     742                    Main.pref.put("geoimage.timezone", formatTimezone(timezone)); 
     743                    Main.pref.put("geoimage.delta", Long.toString(delta * 1000)); 
     744                    Main.pref.put("geoimage.showThumbs", yLayer.useThumbs); 
     745 
     746                    yLayer.useThumbs = cbShowThumbs.isSelected();//FIXME 
     747                    yLayer.loadThumbs(); 
     748 
     749                    // Search whether an other layer has yet defined some bounding box. 
     750                    // If none, we'll zoom to the bounding box of the layer with the photos. 
     751                    boolean boundingBoxedLayerFound = false; 
     752                    for (Layer l: Main.map.mapView.getAllLayers()) { 
     753                        if (l != yLayer) { 
     754                            BoundingXYVisitor bbox = new BoundingXYVisitor(); 
     755                            l.visitBoundingBox(bbox); 
     756                            if (bbox.getBounds() != null) { 
     757                                boundingBoxedLayerFound = true; 
     758                                break; 
    764759                            } 
    765760                        } 
    766                         if (! boundingBoxedLayerFound) { 
    767                             BoundingXYVisitor bbox = new BoundingXYVisitor(); 
    768                             yLayer.visitBoundingBox(bbox); 
    769                             Main.map.mapView.recalculateCenterScale(bbox); 
    770                         } 
    771  
    772  
    773                         for (ImageEntry ie : yLayer.data) { 
    774                             ie.applyTmp(); 
    775                         } 
    776  
    777                         yLayer.updateBufferAndRepaint(); 
    778  
    779  
    780                         break; 
    781761                    } 
    782                     default: 
    783                         throw new IllegalStateException(); 
     762                    if (! boundingBoxedLayerFound) { 
     763                        BoundingXYVisitor bbox = new BoundingXYVisitor(); 
     764                        yLayer.visitBoundingBox(bbox); 
     765                        Main.map.mapView.recalculateCenterScale(bbox); 
     766                    } 
     767 
     768 
     769                    for (ImageEntry ie : yLayer.data) { 
     770                        ie.applyTmp(); 
     771                    } 
     772 
     773                    yLayer.updateBufferAndRepaint(); 
     774 
     775 
     776                    break; 
     777                } 
     778                default: 
     779                    throw new IllegalStateException(); 
    784780                } 
    785781            } 
     
    807803     */ 
    808804    private class AdjustActionListener implements ActionListener { 
    809      
     805 
    810806        public void actionPerformed(ActionEvent arg0) { 
    811807 
    812808            long diff = delta + Math.round(timezone*60*60); 
    813              
     809 
    814810            double diffInH = (double)diff/(60*60);    // hours 
    815811 
    816812            // Find day difference 
    817813            final int dayOffset = (int)Math.round(diffInH / 24); // days 
    818             double tmz = diff - dayOffset*24*60*60;  // seconds 
     814            double tmz = diff - dayOffset*24*60*60l;  // seconds 
    819815 
    820816            // In hours, rounded to two decimal places 
     
    881877                    tfTimezone.getDocument().removeDocumentListener(statusBarListener); 
    882878                    tfOffset.getDocument().removeDocumentListener(statusBarListener); 
    883                      
     879 
    884880                    tfTimezone.setText(formatTimezone(timezone)); 
    885                     tfOffset.setText(Long.toString(delta + dayOffset*24*60*60));    // add the day offset to the offset field 
     881                    tfOffset.setText(Long.toString(delta + dayOffset*24*60*60l));    // add the day offset to the offset field 
    886882 
    887883                    tfTimezone.getDocument().addDocumentListener(statusBarListener); 
     
    937933                    tr("Adjust timezone and offset"), 
    938934                    new String[] { tr("Close")}). 
    939                 setContent(p).setButtonIcons(new String[] {"ok.png"}).showDialog(); 
     935                    setContent(p).setButtonIcons(new String[] {"ok.png"}).showDialog(); 
    940936        } 
    941937    } 
    942938 
    943939    private class AutoGuessActionListener implements ActionListener { 
    944      
     940 
    945941        public void actionPerformed(ActionEvent arg0) { 
    946942            GpxDataWrapper gpxW = selectedGPX(true); 
     
    948944                return; 
    949945            GpxData gpx = gpxW.data; 
    950              
     946 
    951947            ArrayList<ImageEntry> imgs = getSortedImgList(); 
    952948            PrimaryDateParser dateParser = new PrimaryDateParser(); 
     
    996992            // Find day difference 
    997993            int dayOffset = (int)Math.round(diffInH / 24); // days 
    998             double tz = diff - dayOffset*24*60*60;  // seconds 
     994            double tz = diff - dayOffset*24*60*60l;  // seconds 
    999995 
    1000996            // In hours, rounded to two decimal places 
     
    10041000            // -2 minutes offset. This determines the real timezone and finds offset. 
    10051001            timezone = (double)Math.round(tz * 2)/2; // hours, rounded to one decimal place 
    1006             delta = (long)Math.round(diff - timezone*60*60); // seconds 
     1002            delta = Math.round(diff - timezone*60*60); // seconds 
    10071003 
    10081004            /*System.out.println("phto " + firstExifDate); 
     
    10171013            tfTimezone.getDocument().removeDocumentListener(statusBarListener); 
    10181014            tfOffset.getDocument().removeDocumentListener(statusBarListener); 
    1019              
     1015 
    10201016            tfTimezone.setText(formatTimezone(timezone)); 
    10211017            tfOffset.setText(Long.toString(delta)); 
     
    10241020            tfTimezone.getDocument().addDocumentListener(statusBarListener); 
    10251021            tfOffset.getDocument().addDocumentListener(statusBarListener); 
    1026              
     1022 
    10271023            statusBarListener.updateStatusBar(); 
    10281024            yLayer.updateBufferAndRepaint(); 
     
    10331029        return getSortedImgList(cbExifImg.isSelected(), cbTaggedImg.isSelected()); 
    10341030    } 
    1035      
     1031 
    10361032    /** 
    10371033     * Returns a list of images that fulfill the given criteria. 
    10381034     * Default setting is to return untagged images, but may be overwritten. 
    10391035     * @param boolean all -- returns all available images 
    1040      * @param boolean noexif -- returns untagged images without EXIF-GPS coords  
     1036     * @param boolean noexif -- returns untagged images without EXIF-GPS coords 
    10411037     *                          this parameter is irrelevant if <code>all</code> is true 
    10421038     * @param boolean exif -- also returns images with exif-gps info 
     
    10471043        ArrayList<ImageEntry> dateImgLst = new ArrayList<ImageEntry>(yLayer.data.size()); 
    10481044        for (ImageEntry e : yLayer.data) { 
    1049             if (e.time == null) 
     1045            if (e.time == null) { 
    10501046                continue; 
    1051                  
     1047            } 
     1048 
    10521049            if (e.exifCoor != null) { 
    1053                 if (!exif) 
     1050                if (!exif) { 
    10541051                    continue; 
    1055             } 
    1056                  
     1052                } 
     1053            } 
     1054 
    10571055            if (e.isTagged() && e.exifCoor == null) { 
    1058                 if (!tagged) 
     1056                if (!tagged) { 
    10591057                    continue; 
    1060             } 
    1061                  
     1058                } 
     1059            } 
     1060 
    10621061            dateImgLst.add(e); 
    10631062        } 
    1064          
     1063 
    10651064        Collections.sort(dateImgLst, new Comparator<ImageEntry>() { 
    10661065            public int compare(ImageEntry arg0, ImageEntry arg1) { 
     
    12511250 
    12521251    private double parseTimezone(String timezone) throws ParseException { 
    1253   
     1252 
    12541253        String error = tr("Error while parsing timezone.\nExpected format: {0}", "+H:MM"); 
    1255   
    1256   
     1254 
     1255 
    12571256        if (timezone.length() == 0) 
    12581257            return 0; 
     
    13241323    private long parseOffset(String offset) throws ParseException { 
    13251324        String error = tr("Error while parsing offset.\nExpected format: {0}", "number"); 
    1326      
     1325 
    13271326        if (offset.length() > 0) { 
    13281327            try { 
     
    13341333                throw new ParseException(error,0); 
    13351334            } 
    1336         } else { 
     1335        } else 
    13371336            return 0; 
    1338         } 
    13391337    } 
    13401338} 
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r2512 r2676  
    7777        } catch (OsmTransferException e) { 
    7878            throw e; 
    79         } catch (Exception e) { 
     79        } catch (RuntimeException e) { 
    8080            if (cancel) 
    8181                return null; 
    82             if (e instanceof RuntimeException) 
    83                 throw (RuntimeException)e; 
    84             throw new RuntimeException(e); 
     82            throw e; 
    8583        } finally { 
    8684            progressMonitor.finishTask(); 
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r2655 r2676  
    233233    private boolean ParseNMEASentence(String s, NMEAParserState ps) { 
    234234        try { 
    235             if(s.equals("")) throw(null); 
     235            if (s.equals("")) 
     236                throw new NullPointerException(); 
    236237 
    237238            // checksum check: 
     
    444445            return true; 
    445446 
    446         } catch(Exception x) { 
     447        } catch(RuntimeException x) { 
    447448            // out of bounds and such 
    448449            // x.printStackTrace(); 
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r2642 r2676  
    3131 */ 
    3232public class XmlObjectParser implements Iterable<Object> { 
    33     public class PresetParsingException extends SAXException { 
     33    public static class PresetParsingException extends SAXException { 
    3434        private int columnNumber; 
    3535        private int lineNumber; 
     
    110110        public void setDocumentLocator(Locator locator) { 
    111111            this.locator = locator; 
    112         } 
    113  
    114         protected void throwException(String msg) throws PresetParsingException{ 
    115             throw new PresetParsingException(msg).rememberLocation(locator); 
    116112        } 
    117113 
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java

    r1954 r2676  
    1919 
    2020    @Test 
    21     public void TagMergeModel() { 
    22         TagMergeModel model = new TagMergeModel(); 
    23     } 
    24  
    25     @Test 
    2621    public void addPropertyChangeListener() { 
    2722        TagMergeModel model = new TagMergeModel(); 
     
    3328        model.addPropertyChangeListener(listener); 
    3429 
    35         ArrayList list = field("listeners").ofType(ArrayList.class) 
     30        ArrayList<?> list = field("listeners").ofType(ArrayList.class) 
    3631        .in(model) 
    3732        .get(); 
     
    5247        model.removePropertyChangeListener(listener); 
    5348 
    54         ArrayList list = field("listeners") 
     49        ArrayList<?> list = field("listeners") 
    5550        .ofType(ArrayList.class) 
    5651        .in(model) 
Note: See TracChangeset for help on using the changeset viewer.