Changeset 15497 in josm


Ignore:
Timestamp:
2019-11-02T16:28:02+01:00 (4 years ago)
Author:
Don-vip
Message:

see #16796 - fix most of checkstyle/pmd/findbugs violations

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r15496 r15497  
    132132
    133133    /** rename keys that equal */
    134     private final static Map<String, String> UPDATE_PREF_KEYS = getUpdatePrefKeys();
     134    private static final Map<String, String> UPDATE_PREF_KEYS = getUpdatePrefKeys();
    135135
    136136    private static Map<String, String> getUpdatePrefKeys() {
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r15496 r15497  
    12081208         * Creates a schema with prefix, URI and location.
    12091209         * Does NOT try to determine prefix from URI!
    1210          * @param prefix
    1211          * @param uri
    1212          * @param location
     1210         * @param prefix XML namespace prefix
     1211         * @param uri XML namespace URI
     1212         * @param location XML namespace location
    12131213         */
    12141214        public XMLNamespace(String prefix, String uri, String location) {
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java

    r15496 r15497  
    1212 * @since 15496
    1313 */
    14 public class GpxExtension extends WithAttributes implements IWithAttributes, GpxConstants {
     14public class GpxExtension extends WithAttributes implements GpxConstants {
    1515    private final String qualifiedName, prefix, key;
    1616    private IWithAttributes parent;
     
    6060    /**
    6161     * Finds the default prefix used by JOSM for the given namespaceURI as the document is free specify another one.
    62      * @param namespaceURI
     62     * @param namespaceURI namespace URI
    6363     * @return the prefix
    6464     */
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java

    r15496 r15497  
    2020 */
    2121public class GpxExtensionCollection extends ArrayList<GpxExtension> {
     22
     23    private static final long serialVersionUID = 1L;
    2224
    2325    private Stack<GpxExtension> childStack = new Stack<>();
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r15496 r15497  
    9595
    9696    private void setColorExtension(Color color) {
    97         getExtensions().findAndRemove("gpxx",  "DisplayColor");
     97        getExtensions().findAndRemove("gpxx", "DisplayColor");
    9898        if (color == null) {
    99             getExtensions().findAndRemove("gpxd",  "color");
     99            getExtensions().findAndRemove("gpxd", "color");
    100100        } else {
    101101            getExtensions().addOrUpdate("gpxd", "color", String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue()));
  • trunk/src/org/openstreetmap/josm/data/gpx/IGpxTrack.java

    r15496 r15497  
    4242    /**
    4343     * Sets the color of this track. Not necessarily supported by all implementations.
    44      * @param color
     44     * @param color color of this track
    4545     * @since 15496
    4646     */
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r15496 r15497  
    175175     * Will not be saved to .osm files, but that's not necessary because GPX files won't automatically be overridden after that.
    176176     */
    177     private List<XMLNamespace> GPXNamespaces;
     177    private List<XMLNamespace> gpxNamespaces;
    178178
    179179    /**
     
    12061206     */
    12071207    public List<XMLNamespace> getGPXNamespaces() {
    1208         return GPXNamespaces;
     1208        return gpxNamespaces;
    12091209    }
    12101210
    12111211    /**
    12121212     * Sets the GPX (XML) namespaces
    1213      * @param GPXNamespaces the GPXNamespaces to set
    1214      */
    1215     public void setGPXNamespaces(List<XMLNamespace> GPXNamespaces) {
    1216         this.GPXNamespaces = GPXNamespaces;
     1213     * @param gpxNamespaces the GPXNamespaces to set
     1214     */
     1215    public void setGPXNamespaces(List<XMLNamespace> gpxNamespaces) {
     1216        this.gpxNamespaces = gpxNamespaces;
    12171217    }
    12181218
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxExporter.java

    r15496 r15497  
    195195
    196196        garmin.addActionListener(l -> {
    197             if (garmin.isSelected() &&
    198                     !ConditionalOptionPaneUtil.showConfirmationDialog(
    199                             "gpx_color_garmin",
    200                             ed,
    201                             new JLabel(tr("<html>Garmin track extensions only support 16 colors.<br>If you continue, the closest supported track color will be used.</html>")),
    202                             tr("Information"),
    203                             JOptionPane.OK_CANCEL_OPTION,
    204                             JOptionPane.INFORMATION_MESSAGE,
    205                             JOptionPane.OK_OPTION)) {
     197            if (garmin.isSelected() && !ConditionalOptionPaneUtil.showConfirmationDialog(
     198                    "gpx_color_garmin",
     199                    ed,
     200                    new JLabel("<html>" + tr("Garmin track extensions only support 16 colors.") + "<br>"
     201                                        + tr("If you continue, the closest supported track color will be used.")
     202                             + "</html>"),
     203                    tr("Information"),
     204                    JOptionPane.OK_CANCEL_OPTION,
     205                    JOptionPane.INFORMATION_MESSAGE,
     206                    JOptionPane.OK_OPTION)) {
    206207                garmin.setSelected(false);
    207208            }
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r15496 r15497  
    306306        if (Logging.isDebugEnabled() && !data.getLayerPrefs().isEmpty()) {
    307307            info.append("<br><br>")
    308                 .append(String.join("<br>", data.getLayerPrefs().entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList())));
     308                .append(String.join("<br>", data.getLayerPrefs().entrySet().stream()
     309                        .map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList())));
    309310        }
    310311
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ConvertFromGpxLayerAction.java

    r15496 r15497  
    149149                    pre = "other";
    150150                }
    151                 String segpre = seg ? "segment:" : ""; //needs to be distinguished since both track and segment extensions are applied to the resulting way
     151                // needs to be distinguished since both track and segment extensions are applied to the resulting way
     152                String segpre = seg ? "segment:" : "";
    152153                String key = ext.getFlatKey();
    153154                String fullkey = GpxConstants.GPX_PREFIX + extpre + pre + ":" + segpre + key;
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java

    r15496 r15497  
    7676    @Override
    7777    public void actionPerformed(ActionEvent e) {
    78         GPXSettingsPanel panel = new GPXSettingsPanel(layers.stream().filter(l -> l instanceof GpxLayer).map(l -> (GpxLayer) l).collect(Collectors.toList()));
     78        GPXSettingsPanel panel = new GPXSettingsPanel(
     79                layers.stream().filter(l -> l instanceof GpxLayer).map(l -> (GpxLayer) l).collect(Collectors.toList()));
    7980        JScrollPane scrollpane = GuiHelper.embedInVerticalScrollPane(panel);
    8081        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r13475 r15497  
    6565
    6666        String labelText = getText();
    67         if (labelText != null && Config.getPref().getBoolean("marker.buttonlabels", true)) {
     67        if (!labelText.isEmpty() && Config.getPref().getBoolean("marker.buttonlabels", true)) {
    6868            g.drawString(labelText, screen.x+4, screen.y+2);
    6969        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r15496 r15497  
    279279
    280280        String labelText = getText();
    281         if ((labelText != null) && showTextOrIcon) {
     281        if (!labelText.isEmpty() && showTextOrIcon) {
    282282            g.drawString(labelText, screen.x+4, screen.y+2);
    283283        }
     
    321321    private String getDefaultTextTemplate() {
    322322        if (cachedDefaultTemplate == null) {
    323             cachedDefaultTemplate = GPXSettingsPanel.getLayerPref(null,  getTextTemplateKey());
     323            cachedDefaultTemplate = GPXSettingsPanel.getLayerPref(null, getTextTemplateKey());
    324324        }
    325325        return cachedDefaultTemplate;
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    r15496 r15497  
    104104    private final boolean hasNonLocalFile; // flag to display AllLines checkbox
    105105
    106     private final static Map<String, Object> DEFAULT_PREFS = getDefaultPrefs();
     106    private static final Map<String, Object> DEFAULT_PREFS = getDefaultPrefs();
    107107
    108108    private static Map<String, Object> getDefaultPrefs() {
     
    263263     */
    264264    public static void putLayerPrefLocal(GpxData data, String key, String value) {
    265         if (value == null || value.trim().isEmpty() || (getLayerPref(null, key).equals(value) && DEFAULT_PREFS.get(key) != null && DEFAULT_PREFS.get(key).toString().equals(value))) {
     265        if (value == null || value.trim().isEmpty() ||
     266                (getLayerPref(null, key).equals(value) && DEFAULT_PREFS.get(key) != null && DEFAULT_PREFS.get(key).toString().equals(value))) {
    266267            data.getLayerPrefs().remove(key);
    267268        } else {
  • trunk/src/org/openstreetmap/josm/gui/util/StayOpenPopupMenu.java

    r15492 r15497  
    5353        if (PlatformManager.isPlatformOsx()) {
    5454            try {
    55                 Class<?> AppContextClass = Class.forName("sun.awt.AppContext");
    56                 Field tableField = AppContextClass.getDeclaredField("table");
     55                Class<?> appContextClass = Class.forName("sun.awt.AppContext");
     56                Field tableField = appContextClass.getDeclaredField("table");
    5757                ReflectionUtils.setObjectsAccessible(tableField);
    5858                Object mouseGrabber = null;
    5959                for (Entry<?, ?> e : ((Map<?, ?>)
    60                         tableField.get(AppContextClass.getMethod("getAppContext").invoke(AppContextClass))).entrySet()) {
     60                        tableField.get(appContextClass.getMethod("getAppContext").invoke(appContextClass))).entrySet()) {
    6161                    if (MOUSE_GRABBER_KEY.equals(Objects.toString(e.getKey()))) {
    6262                        mouseGrabber = e.getValue();
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r15496 r15497  
    264264                    currentState = State.EXT;
    265265                    break;
     266                default: // Do nothing
    266267                }
    267268                break;
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r15496 r15497  
    128128        out.println("<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"");
    129129
    130         String schemaLocations = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd";
     130        StringBuilder schemaLocations = new StringBuilder("http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
    131131
    132132        for (XMLNamespace n : namespaces) {
     
    134134                out.println(String.format("    xmlns:%s=\"%s\"", n.getPrefix(), n.getURI()));
    135135                if (n.getLocation() != null) {
    136                     schemaLocations += " " + n.getURI() + " " + n.getLocation();
     136                    schemaLocations.append(' ').append(n.getURI()).append(' ').append(n.getLocation());
    137137                }
    138138            }
     
    394394                // but otherwise the file is invalid and can't even be parsed by SAX anymore
    395395                String k = (e.getPrefix().isEmpty() ? "" : e.getPrefix() + ":") + e.getKey();
    396                 String attr = String.join(" ", e.getAttributes().entrySet().stream().map(a -> encode(a.getKey()) + "=\"" + encode(a.getValue().toString()) + "\"").sorted().collect(Collectors.toList()));
     396                String attr = String.join(" ", e.getAttributes().entrySet().stream()
     397                        .map(a -> encode(a.getKey()) + "=\"" + encode(a.getValue().toString()) + "\"").sorted().collect(Collectors.toList()));
    397398                if (e.getValue() == null && e.getExtensions().isEmpty()) {
    398399                    inline(k, attr);
  • trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java

    r15496 r15497  
    480480        EqualsVerifier.forClass(GpxData.class).usingGetClass()
    481481            .suppress(Warning.NONFINAL_FIELDS)
    482             .withIgnoredFields("creator", "fromServer", "storageFile", "initializing", "updating", "suppressedInvalidate", "listeners", "tracks", "routes", "waypoints", "proxy", "segSpans", "modified")
     482            .withIgnoredFields("creator", "fromServer", "storageFile", "initializing", "updating",
     483                    "suppressedInvalidate", "listeners", "tracks", "routes", "waypoints", "proxy", "segSpans", "modified")
    483484            .withPrefabValues(WayPoint.class, new WayPoint(LatLon.NORTH_POLE), new WayPoint(LatLon.SOUTH_POLE))
    484485            .withPrefabValues(ListenerList.class, ListenerList.create(), ListenerList.create())
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java

    r15496 r15497  
    4545                "<html>Select all tracks that you want to be displayed. " +
    4646                        "You can drag select a range of tracks or use CTRL+Click to select specific ones. " +
    47                         "The map is updated live in the background. Open the URLs by double clicking them, edit name and description by double clicking the cell.</html>",
     47                        "The map is updated live in the background. "+
     48                        "Open the URLs by double clicking them, edit name and description by double clicking the cell.</html>",
    4849                        "Show all"
    4950                );
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java

    r15496 r15497  
    141141
    142142        List<String> ways = osm.getWays().stream()
    143                 .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList()).toString())
     143                .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream()
     144                        .sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList()).toString())
    144145                .sorted()
    145146                .collect(Collectors.toList());
    146147
    147148        List<String> waysExpected = osmExpected.getWays().stream()
    148                 .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList()).toString())
     149                .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream()
     150                        .sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList()).toString())
    149151                .sorted()
    150152                .collect(Collectors.toList());
     
    152154        assertEquals("Conversion " + originalGpx + " -> " + expectedOsm + " didn't match!", waysExpected, ways);
    153155
    154         assertEquals("Conversion " + originalGpx + " -> " + expectedOsm + " didn't match!", osmExpected.allPrimitives().size(), osm.allPrimitives().size());
     156        assertEquals("Conversion " + originalGpx + " -> " + expectedOsm + " didn't match!", osmExpected.allPrimitives().size(),
     157                osm.allPrimitives().size());
    155158    }
    156159
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java

    r15496 r15497  
    7272    @Test
    7373    public void testVelocity() throws IOException, SAXException {
    74         final List<String> colors = calculateColors("data_nodist/2094047.gpx", ImmutableMap.of("colormode", Integer.toString(ColorMode.VELOCITY.toIndex())), 10);
     74        final List<String> colors = calculateColors("data_nodist/2094047.gpx",
     75                ImmutableMap.of("colormode", Integer.toString(ColorMode.VELOCITY.toIndex())), 10);
    7576        assertEquals("[#000000, #FFAD00, #FFA800, #FFA800, #FF9E00, #FF9400, #FF7000, #FF7000, #FF8000, #FF9400]", colors.toString());
    7677    }
     
    99100    @Test
    100101    public void testDirection() throws IOException, SAXException {
    101         final List<String> colors = calculateColors("data_nodist/2094047.gpx", ImmutableMap.of("colormode", Integer.toString(ColorMode.DIRECTION.toIndex())), 10);
     102        final List<String> colors = calculateColors("data_nodist/2094047.gpx",
     103                ImmutableMap.of("colormode", Integer.toString(ColorMode.DIRECTION.toIndex())), 10);
    102104        assertEquals("[#000000, #EAEC25, #EDEA26, #EDE525, #ECD322, #EBB81D, #E85A0D, #E73708, #E84D0B, #EA8A15]", colors.toString());
    103105    }
     
    111113    @Test
    112114    public void testTime() throws IOException, SAXException {
    113         final List<String> colors = calculateColors("data_nodist/2094047.gpx", ImmutableMap.of("colormode", Integer.toString(ColorMode.TIME.toIndex())), 10);
     115        final List<String> colors = calculateColors("data_nodist/2094047.gpx",
     116                ImmutableMap.of("colormode", Integer.toString(ColorMode.TIME.toIndex())), 10);
    114117        assertEquals("[#000000, #FF0000, #FF0000, #FF0500, #FF0500, #FF0A00, #FF0A00, #FF1F00, #FF2E00, #FF3300]", colors.toString());
    115118    }
  • trunk/test/unit/org/openstreetmap/josm/io/GpxWriterTest.java

    r15496 r15497  
    103103    public void testExtensions() throws IOException {
    104104        GpxData data = new GpxData();
    105         data.getNamespaces().add(new XMLNamespace("test", "http://example.com/testURI")); //only namespace, no location printed
    106         data.getNamespaces().add(new XMLNamespace("knownprefix", "http://example.com/URI", "http://example.com/location.xsd")); //printed
    107         data.getNamespaces().add(new XMLNamespace("notpresent", "http://example.com/notpresent", "http://example.com/notpresent.xsd")); //NOT printed
     105        // only namespace, no location printed
     106        data.getNamespaces().add(new XMLNamespace("test", "http://example.com/testURI"));
     107        // printed
     108        data.getNamespaces().add(new XMLNamespace("knownprefix", "http://example.com/URI", "http://example.com/location.xsd"));
     109        // NOT printed
     110        data.getNamespaces().add(new XMLNamespace("notpresent", "http://example.com/notpresent", "http://example.com/notpresent.xsd"));
    108111
    109112        GpxExtensionCollection exts = data.getExtensions();
     
    128131        GpxWriter writer = new GpxWriter(baos);
    129132
     133        // CHECKSTYLE.OFF: LineLength
     134
    130135        writer.write(data);
    131136        assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" +
     
    275280                "</gpx>", baos.toString());
    276281
     282        // CHECKSTYLE.ON: LineLength
     283
    277284        writer.close();
    278285    }
Note: See TracChangeset for help on using the changeset viewer.