Ignore:
Timestamp:
2024-04-19T16:21:11+02:00 (2 years ago)
Author:
taylor.smock
Message:

Dependency updates

ivy.xml

  • org.eclipse.parsson:parsson: 1.1.5 -> 1.1.6
  • org.apache.commons:commons-compress: 1.25.0 -> 1.26.1
    • Note: This deprecated some functions
  • ch.poole:OpeningHoursParser: 0.28.1 -> 0.28.2
  • org.jacoco:org.jacoco.ant: 0.8.11 -> 0.8.12
  • com.github.spotbugs:spotbugs-annotations: 4.8.3 -> 4.8.4
  • com.github.tomakehurst:wiremock: 2.35.0 -> 3.0.1
  • io.github.classgraph:classgraph: 4.8.165 -> 4.8.171
  • nl.jqno.equalsverifier:equalsverifier: 3.15.6 -> 3.16.1
  • org.awaitility:awaitility: 4.2.0 -> 4.2.1

tools/ivy.xml

  • com.puppycrawl.tools:checkstyle: 9.3 -> 10.15.0
  • com.github.spotbugs:spotbugs: 4.8.3 -> 4.8.4
  • com.google.errorprone: 2.(10.0|24.1) -> 2.26.1
  • net.sourceforge.pmd:pmd was not updated to 7.0.0 due to a significant number of false positives.

There were some additional changes to cleanup new warnings and remove some
additional Java 8 files. There are more warnings that need to be cleaned up.

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
6 edited

Legend:

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

    r18628 r19048  
    77import java.awt.Dimension;
    88import java.awt.GraphicsEnvironment;
     9import java.awt.GridBagConstraints;
    910import java.awt.GridBagLayout;
    1011import java.awt.event.ActionEvent;
     
    1415import java.time.Year;
    1516import java.time.ZoneOffset;
    16 import java.util.Collection;
    1717import java.util.Collections;
    1818import java.util.List;
     
    2626import javax.swing.JScrollPane;
    2727
    28 import org.openstreetmap.josm.data.coor.LatLon;
    29 import org.openstreetmap.josm.data.imagery.DefaultLayer;
    3028import org.openstreetmap.josm.data.imagery.ImageryInfo;
    3129import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     
    6260        SelectWmsLayersDialog(WMSLayerTree tree, JComboBox<String> formats) {
    6361            super(MainApplication.getMainFrame(), tr("Select WMS layers"), tr("Add layers"), tr("Cancel"));
    64             final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
     62            final var scrollPane = new JScrollPane(tree.getLayerTree());
    6563            scrollPane.setPreferredSize(new Dimension(400, 400));
    66             final JPanel panel = new JPanel(new GridBagLayout());
     64            final var panel = new JPanel(new GridBagLayout());
    6765            panel.add(scrollPane, GBC.eol().fill());
    68             panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
     66            panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    6967            setContent(panel);
    7068        }
     
    8482
    8583        // change toolbar icon from if specified
    86         String icon = info.getIcon();
     84        var icon = info.getIcon();
    8785        if (icon != null) {
    8886            new ImageProvider(icon).setOptional(true).getResourceAsync(result -> {
     
    103101        try {
    104102            if (info.getUrl() != null && info.getUrl().contains("{time}")) {
    105                 final String instant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString();
    106                 final String example = String.join("/", instant, instant);
    107                 final String initialSelectionValue = info.getDate() != null ? info.getDate() : example;
    108                 final String userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(),
     103                final var instant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString();
     104                final var example = String.join("/", instant, instant);
     105                final var initialSelectionValue = info.getDate() != null ? info.getDate() : example;
     106                final var userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(),
    109107                        tr("Time filter for \"{0}\" such as \"{1}\"", info.getName(), example),
    110108                        initialSelectionValue);
     
    115113                // TODO persist new {time} value (via ImageryLayerInfo.save?)
    116114            }
    117             switch(info.getImageryType()) {
     115            switch (info.getImageryType()) {
    118116            case WMS_ENDPOINT:
    119117                // convert to WMS type
     
    126124                // specify which layer to use
    127125                if (Utils.isEmpty(info.getDefaultLayers())) {
    128                     WMTSTileSource tileSource = new WMTSTileSource(info);
    129                     DefaultLayer layerId = tileSource.userSelectLayer();
     126                    var tileSource = new WMTSTileSource(info);
     127                    var layerId = tileSource.userSelectLayer();
    130128                    if (layerId != null) {
    131                         ImageryInfo copy = new ImageryInfo(info);
     129                        var copy = new ImageryInfo(info);
    132130                        copy.setDefaultLayers(Collections.singletonList(layerId));
    133                         String layerName = tileSource.getLayers().stream()
     131                        var layerName = tileSource.getLayers().stream()
    134132                                .filter(x -> x.getIdentifier().equals(layerId.getLayerName()))
    135133                                .map(Layer::getUserTitle)
     
    165163        ImageryLayer layer = null;
    166164        try {
    167             final ImageryInfo infoToAdd = convertImagery(info);
     165            final var infoToAdd = convertImagery(info);
    168166            if (infoToAdd != null) {
    169167                layer = ImageryLayer.create(infoToAdd);
     
    207205
    208206    private static LayerSelection askToSelectLayers(WMSImagery wms) {
    209         final WMSLayerTree tree = new WMSLayerTree();
    210 
    211         Collection<String> wmsFormats = wms.getFormats();
    212         final JComboBox<String> formats = new JComboBox<>(wmsFormats.toArray(new String[0]));
     207        final var tree = new WMSLayerTree();
     208
     209        var wmsFormats = wms.getFormats();
     210        final var formats = new JComboBox<String>(wmsFormats.toArray(new String[0]));
    213211        formats.setSelectedItem(wms.getPreferredFormat());
    214212        formats.setToolTipText(tr("Select image format for WMS layer"));
    215213
    216         JCheckBox checkBounds = new JCheckBox(tr("Show only layers for current view"), true);
     214        var checkBounds = new JCheckBox(tr("Show only layers for current view"), true);
    217215        Runnable updateTree = () -> {
    218             LatLon latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView()
     216            var latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView()
    219217                    ? MainApplication.getMap().mapView.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter())
    220218                    : null;
     
    227225
    228226        if (!GraphicsEnvironment.isHeadless()) {
    229             ExtendedDialog dialog = new ExtendedDialog(MainApplication.getMainFrame(),
     227            var dialog = new ExtendedDialog(MainApplication.getMainFrame(),
    230228                    tr("Select WMS layers"), tr("Add layers"), tr("Cancel"));
    231             final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
     229            final var scrollPane = new JScrollPane(tree.getLayerTree());
    232230            scrollPane.setPreferredSize(new Dimension(400, 400));
    233             final JPanel panel = new JPanel(new GridBagLayout());
     231            final var panel = new JPanel(new GridBagLayout());
    234232            panel.add(scrollPane, GBC.eol().fill());
    235             panel.add(checkBounds, GBC.eol().fill(GBC.HORIZONTAL));
    236             panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
     233            panel.add(checkBounds, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
     234            panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    237235            dialog.setContent(panel);
    238236
     
    283281        CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT == info.getImageryType(), "wms_endpoint imagery type expected");
    284282        // We need to get the URL with {apikey} replaced. See #22642.
    285         final TemplatedWMSTileSource tileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection());
    286         final WMSImagery wms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders());
    287         LayerSelection selection = choice.apply(wms);
     283        final var tileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection());
     284        final var wms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders());
     285        var selection = choice.apply(wms);
    288286        if (selection == null) {
    289287            return null;
    290288        }
    291289
    292         final String url = wms.buildGetMapUrl(
     290        final var url = wms.buildGetMapUrl(
    293291                selection.layers.stream().map(LayerDetails::getName).collect(Collectors.toList()),
    294292                (List<String>) null,
     
    297295                );
    298296
    299         String selectedLayers = selection.layers.stream()
     297        var selectedLayers = selection.layers.stream()
    300298                .map(LayerDetails::getName)
    301299                .collect(Collectors.joining(", "));
    302300        // Use full copy of original Imagery info to copy all attributes. Only overwrite what's different
    303         ImageryInfo ret = new ImageryInfo(info);
     301        var ret = new ImageryInfo(info);
    304302        ret.setUrl(url);
    305303        ret.setImageryType(ImageryType.WMS);
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r18211 r19048  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
    10 import java.awt.geom.Area;
    1110import java.util.ArrayList;
    1211import java.util.Collection;
     
    2322import org.openstreetmap.josm.data.DataSource;
    2423import org.openstreetmap.josm.data.conflict.Conflict;
    25 import org.openstreetmap.josm.data.osm.DataSet;
    2624import org.openstreetmap.josm.data.osm.IPrimitive;
    2725import org.openstreetmap.josm.data.osm.OsmData;
     
    3432import org.openstreetmap.josm.gui.MapView;
    3533import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
    36 import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
    3734import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    3835import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor;
     
    146143     */
    147144    public static void zoomTo(Collection<? extends IPrimitive> sel) {
    148         BoundingXYVisitor bboxCalculator = new BoundingXYVisitor();
     145        final var bboxCalculator = new BoundingXYVisitor();
    149146        bboxCalculator.computeBoundingBox(sel);
    150147        if (bboxCalculator.getBounds() != null) {
     
    244241    public void autoScale() {
    245242        if (MainApplication.isDisplayingMapView()) {
    246             MapView mapView = MainApplication.getMap().mapView;
     243            final var mapView = MainApplication.getMap().mapView;
    247244            switch (mode) {
    248245            case PREVIOUS:
     
    312309    private void modeLayer(BoundingXYVisitor v) {
    313310        // try to zoom to the first selected layer
    314         Layer l = getFirstSelectedLayer();
     311        final var l = getFirstSelectedLayer();
    315312        if (l == null)
    316313            return;
     
    327324            }
    328325        } else {
    329             ConflictDialog conflictDialog = MainApplication.getMap().conflictDialog;
     326            final var conflictDialog = MainApplication.getMap().conflictDialog;
    330327            Conflict<? extends IPrimitive> c = conflictDialog.getSelectedConflict();
    331328            if (c != null) {
     
    359356        }
    360357        Bounds bbox = null;
    361         final DataSet dataset = getLayerManager().getActiveDataSet();
     358        final var dataset = getLayerManager().getActiveDataSet();
    362359        if (dataset != null) {
    363360            List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources());
     
    372369                } else {
    373370                    lastZoomArea = -1;
    374                     Area sourceArea = getLayerManager().getActiveDataSet().getDataSourceArea();
     371                    final var sourceArea = getLayerManager().getActiveDataSet().getDataSourceArea();
    375372                    if (sourceArea != null) {
    376373                        bbox = new Bounds(sourceArea.getBounds2D());
     
    439436     * Adapter for zoom change events
    440437     */
    441     private class ZoomChangeAdapter implements ZoomChangeListener {
     438    private final class ZoomChangeAdapter implements ZoomChangeListener {
    442439        @Override
    443440        public void zoomChanged() {
  • trunk/src/org/openstreetmap/josm/actions/ChangesetManagerToggleAction.java

    r17188 r19048  
    4949    }
    5050
    51     private class ChangesetCacheManagerClosedHandler extends WindowAdapter {
     51    private final class ChangesetCacheManagerClosedHandler extends WindowAdapter {
    5252        @Override
    5353        public void windowClosed(WindowEvent e) {
  • trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java

    r17052 r19048  
    3737    @Override
    3838    public void actionPerformed(ActionEvent e) {
    39         final Bounds bounds = MainApplication.getMap().mapView.getRealBounds();
    40         DownloadOsmInViewTask task = new DownloadOsmInViewTask();
     39        final var bounds = MainApplication.getMap().mapView.getRealBounds();
     40        final var task = new DownloadOsmInViewTask();
    4141        task.setZoomAfterDownload(false);
    4242        Future<?> future = task.download(bounds);
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r18972 r19048  
    210210
    211211        public List<Node> getNodes() {
    212             List<Node> nodes = new ArrayList<>();
     212            final var nodes = new ArrayList<Node>();
    213213            for (WayInPolygon way : this.ways) {
    214214                //do not add the last node as it will be repeated in the next way
    215215                if (way.insideToTheRight) {
    216                     for (int pos = 0; pos < way.way.getNodesCount() - 1; pos++) {
     216                    for (var pos = 0; pos < way.way.getNodesCount() - 1; pos++) {
    217217                        nodes.add(way.way.getNode(pos));
    218218                    }
     
    343343         */
    344344        private static double getAngle(Node n1, Node n2, Node n3) {
    345             EastNorth en1 = n1.getEastNorth();
    346             EastNorth en2 = n2.getEastNorth();
    347             EastNorth en3 = n3.getEastNorth();
     345            final var en1 = n1.getEastNorth();
     346            final var en2 = n2.getEastNorth();
     347            final var en3 = n3.getEastNorth();
    348348            double angle = Math.atan2(en3.getY() - en1.getY(), en3.getX() - en1.getX()) -
    349349                    Math.atan2(en2.getY() - en1.getY(), en2.getX() - en1.getX());
     
    362362         */
    363363        public WayInPolygon walk() {
    364             Node headNode = getHeadNode();
    365             Node prevNode = getPrevNode();
     364            final var headNode = getHeadNode();
     365            final var prevNode = getPrevNode();
    366366
    367367            double headAngle = Math.atan2(headNode.getEastNorth().east() - prevNode.getEastNorth().east(),
     
    371371            //find best next way
    372372            WayInPolygon bestWay = null;
    373             boolean bestWayReverse = false;
     373            var bestWayReverse = false;
    374374
    375375            for (WayInPolygon way : availableWays) {
     
    418418         */
    419419        public WayInPolygon leftComingWay() {
    420             Node headNode = getHeadNode();
    421             Node prevNode = getPrevNode();
     420            final var headNode = getHeadNode();
     421            final var prevNode = getPrevNode();
    422422
    423423            WayInPolygon mostLeft = null; // most left way connected to head node
    424             boolean comingToHead = false; // true if candidate come to head node
     424            var comingToHead = false; // true if candidate come to head node
    425425            double angle = 2*Math.PI;
    426426
     
    649649        }
    650650
    651         boolean hasChanges = false;
    652 
    653         List<Way> allStartingWays = new ArrayList<>();
    654         List<Way> innerStartingWays = new ArrayList<>();
    655         List<Way> outerStartingWays = new ArrayList<>();
     651        var hasChanges = false;
     652
     653        final var allStartingWays = new ArrayList<Way>();
     654        final var innerStartingWays = new ArrayList<Way>();
     655        final var outerStartingWays = new ArrayList<Way>();
    656656
    657657        for (Multipolygon area : areas) {
     
    721721        if (discardedWays.stream().anyMatch(w -> !w.isNew())) {
    722722            for (AssembledPolygon ring : boundaries) {
    723                 for (int k = 0; k < ring.ways.size(); k++) {
     723                for (var k = 0; k < ring.ways.size(); k++) {
    724724                    WayInPolygon ringWay = ring.ways.get(k);
    725725                    Way older = keepOlder(ringWay.way, oldestWayMap, discardedWays);
    726726
    727727                    if (ringWay.way != older) {
    728                         WayInPolygon repl = new WayInPolygon(older, ringWay.insideToTheRight);
     728                        final var repl = new WayInPolygon(older, ringWay.insideToTheRight);
    729729                        ring.ways.set(k, repl);
    730730                    }
     
    769769        // Delete the discarded inner ways
    770770        if (!discardedWays.isEmpty()) {
    771             Command deleteCmd = DeleteCommand.delete(discardedWays, true);
     771            final var deleteCmd = DeleteCommand.delete(discardedWays, true);
    772772            if (deleteCmd != null) {
    773773                cmds.add(deleteCmd);
     
    796796    private Way keepOlder(Way way, Map<Node, Way> oldestWayMap, List<Way> discardedWays) {
    797797        Way oldest = null;
    798         for (Node n : way.getNodes()) {
    799             Way orig = oldestWayMap .get(n);
     798        for (var n : way.getNodes()) {
     799            final var orig = oldestWayMap .get(n);
    800800            if (orig != null && (oldest == null || oldest.getUniqueId() > orig.getUniqueId())
    801801                    && discardedWays.contains(orig)) {
     
    830830        }
    831831
    832         TagCollection wayTags = TagCollection.unionOfAllPrimitives(ways);
     832        final var wayTags = TagCollection.unionOfAllPrimitives(ways);
    833833        try {
    834834            cmds.addAll(CombinePrimitiveResolverDialog.launchIfNecessary(wayTags, ways, ways));
     
    847847     */
    848848    private boolean removeDuplicateNodes(List<Way> ways) {
    849         Map<Node, Node> nodeMap = new TreeMap<>(new NodePositionComparator());
    850         int totalWaysModified = 0;
     849        final var nodeMap = new TreeMap<Node, Node>(new NodePositionComparator());
     850        var totalWaysModified = 0;
    851851
    852852        for (Way way : ways) {
     
    855855            }
    856856
    857             List<Node> newNodes = new ArrayList<>();
     857            final var newNodes = new ArrayList<Node>();
    858858            Node prevNode = null;
    859             boolean modifyWay = false;
     859            var modifyWay = false;
    860860
    861861            for (Node node : way.getNodes()) {
    862                 Node representator = nodeMap.get(node);
     862                var representator = nodeMap.get(node);
    863863                if (representator == null) {
    864864                    //new node
     
    898898     */
    899899    private void commitCommands(String description) {
    900         switch(cmds.size()) {
     900        switch (cmds.size()) {
    901901        case 0:
    902902            return;
     
    923923        cmds.clear();
    924924        if (addUndoRedo && !executedCmds.isEmpty()) {
    925             UndoRedoHandler ur = UndoRedoHandler.getInstance();
     925            final var ur = UndoRedoHandler.getInstance();
    926926            if (executedCmds.size() == 1) {
    927927                ur.add(executedCmds.getFirst(), false);
     
    945945        Map<Way, Way> nextWayMap = new HashMap<>();
    946946
    947         for (int pos = 0; pos < parts.size(); pos++) {
     947        for (var pos = 0; pos < parts.size(); pos++) {
    948948
    949949            if (!parts.get(pos).lastNode().equals(parts.get((pos + 1) % parts.size()).firstNode()))
     
    956956        Way topWay = null;
    957957        Node topNode = null;
    958         int topIndex = 0;
     958        var topIndex = 0;
    959959        double minY = Double.POSITIVE_INFINITY;
    960960
    961961        for (Way way : parts) {
    962             for (int pos = 0; pos < way.getNodesCount(); pos++) {
    963                 Node node = way.getNode(pos);
     962            for (var pos = 0; pos < way.getNodesCount(); pos++) {
     963                final var node = way.getNode(pos);
    964964
    965965                if (node.getEastNorth().getY() < minY) {
     
    996996            for (Way way : parts) {
    997997                if (way.firstNode().equals(headNode)) {
    998                     Node nextNode = way.getNode(1);
     998                    final var nextNode = way.getNode(1);
    999999
    10001000                    if (topWay == null || !Geometry.isToTheRightSideOfLine(prevNode, headNode, bestWayNextNode, nextNode)) {
     
    10081008                if (way.lastNode().equals(headNode)) {
    10091009                    //end adjacent to headNode
    1010                     Node nextNode = way.getNode(way.getNodesCount() - 2);
     1010                    final var nextNode = way.getNode(way.getNodesCount() - 2);
    10111011
    10121012                    if (topWay == null || !Geometry.isToTheRightSideOfLine(prevNode, headNode, bestWayNextNode, nextNode)) {
     
    10201020        } else {
    10211021            //node is inside way - pick the clockwise going end.
    1022             Node prev = topWay.getNode(topIndex - 1);
    1023             Node next = topWay.getNode(topIndex + 1);
     1022            final var prev = topWay.getNode(topIndex - 1);
     1023            final var next = topWay.getNode(topIndex + 1);
    10241024
    10251025            //there will be no parallel segments in the middle of way, so all fine.
     
    10271027        }
    10281028
    1029         Way curWay = topWay;
     1029        var curWay = topWay;
    10301030        boolean curWayInsideToTheRight = wayClockwise ^ isInner;
    10311031        List<WayInPolygon> result = new ArrayList<>();
     
    10351035
    10361036            //add cur way
    1037             WayInPolygon resultWay = new WayInPolygon(curWay, curWayInsideToTheRight);
     1037            final var resultWay = new WayInPolygon(curWay, curWayInsideToTheRight);
    10381038            result.add(resultWay);
    10391039
    10401040            //process next way
    1041             Way nextWay = nextWayMap.get(curWay);
    1042             Node prevNode = curWay.getNode(curWay.getNodesCount() - 2);
    1043             Node headNode = curWay.lastNode();
    1044             Node nextNode = nextWay.getNode(1);
     1041            final var nextWay = nextWayMap.get(curWay);
     1042            final var prevNode = curWay.getNode(curWay.getNodesCount() - 2);
     1043            final var headNode = curWay.lastNode();
     1044            final var nextNode = nextWay.getNode(1);
    10451045
    10461046            if (nextWay == topWay) {
     
    10681068            //                       |
    10691069
    1070             int intersectionCount = 0;
     1070            var intersectionCount = 0;
    10711071
    10721072            for (Way wayA : parts) {
     
    10781078                if (wayA.lastNode().equals(headNode)) {
    10791079
    1080                     Way wayB = nextWayMap.get(wayA);
     1080                    final var wayB = nextWayMap.get(wayA);
    10811081
    10821082                    //test if wayA is opposite wayB relative to curWay and nextWay
    10831083
    1084                     Node wayANode = wayA.getNode(wayA.getNodesCount() - 2);
    1085                     Node wayBNode = wayB.getNode(1);
     1084                    final var wayANode = wayA.getNode(wayA.getNodesCount() - 2);
     1085                    final var wayBNode = wayB.getNode(1);
    10861086
    10871087                    boolean wayAToTheRight = Geometry.isToTheRightSideOfLine(prevNode, headNode, nextNode, wayANode);
     
    11171117     */
    11181118    private static void revertDuplicateTwoNodeWays(List<WayInPolygon> parts) {
    1119         for (int i = 0; i < parts.size(); i++) {
     1119        for (var i = 0; i < parts.size(); i++) {
    11201120            WayInPolygon w1 = parts.get(i);
    11211121            if (w1.way.getNodesCount() != 2)
     
    11411141    private List<Way> splitWayOnNodes(Way way, Set<Node> nodes, Map<Node, Way> oldestWayMap) {
    11421142
    1143         List<Way> result = new ArrayList<>();
     1143        final var result = new ArrayList<Way>();
    11441144        List<List<Node>> chunks = buildNodeChunks(way, nodes);
    11451145
    11461146        if (chunks.size() > 1) {
    1147             SplitWayCommand split = SplitWayCommand.splitWay(way, chunks,
     1147            final var split = SplitWayCommand.splitWay(way, chunks,
    11481148                    Collections.emptyList(), SplitWayCommand.Strategy.keepFirstChunk());
    11491149
     
    11591159                if (!way.isNew() && result.size() > 1) {
    11601160                    for (Way part : result) {
    1161                         Node n = part.firstNode();
    1162                         Way old = oldestWayMap.get(n);
     1161                        final var n = part.firstNode();
     1162                        final var old = oldestWayMap.get(n);
    11631163                        if (old == null || old.getUniqueId() > way.getUniqueId()) {
    11641164                            oldestWayMap.put(n, way);
     
    12311231
    12321232        //TODO: bad performance for deep nestings...
    1233         List<PolygonLevel> result = new ArrayList<>();
     1233        final var result = new ArrayList<PolygonLevel>();
    12341234
    12351235        for (AssembledPolygon outerWay : boundaryWays) {
    12361236
    1237             boolean outerGood = true;
    1238             List<AssembledPolygon> innerCandidates = new ArrayList<>();
     1237            var outerGood = true;
     1238            final var innerCandidates = new ArrayList<AssembledPolygon>();
    12391239
    12401240            for (AssembledPolygon innerWay : boundaryWays) {
     
    12561256
    12571257            //add new outer polygon
    1258             AssembledMultipolygon pol = new AssembledMultipolygon(outerWay);
    1259             PolygonLevel polLev = new PolygonLevel(pol, level);
     1258            final var pol = new AssembledMultipolygon(outerWay);
     1259            final var polLev = new PolygonLevel(pol, level);
    12601260
    12611261            //process inner ways
     
    12881288        // This seems to appear when is apply over invalid way like #9911 test-case
    12891289        // Remove all of these way to make the next work.
    1290         List<WayInPolygon> cleanMultigonWays = new ArrayList<>();
     1290        final var cleanMultigonWays = new ArrayList<WayInPolygon>();
    12911291        for (WayInPolygon way: multigonWays) {
    12921292            if (way.way.getNodesCount() != 2 || !way.way.isClosed())
    12931293                cleanMultigonWays.add(way);
    12941294        }
    1295         WayTraverser traverser = new WayTraverser(cleanMultigonWays);
    1296         List<AssembledPolygon> result = new ArrayList<>();
     1295        final var traverser = new WayTraverser(cleanMultigonWays);
     1296        final var result = new ArrayList<AssembledPolygon>();
    12971297
    12981298        WayInPolygon startWay;
    12991299        while ((startWay = traverser.startNewWay()) != null) {
    1300             List<WayInPolygon> path = new ArrayList<>();
    1301             List<WayInPolygon> startWays = new ArrayList<>();
     1300            final var path = new ArrayList<WayInPolygon>();
     1301            final var startWays = new ArrayList<WayInPolygon>();
    13021302            path.add(startWay);
    13031303            while (true) {
     
    13181318                if (path.get(0) == nextWay) {
    13191319                    // path is closed -> stop here
    1320                     AssembledPolygon ring = new AssembledPolygon(path);
     1320                    final var ring = new AssembledPolygon(path);
    13211321                    if (ring.getNodes().size() <= 2) {
    13221322                        // Invalid ring (2 nodes) -> remove
     
    13571357     */
    13581358    public static List<AssembledPolygon> fixTouchingPolygons(List<AssembledPolygon> polygons) {
    1359         List<AssembledPolygon> newPolygons = new ArrayList<>();
     1359        final var newPolygons = new ArrayList<AssembledPolygon>();
    13601360
    13611361        for (AssembledPolygon ring : polygons) {
    13621362            ring.reverse();
    1363             WayTraverser traverser = new WayTraverser(ring.ways);
     1363            final var traverser = new WayTraverser(ring.ways);
    13641364            WayInPolygon startWay;
    13651365
    13661366            while ((startWay = traverser.startNewWay()) != null) {
    1367                 List<WayInPolygon> simpleRingWays = new ArrayList<>();
     1367                final var simpleRingWays = new ArrayList<WayInPolygon>();
    13681368                simpleRingWays.add(startWay);
    13691369                WayInPolygon nextWay;
     
    13741374                }
    13751375                traverser.removeWays(simpleRingWays);
    1376                 AssembledPolygon simpleRing = new AssembledPolygon(simpleRingWays);
     1376                final var simpleRing = new AssembledPolygon(simpleRingWays);
    13771377                simpleRing.reverse();
    13781378                newPolygons.add(simpleRing);
     
    14111411     */
    14121412    private Multipolygon joinPolygon(AssembledMultipolygon polygon) throws UserCancelException {
    1413         Multipolygon result = new Multipolygon(joinWays(polygon.outerWay.ways));
     1413        final var result = new Multipolygon(joinWays(polygon.outerWay.ways));
    14141414
    14151415        for (AssembledPolygon pol : polygon.innerWays) {
     
    14291429
    14301430        //leave original orientation, if all paths are reverse.
    1431         boolean allReverse = true;
     1431        var allReverse = true;
    14321432        for (WayInPolygon way : ways) {
    14331433            allReverse &= !way.insideToTheRight;
     
    14401440        }
    14411441
    1442         Way joinedWay = joinOrientedWays(ways);
     1442        final var joinedWay = joinOrientedWays(ways);
    14431443
    14441444        //should not happen
     
    14621462        // the user about this.
    14631463
    1464         List<Way> actionWays = new ArrayList<>(ways.size());
    1465         int oldestPos = 0;
     1464        final var actionWays = new ArrayList<Way>(ways.size());
     1465        var oldestPos = 0;
    14661466        Way oldest = ways.get(0).way;
    14671467        for (WayInPolygon way : ways) {
     
    15111511            }
    15121512
    1513             boolean hasKnownOuter = false;
     1513            var hasKnownOuter = false;
    15141514            outerWays.clear();
    15151515            innerWays.clear();
     
    15381538            }
    15391539
    1540             Way outerWay = outerWays.get(0);
     1540            final var outerWay = outerWays.get(0);
    15411541
    15421542            //retain only selected inner ways
     
    15881588            processedInnerWays.addAll(innerWays);
    15891589
    1590             Multipolygon pol = new Multipolygon(outerWay);
     1590            final var pol = new Multipolygon(outerWay);
    15911591            pol.innerWays.addAll(innerWays);
    15921592
     
    16151615        OsmDataLayer layer = getLayerManager().getEditLayer();
    16161616        // Create new multipolygon relation and add all inner ways to it
    1617         Relation newRel = new Relation();
     1617        final var newRel = new Relation();
    16181618        newRel.put("type", "multipolygon");
    16191619        for (Way w : inner) {
     
    16501650
    16511651                cmds.add(new ChangeMembersCommand(r, members));
    1652                 RelationRole saverel = new RelationRole(r, rm.getRole());
     1652                final var saverel = new RelationRole(r, rm.getRole());
    16531653                if (!result.contains(saverel)) {
    16541654                    result.add(saverel);
     
    17011701        default:
    17021702            // Create a new relation with all previous members and (Way)outer as outer.
    1703             Relation newRel = new Relation();
     1703            final var newRel = new Relation();
    17041704            for (RelationRole r : multiouters) {
    17051705                // Add members
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r18759 r19048  
    77
    88import java.awt.Component;
     9import java.awt.GridBagConstraints;
    910import java.awt.GridBagLayout;
    1011import java.awt.event.ActionEvent;
     
    146147
    147148        // Finally, applicableWays contains only one perfect way
    148         final Way selectedWay = applicableWays.get(0);
    149         final List<OsmPrimitive> sel = new ArrayList<>(ds.getSelectedRelations());
     149        final var selectedWay = applicableWays.get(0);
     150        final var sel = new ArrayList<OsmPrimitive>(ds.getSelectedRelations());
    150151        sel.addAll(selectedWays);
    151152        doSplitWayShowSegmentSelection(selectedWay, selectedNodes, sel);
     
    164165        if (wayChunks != null) {
    165166            final List<Way> newWays = SplitWayCommand.createNewWaysFromChunks(splitWay, wayChunks);
    166             final Way wayToKeep = SplitWayCommand.Strategy.keepLongestChunk().determineWayToKeep(newWays);
     167            final var wayToKeep = SplitWayCommand.Strategy.keepLongestChunk().determineWayToKeep(newWays);
    167168
    168169            if (ExpertToggleAction.isExpert() && !splitWay.isNew()) {
     
    210211
    211212            setButtonIcons("ok", "cancel");
    212             final JPanel pane = new JPanel(new GridBagLayout());
    213             pane.add(new JLabel(getTitle()), GBC.eol().fill(GBC.HORIZONTAL));
    214             pane.add(list, GBC.eop().fill(GBC.HORIZONTAL));
     213            final var pane = new JPanel(new GridBagLayout());
     214            pane.add(new JLabel(getTitle()), GBC.eol().fill(GridBagConstraints.HORIZONTAL));
     215            pane.add(list, GBC.eop().fill(GridBagConstraints.HORIZONTAL));
    215216            setContent(pane);
    216217            setDefaultCloseOperation(HIDE_ON_CLOSE);
     
    224225                    final Collection<WaySegment> segments = new ArrayList<>(selected.getNodesCount() - 1);
    225226                    final Iterator<Node> it = selected.getNodes().iterator();
    226                     Node previousNode = it.next();
     227                    var previousNode = it.next();
    227228                    while (it.hasNext()) {
    228                         final Node node = it.next();
     229                        final var node = it.next();
    229230                        segments.add(WaySegment.forNodePair(selectedWay, previousNode, node));
    230231                        previousNode = node;
     
    237238
    238239        protected void setHighlightedWaySegments(Collection<WaySegment> segments) {
    239             DataSet ds = selectedWay.getDataSet();
     240            final var ds = selectedWay.getDataSet();
    240241            if (ds != null) {
    241242                ds.setHighlightedWaySegments(segments);
     
    247248        public void setVisible(boolean visible) {
    248249            super.setVisible(visible);
    249             DataSet ds = selectedWay.getDataSet();
     250            final var ds = selectedWay.getDataSet();
    250251            if (visible) {
    251252                DISPLAY_COUNT.incrementAndGet();
     
    276277        }
    277278
    278         private class SplitWayDataSetListener implements DataSetListener {
     279        private final class SplitWayDataSetListener implements DataSetListener {
    279280
    280281            @Override
     
    336337        @Override
    337338        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    338             final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
     339            final var c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    339340            final String name = DefaultNameFormatter.getInstance().format((Way) value);
    340341            // get rid of id from DefaultNameFormatter.decorateNameWithId()
     
    359360        // Special case - one of the selected ways touches (not cross) way that we want to split
    360361        if (selectedNodes.size() == 1) {
    361             Node n = selectedNodes.get(0);
     362            final var n = selectedNodes.get(0);
    362363            List<Way> referredWays = n.getParentWays();
    363364            Way inTheMiddle = null;
Note: See TracChangeset for help on using the changeset viewer.