Changeset 13824 in josm for trunk/src


Ignore:
Timestamp:
2018-05-23T21:03:31+02:00 (15 months ago)
Author:
Don-vip
Message:

SonarQube - fix code style issues

Location:
trunk/src/org/openstreetmap/josm
Files:
16 edited

Legend:

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

    r13783 r13824  
    123123        // Get the list of Launchpad contributors using customary msgid “translator-credits”
    124124        String translators = tr("translator-credits");
    125         if (translators != null && !translators.isEmpty() && !translators.equals("translator-credits")) {
     125        if (translators != null && !translators.isEmpty() && !"translator-credits".equals(translators)) {
    126126            about.addTab(tr("Translators"), createScrollPane(new JosmTextArea(translators)));
    127127        }
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r13741 r13824  
    2525import org.openstreetmap.josm.data.imagery.ImageryInfo;
    2626import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     27import org.openstreetmap.josm.data.imagery.LayerDetails;
    2728import org.openstreetmap.josm.data.imagery.WMTSTileSource;
    2829import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException;
     
    204205
    205206            final String url = wms.buildGetMapUrl(
    206                     tree.getSelectedLayers().stream().map(x -> x.getName()).collect(Collectors.toList()),
     207                    tree.getSelectedLayers().stream().map(LayerDetails::getName).collect(Collectors.toList()),
    207208                    (List<String>) null,
    208209                    (String) formats.getSelectedItem(),
    209                     true // TODO: ask the user if (s)he wants transparent layer
     210                    true // TODO: ask the user if transparent layer is wanted
    210211                    );
    211212
    212213            String selectedLayers = tree.getSelectedLayers().stream()
    213                     .map(x -> x.getName())
     214                    .map(LayerDetails::getName)
    214215                    .collect(Collectors.joining(", "));
    215216            ImageryInfo ret = new ImageryInfo(info.getName() + selectedLayers,
  • trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java

    r13742 r13824  
    126126            if (XMLStreamReader.START_ELEMENT == event) {
    127127                if (level > 0) {
    128                     ret.append("<" + reader.getLocalName() +">");
     128                    ret.append('<').append(reader.getLocalName()).append('>');
    129129                }
    130130                level += 1;
     
    134134                    return ret.toString();
    135135                }
    136                 ret.append("</" + reader.getLocalName() +">");
     136                ret.append("</").append(reader.getLocalName()).append('>');
    137137            } else if (XMLStreamReader.CHARACTERS == event) {
    138138                ret.append(reader.getText());
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r13792 r13824  
    409409            modTileFeatures = i.isModTileFeatures();
    410410            if (!i.defaultLayers.isEmpty()) {
    411                 default_layers = i.defaultLayers.stream().map(x -> x.toJson()).collect(JsonCollectors.toJsonArray()).toString();
     411                default_layers = i.defaultLayers.stream().map(DefaultLayer::toJson).collect(JsonCollectors.toJsonArray()).toString();
    412412            }
    413413            customHttpHeaders = i.customHttpHeaders;
  • trunk/src/org/openstreetmap/josm/data/imagery/LayerDetails.java

    r13818 r13824  
    1515 */
    1616public class LayerDetails {
    17     private Map<String, String> styles = new ConcurrentHashMap<>(); // name -> title
    18     private Collection<String> crs = new ArrayList<>();
     17    private final Map<String, String> styles = new ConcurrentHashMap<>(); // name -> title
     18    private final Collection<String> crs = new ArrayList<>();
    1919    /**
    2020     * The layer name (WMS {@code Title})
     
    3030     */
    3131    private String abstr;
    32     private LayerDetails parentLayer;
     32    private final LayerDetails parentLayer;
    3333    private Bounds bounds;
    3434    private List<LayerDetails> children = new ArrayList<>();
  • trunk/src/org/openstreetmap/josm/data/imagery/WMSEndpointTileSource.java

    r13742 r13824  
    2424 *
    2525 * @author Wiktor Niesiobedzki
    26  *
     26 * @since 13733
    2727 */
    2828public class WMSEndpointTileSource extends AbstractWMSTileSource implements TemplatedTileSource {
    2929
    3030    private final WMSImagery wmsi;
    31     private List<DefaultLayer> layers;
    32     private String urlPattern;
     31    private final List<DefaultLayer> layers;
     32    private final String urlPattern;
    3333    private static final Pattern PATTERN_PARAM = Pattern.compile("\\{([^}]+)\\}");
    3434    private final Map<String, String> headers = new ConcurrentHashMap<>();
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSCapabilities.java

    r13733 r13824  
    1111 *
    1212 * @author Wiktor Niesiobedzki
    13  *
     13 * @since 13733
    1414 */
    1515public class WMTSCapabilities {
    16     private String baseUrl;
    17     private TransferMode transferMode;
     16    private final String baseUrl;
     17    private final TransferMode transferMode;
    1818    private Collection<Layer> layers;
    19 
    2019
    2120    /**
     
    3534    public void addLayers(Collection<Layer> layers) {
    3635        this.layers = layers;
    37 
    3836    }
    3937
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13759 r13824  
    274274
    275275    private static final class SelectLayerDialog extends ExtendedDialog {
    276         private final transient List<Entry<String, List<Layer>>> layers;
    277276        private final WMTSLayerSelection list;
    278277
    279278        SelectLayerDialog(Collection<Layer> layers) {
    280279            super(Main.parent, tr("Select WMTS layer"), tr("Add layers"), tr("Cancel"));
    281             this.layers = groupLayersByNameAndTileMatrixSet(layers);
    282             this.list = new WMTSLayerSelection(this.layers);
     280            this.list = new WMTSLayerSelection(groupLayersByNameAndTileMatrixSet(layers));
    283281            setContent(list);
    284282        }
     
    296294    private TileMatrixSet currentTileMatrixSet;
    297295    private double crsScale;
    298     private GetCapabilitiesParseHelper.TransferMode transferMode;
     296    private final GetCapabilitiesParseHelper.TransferMode transferMode;
    299297
    300298    private ScaleList nativeScaleList;
     
    329327            }
    330328        } else {
    331             this.defaultLayer = info.getDefaultLayers().iterator().next();
     329            this.defaultLayer = info.getDefaultLayers().get(0);
    332330        }
    333331        if (this.layers.isEmpty())
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r13729 r13824  
    251251    @Override
    252252    public void hideNotify() {
    253         undoTreeModel.setRoot(undoRoot = new DefaultMutableTreeNode());
    254         redoTreeModel.setRoot(redoRoot = new DefaultMutableTreeNode());
     253        undoRoot = new DefaultMutableTreeNode();
     254        redoRoot = new DefaultMutableTreeNode();
     255        undoTreeModel.setRoot(undoRoot);
     256        redoTreeModel.setRoot(redoRoot);
    255257        MainApplication.undoRedo.removeCommandQueuePreciseListener(this);
    256258    }
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/WMTSLayerSelection.java

    r13758 r13824  
    8484    }
    8585
    86     private List<Entry<String, List<Layer>>> layers;
    87     private JTable list;
     86    private final List<Entry<String, List<Layer>>> layers;
     87    private final JTable list;
    8888
    8989    /**
    90      *
     90     * Constructs a new {@code WMTSLayerSelection}.
    9191     * @param layers list of grouped layers (by tileMatrixSet and name)
    9292     */
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r13772 r13824  
    2222import org.openstreetmap.josm.data.imagery.ImageryInfo;
    2323import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     24import org.openstreetmap.josm.data.imagery.LayerDetails;
    2425import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
    2526import org.openstreetmap.josm.gui.util.GuiHelper;
     
    154155        if (wms != null && wms.buildRootUrl() != null) {
    155156            wmsUrl.setText(wms.buildGetMapUrl(
    156                     tree.getSelectedLayers().stream().map(x -> x.getName()).collect(Collectors.toList()),
     157                    tree.getSelectedLayers().stream().map(LayerDetails::getName).collect(Collectors.toList()),
    157158                    (List<String>) null,
    158159                    (String) formats.getSelectedItem(),
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMTSLayerPanel.java

    r13773 r13824  
    77import java.io.IOException;
    88import java.util.Collections;
    9 import java.util.List;
    10 import java.util.Map.Entry;
    119
    1210import javax.swing.JButton;
     
    3028 * Panel for adding WMTS imagery sources
    3129 * @author Wiktor Niesiobędzki
    32  *
     30 * @since 8568
    3331 */
    3432public class AddWMTSLayerPanel extends AddImageryPanel {
     
    3634    private transient WMTSLayerSelection layerTable;
    3735    private final JCheckBox setDefaultLayer = new JCheckBox(tr("Set default layer?"));
    38     private List<Entry<String, List<Layer>>> layers;
    39    
    4036
    4137    /**
     
    6864            try {
    6965                WMTSCapabilities capabilities = WMTSTileSource.getCapabilities(rawUrl.getText(), getCommonHeaders());
    70                 layers = WMTSTileSource.groupLayersByNameAndTileMatrixSet(capabilities.getLayers());
    71                 layerTable = new WMTSLayerSelection(layers);
     66                layerTable = new WMTSLayerSelection(WMTSTileSource.groupLayersByNameAndTileMatrixSet(capabilities.getLayers()));
    7267                layerTable.getTable().getSelectionModel().addListSelectionListener(lsl -> {
    7368                    if (layerTable.getSelectedLayer() != null) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/WMSLayerTree.java

    r13734 r13824  
    7676     */
    7777    public void updateTree(WMSImagery wms) {
    78         // treeRootNode = new DefaultMutableTreeNode();
    7978        while (treeRootNode.getChildCount() > 0) {
    8079            treeRootNode.remove(0);
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java

    r13507 r13824  
    170170        Roles lastrole = null;
    171171        final List<Check> checks = new LinkedList<>();
    172         List<ComboMultiSelect.PresetListEntry> listEntries = new LinkedList<>();
     172        final List<ComboMultiSelect.PresetListEntry> listEntries = new LinkedList<>();
    173173        final Map<String, List<Object>> byId = new HashMap<>();
    174174        final Deque<String> lastIds = new ArrayDeque<>();
     
    297297                            ((Key) o).value = ""; // Fix #8530
    298298                        }
    299                         listEntries = new LinkedList<>();
     299                        listEntries.clear();
    300300                        lastrole = null;
    301301                    }
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r13760 r13824  
    4343 */
    4444public class WMSImagery {
    45 
    4645
    4746    private static final String CAPABILITIES_QUERY_STRING = "SERVICE=WMS&REQUEST=GetCapabilities";
     
    120119    }
    121120
    122     private Map<String, String> headers = new ConcurrentHashMap<>();
     121    private final Map<String, String> headers = new ConcurrentHashMap<>();
    123122    private String version = "1.1.1"; // default version
    124123    private String getMapUrl;
    125124    private URL capabilitiesUrl;
    126     private List<String> formats = new ArrayList<>();
     125    private final List<String> formats = new ArrayList<>();
    127126    private List<LayerDetails> layers = new ArrayList<>();
    128127
     
    283282        return buildGetMapUrl(
    284283                getLayers(selectedLayers),
    285                 selectedLayers.stream().map(x -> x.getStyle()).collect(Collectors.toList()),
     284                selectedLayers.stream().map(DefaultLayer::getStyle).collect(Collectors.toList()),
    286285                transparent);
    287286    }
     
    296295    public String buildGetMapUrl(List<LayerDetails> selectedLayers, List<String> selectedStyles, boolean transparent) {
    297296        return buildGetMapUrl(
    298                 selectedLayers.stream().map(x -> x.getName()).collect(Collectors.toList()),
     297                selectedLayers.stream().map(LayerDetails::getName).collect(Collectors.toList()),
    299298                selectedStyles,
    300299                getPreferredFormat(),
     
    504503     */
    505504    public boolean belowWMS130() {
    506         return this.version.equals("1.1.1") || this.version.equals("1.1") || this.version.equals("1.0");
     505        return "1.1.1".equals(version) || "1.1".equals(version) || "1.0".equals(version);
    507506    }
    508507
     
    569568    }
    570569
    571     private Bounds parseBBox(Projection conv, String miny, String minx, String maxy, String maxx) {
     570    private static Bounds parseBBox(Projection conv, String miny, String minx, String maxy, String maxx) {
    572571        if (miny == null || minx == null || maxy == null || maxx == null) {
    573572            return null;
     
    592591    }
    593592
    594     private String normalizeUrl(String serviceUrlStr) throws MalformedURLException {
     593    private static String normalizeUrl(String serviceUrlStr) throws MalformedURLException {
    595594        URL getCapabilitiesUrl = null;
    596595        String ret = null;
     
    683682    }
    684683
    685 
    686684    /**
    687685     * @param defaultLayers default layers that should select layer object
     
    689687     */
    690688    public List<LayerDetails> getLayers(List<DefaultLayer> defaultLayers) {
    691         Collection<String> layerNames = defaultLayers.stream().map(x -> x.getLayerName()).collect(Collectors.toList());
     689        Collection<String> layerNames = defaultLayers.stream().map(DefaultLayer::getLayerName).collect(Collectors.toList());
    692690        return layers.stream()
    693691                .flatMap(LayerDetails::flattened)
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r13823 r13824  
    11751175    }
    11761176
    1177     private URL getImageUrl(String path, String name) {
     1177    private static URL getImageUrl(String path, String name) {
    11781178        if (path != null && path.startsWith("resource://")) {
    11791179            String p = path.substring("resource://".length());
     
    17781778     * @param enforceTransparency if {@code true}, makes sure to read image metadata and, if the image does not
    17791779     * provide an alpha channel but defines a {@code TransparentColor} metadata node, that the resulting image
    1780      * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color. For Java < 11 only.
     1780     * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color. For Java &lt; 11 only.
    17811781     *
    17821782     * @return a <code>BufferedImage</code> containing the decoded
Note: See TracChangeset for help on using the changeset viewer.