Changeset 18871 in josm


Ignore:
Timestamp:
2023-10-16T19:03:11+02:00 (14 months ago)
Author:
taylor.smock
Message:

See #23218: Use newer error_prone versions when compiling on Java 11+

error_prone 2.11 dropped support for compiling with Java 8, although it still
supports compiling for Java 8. The "major" new check for us is NotJavadoc since
we used /** in quite a few places which were not javadoc.

Other "new" checks that are of interest:

  • AlreadyChecked: if (foo) { doFoo(); } else if (!foo) { doBar(); }
  • UnnecessaryStringBuilder: Avoid StringBuilder (Java converts + to StringBuilder behind-the-scenes, but may also do something else if it performs better)
  • NonApiType: Avoid specific interface types in function definitions
  • NamedLikeContextualKeyword: Avoid using restricted names for classes and methods
  • UnusedMethod: Unused private methods should be removed

This fixes most of the new error_prone issues and some SonarLint issues.

Location:
trunk
Files:
62 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r18861 r18871  
    221221        <element name="cp-elements" optional="true"/>
    222222        <sequential>
     223          <!-- RestrictedApiChecker was removed in error-prone 2.19 -->
     224          <local name="errorProne2.10"/>
     225          <property name="errorProne2.10" value="-Xep:RestrictedApiChecker:OFF" unless:set="isJava11"/>
     226          <local name="errorProne2.22+"/>
     227          <!-- LongDoubleConversion is disabled since SonarLint java:S1905 conflicts -->
     228          <property name="errorProne2.22+" value="-Xep:LongDoubleConversion:OFF" if:set="isJava11"/>
    223229          <javac sourcepath="@{sourcepath}" srcdir="@{srcdir}" fork="@{fork}"
    224230            includes="@{includes}" excludes="@{excludes}" destdir="@{destdir}" release="@{release}"
     
    250256              <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
    251257              <compilerarg value="-XDignore.symbol.file"/>
    252               <compilerarg value="-Xplugin:ErrorProne -XepExcludedPaths:.*/parsergen/.* -Xep:ReferenceEquality:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:BadImport:OFF -Xep:AnnotateFormatMethod:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF -Xep:RestrictedApiChecker:OFF -Xep:InlineMeSuggester:OFF" unless:set="noErrorProne"/>
     258              <compilerarg value="-Xplugin:ErrorProne -XepExcludedPaths:.*/parsergen/.* -Xep:ReferenceEquality:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:BadImport:OFF -Xep:AnnotateFormatMethod:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF ${errorProne2.10} -Xep:InlineMeSuggester:OFF ${errorProne2.22+}" unless:set="noErrorProne"/>
    253259              <compilerarg line="-Xmaxwarns 1000"/>
    254260              <compilerarg value="-Xplugin:semanticdb -sourceroot:@{srcdir} -targetroot:${build.dir}/semanticdb" if:set="lsif" />
  • trunk/ivysettings.xml

    r17647 r18871  
    66    <ibiblio name="josm-nexus" m2compatible="true" root="https://josm.openstreetmap.de/nexus/content/repositories/public/" />
    77  </resolvers>
     8  <!-- Remove error_prone 2.10.0 specific statements in build.xml when we drop Java 8 as a build platform -->
     9  <property name="versions.error_prone" value="2.10.0" unlessset="isJava11"/>
     10  <property name="versions.error_prone" value="2.22.0" ifset="isJava11"/>
    811</ivysettings>
  • trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java

    r16505 r18871  
    3636/**
    3737 * User action to close open changesets.
    38  *
     38 * <p>
    3939 * The list of open changesets will be downloaded from the server and presented
    4040 * to the user.
     
    110110        protected void finish() {
    111111            SwingUtilities.invokeLater(() -> {
    112                             if (lastException != null) {
    113                                 ExceptionDialogUtil.explainException(lastException);
     112                            Exception exception = getLastException();
     113                            if (exception != null) {
     114                                ExceptionDialogUtil.explainException(exception);
    114115                            }
    115116                            ChangesetCache.getInstance().update(changesets);
    116                             if (!canceled && lastException == null) {
     117                            if (!isCanceled() && exception == null) {
    117118                                onPostDownloadOpenChangesets();
    118119                            }
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r17586 r18871  
    246246
    247247    /**
    248      * This hepler class implements algorithm traversing trough connected ways.
     248     * This helper class implements algorithm traversing through connected ways.
    249249     * Assumes you are going in clockwise orientation.
    250250     * @author viesturs
  • trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java

    r18332 r18871  
    275275            if (Utils.isEmpty(files)) return;
    276276
    277             /**
     277            /*
    278278             * Find the importer with the chosen file filter
    279279             */
     
    286286                }
    287287            }
    288             /**
     288            /*
    289289             * If the filter hasn't been changed in the dialog, chosenImporter is null now.
    290290             * When the filter has been set explicitly to AllFormatsImporter, treat this the same.
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r18707 r18871  
    269269     */
    270270    static Map<String, String> getAnonimicDirectorySymbolMap() {
    271         /** maps the anonymized name to the actual used path */
     271        /* maps the anonymized name to the actual used path */
    272272        Map<String, String> map = new LinkedHashMap<>();
    273273        map.put(PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}", getSystemEnv("JAVA_HOME"));
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r18801 r18871  
    7373
    7474    static {
    75         /**
     75        /*
    7676         * Calls validator before upload.
    7777         */
    7878        UPLOAD_HOOKS.add(new ValidateUploadHook());
    7979
    80         /**
     80        /*
    8181         * Fixes database errors
    8282         */
    8383        UPLOAD_HOOKS.add(new FixDataHook());
    8484
    85         /**
     85        /*
    8686         * Checks server capabilities before upload.
    8787         */
    8888        UPLOAD_HOOKS.add(new ApiPreconditionCheckerHook());
    8989
    90         /**
     90        /*
    9191         * Adjusts the upload order of new relations
    9292         */
    9393        UPLOAD_HOOKS.add(new RelationUploadOrderHook());
    9494
    95         /**
     95        /*
    9696         * Removes discardable tags like created_by on modified objects
    9797         */
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    r18494 r18871  
    5656/**
    5757 * MapMode for making parallel ways.
    58  *
     58 * <p>
    5959 * All calculations are done in projected coordinates.
    60  *
     60 * <p>
    6161 * TODO:
     62 * <p>
    6263 * == Functionality ==
    63  *
    64  * 1. Use selected nodes as split points for the selected ways.
    65  *
     64 * <ol>
     65 * <li>Use selected nodes as split points for the selected ways.
     66 * <p>
    6667 * The ways containing the selected nodes will be split and only the "inner"
    67  * parts will be copied
    68  *
    69  * 2. Enter exact offset
    70  *
    71  * 3. Improve snapping
    72  *
    73  * 4. Visual cues could be better
    74  *
    75  * 5. (long term) Parallelize and adjust offsets of existing ways
    76  *
     68 * parts will be copied</li>
     69 * <li>Enter exact offset</li>
     70 * <li>Improve snapping</li>
     71 * <li>Visual cues could be better</li>
     72 * <li>(long term) Parallelize and adjust offsets of existing ways</li>
     73 * </ol>
    7774 * == Code quality ==
    78  *
    79  * a) The mode, flags, and modifiers might be updated more than necessary.
    80  *
    81  * Not a performance problem, but better if they where more centralized
    82  *
    83  * b) Extract generic MapMode services into a super class and/or utility class
    84  *
    85  * c) Maybe better to simply draw our own source way highlighting?
    86  *
     75 * <ol type="a">
     76 * <li>The mode, flags, and modifiers might be updated more than necessary.
     77 * <p>
     78 * Not a performance problem, but better if they where more centralized</li>
     79 * <li>Extract generic MapMode services into a super class and/or utility class</li>
     80 * <li>Maybe better to simply draw our own source way highlighting?</li>
     81 * </ol>
    8782 * Current code doesn't not take into account that ways might been highlighted
    8883 * by other than us. Don't think that situation should ever happen though.
     
    352347    @Override
    353348    public void mouseDragged(MouseEvent e) {
    354         // WTF.. the event passed here doesn't have button info?
     349        // WTF... the event passed here doesn't have button info?
    355350        // Since we get this event from other buttons too, we must check that
    356351        // _BUTTON1_ is down.
     
    456451            modifiers.add(Modifier.SHIFT);
    457452        }
    458         return spec.entrySet().stream().allMatch(entry -> modifiers.contains(entry.getKey()) == entry.getValue().booleanValue());
     453        return spec.entrySet().stream().allMatch(entry -> modifiers.contains(entry.getKey()) == entry.getValue());
    459454    }
    460455
     
    465460
    466461    private void updateFlagsOnlyChangeableOnPress() {
    467         copyTags = COPY_TAGS_DEFAULT.get().booleanValue() != matchesCurrentModifiers(COPY_TAGS_MODIFIER_COMBO);
     462        copyTags = COPY_TAGS_DEFAULT.get() != matchesCurrentModifiers(COPY_TAGS_MODIFIER_COMBO);
    468463    }
    469464
    470465    private void updateFlagsChangeableAlways() {
    471         snap = SNAP_DEFAULT.get().booleanValue() != matchesCurrentModifiers(SNAP_MODIFIER_COMBO);
     466        snap = SNAP_DEFAULT.get() != matchesCurrentModifiers(SNAP_MODIFIER_COMBO);
    472467    }
    473468
     
    554549
    555550        KeyboardModifiersProperty(String key, String defaultValue) {
    556             super(key, createFromString(defaultValue));
     551            this(key, createFromString(defaultValue));
    557552        }
    558553
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r18732 r18871  
    4242import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    4343import org.openstreetmap.josm.gui.tagging.ac.AutoCompComboBoxModel;
     44import org.openstreetmap.josm.gui.widgets.JosmComboBoxModel;
    4445import org.openstreetmap.josm.spi.preferences.Config;
    4546import org.openstreetmap.josm.tools.Logging;
     
    6667    private static final String SEARCH_EXPRESSION = "searchExpression";
    6768
    68     private static AutoCompComboBoxModel<SearchSetting> model = new AutoCompComboBoxModel<>();
     69    private static final AutoCompComboBoxModel<SearchSetting> model = new AutoCompComboBoxModel<>();
    6970
    7071    /** preferences reader/writer with automatic transmogrification to and from String */
    71     private static AutoCompComboBoxModel<SearchSetting>.Preferences prefs = model.prefs(
     72    private static final JosmComboBoxModel<SearchSetting>.Preferences prefs = model.prefs(
    7273            SearchSetting::readFromString, SearchSetting::writeToString);
    7374
     
    491492    @Override
    492493    public List<ActionParameter<?>> getActionParameters() {
    493         return Collections.<ActionParameter<?>>singletonList(new SearchSettingsActionParameter(SEARCH_EXPRESSION));
     494        return Collections.singletonList(new SearchSettingsActionParameter(SEARCH_EXPRESSION));
    494495    }
    495496}
  • trunk/src/org/openstreetmap/josm/command/PurgeCommand.java

    r16800 r18871  
    6161
    6262    private void init(Collection<OsmPrimitive> toPurge, Collection<OsmPrimitive> makeIncomplete) {
    63         /**
     63        /*
    6464         * The topological sort is to avoid missing way nodes and missing
    6565         * relation members when adding primitives back to the dataset on undo.
     
    160160        Set<OsmPrimitive> remainingNodes = new HashSet<>(in.size());
    161161
    162         /**
     162        /*
    163163         *  First add nodes that have no way referrer.
    164164         */
     
    180180            }
    181181
    182         /**
     182        /*
    183183         * Then add all ways, each preceded by its (remaining) nodes.
    184184         */
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r18801 r18871  
    553553     */
    554554    public String encodeAsString(String separator) {
    555         return new StringBuilder()
    556           .append(minLat).append(separator).append(minLon).append(separator)
    557           .append(maxLat).append(separator).append(maxLon).toString();
     555        return minLat + separator + minLon + separator +
     556                maxLat + separator + maxLon;
    558557    }
    559558
  • trunk/src/org/openstreetmap/josm/data/StructUtils.java

    r18723 r18871  
    2020import java.util.stream.Collectors;
    2121
     22import org.openstreetmap.josm.spi.preferences.IPreferences;
     23import org.openstreetmap.josm.tools.JosmRuntimeException;
     24import org.openstreetmap.josm.tools.Logging;
     25import org.openstreetmap.josm.tools.MultiMap;
     26import org.openstreetmap.josm.tools.ReflectionUtils;
     27import org.openstreetmap.josm.tools.StringParser;
     28import org.openstreetmap.josm.tools.Utils;
     29
    2230import jakarta.json.Json;
    2331import jakarta.json.JsonArray;
     
    3038import jakarta.json.JsonWriter;
    3139
    32 import org.openstreetmap.josm.spi.preferences.IPreferences;
    33 import org.openstreetmap.josm.tools.JosmRuntimeException;
    34 import org.openstreetmap.josm.tools.Logging;
    35 import org.openstreetmap.josm.tools.MultiMap;
    36 import org.openstreetmap.josm.tools.ReflectionUtils;
    37 import org.openstreetmap.josm.tools.StringParser;
    38 import org.openstreetmap.josm.tools.Utils;
    39 
    4040/**
    4141 * Utility methods to convert struct-like classes to a string map and back.
    42  *
     42 * <p>
    4343 * A "struct" is a class that has some fields annotated with {@link StructEntry}.
    4444 * Those fields will be respected when converting an object to a {@link Map} and back.
     
    107107    /**
    108108     * Convenience method that saves a MapListSetting which is provided as a collection of objects.
    109      *
     109     * <p>
    110110     * Each object is converted to a <code>Map&lt;String, String&gt;</code> using the fields with {@link StructEntry} annotation.
    111111     * The field name is the key and the value will be converted to a string.
    112      *
     112     * <p>
    113113     * Considers only fields that have the {@code @StructEntry} annotation.
    114114     * In addition it does not write fields with null values. (Thus they are cleared)
     
    149149    /**
    150150     * Convert an object to a String Map, by using field names and values as map key and value.
    151      *
     151     * <p>
    152152     * The field value is converted to a String.
    153      *
     153     * <p>
    154154     * Only fields with annotation {@link StructEntry} are taken into account.
    155      *
     155     * <p>
    156156     * Fields will not be written to the map if the value is null or unchanged
    157157     * (compared to an object created with the no-arg-constructor).
     
    164164     * @return the resulting map (same data content as <code>struct</code>)
    165165     */
    166     public static <T> HashMap<String, String> serializeStruct(T struct, Class<T> klass, SerializeOptions... options) {
     166    public static <T> Map<String, String> serializeStruct(T struct, Class<T> klass, SerializeOptions... options) {
    167167        List<SerializeOptions> optionsList = Arrays.asList(options);
    168168        T structPrototype;
     
    173173        }
    174174
    175         HashMap<String, String> hash = new LinkedHashMap<>();
     175        Map<String, String> hash = new LinkedHashMap<>();
    176176        for (Field f : getDeclaredFieldsInClassOrSuperTypes(klass)) {
    177177            if (f.getAnnotation(StructEntry.class) == null) {
     
    208208     * Converts a String-Map to an object of a certain class, by comparing map keys to field names of the class and assigning
    209209     * map values to the corresponding fields.
    210      *
     210     * <p>
    211211     * The map value (a String) is converted to the field type. Supported types are: boolean, Boolean, int, Integer, double,
    212212     * Double, String, Map&lt;String, String&gt; and Map&lt;String, List&lt;String&gt;&gt;.
    213      *
     213     * <p>
    214214     * Only fields with annotation {@link StructEntry} are taken into account.
    215215     * @param <T> the class
     
    219219     */
    220220    public static <T> T deserializeStruct(Map<String, String> hash, Class<T> klass) {
    221         T struct = null;
     221        T struct;
    222222        try {
    223223            struct = klass.getConstructor().newInstance();
     
    284284    @SuppressWarnings({ "rawtypes", "unchecked" })
    285285    private static Map mapFromJson(String s) {
    286         Map ret = null;
     286        Map ret;
    287287        try (JsonReader reader = Json.createReader(new StringReader(s))) {
    288288            JsonObject object = reader.readObject();
     
    322322    @SuppressWarnings({ "rawtypes", "unchecked" })
    323323    private static MultiMap multiMapFromJson(String s) {
    324         MultiMap ret = null;
     324        MultiMap ret;
    325325        try (JsonReader reader = Json.createReader(new StringReader(s))) {
    326326            JsonObject object = reader.readObject();
  • trunk/src/org/openstreetmap/josm/data/imagery/AbstractWMSTileSource.java

    r16627 r18871  
    232232
    233233    private static String getBboxstr(double x1, double x2, double x3, double x4) {
    234         return new StringBuilder(64)
    235                 .append(LATLON_FORMAT.format(x1))
    236                 .append(',')
    237                 .append(LATLON_FORMAT.format(x2))
    238                 .append(',')
    239                 .append(LATLON_FORMAT.format(x3))
    240                 .append(',')
    241                 .append(LATLON_FORMAT.format(x4))
    242                 .toString();
     234        return LATLON_FORMAT.format(x1) +
     235                ',' +
     236                LATLON_FORMAT.format(x2) +
     237                ',' +
     238                LATLON_FORMAT.format(x3) +
     239                ',' +
     240                LATLON_FORMAT.format(x4);
    243241    }
    244242}
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r18703 r18871  
    2828import java.util.Collections;
    2929import java.util.Deque;
     30import java.util.HashMap;
    3031import java.util.LinkedHashSet;
    3132import java.util.LinkedList;
     
    231232        /**
    232233         * Get title of the layer for user display.
    233          *
     234         * <p>
    234235         * This is either the content of the Title element (if available) or
    235236         * the layer identifier (as fallback)
     
    507508     */
    508509    private static Collection<Layer> parseContents(XMLStreamReader reader) throws XMLStreamException {
    509         Map<String, TileMatrixSet> matrixSetById = new ConcurrentHashMap<>();
     510        Map<String, TileMatrixSet> matrixSetById = new HashMap<>();
    510511        Collection<Layer> layers = new ArrayList<>();
    511512        for (int event = reader.getEventType();
     
    900901                .replace("{TileRow}", Integer.toString(tiley))
    901902                .replace("{TileCol}", Integer.toString(tilex))
    902                 .replaceAll("(?i)\\{style\\}", this.currentLayer.style);
     903                .replaceAll("(?i)\\{style}", this.currentLayer.style);
    903904
    904905        for (Dimension d : currentLayer.dimensions) {
    905             url = url.replaceAll("(?i)\\{"+d.identifier+"\\}", d.defaultValue);
     906            url = url.replaceAll("(?i)\\{"+d.identifier+"}", d.defaultValue);
    906907        }
    907908
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Expression.java

    r18723 r18871  
    2020    /** An empty expression to use */
    2121    public static final Expression EMPTY_EXPRESSION = new Expression(JsonValue.NULL);
    22     private static final String EMPTY_STRING = "";
    2322
    2423    private final String mapcssFilterExpression;
     
    3837                    this.mapcssFilterExpression = convertToString(array.get(1)) + array.getString(0) + convertToString(array.get(2));
    3938                } else {
    40                     this.mapcssFilterExpression = EMPTY_STRING;
     39                    this.mapcssFilterExpression = "";
    4140                }
    4241            } else {
    43                 this.mapcssFilterExpression = EMPTY_STRING;
     42                this.mapcssFilterExpression = "";
    4443            }
    4544        } else {
    46             this.mapcssFilterExpression = EMPTY_STRING;
     45            this.mapcssFilterExpression = "";
    4746        }
    4847    }
     
    7574        case NULL:
    7675        default:
    77             return EMPTY_STRING;
     76            return "";
    7877        }
    7978    }
     
    8180    @Override
    8281    public String toString() {
    83         return !EMPTY_STRING.equals(this.mapcssFilterExpression) ? '[' + this.mapcssFilterExpression + ']' : EMPTY_STRING;
     82        return !"".equals(this.mapcssFilterExpression) ? '[' + this.mapcssFilterExpression + ']' : "";
    8483    }
    8584
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Layers.java

    r18723 r18871  
    1515import java.util.stream.Stream;
    1616
     17import org.openstreetmap.josm.gui.mappaint.StyleKeys;
     18import org.openstreetmap.josm.tools.Utils;
     19
    1720import jakarta.json.JsonArray;
    1821import jakarta.json.JsonNumber;
     
    2023import jakarta.json.JsonString;
    2124import jakarta.json.JsonValue;
    22 
    23 import org.openstreetmap.josm.gui.mappaint.StyleKeys;
    24 import org.openstreetmap.josm.tools.Utils;
    2525
    2626/**
     
    5959    }
    6060
    61     private static final String EMPTY_STRING = "";
    6261    private static final char SEMI_COLON = ';';
    6362    private static final Pattern CURLY_BRACES = Pattern.compile("(\\{(.*?)})");
     
    148147                    break;
    149148                default:
    150                     this.paintProperties = EMPTY_STRING;
     149                    this.paintProperties = "";
    151150                }
    152151            } else {
    153                 this.paintProperties = EMPTY_STRING;
     152                this.paintProperties = "";
    154153            }
    155154        } else {
    156             this.paintProperties = EMPTY_STRING;
     155            this.paintProperties = "";
    157156        }
    158157        this.sourceLayer = layerInfo.getString("source-layer", null);
     
    358357        if (layoutObject.containsKey("text-field")) {
    359358            sb.append(StyleKeys.TEXT).append(':')
    360               .append(layoutObject.getString("text-field").replace("}", EMPTY_STRING).replace("{", EMPTY_STRING))
     359              .append(layoutObject.getString("text-field").replace("}", "").replace("{", ""))
    361360              .append(SEMI_COLON);
    362361        }
     
    461460    public String toString() {
    462461        if (this.filter.toString().isEmpty() && this.paintProperties.isEmpty()) {
    463             return EMPTY_STRING;
     462            return "";
    464463        } else if (this.type == Type.BACKGROUND) {
    465464            // AFAIK, paint has no zoom levels, and doesn't accept a layer
     
    477476            zoomSelector = MessageFormat.format("|z{0}-{1}", this.minZoom, this.maxZoom);
    478477        } else {
    479             zoomSelector = EMPTY_STRING;
     478            zoomSelector = "";
    480479        }
    481480        final String commonData = zoomSelector + this.filter.toString() + "::" + this.id + "{" + this.paintProperties + "}";
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r18801 r18871  
    316316     * @return list of history entries
    317317     */
     318    // This needs to return something like a Sequenced Collection (Java 21)
     319    @SuppressWarnings({"NonApiType", "squid:S1319"})
    318320    public LinkedList<Collection<? extends OsmPrimitive>> getSelectionHistory() {
    319321        return selectionHistory;
  • trunk/src/org/openstreetmap/josm/data/osm/NodePair.java

    r12463 r18871  
    7676    @Override
    7777    public String toString() {
    78         return new StringBuilder()
    79         .append('[')
    80         .append(a.getId())
    81         .append(',')
    82         .append(b.getId())
    83         .append(']')
    84         .toString();
     78        return "[" +
     79                a.getId() +
     80                ',' +
     81                b.getId() +
     82                ']';
    8583    }
    8684
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r18208 r18871  
    125125            this.flags = flags;
    126126
    127             long order = 0;
     127            long styleOrder = 0;
    128128            if ((this.flags & FLAG_DISABLED) == 0) {
    129                 order |= 1;
    130             }
    131 
    132             order <<= 24;
    133             order |= floatToFixed(this.style.majorZIndex, 24);
     129                styleOrder |= 1;
     130            }
     131
     132            styleOrder <<= 24;
     133            styleOrder |= floatToFixed(this.style.majorZIndex, 24);
    134134
    135135            // selected on top of member of selected on top of unselected
    136136            // FLAG_DISABLED bit is the same at this point, but we simply ignore it
    137             order <<= 4;
    138             order |= this.flags & 0xf;
    139 
    140             order <<= 24;
    141             order |= floatToFixed(this.style.zIndex, 24);
    142 
    143             order <<= 1;
     137            styleOrder <<= 4;
     138            styleOrder |= this.flags & 0xf;
     139
     140            styleOrder <<= 24;
     141            styleOrder |= floatToFixed(this.style.zIndex, 24);
     142
     143            styleOrder <<= 1;
    144144            // simple node on top of icons and shapes
    145145            if (DefaultStyles.SIMPLE_NODE_ELEMSTYLE.equals(this.style)) {
    146                 order |= 1;
    147             }
    148 
    149             this.order = order;
     146                styleOrder |= 1;
     147            }
     148
     149            this.order = styleOrder;
    150150        }
    151151
     
    245245    /**
    246246     * Check, if this System has the GlyphVector double translation bug.
    247      *
     247     * <p>
    248248     * With this bug, <code>gv.setGlyphTransform(i, trfm)</code> has a different
    249249     * effect than on most other systems, namely the translation components
     
    251251     * they actually are. The rotation is unaffected (scale &amp; shear not tested
    252252     * so far).
    253      *
     253     * <p>
    254254     * This bug has only been observed on Mac OS X, see #7841.
    255      *
     255     * <p>
    256256     * After switch to Java 7, this test is a false positive on Mac OS X (see #10446),
    257257     * i.e. it returns true, but the real rendering code does not require any special
     
    586586     * Determine, if partial fill should be turned off for this object, because
    587587     * only a small unfilled gap in the center of the area would be left.
    588      *
     588     * <p>
    589589     * This is used to get a cleaner look for urban regions with many small
    590590     * areas like buildings, etc.
     
    623623        double x = p.getInViewX() + bs.xOffset;
    624624        double y = p.getInViewY() + bs.yOffset;
    625         /**
     625        /*
    626626         *
    627627         *       left-above __center-above___ right-above
     
    10171017            INode firstNode = viaWay.firstNode();
    10181018            INode lastNode = viaWay.lastNode();
    1019             Boolean onewayvia = Boolean.FALSE;
     1019            boolean onewayvia = Boolean.FALSE;
    10201020
    10211021            String onewayviastr = viaWay.get("oneway");
     
    14231423        isOutlineOnly = paintSettings.isOutlineOnly();
    14241424
    1425         antialiasing = PREFERENCE_ANTIALIASING_USE.get() ?
     1425        antialiasing = Boolean.TRUE.equals(PREFERENCE_ANTIALIASING_USE.get()) ?
    14261426                        RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF;
    14271427        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasing);
     
    14841484    /**
    14851485     * Fix the clipping area of unclosed polygons for partial fill.
    1486      *
     1486     * <p>
    14871487     * The current algorithm for partial fill simply strokes the polygon with a
    14881488     * large stroke width after masking the outside with a clipping area.
    14891489     * This works, but for unclosed polygons, the mask can crop the corners at
    14901490     * both ends (see #12104).
    1491      *
     1491     * <p>
    14921492     * This method fixes the clipping area by sort of adding the corners to the
    14931493     * clip outline.
     
    15321532    /**
    15331533     * Get the point to add to the clipping area for partial fill of unclosed polygons.
    1534      *
     1534     * <p>
    15351535     * <code>(p1,p2)</code> is the first or last way segment and <code>p3</code> the
    15361536     * opposite endpoint.
     
    16931693            }
    16941694
    1695             for (StyleRecord record : sorted) {
    1696                 paintRecord(record);
     1695            for (StyleRecord styleRecord : sorted) {
     1696                paintRecord(styleRecord);
    16971697            }
    16981698
     
    17101710    }
    17111711
    1712     private void paintRecord(StyleRecord record) {
     1712    private void paintRecord(StyleRecord styleRecord) {
    17131713        try {
    1714             record.paintPrimitive(paintSettings, this);
     1714            styleRecord.paintPrimitive(paintSettings, this);
    17151715        } catch (RuntimeException e) {
    1716             throw BugReport.intercept(e).put("record", record);
     1716            throw BugReport.intercept(e).put("record", styleRecord);
    17171717        }
    17181718    }
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java

    r16466 r18871  
    311311     */
    312312    public String getDetails() {
    313         return new StringBuilder(256)
    314             .append("Sub Grid : ")
    315             .append(subGridName)
    316             .append("\nParent   : ")
    317             .append(parentSubGridName)
    318             .append("\nCreated  : ")
    319             .append(created)
    320             .append("\nUpdated  : ")
    321             .append(updated)
    322             .append("\nMin Lat  : ")
    323             .append(minLat)
    324             .append("\nMax Lat  : ")
    325             .append(maxLat)
    326             .append("\nMin Lon  : ")
    327             .append(minLon)
    328             .append("\nMax Lon  : ")
    329             .append(maxLon)
    330             .append("\nLat Intvl: ")
    331             .append(latInterval)
    332             .append("\nLon Intvl: ")
    333             .append(lonInterval)
    334             .append("\nNode Cnt : ")
    335             .append(nodeCount)
    336             .toString();
     313        return "Sub Grid : " +
     314                subGridName +
     315                "\nParent   : " +
     316                parentSubGridName +
     317                "\nCreated  : " +
     318                created +
     319                "\nUpdated  : " +
     320                updated +
     321                "\nMin Lat  : " +
     322                minLat +
     323                "\nMax Lat  : " +
     324                maxLat +
     325                "\nMin Lon  : " +
     326                minLon +
     327                "\nMax Lon  : " +
     328                maxLon +
     329                "\nLat Intvl: " +
     330                latInterval +
     331                "\nLon Intvl: " +
     332                lonInterval +
     333                "\nNode Cnt : " +
     334                nodeCount;
    337335    }
    338336
  • trunk/src/org/openstreetmap/josm/data/sources/SourceInfo.java

    r18246 r18871  
    8686      * creation date of the source (in the form YYYY-MM-DD;YYYY-MM-DD, where
    8787      * DD and MM as well as a second date are optional).
    88       *
     88      * <p>
    8989      * Also used as time filter for WMS time={time} parameter (such as Sentinel-2)
    9090      * @since 11570
     
    106106    /** category of the imagery (input string, not saved, copied or used otherwise except for error checks) */
    107107    protected String categoryOriginalString;
    108     /** when adding a field, also adapt the:
     108    /* when adding a field, also adapt the:
    109109     * {@link #ImageryPreferenceEntry ImageryPreferenceEntry object}
    110110     * {@link #ImageryPreferenceEntry#ImageryPreferenceEntry(ImageryInfo) ImageryPreferenceEntry constructor}
     
    149149     * Check if this object equals another SourceInfo with respect to the properties
    150150     * that get written to the preference file.
    151      *
     151     * <p>
    152152     * This should be overridden and called in subclasses.
    153153     *
     
    219219    public String toString() {
    220220        // Used in imagery preferences filtering, so must be efficient
    221         return new StringBuilder(name)
    222                 .append('[').append(countryCode)
     221        return name +
     222                '[' + countryCode +
    223223                // appending the localized country in toString() allows us to filter imagery preferences table with it!
    224                 .append("] ('").append(getLocalizedCountry(countryCode)).append(')')
    225                 .append(" - ").append(url)
    226                 .append(" - ").append(sourceType)
    227                 .toString();
     224                "] ('" + getLocalizedCountry(countryCode) + ')' +
     225                " - " + url +
     226                " - " + sourceType;
    228227    }
    229228
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r18494 r18871  
    428428        if (r.isIncomplete())
    429429            return;
    430         /** array of country codes for which the test should be performed. For now, only Germany */
     430        /* array of country codes for which the test should be performed. For now, only Germany */
    431431        String[] countryCodes = {"DE"};
    432432        TagMap neededtagsForHouse = new TagMap();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r18208 r18871  
    602602     */
    603603    private static Map<List<Way>, List<WaySegment>> findIntersectingWays(Relation r, boolean findSharedWaySegments) {
    604         /** All way segments, grouped by cells */
     604        /* All way segments, grouped by cells */
    605605        final Map<Point2D, List<WaySegment>> cellSegments = new HashMap<>(1000);
    606         /** The detected crossing ways */
     606        /* The detected crossing ways */
    607607        final Map<List<Way>, List<WaySegment>> crossingWays = new HashMap<>(50);
    608608
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r18840 r18871  
    569569
    570570        /**
     571         * Get the detected segments
    571572         * @return the detected segments
    572573         */
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r18643 r18871  
    461461         * @return true if a reasonable connection was found
    462462         */
    463         private boolean isConnectedTo(Node node, LinkedHashSet<Node> visited, double len, Way parent) {
     463        private boolean isConnectedTo(Node node, Set<Node> visited, double len, Way parent) {
    464464            if (len > maxLen) {
    465465                return false;
     
    480480            if (visited != null) {
    481481                visited.add(node);
    482                 List<Way> wantedParents = node.getParentWays().stream().filter(pw -> isWantedWay(pw))
     482                List<Way> wantedParents = node.getParentWays().stream().filter(UnconnectedWays.this::isWantedWay)
    483483                        .collect(Collectors.toList());
    484484                if (wantedParents.size() > 1 && wantedParents.indexOf(parent) != wantedParents.size() - 1) {
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r18759 r18871  
    215215        splitPane.setRightComponent(dialogsPanel);
    216216
    217         /**
     217        /*
    218218         * All additional space goes to the mapView
    219219         */
    220220        splitPane.setResizeWeight(1.0);
    221221
    222         /**
     222        /*
    223223         * Some beautifications.
    224224         */
     
    515515        panel.add(this, BorderLayout.CENTER);
    516516
    517         /**
     517        /*
    518518         * sideToolBar: add map modes icons
    519519         */
     
    526526        }
    527527
    528         /**
     528        /*
    529529         * sideToolBar: add toggle dialogs icons
    530530         */
     
    538538        }
    539539
    540         /**
     540        /*
    541541         * sideToolBar: add dynamic popup menu
    542542         */
     
    545545        sideToolBar.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
    546546
    547         /**
     547        /*
    548548         * sideToolBar: decide scroll- and visibility
    549549         */
    550550        if (Config.getPref().getBoolean("sidetoolbar.scrollable", true)) {
    551             final ScrollViewport svp = new ScrollViewport(sideToolBar, ScrollViewport.VERTICAL_DIRECTION);
    552             sideToolBar = svp;
     551            sideToolBar = new ScrollViewport(sideToolBar, ScrollViewport.VERTICAL_DIRECTION);
    553552        }
    554553        sideToolBar.setVisible(SIDE_TOOLBAR_VISIBLE.get());
     
    556555        SIDE_TOOLBAR_VISIBLE.addListener(sidetoolbarPreferencesChangedListener);
    557556
    558         /**
     557        /*
    559558         * sideToolBar: add it to the panel
    560559         */
    561560        panel.add(sideToolBar, BorderLayout.WEST);
    562561
    563         /**
     562        /*
    564563         * statusLine: add to panel
    565564         */
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r18574 r18871  
    4545import org.openstreetmap.josm.data.osm.DataSet;
    4646import org.openstreetmap.josm.data.osm.IPrimitive;
     47import org.openstreetmap.josm.data.osm.IWaySegment;
    4748import org.openstreetmap.josm.data.osm.Node;
    4849import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    209210    // The only events that may move/resize this map view are window movements or changes to the map view size.
    210211    // We can clean this up more by only recalculating the state on repaint.
    211     private final transient HierarchyListener hierarchyListener = e -> {
     212    private final transient HierarchyListener hierarchyListenerNavigatableComponent = e -> {
    212213        long interestingFlags = HierarchyEvent.ANCESTOR_MOVED | HierarchyEvent.SHOWING_CHANGED;
    213214        if ((e.getChangeFlags() & interestingFlags) != 0) {
     
    216217    };
    217218
    218     private final transient ComponentAdapter componentListener = new ComponentAdapter() {
     219    private final transient ComponentAdapter componentListenerNavigatableComponent = new ComponentAdapter() {
    219220        @Override
    220221        public void componentShown(ComponentEvent e) {
     
    254255    public void addNotify() {
    255256        updateLocationState();
    256         addHierarchyListener(hierarchyListener);
    257         addComponentListener(componentListener);
     257        addHierarchyListener(hierarchyListenerNavigatableComponent);
     258        addComponentListener(componentListenerNavigatableComponent);
    258259        addPrimitiveHoverMouseListeners();
    259260        super.addNotify();
     
    262263    @Override
    263264    public void removeNotify() {
    264         removeHierarchyListener(hierarchyListener);
    265         removeComponentListener(componentListener);
     265        removeHierarchyListener(hierarchyListenerNavigatableComponent);
     266        removeComponentListener(componentListenerNavigatableComponent);
    266267        removePrimitiveHoverMouseListeners();
    267268        super.removeNotify();
     
    290291    /**
    291292     * Replies the layer which scale is set to.
    292      * @return the current scale layer (may be null)
     293     * @return the current scale layer (may be {@code null})
    293294     */
    294295    public NativeScaleLayer getNativeScaleLayer() {
     
    324325            ScaleList scaleList = nativeScaleLayer.getNativeScales();
    325326            if (scaleList != null) {
    326                 if (PROP_ZOOM_INTERMEDIATE_STEPS.get()) {
     327                if (Boolean.TRUE.equals(PROP_ZOOM_INTERMEDIATE_STEPS.get())) {
    327328                    scaleList = scaleList.withIntermediateSteps(PROP_ZOOM_RATIO.get());
    328329                }
     
    366367            ScaleList scaleList = nativeScaleLayer.getNativeScales();
    367368            if (scaleList != null) {
    368                 if (PROP_ZOOM_INTERMEDIATE_STEPS.get()) {
     369                if (Boolean.TRUE.equals(PROP_ZOOM_INTERMEDIATE_STEPS.get())) {
    369370                    scaleList = scaleList.withIntermediateSteps(PROP_ZOOM_RATIO.get());
    370371                }
     
    478479    /**
    479480     * Returns the current center of the viewport.
    480      *
     481     * <p>
    481482     * (Use {@link #zoomTo(EastNorth)} to the change the center.)
    482483     *
     
    489490    /**
    490491     * Returns the current scale.
    491      *
     492     * <p>
    492493     * In east/north units per pixel.
    493494     *
     
    590591    /**
    591592     * Return the point on the screen where this Coordinate would be.
    592      *
     593     * <p>
    593594     * Alternative: {@link #getState()}, then {@link MapViewState#getPointFor(ILatLon)}
    594595     * @param latlon The point, where this geopoint would be drawn.
     
    605606    /**
    606607     * Return the point on the screen where this Coordinate would be.
    607      *
     608     * <p>
    608609     * Alternative: {@link #getState()}, then {@link MapViewState#getPointFor(ILatLon)}
    609610     * @param latlon The point, where this geopoint would be drawn.
     
    616617    /**
    617618     * Return the point on the screen where this Node would be.
    618      *
     619     * <p>
    619620     * Alternative: {@link #getState()}, then {@link MapViewState#getPointFor(ILatLon)}
    620621     * @param n The node, where this geopoint would be drawn.
     
    827828                for (int i = 0; i < frames && !doStop; i++) {
    828829                    final EastNorth z = oldCenter.interpolate(finalNewCenter, (1.0+i) / frames);
    829                     GuiHelper.runInEDTAndWait(() -> {
    830                         zoomTo(z);
    831                     });
     830                    GuiHelper.runInEDTAndWait(() -> zoomTo(z));
    832831                    Thread.sleep(sleepTime);
    833832                }
     
    11091108                    if (!nlist.isEmpty()) {
    11101109                        minDistSq = distSq;
    1111                         nearestList = new ArrayList<>();
    1112                         nearestList.addAll(nlist);
     1110                        nearestList = new ArrayList<>(nlist);
    11131111                    }
    11141112                } else {
     
    11411139    /**
    11421140     * The *result* depends on the current map selection state IF use_selected is true.
    1143      *
     1141     * <p>
    11441142     * If more than one node within node.snap-distance pixels is found,
    11451143     * the nearest node selected is returned IF use_selected is true.
    1146      *
     1144     * <p>
    11471145     * Else the nearest new/id=0 node within about the same distance
    11481146     * as the true nearest node is returned.
    1149      *
     1147     * <p>
    11501148     * If no such node is found either, the true nearest node to p is returned.
    1151      *
    1152      * Finally, if a node is not found at all, null is returned.
     1149     * <p>
     1150     * Finally, if a node is not found at all, {@code null} is returned.
    11531151     *
    11541152     * @param p the screen point
     
    11651163    /**
    11661164     * The *result* depends on the current map selection state IF use_selected is true
    1167      *
     1165     * <p>
    11681166     * If more than one node within node.snap-distance pixels is found,
    11691167     * the nearest node selected is returned IF use_selected is true.
    1170      *
     1168     * <p>
    11711169     * If there are no selected nodes near that point, the node that is related to some of the preferredRefs
    1172      *
     1170     * <p>
    11731171     * Else the nearest new/id=0 node within about the same distance
    11741172     * as the true nearest node is returned.
    1175      *
     1173     * <p>
    11761174     * If no such node is found either, the true nearest node to p is returned.
    1177      *
    1178      * Finally, if a node is not found at all, null is returned.
     1175     * <p>
     1176     * Finally, if a node is not found at all, {@code null} is returned.
    11791177     *
    11801178     * @param p the screen point
     
    12891287                     * loose some precision to account for possible deviations in the calculation above
    12901288                     * e.g. if identical (A and B) come about reversed in another way, values may differ
    1291                      * -- zero out least significant 32 dual digits of mantissa..
     1289                     * -- zero out least significant 32 dual digits of mantissa.
    12921290                     */
    12931291                    double perDistSq = Double.longBitsToDouble(
    12941292                            Double.doubleToLongBits(a - (a - b + c) * (a - b + c) / 4 / c)
    1295                             >> 32 << 32); // resolution in numbers with large exponent not needed here..
     1293                            >> 32 << 32); // resolution in numbers with large exponent not needed here.
    12961294
    12971295                    if (perDistSq < snapDistanceSq && a < c + snapDistanceSq && b < c + snapDistanceSq) {
     
    14621460                .flatMap(Collection::stream)
    14631461                .filter(ws -> wset.add(ws.getWay()))
    1464                 .map(ws -> ws.getWay())
     1462                .map(IWaySegment::getWay)
    14651463                .collect(Collectors.toList());
    14661464        if (ignore != null) {
     
    15041502     * neither does the result *order*.
    15051503     * It solely depends on the distance to point p.
    1506      *
     1504     * <p>
    15071505     * First, nodes will be searched. If there are nodes within BBox found,
    15081506     * return a collection of those nodes only.
    1509      *
     1507     * <p>
    15101508     * If no nodes are found, search for nearest ways. If there are ways
    15111509     * within BBox found, return a collection of those ways only.
    1512      *
     1510     * <p>
    15131511     * If nothing is found, return an empty collection.
    15141512     *
     
    15741572    /**
    15751573     * The *result* depends on the current map selection state IF use_selected is true.
    1576      *
     1574     * <p>
    15771575     * IF use_selected is true, use {@link #getNearestNode(Point, Predicate)} to find
    15781576     * the nearest, selected node.  If not found, try {@link #getNearestWaySegment(Point, Predicate)}
    15791577     * to find the nearest selected way.
    1580      *
     1578     * <p>
    15811579     * IF use_selected is false, or if no selected primitive was found, do the following.
    1582      *
     1580     * <p>
    15831581     * If the nearest node found is within 4px of p, simply take it.
    15841582     * Else, find the nearest way segment. Then, if p is closer to its
    15851583     * middle than to the node, take the way segment, else take the node.
    1586      *
    1587      * Finally, if no nearest primitive is found at all, return null.
     1584     * <p>
     1585     * Finally, if no nearest primitive is found at all, return {@code null}.
    15881586     *
    15891587     * @param p The point on screen.
     
    16371635    /**
    16381636     * if r = 0 returns a, if r=1 returns b,
    1639      * if r = 0.5 returns center between a and b, etc..
     1637     * if r = 0.5 returns center between a and b, etc.
    16401638     *
    16411639     * @param r scale value
     
    16731671                .flatMap(Collection::stream)
    16741672                .filter(ws -> wset.add(ws.getWay()))
    1675                 .map(ws -> ws.getWay())
     1673                .map(IWaySegment::getWay)
    16761674                .collect(Collectors.toList());
    16771675
     
    17241722
    17251723    /**
    1726      * Return a ID which is unique as long as viewport dimensions are the same
     1724     * Return an ID which is unique as long as viewport dimensions are the same
    17271725     * @return A unique ID, as long as viewport dimensions are the same
    17281726     */
    17291727    public int getViewID() {
    17301728        EastNorth center = getCenter();
    1731         String x = new StringBuilder().append(center.east())
    1732                           .append('_').append(center.north())
    1733                           .append('_').append(getScale())
    1734                           .append('_').append(getWidth())
    1735                           .append('_').append(getHeight())
    1736                           .append('_').append(getProjection()).toString();
     1729        String x = String.valueOf(center.east()) +
     1730                '_' + center.north() +
     1731                '_' + getScale() +
     1732                '_' + getWidth() +
     1733                '_' + getHeight() +
     1734                '_' + getProjection();
    17371735        CRC32 id = new CRC32();
    17381736        id.update(x.getBytes(StandardCharsets.UTF_8));
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r18494 r18871  
    1313import java.util.LinkedHashMap;
    1414import java.util.List;
     15import java.util.Map;
    1516import java.util.concurrent.CopyOnWriteArrayList;
    1617import java.util.stream.Collectors;
     
    147148    }
    148149
    149     private static LinkedHashMap<String, TileSource> getAllTileSources() {
     150    private static Map<String, TileSource> getAllTileSources() {
    150151        // using a LinkedHashMap of <id, TileSource> to retain ordering but provide deduplication
    151152        return providers.stream().flatMap(
     
    366367     */
    367368    public final void refreshTileSources() {
    368         final LinkedHashMap<String, TileSource> newTileSources = getAllTileSources();
     369        final Map<String, TileSource> newTileSources = getAllTileSources();
    369370        final TileSource currentTileSource = this.getTileController().getTileSource();
    370371
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java

    r17340 r18871  
    3535        // editing cells in the first column
    3636        //
    37         mergedEntriesTableModel = this.new EntriesTableModel(ListRole.MERGED_ENTRIES) {
     37        mergedEntriesTableModel = new EntriesTableModel(ListRole.MERGED_ENTRIES) {
    3838            @Override
    3939            public boolean isCellEditable(int row, int column) {
    40                 switch(column) {
    41                 case 1: return true;
    42                 default: return false;
    43                 }
     40                return column == 1;
    4441            }
    4542        };
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    r18686 r18871  
    175175        final int n = allDialogs.size();
    176176
    177         /**
     177        /*
    178178         * reset the panels
    179179         */
     
    183183        }
    184184
    185         /**
     185        /*
    186186         * Add the elements to their respective panel.
    187187         *
     
    216216        final int numPanels = n - k;
    217217
    218         /**
     218        /*
    219219         * Determine the panel geometry
    220220         */
     
    245245            }
    246246
    247             /**
     247            /*
    248248             * If we add additional dialogs on startup (e.g. geoimage), they may
    249249             * not have an actual height yet.
     
    255255            }
    256256
    257             /** total Height */
     257            /* total Height */
    258258            final int h = mSpltPane.getMultiSplitLayout().getModel().getBounds().getSize().height;
    259259
    260             /** space, that is available for dialogs in default view (after the reconfiguration) */
     260            /* space, that is available for dialogs in default view (after the reconfiguration) */
    261261            final int s2 = h - (numPanels - 1) * DIVIDER_SIZE - sumC;
    262262
     
    264264            if (hpTrig <= 0) throw new IllegalStateException(); // Must be positive
    265265
    266             /** The new dialog gets a fair share */
     266            /* The new dialog gets a fair share */
    267267            final int hnTrig = hpTrig * s2 / (hpTrig + sumP);
    268268            triggeredBy.setPreferredSize(new Dimension(Integer.MAX_VALUE, hnTrig));
    269269
    270             /** This is remaining for the other default view dialogs */
     270            /* This is remaining for the other default view dialogs */
    271271            final int r = s2 - hnTrig;
    272272
    273             /**
     273            /*
    274274             * Take space only from dialogs that are relatively large
    275275             */
     
    289289                }
    290290            }
    291             /** adjust, without changing the sum */
     291            /* adjust, without changing the sum */
    292292            for (final ToggleDialog dlg : allDialogs) {
    293293                if (dlg != triggeredBy && dlg.isDialogInDefaultView()) {
     
    306306        }
    307307
    308         /**
     308        /*
    309309         * create Layout
    310310         */
     
    334334        mSpltPane.revalidate();
    335335
    336         /**
     336        /*
    337337         * Hide the Panel, if there is nothing to show
    338338         */
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r18686 r18871  
    256256        this.preferenceClass = prefClass;
    257257
    258         /** Use the full width of the parent element */
     258        /* Use the full width of the parent element */
    259259        setPreferredSize(new Dimension(0, preferredHeight));
    260         /** Override any minimum sizes of child elements so the user can resize freely */
     260        /* Override any minimum sizes of child elements so the user can resize freely */
    261261        setMinimumSize(new Dimension(0, 0));
    262262        this.preferredHeight = Config.getPref().getInt(preferencePrefix+".preferredHeight", preferredHeight);
     
    268268        buttonHiding = propButtonHiding.get();
    269269
    270         /** show the minimize button */
     270        /* show the minimize button */
    271271        titleBar = new TitleBar(name, iconName);
    272272        add(titleBar, BorderLayout.NORTH);
     
    293293    /**
    294294     * The action to toggle the visibility state of this toggle dialog.
    295      *
     295     * <p>
    296296     * Emits {@link PropertyChangeEvent}s for the property <code>selected</code>:
    297297     * <ul>
     
    382382    @Override
    383383    public void buttonHidden() {
    384         if ((Boolean) toggleAction.getValue("selected")) {
     384        if (Boolean.TRUE.equals(toggleAction.getValue("selected"))) {
    385385            toggleAction.actionPerformed(null);
    386386        }
     
    597597            // show the help button
    598598            addButton(new JButton(ImageProvider.get("help", ImageProvider.ImageSizes.SMALLICON)),
    599                     tr("Open help for this panel"), e -> {
    600                 HelpBrowser.setUrlForHelpTopic(helpTopic());
    601             });
     599                    tr("Open help for this panel"), e -> HelpBrowser.setUrlForHelpTopic(helpTopic()));
    602600
    603601            // show the sticky button
     
    967965                        ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1, buttonRow.size()));
    968966                buttonsPanel.add(buttonRowPanel);
    969                 for (SideButton button : buttonRow) {
    970                     buttonRowPanel.add(button);
    971                     javax.swing.Action action = button.getAction();
     967                for (SideButton sideButton : buttonRow) {
     968                    buttonRowPanel.add(sideButton);
     969                    javax.swing.Action action = sideButton.getAction();
    972970                    if (action != null) {
    973971                        buttonActions.add(action);
    974972                    } else {
    975                         Logging.warn("Button " + button + " doesn't have action defined");
     973                        Logging.warn("Button " + sideButton + " doesn't have action defined");
    976974                        Logging.error(new Exception());
    977975                    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSortUtils.java

    r17867 r18871  
    4747                INode n3 = w.getNode(2);
    4848                if (n1 != null && n2 != null && n3 != null && w.isClosed()) {
    49                     /** do some simple determinant / cross product test on the first 3 nodes
    50                         to see, if the roundabout goes clock wise or ccw */
     49                    /* do some simple determinant / cross product test on the first 3 nodes
     50                       to see, if the roundabout goes clock wise or ccw */
    5151                    EastNorth en1 = n1.getEastNorth();
    5252                    EastNorth en2 = n2.getEastNorth();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r16886 r18871  
    77
    88import java.util.ArrayList;
     9import java.util.Collections;
    910import java.util.List;
    10 import java.util.stream.Collectors;
    1111
    1212import org.openstreetmap.josm.data.osm.Node;
     
    4545    public List<WayConnectionType> updateLinks(Relation r, List<RelationMember> members) {
    4646        this.members = members;
    47         final List<WayConnectionType> con = members.stream()
    48                 .map(ignore -> (WayConnectionType) null)
    49                 .collect(Collectors.toList());
     47        final List<WayConnectionType> con = new ArrayList<>(Collections.nCopies(members.size(), null));
    5048
    5149        firstGroupIdx = 0;
     
    165163    }
    166164
    167     private boolean isSuperRoute(Relation r) {
     165    private static boolean isSuperRoute(Relation r) {
    168166        return r != null && r.hasTag("type", "superroute");
    169167    }
     
    226224            if (RelationSortUtils.isBackward(m) != reversed) return BACKWARD;
    227225            else return FORWARD;
    228         } else { /** guess the direction and see if it fits with the next member */
     226        } else { /* guess the direction and see if it fits with the next member */
    229227            if (determineDirection(i, FORWARD, i+1) != NONE) return FORWARD;
    230228            if (determineDirection(i, BACKWARD, i+1) != NONE) return BACKWARD;
     
    332330     * Determines the direction of way {@code k} with respect to the way {@code ref_i}.
    333331     * The way {@code ref_i} is assumed to have the direction {@code ref_direction} and to be the predecessor of {@code k}.
    334      *
     332     * <p>
    335333     * If both ways are not linked in any way, NONE is returned.
    336      *
     334     * <p>
    337335     * Else the direction is given as follows:
    338336     * Let the relation be a route of oneway streets, and someone travels them in the given order.
     
    363361            return NONE;
    364362
    365         /** the list of nodes the way k can dock to */
     363        /* the list of nodes the way k can dock to */
    366364        List<Node> refNodes = new ArrayList<>();
    367365
     
    419417    }
    420418
    421     private boolean isConnected(Way way1, Way way2) {
     419    private static boolean isConnected(Way way1, Way way2) {
    422420        return way1 != null && way2 != null && way1.isUsable() && way2.isUsable()
    423421                && (way1.isFirstLastNode(way2.firstNode()) || way1.isFirstLastNode(way2.lastNode()));
  • trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java

    r18218 r18871  
    1616import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration.OverpassWizardCallbacks;
    1717import org.openstreetmap.josm.gui.tagging.ac.AutoCompComboBoxModel;
     18import org.openstreetmap.josm.gui.widgets.JosmComboBoxModel;
    1819import org.openstreetmap.josm.tools.Logging;
    1920import org.openstreetmap.josm.tools.SearchCompilerQueryWizard;
     
    2930
    3031    private static final ListProperty OVERPASS_WIZARD_HISTORY =
    31             new ListProperty("download.overpass.wizard", new ArrayList<String>());
     32            new ListProperty("download.overpass.wizard", new ArrayList<>());
    3233    private final OverpassWizardCallbacks callbacks;
    3334
     
    3738    private static final int CANCEL = 2;
    3839
    39     private AutoCompComboBoxModel<SearchSetting> model;
     40    private final AutoCompComboBoxModel<SearchSetting> model;
    4041
    4142    /** preferences reader/writer with automatic transmogrification to and from String */
    42     private AutoCompComboBoxModel<SearchSetting>.Preferences prefs;
     43    private final JosmComboBoxModel<SearchSetting>.Preferences prefs;
    4344
    4445    /**
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r18801 r18871  
    200200            if (e.getButton() == MouseEvent.BUTTON3) {
    201201                Component component = e.getComponent();
    202                 if (POPUP_MENU_ENABLED.get() && component.isShowing()) {
     202                if (Boolean.TRUE.equals(POPUP_MENU_ENABLED.get()) && component.isShowing()) {
    203203                    new TileSourceLayerPopup(e.getX(), e.getY()).show(component, e.getX(), e.getY());
    204204                }
     
    422422
    423423        private static String getSizeString(int size) {
    424             return new StringBuilder().append(size).append('x').append(size).toString();
     424            return Integer.toString(size) + 'x' + size;
    425425        }
    426426
     
    452452                        getSizeString(tile.getTileSource().getTileSize())));
    453453                content.add(Arrays.asList(tr("Tile display size"),
    454                         new StringBuilder().append(displaySize.getWidth())
    455                                 .append('x')
    456                                 .append(displaySize.getHeight()).toString()));
     454                        Double.toString(displaySize.getWidth()) +
     455                                'x' +
     456                                displaySize.getHeight()));
    457457                if (layer.coordinateConverter.requiresReprojection()) {
    458458                    content.add(Arrays.asList(tr("Reprojection"),
     
    561561        MapView.addZoomChangeListener(this);
    562562
    563         if (this instanceof NativeScaleLayer && NavigatableComponent.PROP_ZOOM_SCALE_FOLLOW_NATIVE_RES_AT_LOAD.get()) {
     563        if (this instanceof NativeScaleLayer && Boolean.TRUE.equals(NavigatableComponent.PROP_ZOOM_SCALE_FOLLOW_NATIVE_RES_AT_LOAD.get())) {
    564564            event.getMapView().setNativeScaleLayer((NativeScaleLayer) this);
    565565        }
     
    640640            tileSize = tileSource.getTileSize();
    641641        }
    642         /**
     642        /*
    643643         * As we can see part of the tile at the top and at the bottom, use Math.ceil(...) + 1 to accommodate for that
    644644         */
     
    646646        int maxXtiles = (int) Math.ceil((double) width / tileSize + 1);
    647647        int visibleTiles = maxXtiles * maxYtiles;
    648         /**
    649          * Take into account ZOOM_OFFSET to calculate real number of tiles and multiply by 7, to cover all tiles, that might be
    650          * accessed when looking for tiles outside current zoom level.
    651          *
    652          * Currently we use otherZooms = {1, 2, -1, -2, -3, -4, -5}
    653          *
    654          * The value should be sum(2^x for x in (-5 to 2)) - 1
    655          * -1 to exclude current zoom level
    656          *
    657          * Check call to tryLoadFromDifferentZoom
    658          * @see #tryLoadFromDifferentZoom(Graphics2D, int, List<Tile>,int)
    659          * @see #drawInViewArea((Graphics2D, MapView, ProjectionBounds)
    660          *
    661          * Add +2 to maxYtiles / maxXtiles to add space in cache for extra tiles in current zoom level that are
    662          * download by overloadTiles(). This is not added in computation of visibleTiles as this unnecessarily grow the cache size
    663          * @see #overloadTiles()
    664          */
    665         int ret = (int) Math.ceil(
    666                 Math.pow(2d, ZOOM_OFFSET.get()) * // use offset to decide, how many tiles are visible
    667                 visibleTiles * 7 + // 7 to cover tiles from other zooms as described above
    668                 ((maxYtiles + 2) * (maxXtiles +2))); // to add as many tiles as they will be accessed on current zoom level
     648
     649        int ret = calculateRealTiles(visibleTiles, maxXtiles, maxYtiles);
    669650        Logging.info("AbstractTileSourceLayer: estimated visible tiles: {0}, estimated cache size: {1}", visibleTiles, ret);
    670651        return ret;
     652    }
     653
     654    /**
     655     * Take into account ZOOM_OFFSET to calculate real number of tiles and multiply by 7, to cover all tiles, that might be
     656     * accessed when looking for tiles outside current zoom level.
     657     * <p>
     658     * Currently we use otherZooms = {1, 2, -1, -2, -3, -4, -5}
     659     * <p>
     660     * The value should be sum(2^x for x in (-5 to 2)) - 1
     661     * -1 to exclude current zoom level
     662     * <p>
     663     * Check call to tryLoadFromDifferentZoom
     664     * @see #tryLoadFromDifferentZoom(Graphics2D, int, List, int)
     665     * @see #drawInViewArea(Graphics2D, MapView, ProjectionBounds)
     666     *
     667     * Add +2 to maxYtiles / maxXtiles to add space in cache for extra tiles in current zoom level that are
     668     * download by overloadTiles(). This is not added in computation of visibleTiles as this unnecessarily grow the cache size
     669     * @see TileSet#overloadTiles()
     670     */
     671    private static int calculateRealTiles(int visibleTiles, int maxXtiles, int maxYtiles) {
     672        return (int) Math.ceil(
     673                Math.pow(2d, ZOOM_OFFSET.get()) * // use offset to decide, how many tiles are visible
     674                        visibleTiles * 7 + // 7 to cover tiles from other zooms as described above
     675                        ((maxYtiles + 2) * (maxXtiles +2))); // to add as many tiles as they will be accessed on current zoom level
    671676    }
    672677
     
    13251330         */
    13261331        private void overloadTiles() {
    1327             /**
     1332            /*
    13281333             * consult calculation in estimateTileCacheSize() before changing values here.
    13291334             *
     
    15961601        }
    15971602        if (getDisplaySettings().isAutoZoom()) {
    1598             /**
     1603            /*
    15991604             * consult calculation in estimateTileCacheSize() before changing values here.
    16001605             *
     
    19471952     * Calculates tiles, that needs to be downloaded to cache, gets a current tile loader and creates a task to download
    19481953     * all of the tiles. Buffer contains at least one tile.
    1949      *
     1954     * <p>
    19501955     * To prevent accidental clear of the queue, new download executor is created with separate queue
    19511956     *
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r16967 r18871  
    4242public class WMSLayer extends AbstractCachedTileSourceLayer<AbstractWMSTileSource> {
    4343    private static final String PREFERENCE_PREFIX = "imagery.wms";
    44     /**
     44    /*
    4545     * Registers all setting properties
    4646     */
     
    148148
    149149    private Projection chooseProjection(Projection requested) {
    150         if (serverProjections.contains(requested.toCode())) {
    151             return requested;
    152         } else {
     150        if (!serverProjections.contains(requested.toCode())) {
    153151            LatLon center = MainApplication.isDisplayingMapView() ?
    154152                    requested.eastNorth2latlon(MainApplication.getMap().mapView.getCenter()) : null;
     
    173171            }
    174172            Logging.warn(tr("Unable to find supported projection for layer {0}. Using {1}.", getName(), requested.toCode()));
    175             return requested;
    176         }
     173        }
     174        return requested;
    177175    }
    178176
  • trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java

    r16553 r18871  
    2323 * WMTS layer based on AbstractTileSourceLayer. Overrides few methods to align WMTS to Tile based computations
    2424 * but most magic is done within WMTSTileSource class.
    25  *
     25 * <p>
    2626 * Full specification of the protocol available at:
    27  * http://www.opengeospatial.org/standards/wmts
     27 * <a href="https://www.ogc.org/standard/wmts/">OpenGIS Web Map Tile Service Implementation Standard</a>
    2828 *
    2929 * @author Wiktor NiesiobÄ™dzki
     
    3333    private static final String PREFERENCE_PREFIX = "imagery.wmts";
    3434
    35     /**
     35    /*
    3636     * Registers all setting properties
    3737     */
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r18797 r18871  
    2222import java.io.File;
    2323import java.util.ArrayList;
    24 import java.util.Arrays;
    2524import java.util.Collection;
    2625import java.util.Collections;
     
    193192        this.data.addImageDataUpdateListener(this);
    194193        this.data.setLayer(this);
    195         synchronized (ImageViewerDialog.class) {
    196             if (!ImageViewerDialog.hasInstance()) {
    197                 GuiHelper.runInEDTAndWait(ImageViewerDialog::createInstance);
    198             }
     194        if (!ImageViewerDialog.hasInstance()) {
     195            GuiHelper.runInEDTAndWait(() -> {
     196                if (!ImageViewerDialog.hasInstance()) {
     197                    ImageViewerDialog.createInstance();
     198                }
     199            });
    199200        }
    200201        if (getInvalidGeoImages().size() == data.size()) {
     
    202203            // We do have to wrap the EDT call in a worker call, since layers may be created in the EDT.
    203204            // And the layer must be added to the layer list in order for the dialog to work properly.
    204             MainApplication.worker.execute(() -> GuiHelper.runInEDT(() -> {
    205                 ImageViewerDialog.getInstance().displayImages(this.getSelection());
    206             }));
     205            MainApplication.worker.execute(() -> GuiHelper.runInEDT(() -> ImageViewerDialog.getInstance().displayImages(this.getSelection())));
    207206        }
    208207    }
     
    813812    /**
    814813     * Stop to load thumbnails.
    815      *
     814     * <p>
    816815     * Can be called at any time to make sure that the
    817816     * thumbnail loader is stopped.
     
    826825    /**
    827826     * Called to signal that the loading of thumbnails has finished.
    828      *
     827     * <p>
    829828     * Usually called from {@link ThumbsLoader} in another thread.
    830829     */
     
    874873        return gpxData != null ? MainApplication.getLayerManager().getLayersOfType(GpxLayer.class)
    875874                .stream().filter(l -> gpxData.equals(l.getGpxData()))
    876                 .findFirst().orElseThrow(() -> new IllegalStateException()) : null;
     875                .findFirst().orElseThrow(IllegalStateException::new) : null;
    877876    }
    878877
     
    912911        if (gpxFauxData == null) {
    913912            gpxFauxData = new GpxData();
    914             gpxFauxData.addTrack(new GpxTrack(Arrays.asList(
     913            gpxFauxData.addTrack(new GpxTrack(Collections.singletonList(
    915914                    data.getImages().stream().map(ImageEntry::asWayPoint).filter(Objects::nonNull).collect(toList())),
    916915                    Collections.emptyMap()));
     
    974973    @Override
    975974    public Data getData() {
    976         return data;
     975        return getImageData();
    977976    }
    978977
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java

    r18684 r18871  
    120120        private boolean restart;
    121121
     122        @SuppressWarnings("DoNotCall") // we are calling `run` from the thread we want it to be running on (aka recursive)
    122123        @Override
    123124        public void run() {
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r18753 r18871  
    240240        hdopAlpha = Config.getPref().getInt("hdop.color.alpha", -1);
    241241        velocityScale = ColorScale.createHSBScale(256);
    242         /** Colors (without custom alpha channel, if given) for HDOP painting. **/
     242        /* Colors (without custom alpha channel, if given) for HDOP painting. */
    243243        hdopScale = ColorScale.createHSBScale(256).makeReversed().addTitle(tr("HDOP"));
    244244        qualityScale = ColorScale.createFixedScale(rtkLibQualityColors).addTitle(tr("Quality")).addColorBarTitles(rtkLibQualityNames);
     
    769769     */
    770770    private void drawArrows(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    771         /****************************************************************
    772          ********** STEP 3b - DRAW NICE ARROWS **************************
    773          ****************************************************************/
     771        drawArrows3b(g, mv, visibleSegments);
     772        drawArrows3c(g, mv, visibleSegments);
     773    }
     774
     775    /****************************************************************
     776     ********** STEP 3b - DRAW NICE ARROWS **************************
     777     ****************************************************************/
     778    private void drawArrows3b(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    774779        if (lines && arrows && !arrowsFast) {
    775780            Point old = null;
     
    798803            } // end for trkpnt
    799804        }
    800 
    801         /****************************************************************
    802          ********** STEP 3c - DRAW FAST ARROWS **************************
    803          ****************************************************************/
     805    }
     806
     807    /****************************************************************
     808     ********** STEP 3c - DRAW FAST ARROWS **************************
     809     ****************************************************************/
     810    private void drawArrows3c(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    804811        if (lines && arrows && arrowsFast) {
    805812            Point old = null;
     
    836843     */
    837844    private void drawPoints(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    838         /****************************************************************
    839          ********** STEP 3d - DRAW LARGE POINTS AND HDOP CIRCLE *********
    840          ****************************************************************/
     845        drawPointsStep3d(g, mv, visibleSegments);
     846        drawPointsStep3e(g, mv, visibleSegments);
     847        drawPointsStep3f(g, mv, visibleSegments);
     848    }
     849
     850    /****************************************************************
     851     ********** STEP 3d - DRAW LARGE POINTS AND HDOP CIRCLE *********
     852     ****************************************************************/
     853    private void drawPointsStep3d(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    841854        if (large || hdopCircle) {
    842             final int halfSize = largesize/2;
     855            final int halfSize = largesize / 2;
    843856            for (WayPoint trkPnt : visibleSegments) {
    844857                LatLon c = trkPnt.getCoor();
     
    855868                    }
    856869                    Color customColoringTransparent = hdopAlpha < 0 ? trkPnt.customColoring :
    857                         new Color((trkPnt.customColoring.getRGB() & 0x00ffffff) | (hdopAlpha << 24), true);
     870                            new Color((trkPnt.customColoring.getRGB() & 0x00ffffff) | (hdopAlpha << 24), true);
    858871                    g.setColor(customColoringTransparent);
    859872                    // hdop circles
    860873                    int hdopp = mv.getPoint(new LatLon(
    861874                            trkPnt.getCoor().lat(),
    862                             trkPnt.getCoor().lon() + 2d*6*hdop*360/40000000d)).x - screen.x;
    863                     g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360);
     875                            trkPnt.getCoor().lon() + 2d * 6 * hdop * 360 / 40000000d)).x - screen.x;
     876                    g.drawArc(screen.x - hdopp / 2, screen.y - hdopp / 2, hdopp, hdopp, 0, 360);
    864877                }
    865878                if (large) {
     
    870883                        } else {
    871884                            Color customColoringTransparent = largePointAlpha < 0 ? trkPnt.customColoring :
    872                                 new Color((trkPnt.customColoring.getRGB() & 0x00ffffff) | (largePointAlpha << 24), true);
     885                                    new Color((trkPnt.customColoring.getRGB() & 0x00ffffff) | (largePointAlpha << 24), true);
    873886
    874887                            g.setColor(customColoringTransparent);
     
    877890                        }
    878891                    }
    879                     g.fillRect(screen.x-halfSize, screen.y-halfSize, largesize, largesize);
     892                    g.fillRect(screen.x - halfSize, screen.y - halfSize, largesize, largesize);
    880893                }
    881894            } // end for trkpnt
    882895        } // end if large || hdopcircle
    883 
    884         /****************************************************************
    885          ********** STEP 3e - DRAW SMALL POINTS FOR LINES ***************
    886          ****************************************************************/
     896    }
     897
     898    /****************************************************************
     899     ********** STEP 3e - DRAW SMALL POINTS FOR LINES ***************
     900     ****************************************************************/
     901    private void drawPointsStep3e(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    887902        if (!large && lines) {
    888903            g.setColor(neutralColor);
     
    899914            } // end for trkpnt
    900915        } // end if large
    901 
    902         /****************************************************************
    903          ********** STEP 3f - DRAW SMALL POINTS INSTEAD OF LINES ********
    904          ****************************************************************/
     916    }
     917
     918    /****************************************************************
     919     ********** STEP 3f - DRAW SMALL POINTS INSTEAD OF LINES ********
     920     ****************************************************************/
     921    private void drawPointsStep3f(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    905922        if (!large && !lines) {
    906923            g.setColor(neutralColor);
     
    13081325                }
    13091326
    1310                 boolean bDrawIt = false;
    1311 
    13121327                // when one of segment is mapped to black
    1313                 bDrawIt = bDrawIt || (lastPixelColor == 0) || (thePixelColor == 0);
     1328                boolean bDrawIt = (lastPixelColor == 0) || (thePixelColor == 0);
    13141329
    13151330                // different color
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/LoadAllTilesAction.java

    r11950 r18871  
    22package org.openstreetmap.josm.gui.layer.imagery;
    33
    4 /**
    5  * Load all tiles.
    6  * @since 11950 (extracted from {@link AbstractTileSourceLayer})
    7  */
    84import static org.openstreetmap.josm.tools.I18n.tr;
    95
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r18494 r18871  
    4646/**
    4747 * MapCSS selector.
    48  *
     48 * <p>
    4949 * A rule has two parts, a selector and a declaration block
    5050 * e.g.
     
    5555 *
    5656 * The selector decides, if the declaration block gets applied or not.
    57  *
     57 * <p>
    5858 * All implementing classes of Selector are immutable.
    5959 */
     
    355355            private Map<List<Way>, List<WaySegment>> findCrossings(IPrimitive area,
    356356                    Map<Point2D, List<WaySegment>> cellSegments) {
    357                 /** The detected crossing ways */
     357                /* The detected crossing ways */
    358358                Map<List<Way>, List<WaySegment>> crossingWays = new HashMap<>(50);
    359359                if (area instanceof Way) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r18603 r18871  
    765765    private static void prepareFileChooser(String url, AbstractFileChooser fc) {
    766766        if (Utils.isBlank(url)) return;
    767         URL sourceUrl = null;
     767        URL sourceUrl;
    768768        try {
    769769            sourceUrl = new URL(url);
     
    816816            p.add(new JLabel(tr("URL / File:")), GBC.std().insets(15, 0, 5, 0));
    817817            p.add(tfURL, GBC.std().insets(0, 0, 5, 5));
    818             JButton fileChooser = new JButton(new LaunchFileChooserAction());
     818            JButton fileChooser = new JButton(new LaunchFileChooserSourceTypeAction());
    819819            fileChooser.setMargin(new Insets(0, 0, 0, 0));
    820820            p.add(fileChooser, GBC.eol().insets(0, 0, 5, 5));
     
    848848        }
    849849
    850         class LaunchFileChooserAction extends AbstractAction {
    851             LaunchFileChooserAction() {
     850        class LaunchFileChooserSourceTypeAction extends AbstractAction {
     851            LaunchFileChooserSourceTypeAction() {
    852852                new ImageProvider("open").getResource().attachImageIcon(this);
    853853                putValue(SHORT_DESCRIPTION, tr("Launch a file chooser to select a file"));
     
    15351535            gc.weightx = 0.0;
    15361536            gc.weighty = 1.0;
    1537             add(new JButton(new LaunchFileChooserAction()));
     1537            add(new JButton(new LaunchFileChooserEditCellAction()));
    15381538
    15391539            tfFileName.addFocusListener(
     
    16221622        }
    16231623
    1624         class LaunchFileChooserAction extends AbstractAction {
    1625             LaunchFileChooserAction() {
     1624        class LaunchFileChooserEditCellAction extends AbstractAction {
     1625            LaunchFileChooserEditCellAction() {
    16261626                putValue(NAME, "...");
    16271627                putValue(SHORT_DESCRIPTION, tr("Launch a file chooser to select a file"));
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r18801 r18871  
    2424import java.util.Collection;
    2525import java.util.Collections;
     26import java.util.HashMap;
    2627import java.util.LinkedList;
    2728import java.util.List;
     
    299300                return null;
    300301
    301             ActionDefinition result = new ActionDefinition(action);
     302            ActionDefinition actionDefinition = new ActionDefinition(action);
    302303
    303304            if (action instanceof ParameterizedAction) {
     
    305306
    306307                ParameterizedAction parametrizedAction = (ParameterizedAction) action;
    307                 Map<String, ActionParameter<?>> actionParams = new ConcurrentHashMap<>();
     308                Map<String, ActionParameter<?>> actionParams = new HashMap<>();
    308309                for (ActionParameter<?> param: parametrizedAction.getActionParameters()) {
    309310                    actionParams.put(param.getName(), param);
     
    317318                        ActionParameter<?> actionParam = actionParams.get(paramName);
    318319                        if (actionParam != null) {
    319                             result.getParameters().put(paramName, actionParam.readFromString(paramValue));
     320                            actionDefinition.getParameters().put(paramName, actionParam.readFromString(paramValue));
    320321                        }
    321322                    }
     
    332333                    String paramValue = readTillChar(',', '}');
    333334                    if ("icon".equals(paramName) && !paramValue.isEmpty()) {
    334                         result.setIcon(paramValue);
     335                        actionDefinition.setIcon(paramValue);
    335336                    } else if ("name".equals(paramName) && !paramValue.isEmpty()) {
    336                         result.setName(paramValue);
     337                        actionDefinition.setName(paramValue);
    337338                    }
    338339                    skip(',');
     
    341342            }
    342343
    343             return result;
     344            return actionDefinition;
    344345        }
    345346
     
    798799        private JButton createButton(String name) {
    799800            JButton b = new JButton();
    800             if ("up".equals(name)) {
    801                 b.setIcon(ImageProvider.get("dialogs", "up", ImageSizes.LARGEICON));
    802                 b.setToolTipText(tr("Move the currently selected members up"));
    803             } else if ("down".equals(name)) {
    804                 b.setIcon(ImageProvider.get("dialogs", "down", ImageSizes.LARGEICON));
    805                 b.setToolTipText(tr("Move the currently selected members down"));
    806             } else if ("<".equals(name)) {
    807                 b.setIcon(ImageProvider.get("dialogs/conflict", "copybeforecurrentright", ImageSizes.LARGEICON));
    808                 b.setToolTipText(tr("Add all objects selected in the current dataset before the first selected member"));
    809             } else if (">".equals(name)) {
    810                 b.setIcon(ImageProvider.get("dialogs", "delete", ImageSizes.LARGEICON));
    811                 b.setToolTipText(tr("Remove"));
     801            switch (name) {
     802                case "up":
     803                    b.setIcon(ImageProvider.get("dialogs", "up", ImageSizes.LARGEICON));
     804                    b.setToolTipText(tr("Move the currently selected members up"));
     805                    break;
     806                case "down":
     807                    b.setIcon(ImageProvider.get("dialogs", "down", ImageSizes.LARGEICON));
     808                    b.setToolTipText(tr("Move the currently selected members down"));
     809                    break;
     810                case "<":
     811                    b.setIcon(ImageProvider.get("dialogs/conflict", "copybeforecurrentright", ImageSizes.LARGEICON));
     812                    b.setToolTipText(tr("Add all objects selected in the current dataset before the first selected member"));
     813                    break;
     814                case ">":
     815                    b.setIcon(ImageProvider.get("dialogs", "delete", ImageSizes.LARGEICON));
     816                    b.setToolTipText(tr("Remove"));
     817                    break;
     818                default:
     819                    // do nothing
    812820            }
    813821            b.addActionListener(moveAction);
     
    10441052                        continue;
    10451053                    } else if (!(tb instanceof String)) {
    1046                         if (!(tb instanceof Boolean) || (Boolean) tb) {
     1054                        if (!(tb instanceof Boolean) || Boolean.TRUE.equals(tb)) {
    10471055                            Logging.info(tr("Strange toolbar value: {0}",
    10481056                            action.getClass().getName()));
     
    11621170    /**
    11631171     * Parse the toolbar preference setting and construct the toolbar GUI control.
    1164      *
     1172     * <p>
    11651173     * Call this, if anything has changed in the toolbar settings and you want to refresh
    11661174     * the toolbar content (e.g. after registering actions in a plugin)
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    r18781 r18871  
    216216        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    217217            if (columnIndex == 1 && aValue instanceof Color) {
    218                 data.get(rowIndex).info.setValue((Color) aValue);
     218                getEntry(rowIndex).info.setValue((Color) aValue);
    219219                fireTableCellUpdated(rowIndex, columnIndex);
    220220            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheSettingsPanel.java

    r18186 r18871  
    99import java.util.ArrayList;
    1010import java.util.Comparator;
     11import java.util.HashMap;
    1112import java.util.List;
    1213import java.util.Locale;
     
    1415import java.util.Map.Entry;
    1516import java.util.Set;
    16 import java.util.concurrent.ConcurrentHashMap;
    1717
    1818import javax.swing.AbstractAction;
     
    120120    public static String[][] getCacheStats(CacheAccess<String, BufferedImageCacheEntry> cache) {
    121121        Set<String> keySet = cache.getCacheControl().getKeySet();
    122         Map<String, int[]> temp = new ConcurrentHashMap<>(); // use int[] as a Object reference to int, gives better performance
     122        Map<String, int[]> temp = new HashMap<>(); // use int[] as a Object reference to int, gives better performance
    123123        for (String key: keySet) {
    124124            String[] keyParts = key.split(":", 2);
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r18694 r18871  
    306306                boolean requiresRestart = PluginHandler.removePlugins(deactivatedPlugins);
    307307                if (requiresRestart)
    308                     return requiresRestart;
     308                    return true;
    309309            }
    310310            return model.getNewlyActivatedPlugins().stream().anyMatch(pi -> !pi.canloadatruntime);
     
    521521            // It removes a list item mark at the beginning of the line: +, -, *
    522522            // It removes the version number after the plugin, like: 123, (123), (v5.7alpha3), (1b3), (v1-SNAPSHOT-1)...
    523             Pattern regex = Pattern.compile("^[-+\\*\\s]*|\\s[\\d\\s]*(\\([^\\(\\)\\[\\]]*\\))?[\\d\\s]*$");
     523            Pattern regex = Pattern.compile("^[-+*\\s]*|\\s[\\d\\s]*(\\([^()\\[\\]]*\\))?[\\d\\s]*$");
    524524            for (String line : lines) {
    525525                String name = regex.matcher(line).replaceAll("");
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r18417 r18871  
    5151/**
    5252 * Projection preferences.
    53  *
     53 * <p>
    5454 * How to add new Projections:
    5555 *  - Find EPSG code for the projection.
    56  *  - Look up the parameter string for Proj4, e.g. on http://spatialreference.org/
     56 *  - Look up the parameter string for Proj4, e.g. on <a href="https://spatialreference.org">https://spatialreference.org</a>/
    5757 *      and add it to the file 'data/projection/epsg' in JOSM trunk
    5858 *  - Search for official references and verify the parameter values. These
    5959 *      documents are often available in the local language only.
    6060 *  - Use {@link #registerProjectionChoice}, to make the entry known to JOSM.
    61  *
     61 * <p>
    6262 * In case there is no EPSG code:
    6363 *  - override {@link AbstractProjectionChoice#getProjection()} and provide
     
    8787    /**
    8888     * Mercator Projection.
    89      *
     89     * <p>
    9090     * The center of the mercator projection is always the 0 grad coordinate.
    91      *
    92      * See also USGS Bulletin 1532 (http://pubs.usgs.gov/bul/1532/report.pdf)
    93      * initially EPSG used 3785 but that has been superseded by 3857, see https://www.epsg-registry.org/
     91     * <p>
     92     * See also <a href="https://pubs.usgs.gov/bul/1532/report.pdf">USGS Bulletin 1532</a>
     93     * initially EPSG used 3785 but that has been superseded by 3857, see <a href="https://www.epsg-registry.org/">epsg-registry.org</a>
    9494     */
    9595    public static final ProjectionChoice mercator = registerProjectionChoice(tr("Mercator"), "core:mercator", 3857);
     
    9797    /**
    9898     * Lambert conic conform 4 zones using the French geodetic system NTF.
    99      *
     99     * <p>
    100100     * This newer version uses the grid translation NTF&lt;-&gt;RGF93 provided by IGN for a submillimetric accuracy.
    101101     * (RGF93 is the French geodetic system similar to WGS84 but not mathematically equal)
    102      *
    103      * Source: http://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf
     102     * <p>
     103     * Source: <a href="https://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf">Changement_systeme_geodesique.pdf</a>
    104104     */
    105105    public static final ProjectionChoice lambert = new LambertProjectionChoice();
     
    107107    /**
    108108     * French regions in the Caribbean Sea and Indian Ocean.
    109      *
     109     * <p>
    110110     * Using the UTM transvers Mercator projection and specific geodesic settings.
    111111     */
     
    114114    /**
    115115     * Lambert Conic Conform 9 Zones projection.
    116      *
     116     * <p>
    117117     * As specified by the IGN in this document
    118      * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf
     118     * <a href="https://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf">cc9zones.pdf</a>
    119119     */
    120120    public static final ProjectionChoice lambert_cc9 = new LambertCC9ZonesProjectionChoice();
     
    122122    static {
    123123
    124         /************************
     124        /* ***********************
    125125         * Global projections.
    126126         */
    127127
    128         /**
     128        /* *
    129129         * UTM.
    130130         */
    131131        registerProjectionChoice(new UTMProjectionChoice());
    132132
    133         /************************
     133        /* ***********************
    134134         * Regional - alphabetical order by country code.
    135135         */
    136136
    137         /**
     137        /*
    138138         * Belgian Lambert 72 projection.
    139          *
     139         * <p>
    140140         * As specified by the Belgian IGN in this document:
    141141         * http://www.ngi.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf
     
    145145        registerProjectionChoice(tr("Belgian Lambert 1972"), "core:belgianLambert1972", 31370);     // BE
    146146
    147         /**
     147        /*
    148148         * Belgian Lambert 2008 projection.
    149          *
     149         * <p>
    150150         * As specified by the Belgian IGN in this document:
    151151         * http://www.ngi.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf
     
    155155        registerProjectionChoice(tr("Belgian Lambert 2008"), "core:belgianLambert2008", 3812);      // BE
    156156
    157         /**
     157        /*
    158158         * SwissGrid CH1903 / L03, see https://en.wikipedia.org/wiki/Swiss_coordinate_system.
    159          *
     159         * <p>
    160160         * Actually, what we have here, is CH1903+ (EPSG:2056), but without
    161161         * the additional false easting of 2000km and false northing 1000 km.
    162          *
     162         * <p>
    163163         * To get to CH1903, a shift file is required. So currently, there are errors
    164164         * up to 1.6m (depending on the location).
     
    168168        registerProjectionChoice(new GaussKruegerProjectionChoice());                               // DE
    169169
    170         /**
     170        /*
    171171         * Estonian Coordinate System of 1997.
    172          *
     172         * <p>
    173173         * Thanks to Johan Montagnat and its geoconv java converter application
    174174         * (https://www.i3s.unice.fr/~johan/gps/ , published under GPL license)
     
    177177        registerProjectionChoice(tr("Lambert Zone (Estonia)"), "core:lambertest", 3301);            // EE
    178178
    179         /**
     179        /*
    180180         * Lambert conic conform 4 zones using the French geodetic system NTF.
    181          *
     181         * <p>
    182182         * This newer version uses the grid translation NTF<->RGF93 provided by IGN for a submillimetric accuracy.
    183183         * (RGF93 is the French geodetic system similar to WGS84 but not mathematically equal)
    184          *
    185          * Source: http://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf
     184         * <p>
     185         * Source: https://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf
    186186         * @author Pieren
    187187         */
    188188        registerProjectionChoice(lambert);                                                          // FR
    189189
    190         /**
     190        /*
    191191         * Lambert 93 projection.
    192          *
     192         * <p>
    193193         * As specified by the IGN in this document
    194          * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/Lambert-93.pdf
     194         * https://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/Lambert-93.pdf
    195195         * @author Don-vip
    196196         */
    197197        registerProjectionChoice(tr("Lambert 93 (France)"), "core:lambert93", 2154);                // FR
    198198
    199         /**
     199        /*
    200200         * Lambert Conic Conform 9 Zones projection.
    201          *
     201         * <p>
    202202         * As specified by the IGN in this document
    203          * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf
     203         * https://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf
    204204         * @author Pieren
    205205         */
    206206        registerProjectionChoice(lambert_cc9);                                                      // FR
    207207
    208         /**
     208        /*
    209209         * French departements in the Caribbean Sea and Indian Ocean.
    210          *
     210         * <p>
    211211         * Using the UTM transvers Mercator projection and specific geodesic settings.
    212212         */
    213213        registerProjectionChoice(utm_france_dom);                                                   // FR
    214214
    215         /**
     215        /*
    216216         * LKS-92/ Latvia TM projection.
    217          *
     217         * <p>
    218218         * Based on data from spatialreference.org.
    219          * http://spatialreference.org/ref/epsg/3059/
     219         * https://spatialreference.org/ref/epsg/3059/
    220220         *
    221221         * @author Viesturs Zarins
     
    223223        registerProjectionChoice(tr("LKS-92 (Latvia TM)"), "core:tmerclv", 3059);                   // LV
    224224
    225         /**
     225        /*
    226226         * Netherlands RD projection
    227227         *
     
    230230        registerProjectionChoice(tr("Rijksdriehoekscoördinaten (Netherlands)"), "core:dutchrd", 28992); // NL
    231231
    232         /**
     232        /*
    233233         * PUWG 1992 and 2000 are the official cordinate systems in Poland.
    234          *
     234         * <p>
    235235         * They use the same math as UTM only with different constants.
    236236         *
     
    239239        registerProjectionChoice(new PuwgProjectionChoice());                                       // PL
    240240
    241         /**
     241        /*
    242242         * SWEREF99 projections. Official coordinate system in Sweden.
    243243         */
     
    245245        registerProjectionChoice(tr("SWEREF99 13 30 / EPSG:3008 (Sweden)"), "core:sweref99", 3008); // SE
    246246
    247         /************************
     247        /* ***********************
    248248         * Projection by Code.
    249249         */
    250250        registerProjectionChoice(new CodeProjectionChoice());
    251251
    252         /************************
     252        /* ***********************
    253253         * Custom projection.
    254254         */
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetMenu.java

    r18683 r18871  
    3535 */
    3636public class TaggingPresetMenu extends TaggingPreset {
     37    /** The menu to show users */
    3738    public JMenu menu; // set by TaggingPresets
    3839
     
    7374    public void setDisplayName() {
    7475        putValue(Action.NAME, getName());
    75         /** Tooltips should be shown for the toolbar buttons, but not in the menu. */
     76        /* Tooltips should be shown for the toolbar buttons, but not in the menu. */
    7677        putValue(OPTIONAL_TOOLTIP_TEXT, group != null ?
    7778                tr("Preset group {1} / {0}", getLocaleName(), group.getName()) :
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java

    r18342 r18871  
    167167     */
    168168    public static Collection<TaggingPreset> readAll(Reader in, boolean validate) throws SAXException {
    169         return readAll(in, validate, new HashSetWithLast<TaggingPreset>());
     169        return readAll(in, validate, new HashSetWithLast<>());
    170170    }
    171171
     
    181181        XmlObjectParser parser = buildParser();
    182182
    183         /** to detect end of {@code <checkgroup>} */
     183        /* to detect end of {@code <checkgroup>} */
    184184        CheckGroup lastcheckgroup = null;
    185         /** to detect end of {@code <group>} */
     185        /* to detect end of {@code <group>} */
    186186        TaggingPresetMenu lastmenu = null;
    187         /** to detect end of reused {@code <group>} */
     187        /* to detect end of reused {@code <group>} */
    188188        TaggingPresetMenu lastmenuOriginal = null;
    189189        Roles lastrole = null;
     
    192192        final Map<String, List<Object>> byId = new HashMap<>();
    193193        final Deque<String> lastIds = new ArrayDeque<>();
    194         /** lastIdIterators contains non empty iterators of items to be handled before obtaining the next item from the XML parser */
     194        /* lastIdIterators contains non empty iterators of items to be handled before obtaining the next item from the XML parser */
    195195        final Deque<Iterator<Object>> lastIdIterators = new ArrayDeque<>();
    196196
     
    351351     */
    352352    public static Collection<TaggingPreset> readAll(String source, boolean validate) throws SAXException, IOException {
    353         return readAll(source, validate, new HashSetWithLast<TaggingPreset>());
     353        return readAll(source, validate, new HashSetWithLast<>());
    354354    }
    355355
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java

    r18692 r18871  
    242242            return tags.containsKey(key);
    243243        case KEY_VALUE:
    244             return tags.containsKey(key) && getValues().contains(tags.get(key)) ? Boolean.TRUE : null;
     244            return (tags.containsKey(key) && getValues().contains(tags.get(key))) ? Boolean.TRUE : null;
    245245        case KEY_VALUE_REQUIRED:
    246246            return tags.containsKey(key) && getValues().contains(tags.get(key));
  • trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

    r18801 r18871  
    11201120        @Override
    11211121        public String toString() {
    1122             return new StringBuilder("MultiSplitLayout.Leaf \"")
    1123               .append(getName())
    1124               .append("\" weight=")
    1125               .append(getWeight())
    1126               .append(' ')
    1127               .append(getBounds())
    1128               .toString();
     1122            return "MultiSplitLayout.Leaf \"" +
     1123                    getName() +
     1124                    "\" weight=" +
     1125                    getWeight() +
     1126                    ' ' +
     1127                    getBounds();
    11291128        }
    11301129    }
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r18801 r18871  
    307307     */
    308308    protected final String toXml(IPrimitive o, boolean addBody) {
    309         StringWriter swriter = new StringWriter();
    310         try (OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(swriter), true, version)) {
    311             swriter.getBuffer().setLength(0);
     309        StringWriter stringWriter = new StringWriter();
     310        try (OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(stringWriter), true, version)) {
     311            stringWriter.getBuffer().setLength(0);
    312312            osmWriter.setWithBody(addBody);
    313313            osmWriter.setChangeset(changeset);
     
    319319            Logging.warn(e);
    320320        }
    321         return swriter.toString();
     321        return stringWriter.toString();
    322322    }
    323323
     
    328328     */
    329329    protected final String toXml(Changeset s) {
    330         StringWriter swriter = new StringWriter();
    331         try (OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(swriter), true, version)) {
    332             swriter.getBuffer().setLength(0);
     330        StringWriter stringWriter = new StringWriter();
     331        try (OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(stringWriter), true, version)) {
     332            stringWriter.getBuffer().setLength(0);
    333333            osmWriter.header();
    334334            osmWriter.visit(s);
     
    338338            Logging.warn(e);
    339339        }
    340         return swriter.toString();
     340        return stringWriter.toString();
    341341    }
    342342
     
    348348        rv.append('/');
    349349        // this works around a ruby (or lighttpd) bug where two consecutive slashes in
    350         // an URL will cause a "404 not found" response.
     350        // a URL will cause a "404 not found" response.
    351351        int p;
    352352        while ((p = rv.indexOf("//", rv.indexOf("://")+2)) > -1) {
     
    456456     * Creates a new changeset based on the keys in <code>changeset</code>. If this
    457457     * method succeeds, changeset.getId() replies the id the server assigned to the new changeset
    458      *
     458     * <p>
    459459     * The changeset must not be null, but its key/value-pairs may be empty.
    460460     *
     
    741741    /**
    742742     * Generic method for sending requests to the OSM API.
    743      *
     743     * <p>
    744744     * This method will automatically re-try any requests that are answered with a 5xx
    745745     * error code, or that resulted in a timeout exception from the TCP layer.
     
    851851            } catch (IOException e) {
    852852                throw new OsmTransferException(e);
    853             } catch (OsmTransferException e) {
    854                 throw e;
    855853            }
    856854        }
     
    922920    public Note createNote(LatLon latlon, String text, ProgressMonitor monitor) throws OsmTransferException {
    923921        initialize(monitor);
    924         String noteUrl = new StringBuilder()
    925             .append("notes?lat=")
    926             .append(latlon.lat())
    927             .append("&lon=")
    928             .append(latlon.lon())
    929             .append("&text=")
    930             .append(Utils.encodeUrl(text)).toString();
     922        String noteUrl = "notes?lat=" +
     923                latlon.lat() +
     924                "&lon=" +
     925                latlon.lon() +
     926                "&text=" +
     927                Utils.encodeUrl(text);
    931928
    932929        return parseSingleNote(sendPostRequest(noteUrl, null, monitor));
  • trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java

    r13901 r18871  
    4040            if (locator == null)
    4141                return "";
    42             return new StringBuilder().append('(').append(locator.getLineNumber())
    43                                       .append(',').append(locator.getColumnNumber()).append(')').toString();
     42            return "(" + locator.getLineNumber() +
     43                    ',' + locator.getColumnNumber() + ')';
    4444        }
    4545
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r17417 r18871  
    314314            default: // Do nothing
    315315            }
    316             /**
     316            /*
    317317             * Did not recognize the element, so the new state is UNKNOWN.
    318318             * This includes the case where we are already inside an unknown
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r18801 r18871  
    313313    /**
    314314     * Returns URL for accessing GetMap service. String will contain following parameters:
    315      * * {proj} - that needs to be replaced with projection (one of {@link #getServerProjections(List)})
    316      * * {width} - that needs to be replaced with width of the tile
    317      * * {height} - that needs to be replaces with height of the tile
    318      * * {bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates)
    319      *
     315     * <ul>
     316     *   <li>{proj} - that needs to be replaced with projection (one of {@link #getServerProjections(List)})</li>
     317     *   <li>{width} - that needs to be replaced with width of the tile</li>
     318     *   <li>{height} - that needs to be replaces with height of the tile</li>
     319     *   <li>{bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates)</li>
     320     * </ul>
    320321     * Format of the response will be calculated using {@link #getPreferredFormat()}
    321322     *
     
    333334    /**
    334335     * Returns URL for accessing GetMap service. String will contain following parameters:
    335      * * {proj} - that needs to be replaced with projection (one of {@link #getServerProjections(List)})
    336      * * {width} - that needs to be replaced with width of the tile
    337      * * {height} - that needs to be replaces with height of the tile
    338      * * {bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates)
    339      *
     336     * <ul>
     337     *   <li>{proj} - that needs to be replaced with projection (one of {@link #getServerProjections(List)})</li>
     338     *   <li>{width} - that needs to be replaced with width of the tile</li>
     339     *   <li>{height} - that needs to be replaces with height of the tile</li>
     340     *   <li>{bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates)</li>
     341     * </ul>
    340342     * Format of the response will be calculated using {@link #getPreferredFormat()}
    341343     *
     
    411413        boolean ret = a.equals(b);
    412414        if (ret) {
    413             return ret;
     415            return true;
    414416        }
    415417
     
    488490
    489491    private void parseRequest(XMLStreamReader reader) throws XMLStreamException {
    490         String mode = "";
    491         String getMapUrl = "";
     492        String mode;
     493        String newGetMapUrl = "";
    492494        if (GetCapabilitiesParseHelper.moveReaderToTag(reader, this::tagEquals, QN_GETMAP)) {
    493495            for (int event = reader.getEventType();
     
    506508                        mode = reader.getName().getLocalPart();
    507509                        if (GetCapabilitiesParseHelper.moveReaderToTag(reader, this::tagEquals, QN_ONLINE_RESOURCE)) {
    508                             getMapUrl = reader.getAttributeValue(GetCapabilitiesParseHelper.XLINK_NS_URL, "href");
     510                            newGetMapUrl = reader.getAttributeValue(GetCapabilitiesParseHelper.XLINK_NS_URL, "href");
    509511                        }
    510512                        // TODO should we handle also POST?
    511                         if ("GET".equalsIgnoreCase(mode) && getMapUrl != null && !getMapUrl.isEmpty()) {
     513                        if ("GET".equalsIgnoreCase(mode) && newGetMapUrl != null && !newGetMapUrl.isEmpty()) {
    512514                            try {
    513                                 String query = new URL(getMapUrl).getQuery();
     515                                String query = new URL(newGetMapUrl).getQuery();
    514516                                if (query == null) {
    515                                     this.getMapUrl = getMapUrl + "?";
     517                                    this.getMapUrl = newGetMapUrl + "?";
    516518                                } else {
    517                                     this.getMapUrl = getMapUrl;
     519                                    this.getMapUrl = newGetMapUrl;
    518520                                }
    519521                            } catch (MalformedURLException e) {
     
    581583    private void parseAndAddStyle(XMLStreamReader reader, LayerDetails ld) throws XMLStreamException {
    582584        String name = null;
    583         String title = null;
     585        String styleTitle = null;
    584586        for (int event = reader.getEventType();
    585587                reader.hasNext() && !(event == XMLStreamReader.END_ELEMENT && tagEquals(QN_STYLE, reader.getName()));
     
    590592                }
    591593                if (tagEquals(QN_TITLE, reader.getName())) {
    592                     title = reader.getElementText();
     594                    styleTitle = reader.getElementText();
    593595                }
    594596            }
     
    597599            name = "";
    598600        }
    599         ld.addStyle(name, title);
     601        ld.addStyle(name, styleTitle);
    600602    }
    601603
     
    665667
    666668    private static String normalizeUrl(String serviceUrlStr) throws MalformedURLException {
    667         URL getCapabilitiesUrl = null;
    668         String ret = null;
     669        URL getCapabilitiesUrl;
     670        String ret;
    669671
    670672        if (!Pattern.compile(".*GetCapabilities.*", Pattern.CASE_INSENSITIVE).matcher(serviceUrlStr).matches()) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r18581 r18871  
    196196        }
    197197
    198         /**
     198        /*
    199199         * deselect objects if parameter addtags given
    200200         */
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadDataHandler.java

    r18304 r18871  
    8282        validateDownloadParams();
    8383        this.data = args.get("data");
    84         /**
     84        /*
    8585         * Holds the mime type. Currently only OSM_MIME_TYPE is supported
    8686         * But it could be extended to text/csv, application/gpx+xml, ... or even binary encoded data
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r18801 r18871  
    8989     * Handles self-intersections too.
    9090     * And makes commands to add the intersection points to ways.
    91      *
     91     * <p>
    9292     * Prerequisite: no two nodes have the same coordinates.
    9393     *
     
    244244    /**
    245245     * Tests if given point is to the right side of path consisting of 3 points.
    246      *
     246     * <p>
    247247     * (Imagine the path is continued beyond the endpoints, so you get two rays
    248248     * starting from lineP2 and going through lineP1 and lineP3 respectively
     
    532532    /**
    533533     * This method tests if secondNode is clockwise to first node.
    534      *
     534     * <p>
    535535     * The line through the two points commonNode and firstNode divides the
    536536     * plane into two parts. The test returns true, if secondNode lies in
     
    564564     */
    565565    public static Area getArea(List<? extends INode> polygon) {
    566         Path2D path = new Path2D.Double();
     566        Path2D path = new Path2D.Double(Path2D.WIND_NON_ZERO, polygon.size());
    567567
    568568        boolean begin = true;
     
    842842    /**
    843843     * Determines whether a way is oriented clockwise.
    844      *
     844     * <p>
    845845     * Internals: Assuming a closed non-looping way, compute twice the area
    846846     * of the polygon using the formula {@code 2 * area = sum (X[n] * Y[n+1] - X[n+1] * Y[n])}.
    847847     * If the area is negative the way is ordered in a clockwise direction.
    848      *
    849      * See http://paulbourke.net/geometry/polyarea/
     848     * <p>
     849     * See <a href="https://web.archive.org/web/20120722100030/http://paulbourke.net/geometry/polyarea/">
     850     *     https://paulbourke.net/geometry/polyarea/
     851     *     </a>
    850852     *
    851853     * @param w the way to be checked.
     
    994996    /**
    995997     * Compute the center of the circle closest to different nodes.
    996      *
     998     * <p>
    997999     * Ensure exact center computation in case nodes are already aligned in circle.
    9981000     * This is done by least square method.
     
    10131015        int nc = nodes.size();
    10141016        if (nc < 3) return null;
    1015         /**
     1017        /*
    10161018         * Equation of each bisector ax + by + c = 0
    10171019         */
     
    11601162        if (!polygon.isClosed() || polygon.getNodesCount() <= 3)
    11611163            return res;
    1162         /** polygon area in east north space, calculated only when really needed */
     1164        /* polygon area in east north space, calculated only when really needed */
    11631165        Area polygonArea = null;
    11641166        for (IPrimitive p : primitives) {
     
    12831285    /**
    12841286     * Calculate area and perimeter length of a polygon.
    1285      *
     1287     * <p>
    12861288     * Uses current projection; units are that of the projected coordinates.
    12871289     *
     
    13271329     * Get the closest primitive to {@code osm} from the collection of
    13281330     * OsmPrimitive {@code primitives}
    1329      *
     1331     * <p>
    13301332     * The {@code primitives} should be fully downloaded to ensure accuracy.
    1331      *
     1333     * <p>
    13321334     * Note: The complexity of this method is O(n*m), where n is the number of
    13331335     * children {@code osm} has plus 1, m is the number of children the
     
    13511353     * Get the closest primitives to {@code osm} from the collection of
    13521354     * OsmPrimitive {@code primitives}
    1353      *
     1355     * <p>
    13541356     * The {@code primitives} should be fully downloaded to ensure accuracy.
    1355      *
     1357     * <p>
    13561358     * Note: The complexity of this method is O(n*m), where n is the number of
    13571359     * children {@code osm} has plus 1, m is the number of children the
     
    13861388     * Get the furthest primitive to {@code osm} from the collection of
    13871389     * OsmPrimitive {@code primitives}
    1388      *
     1390     * <p>
    13891391     * The {@code primitives} should be fully downloaded to ensure accuracy.
    1390      *
     1392     * <p>
    13911393     * It does NOT give the furthest primitive based off of the furthest
    13921394     * part of that primitive
    1393      *
     1395     * <p>
    13941396     * Note: The complexity of this method is O(n*m), where n is the number of
    13951397     * children {@code osm} has plus 1, m is the number of children the
     
    14121414     * Get the furthest primitives to {@code osm} from the collection of
    14131415     * OsmPrimitive {@code primitives}
    1414      *
     1416     * <p>
    14151417     * The {@code primitives} should be fully downloaded to ensure accuracy.
    1416      *
     1418     * <p>
    14171419     * It does NOT give the furthest primitive based off of the furthest
    14181420     * part of that primitive
    1419      *
     1421     * <p>
    14201422     * Note: The complexity of this method is O(n*m), where n is the number of
    14211423     * children {@code osm} has plus 1, m is the number of children the
     
    14541456     * (or the unit of the current projection, see {@link Projection}).
    14551457     * May return {@link Double#NaN} if one of the primitives is incomplete.
    1456      *
     1458     * <p>
    14571459     * Note: The complexity is O(n*m), where (n,m) are the number of child
    14581460     * objects the {@link OsmPrimitive}s have.
  • trunk/src/org/openstreetmap/josm/tools/ReflectionUtils.java

    r16462 r18871  
    6161    }
    6262
    63     private static <T extends Object> T findCaller(Function<StackTraceElement, T> getter, Collection<T> exclusions) {
     63    private static <T> T findCaller(Function<StackTraceElement, T> getter, Collection<T> exclusions) {
    6464        StackTraceElement[] stack = Thread.currentThread().getStackTrace();
    6565        for (int i = 3; i < stack.length; i++) {
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r18801 r18871  
    2828/**
    2929 * Global shortcut class.
    30  *
     30 * <p>
    3131 * Note: This class represents a single shortcut, contains the factory to obtain
    3232 *       shortcut objects from, manages shortcuts and shortcut collisions, and
    3333 *       finally manages loading and saving shortcuts to/from the preferences.
    34  *
     34 * <p>
    3535 * Action authors: You only need the {@link #registerShortcut} factory. Ignore everything else.
    36  *
     36 * <p>
    3737 * All: Use only public methods that are also marked to be used. The others are
    3838 *      public so the shortcut preferences can use them.
     
    433433
    434434    // shutdown handling
     435
     436    /**
     437     * Save shortcuts to preferences
     438     * @return {@code true} if preferences were changed
     439     */
    435440    public static boolean savePrefs() {
    436441        return shortcuts.stream()
     
    485490            Integer code = (int) c;
    486491            result.add(registerShortcut(
    487                     new StringBuilder(shortText).append(" (").append(i).append(')').toString(), longText,
     492                    shortText + " (" + i + ')', longText,
    488493                    // Add extended keyCode if not a regular one
    489494                    regularKeyCodes.containsKey(code) ? regularKeyCodes.get(code) :
     
    501506    /**
    502507     * Register a shortcut.
    503      *
     508     * <p>
    504509     * Here you get your shortcuts from. The parameters are:
    505510     *
     
    623628    /**
    624629     * Returns the tooltip text plus the {@linkplain #getKeyText(KeyStroke) key stroke text}.
    625      *
     630     * <p>
    626631     * Tooltips are usually not system dependent, unless the
    627632     * JVM is too dumb to provide correct names for all the keys.
    628      *
     633     * <p>
    629634     * Some LAFs don't understand HTML, such as the OSX LAFs.
    630635     *
  • trunk/tools/ivy.xml

    r18857 r18871  
    3131        <dependency org="com.github.spotbugs" name="spotbugs-ant" rev="4.7.3" conf="spotbugs->default"/>
    3232        <!-- errorprone->default -->
    33         <dependency org="com.google.errorprone" name="error_prone_core" rev="2.10.0" conf="errorprone->default"/>
     33        <dependency org="com.google.errorprone" name="error_prone_core" rev="${versions.error_prone}" conf="errorprone->default"/>
    3434        <!-- errorprone->default -->
    3535        <dependency org="com.google.errorprone" name="javac" rev="9+181-r4173-1" conf="errorprone_javac->default"/>
Note: See TracChangeset for help on using the changeset viewer.