Ignore:
Timestamp:
2015-06-20T23:42:21+02:00 (9 years ago)
Author:
Don-vip
Message:

checkstyle: enable relevant whitespace checks and fix them

Location:
trunk/src/org/openstreetmap/josm/gui/download
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java

    r8509 r8510  
    4545        public Bookmark(Collection<String> list) {
    4646            List<String> array = new ArrayList<>(list);
    47             if(array.size() < 5)
     47            if (array.size() < 5)
    4848                throw new IllegalArgumentException(tr("Wrong number of arguments for bookmark"));
    4949            name = array.get(0);
     
    155155     */
    156156    public final void load() {
    157         DefaultListModel<Bookmark> model = (DefaultListModel<Bookmark>)getModel();
     157        DefaultListModel<Bookmark> model = (DefaultListModel<Bookmark>) getModel();
    158158        model.removeAllElements();
    159159        Collection<Collection<String>> args = Main.pref.getArray("bookmarks", null);
    160         if(args != null) {
     160        if (args != null) {
    161161            List<Bookmark> bookmarks = new LinkedList<>();
    162             for(Collection<String> entry : args) {
     162            for (Collection<String> entry : args) {
    163163                try {
    164164                    bookmarks.add(new Bookmark(entry));
     
    179179    public final void save() {
    180180        List<Collection<String>> coll = new LinkedList<>();
    181         for (Object o : ((DefaultListModel<Bookmark>)getModel()).toArray()) {
     181        for (Object o : ((DefaultListModel<Bookmark>) getModel()).toArray()) {
    182182            String[] array = new String[5];
    183183            Bookmark b = (Bookmark) o;
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java

    r7029 r8510  
    8585        GridBagConstraints  gc = new GridBagConstraints();
    8686        gc.anchor = GridBagConstraints.NORTHWEST;
    87         gc.insets = new Insets(5,5,5,5);
     87        gc.insets = new Insets(5, 5, 5, 5);
    8888        pnl.add(lblCurrentDownloadArea = new JMultilineLabel(""), gc);
    8989
     
    9999        gc.weightx = 0.0;
    100100        gc.weighty = 0.0;
    101         gc.insets = new Insets(5,5,5,5);
     101        gc.insets = new Insets(5, 5, 5, 5);
    102102        pnl.add(new JButton(actAdd = new AddAction()), gc);
    103103        return pnl;
     
    116116                Bookmark b = bookmarks.getSelectedValue();
    117117                if (b != null) {
    118                     gui.boundingBoxChanged(b.getArea(),BookmarkSelection.this);
     118                    gui.boundingBoxChanged(b.getArea(), BookmarkSelection.this);
    119119                }
    120120            }
     
    126126        gc.weighty = 0.0;
    127127        gc.gridwidth = 2;
    128         dlg.add(buildDownloadAreaAddPanel(),gc);
     128        dlg.add(buildDownloadAreaAddPanel(), gc);
    129129
    130130        gc.gridwidth = 1;
     
    134134        gc.weightx = 0.0;
    135135        gc.weighty = 1.0;
    136         dlg.add(buildButtonPanel(),gc);
     136        dlg.add(buildButtonPanel(), gc);
    137137
    138138        gc.gridwidth = 1;
     
    196196            b.setName(
    197197                    JOptionPane.showInputDialog(
    198                             Main.parent,tr("Please enter a name for the bookmarked download area."),
     198                            Main.parent, tr("Please enter a name for the bookmarked download area."),
    199199                            tr("Name of location"),
    200200                            JOptionPane.QUESTION_MESSAGE)
     
    202202            b.setArea(currentArea);
    203203            if (b.getName() != null && !b.getName().isEmpty()) {
    204                 ((DefaultListModel<BookmarkList.Bookmark>)bookmarks.getModel()).addElement(b);
     204                ((DefaultListModel<BookmarkList.Bookmark>) bookmarks.getModel()).addElement(b);
    205205                bookmarks.save();
    206206            }
     
    209209
    210210    class RemoveAction extends AbstractAction implements ListSelectionListener{
     211        /**
     212         * Constructs a new {@code RemoveAction}.
     213         */
    211214        public RemoveAction() {
    212215            putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
     
    221224                return;
    222225            for (Object sel: sels) {
    223                 ((DefaultListModel<Bookmark>)bookmarks.getModel()).removeElement(sel);
     226                ((DefaultListModel<Bookmark>) bookmarks.getModel()).removeElement(sel);
    224227            }
    225228            bookmarks.save();
     
    229232            setEnabled(bookmarks.getSelectedIndices().length > 0);
    230233        }
     234
    231235        @Override
    232236        public void valueChanged(ListSelectionEvent e) {
     
    235239    }
    236240
    237     class RenameAction extends AbstractAction implements ListSelectionListener{
     241    class RenameAction extends AbstractAction implements ListSelectionListener {
     242        /**
     243         * Constructs a new {@code RenameAction}.
     244         */
    238245        public RenameAction() {
    239246            putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));
     
    250257            Object value =
    251258                JOptionPane.showInputDialog(
    252                         Main.parent,tr("Please enter a name for the bookmarked download area."),
     259                        Main.parent, tr("Please enter a name for the bookmarked download area."),
    253260                        tr("Name of location"),
    254261                        JOptionPane.QUESTION_MESSAGE,
  • trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java

    r8444 r8510  
    5757    protected void buildDownloadAreaInputFields() {
    5858        latlon = new JosmTextField[4];
    59         for(int i=0; i< 4; i++) {
     59        for (int i = 0; i < 4; i++) {
    6060            latlon[i] = new JosmTextField(11);
    61             latlon[i].setMinimumSize(new Dimension(100,new JosmTextField().getMinimumSize().height));
     61            latlon[i].setMinimumSize(new Dimension(100, new JosmTextField().getMinimumSize().height));
    6262            latlon[i].addFocusListener(new SelectAllOnFocusHandler(latlon[i]));
    6363        }
     
    9595        tfOsmUrl.setBorder(latlon[0].getBorder());
    9696
    97         dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10,20,5,0));
    98         dlg.add(latlon[0], GBC.std().insets(0,20,0,0));
    99         dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10,20,5,0));
    100         dlg.add(latlon[1], GBC.eol().insets(0,20,0,0));
    101         dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10,0,5,0));
     97        dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20, 5, 0));
     98        dlg.add(latlon[0], GBC.std().insets(0, 20, 0, 0));
     99        dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20, 5, 0));
     100        dlg.add(latlon[1], GBC.eol().insets(0, 20, 0, 0));
     101        dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0, 5, 0));
    102102        dlg.add(latlon[2], GBC.std());
    103         dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10,0,5,0));
     103        dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0, 5, 0));
    104104        dlg.add(latlon[3], GBC.eol());
    105105
     
    111111            }
    112112        });
    113         dlg.add(btnClear, GBC.eol().insets(10,20,0,0));
    114 
    115         dlg.add(new JLabel(tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")), GBC.eol().insets(10,5,5,0));
    116         dlg.add(tfOsmUrl, GBC.eop().insets(10,0,5,0).fill());
    117         dlg.add(showUrl, GBC.eop().insets(10,0,5,5));
     113        dlg.add(btnClear, GBC.eol().insets(10, 20, 0, 0));
     114
     115        dlg.add(new JLabel(tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")),
     116                GBC.eol().insets(10, 5, 5, 0));
     117        dlg.add(tfOsmUrl, GBC.eop().insets(10, 0, 5, 0).fill());
     118        dlg.add(showUrl, GBC.eop().insets(10, 0, 5, 5));
    118119        showUrl.setEditable(false);
    119120        showUrl.setBackground(dlg.getBackground());
     
    136137    public Bounds getDownloadArea() {
    137138        double[] values = new double[4];
    138         for (int i=0; i < 4; i++) {
     139        for (int i = 0; i < 4; i++) {
    139140            try {
    140141                values[i] = Double.parseDouble(latlon[i].getText());
    141             } catch(NumberFormatException x) {
     142            } catch (NumberFormatException x) {
    142143                return null;
    143144            }
     
    152153    private boolean parseURL(DownloadDialog gui) {
    153154        Bounds b = OsmUrlToBounds.parse(tfOsmUrl.getText());
    154         if(b == null) return false;
    155         gui.boundingBoxChanged(b,BoundingBoxSelection.this);
     155        if (b == null) return false;
     156        gui.boundingBoxChanged(b, BoundingBoxSelection.this);
    156157        updateBboxFields(b);
    157158        updateUrl(b);
     
    198199            try {
    199200                value = Double.parseDouble(tfLatValue.getText());
    200             } catch(NumberFormatException ex) {
    201                 setErrorMessage(tfLatValue,tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText()));
     201            } catch (NumberFormatException ex) {
     202                setErrorMessage(tfLatValue, tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText()));
    202203                return;
    203204            }
    204205            if (!LatLon.isValidLat(value)) {
    205                 setErrorMessage(tfLatValue,tr("Value for latitude in range [-90,90] required.", tfLatValue.getText()));
     206                setErrorMessage(tfLatValue, tr("Value for latitude in range [-90,90] required.", tfLatValue.getText()));
    206207                return;
    207208            }
     
    231232            try {
    232233                value = Double.parseDouble(tfLonValue.getText());
    233             } catch(NumberFormatException ex) {
    234                 setErrorMessage(tfLonValue,tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText()));
     234            } catch (NumberFormatException ex) {
     235                setErrorMessage(tfLonValue, tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText()));
    235236                return;
    236237            }
    237238            if (!LatLon.isValidLon(value)) {
    238                 setErrorMessage(tfLonValue,tr("Value for longitude in range [-180,180] required.", tfLonValue.getText()));
     239                setErrorMessage(tfLonValue, tr("Value for longitude in range [-180,180] required.", tfLonValue.getText()));
    239240                return;
    240241            }
     
    255256    static class SelectAllOnFocusHandler extends FocusAdapter {
    256257        private JTextComponent tfTarget;
     258
    257259        public SelectAllOnFocusHandler(JTextComponent tfTarget) {
    258260            this.tfTarget = tfTarget;
     
    267269    class OsmUrlRefresher implements DocumentListener {
    268270        @Override
    269         public void changedUpdate(DocumentEvent e) { parseURL(parent); }
    270         @Override
    271         public void insertUpdate(DocumentEvent e) { parseURL(parent); }
    272         @Override
    273         public void removeUpdate(DocumentEvent e) { parseURL(parent); }
     271        public void changedUpdate(DocumentEvent e) {
     272            parseURL(parent);
     273        }
     274
     275        @Override
     276        public void insertUpdate(DocumentEvent e) {
     277            parseURL(parent);
     278        }
     279
     280        @Override
     281        public void removeUpdate(DocumentEvent e) {
     282            parseURL(parent);
     283        }
    274284    }
    275285
    276286    class BoundingBoxBuilder extends FocusAdapter implements ActionListener {
    277287        protected Bounds build() {
    278             double minlon, minlat, maxlon,maxlat;
     288            double minlon, minlat, maxlon, maxlat;
    279289            try {
    280290                minlat = Double.parseDouble(latlon[0].getText().trim());
     
    282292                maxlat = Double.parseDouble(latlon[2].getText().trim());
    283293                maxlon = Double.parseDouble(latlon[3].getText().trim());
    284             } catch(NumberFormatException e) {
     294            } catch (NumberFormatException e) {
    285295                return null;
    286296            }
     
    292302            if (minlat > maxlat)
    293303                return null;
    294             return new Bounds(minlat,minlon,maxlat,maxlon);
     304            return new Bounds(minlat, minlon, maxlat, maxlon);
    295305        }
    296306
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r8509 r8510  
    8686
    8787    private void makeCheckBoxRespondToEnter(JCheckBox cb) {
    88         cb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "doDownload");
     88        cb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "doDownload");
    8989        cb.getActionMap().put("doDownload", actDownload);
    9090    }
     
    103103
    104104        // adding the download tasks
    105         pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5,5,1,5));
     105        pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5, 5, 1, 5));
    106106        cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), true);
    107107        cbDownloadOsmData.setToolTipText(tr("Select to download OSM data in the selected download area."));
     
    156156        cbStartup = new JCheckBox(tr("Open this dialog on startup"));
    157157        cbStartup.setToolTipText(
    158                 tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>You can open it manually from File menu or toolbar.</html>"));
     158                tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>" +
     159                        "You can open it manually from File menu or toolbar.</html>"));
    159160        cbStartup.addActionListener(new ActionListener() {
    160161            @Override
     
    163164            }});
    164165
    165         pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5,5,5,5));
    166         pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15,5,5,5));
    167 
    168         pnl.add(sizeCheck,  GBC.eol().anchor(GBC.EAST).insets(5,5,5,2));
     166        pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
     167        pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));
     168
     169        pnl.add(sizeCheck,  GBC.eol().anchor(GBC.EAST).insets(5, 5, 5, 2));
    169170
    170171        if (!ExpertToggleAction.isExpert()) {
    171172            JLabel infoLabel  = new JLabel(
    172173                    tr("Use left click&drag to select area, arrows or right mouse button to scroll map, wheel or +/- to zoom."));
    173             pnl.add(infoLabel,GBC.eol().anchor(GBC.SOUTH).insets(0,0,0,0));
     174            pnl.add(infoLabel, GBC.eol().anchor(GBC.SOUTH).insets(0, 0, 0, 0));
    174175        }
    175176        return pnl;
     
    203204
    204205        // -- cancel on ESC
    205         getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), "cancel");
     206        getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
    206207        getRootPane().getActionMap().put("cancel", actCancel);
    207208
     
    219220     */
    220221    public DownloadDialog(Component parent) {
    221         super(JOptionPane.getFrameForComponent(parent),tr("Download"), ModalityType.DOCUMENT_MODAL);
     222        super(JOptionPane.getFrameForComponent(parent), tr("Download"), ModalityType.DOCUMENT_MODAL);
    222223        getContentPane().setLayout(new BorderLayout());
    223224        getContentPane().add(buildMainPanel(), BorderLayout.CENTER);
     
    382383                    mv.getLatLon(mv.getWidth(), 0)
    383384            );
    384             boundingBoxChanged(currentBounds,null);
     385            boundingBoxChanged(currentBounds, null);
    385386        } else {
    386387            Bounds bounds = getSavedDownloadBounds();
     
    414415     */
    415416    public static boolean isAutorunEnabled() {
    416         return Main.pref.getBoolean("download.autorun",false);
     417        return Main.pref.getBoolean("download.autorun", false);
    417418    }
    418419
     
    438439                    WindowGeometry.centerInWindow(
    439440                            getParent(),
    440                             new Dimension(1000,600)
     441                            new Dimension(1000, 600)
    441442                    )
    442443            ).applySafe(this);
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r8464 r8510  
    7575    private DownloadDialog parent;
    7676    private static final Server[] SERVERS = new Server[] {
    77         new Server("Nominatim","https://nominatim.openstreetmap.org/search?format=xml&q=",tr("Class Type"),tr("Bounds"))
     77        new Server("Nominatim", "https://nominatim.openstreetmap.org/search?format=xml&q=", tr("Class Type"), tr("Bounds"))
    7878    };
    7979    private final JosmComboBox<Server> server = new JosmComboBox<>(SERVERS);
    8080
    8181    private static class Server {
    82         public String name;
    83         public String url;
    84         public String thirdcol;
    85         public String fourthcol;
    86         @Override
    87         public String toString() {
    88             return name;
    89         }
     82        public final String name;
     83        public final String url;
     84        public final String thirdcol;
     85        public final String fourthcol;
     86
    9087        public Server(String n, String u, String t, String f) {
    9188            name = n;
     
    9491            fourthcol = f;
    9592        }
     93
     94        @Override
     95        public String toString() {
     96            return name;
     97        }
    9698    }
    9799
    98100    protected JPanel buildSearchPanel() {
    99101        JPanel lpanel = new JPanel();
    100         lpanel.setLayout(new GridLayout(2,2));
     102        lpanel.setLayout(new GridLayout(2, 2));
    101103        JPanel panel = new JPanel();
    102104        panel.setLayout(new GridBagLayout());
     
    122124        SearchAction searchAction = new SearchAction();
    123125        JButton btnSearch = new JButton(searchAction);
    124         ((JTextField)cbSearchExpression.getEditor().getEditorComponent()).getDocument().addDocumentListener(searchAction);
    125         ((JTextField)cbSearchExpression.getEditor().getEditorComponent()).addActionListener(searchAction);
     126        ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).getDocument().addDocumentListener(searchAction);
     127        ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).addActionListener(searchAction);
    126128
    127129        panel.add(btnSearch, GBC.eol().insets(5, 5, 0, 5));
     
    147149        tblSearchResults.setSelectionModel(selectionModel);
    148150        JScrollPane scrollPane = new JScrollPane(tblSearchResults);
    149         scrollPane.setPreferredSize(new Dimension(200,200));
     151        scrollPane.setPreferredSize(new Dimension(200, 200));
    150152        panel.add(scrollPane, BorderLayout.CENTER);
    151153
     
    216218                    currentResult.name = atts.getValue("name");
    217219                    currentResult.info = atts.getValue("info");
    218                     if(currentResult.info != null) {
     220                    if (currentResult.info != null) {
    219221                        currentResult.info = tr(currentResult.info);
    220222                    }
     
    288290        public SearchAction() {
    289291            putValue(NAME, tr("Search ..."));
    290             putValue(SMALL_ICON, ImageProvider.get("dialogs","search"));
     292            putValue(SMALL_ICON, ImageProvider.get("dialogs", "search"));
    291293            putValue(SHORT_DESCRIPTION, tr("Click to start searching for places"));
    292294            updateEnabledState();
     
    333335
    334336        public NameQueryTask(String searchExpression) {
    335             super(tr("Querying name server"),false /* don't ignore exceptions */);
     337            super(tr("Querying name server"), false /* don't ignore exceptions */);
    336338            this.searchExpression = searchExpression;
    337             useserver = (Server)server.getSelectedItem();
     339            useserver = (Server) server.getSelectedItem();
    338340            Main.pref.put("namefinder.server", useserver.name);
    339341        }
     
    368370                getProgressMonitor().indeterminateSubTask(tr("Querying name server ..."));
    369371                URL url = new URL(urlString);
    370                 synchronized(this) {
     372                synchronized (this) {
    371373                    connection = Utils.openHttpConnection(url);
    372374                }
    373                 connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000);
     375                connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);
    374376                try (
    375377                    InputStream inputStream = connection.getInputStream();
     
    415417            this.selectionModel = selectionModel;
    416418        }
     419
    417420        @Override
    418421        public int getRowCount() {
     
    435438            fireTableDataChanged();
    436439        }
     440
    437441        @Override
    438442        public boolean isCellEditable(int row, int column) {
     
    486490            addColumn(col4);
    487491        }
     492
    488493        public void setHeadlines(String third, String fourth) {
    489494            col3.setHeaderValue(third);
     
    509514    static class NamedResultCellRenderer extends JLabel implements TableCellRenderer {
    510515
     516        /**
     517         * Constructs a new {@code NamedResultCellRenderer}.
     518         */
    511519        public NamedResultCellRenderer() {
    512520            setOpaque(true);
    513             setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
     521            setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    514522        }
    515523
     
    533541            StringBuilder line = new StringBuilder();
    534542            StringTokenizer tok = new StringTokenizer(description, " ");
    535             while(tok.hasMoreElements()) {
     543            while (tok.hasMoreElements()) {
    536544                String t = tok.nextToken();
    537545                if (line.length() == 0) {
     
    570578                break;
    571579            case 3:
    572                 if(sr.bounds != null) {
     580                if (sr.bounds != null) {
    573581                    setText(sr.bounds.toShortString(new DecimalFormat("0.000")));
    574582                } else {
  • trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java

    r8342 r8510  
    5252        if (evt.getPropertyName().equals(BBoxChooser.BBOX_PROP)) {
    5353            if (iGui != null) {
    54                 iGui.boundingBoxChanged((Bounds)evt.getNewValue(), this);
     54                iGui.boundingBoxChanged((Bounds) evt.getNewValue(), this);
    5555            }
    56         } else if(evt.getPropertyName().equals(SlippyMapBBoxChooser.RESIZE_PROP)) {
     56        } else if (evt.getPropertyName().equals(SlippyMapBBoxChooser.RESIZE_PROP)) {
    5757            int w, h;
    5858
  • trunk/src/org/openstreetmap/josm/gui/download/TileSelection.java

    r8378 r8510  
    4949    public void propertyChange(PropertyChangeEvent evt) {
    5050        if (evt.getPropertyName().equals(BBoxChooser.BBOX_PROP)) {
    51             Bounds bbox = (Bounds)evt.getNewValue();
     51            Bounds bbox = (Bounds) evt.getNewValue();
    5252            parent.boundingBoxChanged(bbox, this);
    5353        }
Note: See TracChangeset for help on using the changeset viewer.