From c9bd37b6c4a71f7c8ea395fa99c681436cb0478d Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Wed, 25 Oct 2023 10:48:29 -0600 Subject: [PATCH] Cleanup some lint issues Signed-off-by: Taylor Smock --- .../CreateNewStopPointOperation.java | 47 ++-- ...teStopAreaFromSelectedObjectOperation.java | 2 +- .../CustomizePublicTransportStopDialog.java | 80 +++--- .../CustomizeStopAreaOperation.java | 42 ++- .../NearestWaySegment.java | 4 +- .../StopArea.java | 49 ++-- .../StopAreaOperationBase.java | 10 +- .../actions/DoubleSplitAction.java | 266 +++++++++--------- .../mendrelation/AbstractMendRelation.java | 2 +- .../PersonalTransportMendRelationAction.java | 150 +++++----- 10 files changed, 331 insertions(+), 321 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java index 6a22408e..6d19e9e9 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java @@ -47,7 +47,7 @@ public CreateNewStopPointOperation(DataSet currentDataSet) { /** * The *result* does not depend on the current map selection state, neither does * the result *order*. It solely depends on the distance to point p. - * + *

* This code is coped from JOSM code * * @return a sorted map with the keys representing the distance of their @@ -58,7 +58,8 @@ private Map> getNearestNodesImpl(Point p) { DataSet ds = getCurrentDataSet(); if (ds != null) { - double dist, snapDistanceSq = 200; + double dist; + double snapDistanceSq = 200; snapDistanceSq *= snapDistanceSq; for (Node n : ds.searchNodes(getBBox(p, 200))) { @@ -85,7 +86,7 @@ private Map> getNearestNodesImpl(Point p) { * @param snapDistance Distance for search * @return Area */ - private BBox getBBox(Point p, int snapDistance) { + private static BBox getBBox(Point p, int snapDistance) { MapView mapView = MainApplication.getMap().mapView; return new BBox(mapView.getLatLon(p.x - snapDistance, p.y - snapDistance), mapView.getLatLon(p.x + snapDistance, p.y + snapDistance)); @@ -100,22 +101,18 @@ private BBox getBBox(Point p, int snapDistance) { */ public AbstractMap.SimpleEntry getNearestNode(LatLon platformCoord, StopArea stopArea) { Point p = MainApplication.getMap().mapView.getPoint(platformCoord); - Map> dist_nodes = getNearestNodesImpl(p); - Double[] distances = dist_nodes.keySet().toArray(new Double[0]); + Map> distNodes = getNearestNodesImpl(p); + Double[] distances = distNodes.keySet().toArray(new Double[0]); Arrays.sort(distances); - Integer distanceIndex = -1; - Node nearestNode = null; - while (++distanceIndex < distances.length && nearestNode == null) { - List nodes = dist_nodes.get(distances[distanceIndex]); + int distanceIndex = -1; + while (++distanceIndex < distances.length) { + List nodes = distNodes.get(distances[distanceIndex]); for (Node node : nodes) { for (Way way : getCurrentDataSet().getWays()) { if (way.getNodes().contains(node) && testWay(way, stopArea)) { - nearestNode = node; - return new AbstractMap.SimpleEntry<>(distances[distanceIndex], nearestNode); + return new AbstractMap.SimpleEntry<>(distances[distanceIndex], node); } } - if (nearestNode != null) - break; } } return null; @@ -128,7 +125,7 @@ public AbstractMap.SimpleEntry getNearestNode(LatLon platformCoord * @param stopArea Stop area * @return true, if way can contain stop position */ - public Boolean testWay(final Way way, final StopArea stopArea) { + public boolean testWay(final Way way, final StopArea stopArea) { if (stopArea.isTrainStation || stopArea.isTrainStop) { return OSMTags.RAIL_TAG_VALUE.equals(way.getKeys().get(OSMTags.RAILWAY_TAG)) && OSMTags.MAIN_TAG_VALUE.equals(way.getKeys().get(OSMTags.USAGE_TAG)); @@ -149,7 +146,7 @@ public Boolean testWay(final Way way, final StopArea stopArea) { /** * The *result* does not depend on the current map selection state, neither does * the result *order*. It solely depends on the distance to point p. - * + *

* This code is coped from JOSM code * * @return a sorted map with the keys representing the perpendicular distance of @@ -176,17 +173,17 @@ private Map>> getNearestWaySegmentsImpl(Poin continue; } - Point2D A = MainApplication.getMap().mapView.getPoint2D(lastN); - Point2D B = MainApplication.getMap().mapView.getPoint2D(n); - double c = A.distanceSq(B); - double a = p.distanceSq(B); - double b = p.distanceSq(A); + Point2D pointA = MainApplication.getMap().mapView.getPoint2D(lastN); + Point2D pointB = MainApplication.getMap().mapView.getPoint2D(n); + double c = pointA.distanceSq(pointB); + double a = p.distanceSq(pointB); + double b = p.distanceSq(pointA); /* * perpendicular distance squared loose some precision to account for possible * deviations in the calculation above e.g. if identical (A and B) come about * reversed in another way, values may differ -- zero out least significant 32 - * dual digits of mantissa.. + * dual digits of mantissa. */ double perDistSq = Double.longBitsToDouble( // resolution in numbers with large exponent not needed here.. @@ -221,8 +218,8 @@ private Map>> getNearestWaySegmentsImpl(Poin protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea) { MapView mapView = MainApplication.getMap().mapView; Point p = mapView.getPoint(platformCoord); - Map>> dist_waySegments = getNearestWaySegmentsImpl(p); - for (Map.Entry>> entry : dist_waySegments.entrySet()) { + Map>> distWaySegments = getNearestWaySegmentsImpl(p); + for (Map.Entry>> entry : distWaySegments.entrySet()) { for (IWaySegment waySegment : entry.getValue()) { if (testWay(waySegment.getWay(), stopArea)) { INode n = waySegment.getFirstNode(); @@ -234,7 +231,7 @@ protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea Point2D lastN2D = mapView.getPoint2D(lastN); Point2D n2D = mapView.getPoint2D(n); Point2D newNodePosition2D = mapView.getPoint2D(newNodePosition); - Double distCurrenNodes = lastN2D.distance(n2D); + double distCurrenNodes = lastN2D.distance(n2D); if ((newNodePosition2D.distance(lastN2D) < distCurrenNodes) && (newNodePosition2D.distance(n2D) < distCurrenNodes)) { return new NearestWaySegment(entry.getKey(), waySegment, new Node(newNodePosition)); @@ -281,7 +278,7 @@ public StopArea performCustomizing(StopArea stopArea) { Node newStopPointNode = null; if (nearestNode != null && nearestWaySegment != null) { MapView mapView = MainApplication.getMap().mapView; - Double segmentDist = mapView.getPoint2D(platformCoord) + double segmentDist = mapView.getPoint2D(platformCoord) .distanceSq(mapView.getPoint2D(nearestWaySegment.newNode)); Double nodeDistSq = nearestNode.getKey(); // nodeDistSq *= nodeDistSq - 2; diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateStopAreaFromSelectedObjectOperation.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateStopAreaFromSelectedObjectOperation.java index 67e056e8..50c1f758 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateStopAreaFromSelectedObjectOperation.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateStopAreaFromSelectedObjectOperation.java @@ -98,7 +98,7 @@ public boolean testIsTransportTypeAssigned(OsmPrimitive platform) { * @param stopArea Selected stop area */ public void fromSelectedObject(StopArea stopArea) { - Collection selectedObjects = new ArrayList(); + Collection selectedObjects = new ArrayList<>(); selectedObjects.add(stopArea.selectedObject); for (Relation rel : OsmPrimitive.getParentRelations(selectedObjects)) { if (compareTag(rel, OSMTags.KEY_RELATION_TYPE, OSMTags.PUBLIC_TRANSPORT_TAG) diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopDialog.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopDialog.java index c5dc04ab..ae8b5302 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopDialog.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopDialog.java @@ -62,14 +62,14 @@ public class CustomizePublicTransportStopDialog implements ActionListener, ItemL private static final String CITY_NETWORK_CAPTION = I18n.marktr("City transport"); private static final String HIGH_SPEED_NETWORK_CAPTION = I18n.marktr("High speed"); - private String[] serviceCaptionStrings = {CITY_NETWORK_CAPTION, COMMUTER_NETWORK_CAPTION, REGIONAL_NETWORK_CAPTION, + private final String[] serviceCaptionStrings = {CITY_NETWORK_CAPTION, COMMUTER_NETWORK_CAPTION, REGIONAL_NETWORK_CAPTION, LONG_DISTANCE_NETWORK_CAPTION, HIGH_SPEED_NETWORK_CAPTION}; - private String[] serviceStrings = {OSMTags.CITY_NETWORK_TAG_VALUE, OSMTags.COMMUTER_NETWORK_TAG_VALUE, + private final String[] serviceStrings = {OSMTags.CITY_NETWORK_TAG_VALUE, OSMTags.COMMUTER_NETWORK_TAG_VALUE, OSMTags.REGIONAL_NETWORK_TAG_VALUE, OSMTags.LONG_DISTANCE_NETWORK_TAG_VALUE, OSMTags.HIGH_SPEED_NETWORK_TAG_VALUE}; - private JDialog jDialog = null; - private JTextField textFieldName = null; + private JDialog jDialog; + private JTextField textFieldName; private JTextField textFieldNameEn; private JTextField textFieldNetwork; private JTextField textFieldOperator; @@ -99,7 +99,7 @@ public class CustomizePublicTransportStopDialog implements ActionListener, ItemL /** * Map of check boxes */ - private HashMap checkBoxValues = new HashMap(); + private final HashMap checkBoxValues = new HashMap<>(); /** * Previous stop name @@ -112,11 +112,11 @@ public class CustomizePublicTransportStopDialog implements ActionListener, ItemL /** * Network name at previous call */ - private static String previousNetwork = null; + private static String previousNetwork; /** * Operator name at previous call */ - private static String previousOperator = null; + private static String previousOperator; /** * Reference to dialog object @@ -238,7 +238,7 @@ private JPanel createContentPane() { for (int i = 0; i < serviceCaptionStrings.length; i++) { serviceTransStrings[i] = tr(serviceCaptionStrings[i]); } - comboBoxService = new JComboBox(serviceTransStrings); + comboBoxService = new JComboBox<>(serviceTransStrings); comboBoxService.setSelectedIndex(0); layoutCons.gridx = 1; layoutCons.gridy = 4; @@ -435,7 +435,7 @@ public void setCustomizeStopAction(CustomizeStopAction newCustomizeStopAction) { * @param checkBox Check box * @param value Value of check box */ - public void setCheckBoxValue(JCheckBox checkBox, Boolean value) { + public void setCheckBoxValue(JCheckBox checkBox, boolean value) { checkBoxValues.put(checkBox, value); checkBox.setSelected(value); } @@ -446,7 +446,7 @@ public void setCheckBoxValue(JCheckBox checkBox, Boolean value) { * @param checkBox Check box * @return Value of check box */ - public Boolean getCheckBoxValue(JCheckBox checkBox) { + public boolean getCheckBoxValue(JCheckBox checkBox) { try { if (checkBoxValues.containsKey(checkBox)) { return checkBoxValues.get(checkBox); @@ -476,7 +476,7 @@ public void itemStateChanged(ItemEvent event) { * * @param isVisible Flag of dialog visibility */ - public void setVisible(Boolean isVisible) { + public void setVisible(boolean isVisible) { if (jDialog != null) jDialog.setVisible(isVisible); } @@ -554,35 +554,39 @@ public String getTextFromControl(JTextField textField) { * @return Stop area */ public StopArea saveValues() { - StopArea stopArea = this.stopArea; + StopArea currentStopArea = this.stopArea; try { - if (stopArea == null) - stopArea = new StopArea(); - stopArea.name = getTextFromControl(textFieldName); - previousName = stopArea.name; - stopArea.nameEn = getTextFromControl(textFieldNameEn); - previousNameEn = stopArea.nameEn; - stopArea.network = getTextFromControl(textFieldNetwork); - previousNetwork = stopArea.network; - stopArea.operator = getTextFromControl(textFieldOperator); - previousOperator = stopArea.operator; - stopArea.service = serviceStrings[comboBoxService.getSelectedIndex()]; - stopArea.isBus = getCheckBoxValue(checkBoxIsBus); - stopArea.isShareTaxi = getCheckBoxValue(checkBoxIsShareTaxi); - stopArea.isTrolleybus = getCheckBoxValue(checkBoxIsTrolleybus); - stopArea.isBusStation = getCheckBoxValue(checkBoxIsBusStation); - stopArea.isAssignTransportType = getCheckBoxValue(checkBoxIsAssignTransportType); - stopArea.isTram = getCheckBoxValue(checkBoxIsTram); - stopArea.isTrainStation = getCheckBoxValue(checkBoxIsTrainStation); - stopArea.isTrainStop = getCheckBoxValue(checkBoxIsTrainStop); - stopArea.isBench = getCheckBoxValue(checkBoxIsBench); - stopArea.isShelter = getCheckBoxValue(checkBoxIsShelder); - stopArea.isCovered = getCheckBoxValue(checkBoxIsCover); - stopArea.isArea = getCheckBoxValue(checkBoxIsArea); + if (currentStopArea == null) + currentStopArea = new StopArea(); + currentStopArea.name = getTextFromControl(textFieldName); + currentStopArea.nameEn = getTextFromControl(textFieldNameEn); + currentStopArea.network = getTextFromControl(textFieldNetwork); + currentStopArea.operator = getTextFromControl(textFieldOperator); + currentStopArea.service = serviceStrings[comboBoxService.getSelectedIndex()]; + currentStopArea.isBus = getCheckBoxValue(checkBoxIsBus); + currentStopArea.isShareTaxi = getCheckBoxValue(checkBoxIsShareTaxi); + currentStopArea.isTrolleybus = getCheckBoxValue(checkBoxIsTrolleybus); + currentStopArea.isBusStation = getCheckBoxValue(checkBoxIsBusStation); + currentStopArea.isAssignTransportType = getCheckBoxValue(checkBoxIsAssignTransportType); + currentStopArea.isTram = getCheckBoxValue(checkBoxIsTram); + currentStopArea.isTrainStation = getCheckBoxValue(checkBoxIsTrainStation); + currentStopArea.isTrainStop = getCheckBoxValue(checkBoxIsTrainStop); + currentStopArea.isBench = getCheckBoxValue(checkBoxIsBench); + currentStopArea.isShelter = getCheckBoxValue(checkBoxIsShelder); + currentStopArea.isCovered = getCheckBoxValue(checkBoxIsCover); + currentStopArea.isArea = getCheckBoxValue(checkBoxIsArea); + setPreviousFields(stopArea); } catch (Exception ex) { DialogUtils.showOkWarning("Exception when saving preferences!", ex.getMessage()); } - return stopArea; + return currentStopArea; + } + + private static void setPreviousFields(StopArea stopArea) { + previousName = stopArea.name; + previousNameEn = stopArea.nameEn; + previousNetwork = stopArea.network; + previousOperator = stopArea.operator; } /** @@ -593,8 +597,8 @@ public void actionPerformed(ActionEvent event) { if (SAVE_COMMAND.equals(event.getActionCommand())) { setVisible(false); if (customizeStopAction != null) { - StopArea stopArea = saveValues(); - customizeStopAction.performCustomizing(stopArea); + StopArea currentStopArea = saveValues(); + customizeStopAction.performCustomizing(currentStopArea); } } else { setVisible(false); diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAreaOperation.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAreaOperation.java index 737c6201..4707ee2f 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAreaOperation.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAreaOperation.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.openstreetmap.josm.command.AddCommand; import org.openstreetmap.josm.command.ChangeCommand; @@ -51,7 +52,7 @@ public CustomizeStopAreaOperation(DataSet currentDataSet) { */ public List nameTagAssign(OsmPrimitive target, List commands, StopArea stopArea) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); commands = assignTag(commands, target, OSMTags.NAME_TAG, "".equals(stopArea.name) ? null : stopArea.name); commands = assignTag(commands, target, OSMTags.NAME_EN_TAG, @@ -85,9 +86,9 @@ protected List transportTypeTagClearing(OsmPrimitive target, List transportTypeTagAssign(OsmPrimitive target, List commands, StopArea stopArea, - Boolean isStopPoint) { + boolean isStopPoint) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); if (isStopPoint) { if (stopArea.isTrainStop || stopArea.isTrainStation) { @@ -136,7 +137,7 @@ protected List transportTypeTagAssign(OsmPrimitive target, List generalTagAssign(OsmPrimitive target, List commands, StopArea stopArea) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); commands = nameTagAssign(target, commands, stopArea); commands = assignTag(commands, target, OSMTags.NETWORK_TAG, @@ -160,9 +161,9 @@ public List generalTagAssign(OsmPrimitive target, List command * @return Resulting command list */ public List stopPointTagAssign(OsmPrimitive target, List commands, StopArea stopArea, - Boolean isFirst) { + boolean isFirst) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); commands = generalTagAssign(target, commands, stopArea); commands = transportTypeTagAssign(target, commands, stopArea, true); @@ -196,9 +197,9 @@ public List stopPointTagAssign(OsmPrimitive target, List comma * @return Resulting command list */ public List platformTagAssign(OsmPrimitive target, List commands, StopArea stopArea, - Boolean isFirst) { + boolean isFirst) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); commands = generalTagAssign(target, commands, stopArea); commands = transportTypeTagAssign(target, commands, stopArea, false); @@ -237,7 +238,7 @@ else if (isFirst && !stopArea.isBusStation) */ public List otherMemberTagAssign(OsmPrimitive target, List commands, StopArea stopArea) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); commands = nameTagAssign(target, commands, stopArea); commands = clearTag(commands, target, OSMTags.NETWORK_TAG); @@ -258,7 +259,7 @@ public List otherMemberTagAssign(OsmPrimitive target, List com */ private List createStopAreaRelation(List commands, StopArea stopArea) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); Relation newRelation = new Relation(); for (Node node : stopArea.stopPoints) { @@ -289,11 +290,11 @@ private List createStopAreaRelation(List commands, StopArea st public static List addNewRelationMember(List commands, Relation targetRelation, OsmPrimitive member, String roleName) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); for (RelationMember relationMember : targetRelation.getMembers()) { if (relationMember.getMember() == member) { - if (relationMember.getRole() == roleName) { + if (Objects.equals(relationMember.getRole(), roleName)) { return commands; } return commands; @@ -313,7 +314,7 @@ public static List addNewRelationMember(List commands, Relatio */ private List addNewRelationMembers(List commands, StopArea stopArea) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); for (OsmPrimitive stopPoint : stopArea.stopPoints) { commands = addNewRelationMember(commands, stopArea.stopAreaRelation, stopPoint, OSMTags.STOP_ROLE); @@ -381,10 +382,7 @@ public Node searchBusStop(StopArea stopArea, String tag, String tagValue) { * @return True, stop area must to have separate bus stop node */ public boolean needSeparateBusStop(StopArea stopArea, OsmPrimitive firstPlatform) { - if (((stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) && (firstPlatform instanceof Way))) { - return true; - } - return false; + return (stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) && (firstPlatform instanceof Way); } /** @@ -398,7 +396,7 @@ public boolean needSeparateBusStop(StopArea stopArea, OsmPrimitive firstPlatform */ private List clearExcessTags(List commands, OsmPrimitive target, String tag, String tagValue) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); if (compareTag(target, tag, tagValue)) { commands = clearTag(commands, target, tag); @@ -425,7 +423,7 @@ private List clearExcessTags(List commands, OsmPrimitive targe */ public List clearExcessTags(List commands, StopArea stopArea, String tag, String tagValue) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); for (OsmPrimitive stopPoint : stopArea.stopPoints) { clearExcessTags(commands, stopPoint, tag, tagValue); @@ -452,7 +450,7 @@ public List clearExcessTags(List commands, StopArea stopArea, protected List createSeparateBusStopNode(List commands, StopArea stopArea, OsmPrimitive firstPlatform, String tag, String tagValue) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); LatLon centerOfPlatform = getCenterOfWay(firstPlatform); if (firstPlatform instanceof Way) { @@ -479,7 +477,7 @@ protected List createSeparateBusStopNode(List commands, StopAr */ public List customize(StopArea stopArea) { try { - List commands = new ArrayList(); + List commands = new ArrayList<>(); Node separateBusStopNode = searchBusStop(stopArea, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); if (separateBusStopNode == null) separateBusStopNode = searchBusStop(stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); @@ -496,7 +494,7 @@ public List customize(StopArea stopArea) { getCurrentDataSet()); createNewStopPointOperation.performCustomizing(stopArea); } - Boolean isFirst = true; + boolean isFirst = true; for (Node node : stopArea.stopPoints) { commands = stopPointTagAssign(node, commands, stopArea, isFirst); isFirst = false; diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java index 3d5d1827..0547f548 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java @@ -14,7 +14,7 @@ public class NearestWaySegment { /** * Square of distance */ - public Double distanceSq = 1000000000.0; + public double distanceSq; /** * Way segment */ @@ -31,7 +31,7 @@ public class NearestWaySegment { * @param waySegment Way segment * @param newNode Node */ - public NearestWaySegment(Double distanceSq, IWaySegment waySegment, Node newNode) { + public NearestWaySegment(double distanceSq, IWaySegment waySegment, Node newNode) { this.distanceSq = distanceSq; this.waySegment = waySegment; this.newNode = newNode; diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopArea.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopArea.java index d4975ecb..3b170414 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopArea.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopArea.java @@ -2,6 +2,7 @@ package org.openstreetmap.josm.plugins.customizepublictransportstop; import java.util.ArrayList; +import java.util.List; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.OsmPrimitive; @@ -18,101 +19,101 @@ public class StopArea { /** * Name of stop area */ - public String name = null; + public String name; /** * English name of stop area */ - public String nameEn = null; + public String nameEn; /** * Operator of stop area */ - public String operator = null; + public String operator; /** * Network name */ - public String network = null; + public String network; /** * Level of network including this stop area */ - public String service = null; + public String service; /** * Flag of bus stop area */ - public Boolean isBus = false; + public boolean isBus; /** * Flag of trolleybus stop area */ - public Boolean isTrolleybus = false; + public boolean isTrolleybus; /** * Flag of share taxi stop area */ - public Boolean isShareTaxi = false; + public boolean isShareTaxi; /** * Flag of bus station stop area */ - public Boolean isBusStation = false; + public boolean isBusStation; /** * Flag of tram stop area */ - public Boolean isTram = false; + public boolean isTram; /** * Flag of railway stop area */ - public Boolean isTrainStop = false; + public boolean isTrainStop; /** * Flag of railway station */ - public Boolean isTrainStation = false; + public boolean isTrainStation; /** * Flag of bench on selected platform */ - public Boolean isAssignTransportType = false; + public boolean isAssignTransportType; /** * Flag of bench near platform */ - public Boolean isBench = false; + public boolean isBench; /** * Flag of covered platform */ - public Boolean isCovered = false; + public boolean isCovered; /** * Flag of shelter on selected platform */ - public Boolean isShelter = false; + public boolean isShelter; /** * Relation of stop area */ - public Relation stopAreaRelation = null; + public Relation stopAreaRelation; /** * Flag of existing of stop position */ - public Boolean isStopPointExists = false; + public boolean isStopPointExists; /** * Flag of area platform */ - public Boolean isArea = false; + public boolean isArea; /** * Separate node of bus stop or bus station */ - public Node separateBusStopNode = null; + public Node separateBusStopNode; /** * List of nodes of stop positions */ - public final ArrayList stopPoints = new ArrayList(); + public final List stopPoints = new ArrayList<>(); /** * List of josm objects of platforms */ - public final ArrayList platforms = new ArrayList(); + public final List platforms = new ArrayList<>(); /** * List of non stop positions or platform stop area members */ - public final ArrayList otherMembers = new ArrayList(); + public final List otherMembers = new ArrayList<>(); /** * Selected josm objects. Must be a platform */ - public OsmPrimitive selectedObject = null; + public OsmPrimitive selectedObject; /** * Constructor of stop area object diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopAreaOperationBase.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopAreaOperationBase.java index cab4700b..0a1fc608 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopAreaOperationBase.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/StopAreaOperationBase.java @@ -22,15 +22,15 @@ public abstract class StopAreaOperationBase implements IStopAreaCustomizer { /** * Current dataset of Josm */ - private final DataSet _CurrentDataSet; + private final DataSet currentDataSet; /** * Constructor of operation of customizing of stop area * * @param currentDataSet Current data set of JOSM */ - public StopAreaOperationBase(DataSet currentDataSet) { - _CurrentDataSet = currentDataSet; + protected StopAreaOperationBase(DataSet currentDataSet) { + this.currentDataSet = currentDataSet; } /** @@ -39,7 +39,7 @@ public StopAreaOperationBase(DataSet currentDataSet) { * @return Current dataset of Josm */ protected DataSet getCurrentDataSet() { - return _CurrentDataSet; + return currentDataSet; } /** @@ -88,7 +88,7 @@ public static Boolean compareTag(OsmPrimitive osmObject, String tagName, String */ public static List assignTag(List commands, OsmPrimitive target, String tag, String tagValue) { if (commands == null) - commands = new ArrayList(); + commands = new ArrayList<>(); commands.add(new ChangePropertyCommand(target, tag, tagValue)); return commands; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java index 5c8ac22a..b9686611 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java +++ b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java @@ -6,13 +6,14 @@ import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics2D; +import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Point; -import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; +import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -66,6 +67,9 @@ import org.openstreetmap.josm.tools.Logging; import org.openstreetmap.josm.tools.Pair; import org.openstreetmap.josm.tools.RightAndLefthandTraffic; +import org.openstreetmap.josm.tools.Shortcut; + +import jakarta.annotation.Nonnull; /** * The DoubleSplitAction is a mapmode that allows users to add a bus_bay,a @@ -74,15 +78,27 @@ * @author Biswesh */ public class DoubleSplitAction extends MapMode implements KeyListener { + private static final String BOTH = "both"; + private static final String BRIDGE = "bridge"; + private static final String BUILDING_PASSAGE = "building_passage"; + private static final String BUS_BAY = "bus_bay"; + private static final String CULVERT = "culvert"; + private static final String LEFT = "left"; + private static final String RIGHT = "right"; + private static final String TRAFFIC_CALMING = "traffic_calming"; + private static final String TUNNEL = "tunnel"; + private static final String WATERWAY = "waterway"; + private static final String LAYER = "layer"; + private static final String TABLE = "table"; private final transient Set newHighlights = new HashSet<>(); private final transient Set oldHighlights = new HashSet<>(); private final List atNodes = new ArrayList<>(); - private final DoubleSplitLayer temporaryLayer = new DoubleSplitLayer(); - ILatLon Pos1 = null; - ILatLon Pos2 = null; - Way SegWay1 = null; - Way SegWay2 = null; + private final transient DoubleSplitLayer temporaryLayer = new DoubleSplitLayer(); + ILatLon Pos1; + ILatLon Pos2; + Way SegWay1; + Way SegWay2; Way affected; Way previousAffectedWay; @@ -93,10 +109,11 @@ public class DoubleSplitAction extends MapMode implements KeyListener { * Creates a new DoubleSplitAction */ public DoubleSplitAction() { - super(tr("Double Split"), "double_split", tr("Double Split"), null, getCursor()); + super(tr("Double Split"), "double_split", tr("Double Split"), + Shortcut.registerShortcut("pt_assistant:double_split", tr("PT Assistant: Double Split"), + KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), getCursor()); cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode"); cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway"); - } private static Cursor getCursor() { @@ -157,12 +174,10 @@ private boolean startEndPoints(List commandList) { try { for (Way way : atNodes.get(0).getParentWays()) { - if (atNodes.get(1).getParentWays().contains(way)) { - if (way.isFirstLastNode(atNodes.get(0)) && way.isFirstLastNode(atNodes.get(1))) { - newHighlights.add(way); - dialogBox(SelectFromOptionDialog.TYPE_NODES_ARE_ENDS_OF_SAME_WAY, null, way, way, commandList); - return true; - } + if (atNodes.get(1).getParentWays().contains(way) && way.isFirstLastNode(atNodes.get(0)) && way.isFirstLastNode(atNodes.get(1))) { + newHighlights.add(way); + dialogBox(SelectFromOptionDialog.TYPE_NODES_ARE_ENDS_OF_SAME_WAY, null, way, way, commandList); + return true; } } } catch (Exception e) { @@ -203,28 +218,15 @@ private void action() { // check if the user has selected an existing node, or a new one Point curP1 = MainApplication.getMap().mapView.getPoint(Pos1); - ILatLon P1 = new LatLon(curP1.getX(), curP1.getY()); - Node node1 = createNode(P1, commandList); - if (node1 == null) { - resetLayer(); - reset(); - return; - } + ILatLon p1 = new LatLon(curP1.getX(), curP1.getY()); + Node node1 = createNode(p1, commandList); Point curP2 = MainApplication.getMap().mapView.getPoint(Pos2); - ILatLon P2 = new LatLon(curP2.getX(), curP2.getY()); - Node node2 = createNode(P2, commandList); - if (node2 == null) { - node1.setDeleted(true); - Pos2 = null; - SegWay2 = null; - reset(); - return; - } + ILatLon p2 = new LatLon(curP2.getX(), curP2.getY()); + Node node2 = createNode(p2, commandList); if (node1.equals(node2)) { resetLayer(); - System.out.println("same"); return; } @@ -294,17 +296,18 @@ private void dialogBox(int type, Node commonNode, Way affected, Way previousAffe } // create a node in the position that the user has marked - private Node createNode(ILatLon Pos, List commandList) { + @Nonnull + private Node createNode(ILatLon pos, List commandList) { boolean newNode = false; Node newStopPos; Point p = new Point(); - p.setLocation(Pos.lat(), Pos.lon()); + p.setLocation(pos.lat(), pos.lon()); Node n = MainApplication.getMap().mapView.getNearestNode(p, OsmPrimitive::isUsable); if (n == null) { newNode = true; - newStopPos = new Node(MainApplication.getMap().mapView.getLatLon(Pos.lat(), Pos.lon())); + newStopPos = new Node(MainApplication.getMap().mapView.getLatLon(pos.lat(), pos.lon())); } else { newStopPos = new Node(n); } @@ -414,7 +417,8 @@ private void addKeysOnBothWays(Node commonNode, Way affected, Way previousAffect final List referrers2 = WayUtils.findPTRouteParents(affected); final Map> indices2 = PrimitiveUtils.findIndicesOfPrimitiveInRelations(affected, referrers2); - Way way1 = null, way2 = null; + Way way1 = null; + Way way2 = null; // Find middle way which is a part of both the ways, so find the 2 ways which // together would form middle way @@ -482,19 +486,17 @@ private void addKeysWhenStartEndPoint(Way affected, JComboBox keys, JCom } // check if a way is present in a relation, if not then add it - private void checkMembership(Way way, List referrers, Map> Index) { + private static void checkMembership(Way way, List referrers, Map> index) { for (Relation r : referrers) { boolean isMember = false; for (RelationMember rm : r.getMembers()) { - if (rm.getType() == OsmPrimitiveType.WAY) { - if (rm.getWay().equals(way)) { - isMember = true; - } + if (rm.getType() == OsmPrimitiveType.WAY && rm.getWay().equals(way)) { + isMember = true; } } if (!isMember) { - for (int i = 0; i < Index.get(r).size(); i++) { - r.addMember(Index.get(r).get(i), new RelationMember("", way)); + for (int i = 0; i < index.get(r).size(); i++) { + r.addMember(index.get(r).get(i), new RelationMember("", way)); } } } @@ -509,20 +511,20 @@ private void addTags(List affectedKeysList, List selectedWay, JComb TagMap newKeys1 = affectedKeysList.get(0); String prevValue = null; - if (keys.getSelectedItem() == "bridge") { + if (BRIDGE.equals(keys.getSelectedItem())) { newKeys1.put(keys.getSelectedItem().toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); - newKeys1.put("layer", "1"); - } else if (keys.getSelectedItem() == "tunnel") { + newKeys1.put(LAYER, "1"); + } else if (TUNNEL.equals(keys.getSelectedItem())) { newKeys1.put(keys.getSelectedItem().toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); - if (!values.getSelectedItem().toString().equals("building_passage")) - newKeys1.put("layer", "-1"); - } else if (keys.getSelectedItem() == "traffic_calming") { + if (!values.getSelectedItem().toString().equals(BUILDING_PASSAGE)) + newKeys1.put(LAYER, "-1"); + } else if (keys.getSelectedItem() == TRAFFIC_CALMING) { newKeys1.put(keys.getSelectedItem().toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); newKeys1.put("maxspeed", "30"); } else if (keys.getSelectedItem() != "none") { - if (newKeys1.containsKey("bus_bay")) { - prevValue = newKeys1.get("bus_bay"); - newKeys1.put(Objects.requireNonNull(keys.getSelectedItem()).toString(), "both"); + if (newKeys1.containsKey(BUS_BAY)) { + prevValue = newKeys1.get(BUS_BAY); + newKeys1.put(Objects.requireNonNull(keys.getSelectedItem()).toString(), BOTH); } else { newKeys1.put(Objects.requireNonNull(keys.getSelectedItem()).toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); @@ -532,30 +534,30 @@ private void addTags(List affectedKeysList, List selectedWay, JComb if (affectedKeysList.size() == 2) { TagMap newKeys2 = affectedKeysList.get(1); - if (keys.getSelectedItem() == "bridge") { + if (keys.getSelectedItem() == BRIDGE) { newKeys2.put(keys.getSelectedItem().toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); - newKeys2.put("layer", "1"); - } else if (keys.getSelectedItem() == "tunnel") { + newKeys2.put(LAYER, "1"); + } else if (keys.getSelectedItem() == TUNNEL) { newKeys2.put(keys.getSelectedItem().toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); - if (!values.getSelectedItem().toString().equals("building_passage")) - newKeys2.put("layer", "-1"); - } else if (keys.getSelectedItem() == "traffic_calming") { + if (!values.getSelectedItem().toString().equals(BUILDING_PASSAGE)) + newKeys2.put(LAYER, "-1"); + } else if (keys.getSelectedItem() == TRAFFIC_CALMING) { newKeys2.put(keys.getSelectedItem().toString(), Objects.requireNonNull(values.getSelectedItem()).toString()); newKeys2.put("maxspeed", "30"); } else if (keys.getSelectedItem() != "none") { - if (newKeys2.containsKey("bus_bay")) { - prevValue = newKeys2.get("bus_bay"); - newKeys2.put(keys.getSelectedItem().toString(), "both"); - if (Objects.equals(values.getSelectedItem(), "left") && prevValue.equals("left")) - newKeys1.put("bus_bay", "right"); - else if (Objects.equals(values.getSelectedItem(), "right") && prevValue.equals("right")) - newKeys1.put("bus_bay", "left"); + if (newKeys2.containsKey(BUS_BAY)) { + prevValue = newKeys2.get(BUS_BAY); + newKeys2.put(keys.getSelectedItem().toString(), BOTH); + if (Objects.equals(values.getSelectedItem(), LEFT) && prevValue.equals(LEFT)) + newKeys1.put(BUS_BAY, RIGHT); + else if (Objects.equals(values.getSelectedItem(), RIGHT) && prevValue.equals(RIGHT)) + newKeys1.put(BUS_BAY, LEFT); } else { - if (newKeys1.get("bus_bay").equals("both")) { - if (Objects.equals(values.getSelectedItem(), "left") && Objects.equals(prevValue, "left")) - newKeys2.put("bus_bay", "right"); - else if (Objects.equals(values.getSelectedItem(), "right") && Objects.equals(prevValue, "right")) - newKeys2.put("bus_bay", "left"); + if (newKeys1.get(BUS_BAY).equals(BOTH)) { + if (Objects.equals(values.getSelectedItem(), LEFT) && Objects.equals(prevValue, LEFT)) + newKeys2.put(BUS_BAY, RIGHT); + else if (Objects.equals(values.getSelectedItem(), RIGHT) && Objects.equals(prevValue, RIGHT)) + newKeys2.put(BUS_BAY, LEFT); else newKeys2.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); } else { @@ -596,7 +598,7 @@ private void findIntersection(Set newWays) { if (count == 1) { waysToBeRemoved.add(way); } else { - if (!way.hasKey("highway") && !way.hasKey("waterway") && !way.hasKey("railway")) { + if (!way.hasKey("highway") && !way.hasKey(WATERWAY) && !way.hasKey("railway")) { waysToBeRemoved.add(way); } } @@ -713,26 +715,23 @@ private void updateHighlights() { @Override public void keyTyped(KeyEvent e) { - System.out.println("keyTyped"); + // Do nothing } @Override public void keyPressed(KeyEvent e) { - System.out.println("keyPressed"); boolean z = e.getKeyCode() == KeyEvent.VK_Z; updateKeyModifiers(e); - if (z) { - if (Pos1 != null && Pos2 == null) { - Pos1 = null; - SegWay1 = null; - temporaryLayer.invalidate(); - } + if (z && Pos1 != null && Pos2 == null) { + Pos1 = null; + SegWay1 = null; + temporaryLayer.invalidate(); } } @Override public void keyReleased(KeyEvent e) { - System.out.println("keyReleased"); + // Do nothing } // A dialogBox to query whether to select bus_bay, tunnel or bridge. @@ -742,7 +741,8 @@ private class SelectFromOptionDialog extends ExtendedDialog { private static final int TYPE_NODES_ON_SAME_WAY = 2; private static final int TYPE_NODES_ARE_ENDS_OF_SAME_WAY = 3; - Way affected, previousAffectedWay; + Way affected; + Way previousAffectedWay; private final JComboBox keys; private final JComboBox values; private final int type; @@ -777,7 +777,7 @@ private class SelectFromOptionDialog extends ExtendedDialog { configureContextsensitiveHelp("/Dialog/AddValue", true /* show help button */); final JPanel pane = new JPanel(new GridBagLayout()); - pane.add(new JLabel("Select the appropriate option"), GBC.eol().fill(GBC.HORIZONTAL)); + pane.add(new JLabel("Select the appropriate option"), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); keys = new JComboBox<>(); values = new JComboBox<>(); @@ -785,18 +785,18 @@ private class SelectFromOptionDialog extends ExtendedDialog { Set newWays = new HashSet<>(); findIntersection(newWays); - if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) { + if (previousAffectedWay.hasKey(WATERWAY) || affected.hasKey(WATERWAY)) { setOptionsWithTunnel(); - } else if (previousAffectedWay.hasKey("bus_bay") || affected.hasKey("bus_bay")) { + } else if (previousAffectedWay.hasKey(BUS_BAY) || affected.hasKey(BUS_BAY)) { setOptionsWithBusBay(); - } else if (newWays.size() != 0) { + } else if (!newWays.isEmpty()) { setOptionsWithBridge(); } else { setOptionsWithBusBay(); } - pane.add(keys, GBC.eop().fill(GBC.HORIZONTAL)); - pane.add(values, GBC.eop().fill(GBC.HORIZONTAL)); + pane.add(keys, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); + pane.add(values, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); setContent(pane, false); setDefaultCloseOperation(HIDE_ON_CLOSE); @@ -804,37 +804,37 @@ private class SelectFromOptionDialog extends ExtendedDialog { private void setOptionsWithBusBay() { keys.setModel( - new DefaultComboBoxModel<>(new String[] {"bus_bay", "bridge", "tunnel", "traffic_calming", "none" })); + new DefaultComboBoxModel<>(new String[] {BUS_BAY, BRIDGE, TUNNEL, TRAFFIC_CALMING, "none" })); - if (affected.hasTag("bus_bay", "right") || previousAffectedWay.hasTag("bus_bay", "right")) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"left", "right", "both" })); - } else if (affected.hasTag("bus_bay", "left") || previousAffectedWay.hasTag("bus_bay", "left")) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"right", "left", "both" })); + if (affected.hasTag(BUS_BAY, RIGHT) || previousAffectedWay.hasTag(BUS_BAY, RIGHT)) { + values.setModel(new DefaultComboBoxModel<>(new String[] {LEFT, RIGHT, BOTH })); + } else if (affected.hasTag(BUS_BAY, LEFT) || previousAffectedWay.hasTag(BUS_BAY, LEFT)) { + values.setModel(new DefaultComboBoxModel<>(new String[] {RIGHT, LEFT, BOTH })); } else if (rightHandTraffic) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"right", "left", "both" })); + values.setModel(new DefaultComboBoxModel<>(new String[] {RIGHT, LEFT, BOTH })); } else { - values.setModel(new DefaultComboBoxModel<>(new String[] {"left", "right", "both" })); + values.setModel(new DefaultComboBoxModel<>(new String[] {LEFT, RIGHT, BOTH })); } // below code changes the list in values on the basis of key keys.addActionListener(e -> { - if ("bus_bay".equals(keys.getSelectedItem())) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"both", "right", "left" })); + if (BUS_BAY.equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {BOTH, RIGHT, LEFT})); if (rightHandTraffic) - values.setModel(new DefaultComboBoxModel<>(new String[] {"right", "left", "both" })); + values.setModel(new DefaultComboBoxModel<>(new String[] {RIGHT, LEFT, BOTH})); else - values.setModel(new DefaultComboBoxModel<>(new String[] {"left", "right", "both" })); - } else if ("bridge".equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {LEFT, RIGHT, BOTH})); + } else if (BRIDGE.equals(keys.getSelectedItem())) { values.setModel(new DefaultComboBoxModel<>(new String[] {"yes" })); - } else if ("tunnel".equals(keys.getSelectedItem())) { - if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) + } else if (TUNNEL.equals(keys.getSelectedItem())) { + if (previousAffectedWay.hasKey(WATERWAY) || affected.hasKey(WATERWAY)) values.setModel( - new DefaultComboBoxModel<>(new String[] {"culvert", "yes", "building_passage" })); + new DefaultComboBoxModel<>(new String[] {CULVERT, "yes", BUILDING_PASSAGE })); else values.setModel( - new DefaultComboBoxModel<>(new String[] {"yes", "culvert", "building_passage" })); - } else if ("traffic_calming".equals(keys.getSelectedItem())) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"table" })); + new DefaultComboBoxModel<>(new String[] {"yes", CULVERT, BUILDING_PASSAGE })); + } else if (TRAFFIC_CALMING.equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {TABLE })); } else if ("none".equals(keys.getSelectedItem())) { values.setModel(new DefaultComboBoxModel<>(new String[] {"" })); } @@ -843,32 +843,32 @@ private void setOptionsWithBusBay() { private void setOptionsWithTunnel() { keys.setModel( - new DefaultComboBoxModel<>(new String[] {"tunnel", "bridge", "bus_bay", "traffic_calming", "none" })); + new DefaultComboBoxModel<>(new String[] {TUNNEL, BRIDGE, BUS_BAY, TRAFFIC_CALMING, "none" })); - if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) - values.setModel(new DefaultComboBoxModel<>(new String[] {"culvert", "yes", "building_passage" })); + if (previousAffectedWay.hasKey(WATERWAY) || affected.hasKey(WATERWAY)) + values.setModel(new DefaultComboBoxModel<>(new String[] {CULVERT, "yes", BUILDING_PASSAGE })); else - values.setModel(new DefaultComboBoxModel<>(new String[] {"yes", "culvert", "building_passage" })); + values.setModel(new DefaultComboBoxModel<>(new String[] {"yes", CULVERT, BUILDING_PASSAGE })); // below code changes the list in values on the basis of key keys.addActionListener(e -> { - if ("tunnel".equals(keys.getSelectedItem())) { - if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) + if (TUNNEL.equals(keys.getSelectedItem())) { + if (previousAffectedWay.hasKey(WATERWAY) || affected.hasKey(WATERWAY)) values.setModel( - new DefaultComboBoxModel<>(new String[] {"culvert", "yes", "building_passage" })); + new DefaultComboBoxModel<>(new String[] {CULVERT, "yes", BUILDING_PASSAGE })); else values.setModel( - new DefaultComboBoxModel<>(new String[] {"yes", "culvert", "building_passage" })); - } else if ("bus_bay".equals(keys.getSelectedItem())) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"both", "right", "left" })); + new DefaultComboBoxModel<>(new String[] {"yes", CULVERT, BUILDING_PASSAGE })); + } else if (BUS_BAY.equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {BOTH, RIGHT, LEFT })); if (rightHandTraffic) - values.setModel(new DefaultComboBoxModel<>(new String[] {"right", "left", "both" })); + values.setModel(new DefaultComboBoxModel<>(new String[] {RIGHT, LEFT, BOTH })); else - values.setModel(new DefaultComboBoxModel<>(new String[] {"left", "right", "both" })); - } else if ("bridge".equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {LEFT, RIGHT, BOTH })); + } else if (BRIDGE.equals(keys.getSelectedItem())) { values.setModel(new DefaultComboBoxModel<>(new String[] {"yes" })); - } else if ("traffic_calming".equals(keys.getSelectedItem())) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"table" })); + } else if (TRAFFIC_CALMING.equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {TABLE })); } else if ("none".equals(keys.getSelectedItem())) { values.setModel(new DefaultComboBoxModel<>(new String[] {"" })); } @@ -877,29 +877,29 @@ private void setOptionsWithTunnel() { private void setOptionsWithBridge() { keys.setModel( - new DefaultComboBoxModel<>(new String[] {"bridge", "bus_bay", "tunnel", "traffic_calming", "none" })); + new DefaultComboBoxModel<>(new String[] {BRIDGE, BUS_BAY, TUNNEL, TRAFFIC_CALMING, "none" })); values.setModel(new DefaultComboBoxModel<>(new String[] {"yes" })); // below code changes the list in values on the basis of key keys.addActionListener(e -> { - if ("tunnel".equals(keys.getSelectedItem())) { - if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) + if (TUNNEL.equals(keys.getSelectedItem())) { + if (previousAffectedWay.hasKey(WATERWAY) || affected.hasKey(WATERWAY)) values.setModel( - new DefaultComboBoxModel<>(new String[] {"culvert", "yes", "building_passage" })); + new DefaultComboBoxModel<>(new String[] {CULVERT, "yes", BUILDING_PASSAGE })); else values.setModel( - new DefaultComboBoxModel<>(new String[] {"yes", "culvert", "building_passage" })); - } else if ("bus_bay".equals(keys.getSelectedItem())) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"both", "right", "left" })); + new DefaultComboBoxModel<>(new String[] {"yes", CULVERT, BUILDING_PASSAGE })); + } else if (BUS_BAY.equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {BOTH, RIGHT, LEFT })); if (rightHandTraffic) - values.setModel(new DefaultComboBoxModel<>(new String[] {"right", "left", "both" })); + values.setModel(new DefaultComboBoxModel<>(new String[] {RIGHT, LEFT, BOTH })); else - values.setModel(new DefaultComboBoxModel<>(new String[] {"left", "right", "both" })); - } else if ("bridge".equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {LEFT, RIGHT, BOTH })); + } else if (BRIDGE.equals(keys.getSelectedItem())) { values.setModel(new DefaultComboBoxModel<>(new String[] {"yes" })); - } else if ("traffic_calming".equals(keys.getSelectedItem())) { - values.setModel(new DefaultComboBoxModel<>(new String[] {"table" })); + } else if (TRAFFIC_CALMING.equals(keys.getSelectedItem())) { + values.setModel(new DefaultComboBoxModel<>(new String[] {TABLE })); } else if ("none".equals(keys.getSelectedItem())) { values.setModel(new DefaultComboBoxModel<>(new String[] {"" })); } @@ -934,13 +934,13 @@ public void paint(Graphics2D g, MapView mv, Bounds bbox) { Point curP1 = MainApplication.getMap().mapView.getPoint(Pos1); CheckParameterUtil.ensureParameterNotNull(mv, "mv"); g.setColor(Color.RED); - g.fill(new Rectangle.Double(curP1.x - 3, curP1.y - 3, 6, 6)); + g.fill(new Rectangle2D.Double(curP1.x - 3d, curP1.y - 3d, 6, 6)); } if (Pos2 != null) { Point curP2 = MainApplication.getMap().mapView.getPoint(Pos2); CheckParameterUtil.ensureParameterNotNull(mv, "mv"); g.setColor(Color.RED); - g.fill(new Rectangle.Double(curP2.x - 3, curP2.y - 3, 6, 6)); + g.fill(new Rectangle2D.Double(curP2.x - 3d, curP2.y - 3d, 6, 6)); } } } diff --git a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/AbstractMendRelation.java b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/AbstractMendRelation.java index 4bdf415b..c2ff2485 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/AbstractMendRelation.java +++ b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/AbstractMendRelation.java @@ -10,7 +10,7 @@ * @author sudhanshu2 */ public abstract class AbstractMendRelation extends AbstractRelationEditorAction { - protected boolean shorterRoutes = false; + protected boolean shorterRoutes; protected AbstractMendRelation(IRelationEditorActionAccess editorAccess, IRelationEditorUpdateOn... updateOn) { super(editorAccess, updateOn); diff --git a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/PersonalTransportMendRelationAction.java b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/PersonalTransportMendRelationAction.java index 4484f329..682735d6 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/PersonalTransportMendRelationAction.java +++ b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/PersonalTransportMendRelationAction.java @@ -49,14 +49,20 @@ * @author Ashish Singh and sudhanshu2 */ public class PersonalTransportMendRelationAction extends PublicTransportMendRelationAction { + private static final String FORWARD = "forward"; + private static final String BACKWARD = "backward"; + private static final String ROUTE = "route"; + private static final String ROUNDABOUT = "roundabout"; + private static final String JUNCTION = "junction"; + private static final String BICYCLE = "bicycle"; ////////////////////////Assigning Variables/////////////// Way lastForWay; Way lastBackWay; - int brokenidx = 0; - HashMap Isthere = new HashMap<>(); - static HashMap IsWaythere = new HashMap<>(); + int brokenidx; + HashMap isThere = new HashMap<>(); + static HashMap isWaythere = new HashMap<>(); static List links; static WayConnectionType link; static WayConnectionType prelink; @@ -82,7 +88,7 @@ public void initialise() { super.members = super.editor.getRelation().getMembers(); super.members.removeIf(m -> !m.isWay()); links = connectionTypeCalculator.updateLinks(super.members); - if (super.halt == false) { + if (!super.halt) { updateStates(); getListOfAllWays(); makepanelanddownloadArea(); @@ -127,15 +133,15 @@ public void callNextWay(int idx) { } Way way = super.members.get(idx).getWay(); - if (IsWaythere.get(way) == null) { + if (isWaythere.get(way) == null) { for (Node nod : way.getNodes()) { - if (Isthere.get(nod) == null || Isthere.get(nod) == 0) { - Isthere.put(nod, 1); + if (isThere.get(nod) == null || isThere.get(nod) == 0) { + isThere.put(nod, 1); } else { - Isthere.put(nod, Isthere.get(nod) + 1); + isThere.put(nod, isThere.get(nod) + 1); } } - IsWaythere.put(way, 1); + isWaythere.put(way, 1); } super.wayToReachAfterGap = super.members.get(nexidx).getWay(); Node node = checkVaildityOfWays(way, nexidx); @@ -159,16 +165,16 @@ public void callNextWay(int idx) { } } else { if (node == null) { - if (super.members.get(super.currentIndex).getRole().equals("forward") + if (super.members.get(super.currentIndex).getRole().equals(FORWARD) && prelink.isOnewayLoopBackwardPart) { node = way.lastNode(); - } else if (super.members.get(super.currentIndex).getRole().equals("backward") + } else if (super.members.get(super.currentIndex).getRole().equals(BACKWARD) && prelink.isOnewayLoopForwardPart) { node = way.lastNode(); } else { if (super.currentIndex - 1 >= 0) { Way prevw = super.members.get(super.currentIndex - 1).getWay(); - if (prevw.firstNode().equals(way.lastNode()) || prevw.lastNode().equals(way.lastNode())) { + if (Objects.equals(prevw.firstNode(), way.lastNode()) || Objects.equals(prevw.lastNode(), way.lastNode())) { node = way.lastNode(); } else { node = way.firstNode(); @@ -178,7 +184,7 @@ public void callNextWay(int idx) { if (link.isOnewayLoopBackwardPart) { super.previousWay = way; super.nextIndex = false; - if (Isthere.get(way.firstNode()) != null && Isthere.get(way.firstNode()) != 0) { + if (isThere.get(way.firstNode()) != null && isThere.get(way.firstNode()) != 0) { node = way.firstNode(); } else { node = way.lastNode(); @@ -214,25 +220,24 @@ public void callNextWay(int idx) { boolean checkOneWaySatisfiability(Way way, Node node) { String[] acceptedTags = new String[] { "yes", "designated" }; - if ((link.isOnewayLoopBackwardPart && super.relation.hasTag("route", "bicycle")) + if ((link.isOnewayLoopBackwardPart && super.relation.hasTag(ROUTE, BICYCLE)) || prelink.isOnewayLoopBackwardPart) { return true; } - if (way.hasTag("oneway:bicycle", acceptedTags) && way.lastNode().equals(node) - && relation.hasTag("route", "bicycle")) + if (way.hasTag("oneway:bicycle", acceptedTags) && Objects.equals(way.lastNode(), node) + && relation.hasTag(ROUTE, BICYCLE)) return false; - if (!WayUtils.isNonSplitRoundAbout(way) && way.hasTag("junction", "roundabout")) { - if (way.lastNode().equals(node)) - return false; + if (!WayUtils.isNonSplitRoundAbout(way) && way.hasTag(JUNCTION, ROUNDABOUT) && Objects.equals(node, way.lastNode())) { + return false; } if (RouteUtils.isOnewayForBicycles(way) == 0) return true; - else if (RouteUtils.isOnewayForBicycles(way) == 1 && way.lastNode().equals(node)) + else if (RouteUtils.isOnewayForBicycles(way) == 1 && Objects.equals(way.lastNode(), node)) return false; - else if (RouteUtils.isOnewayForBicycles(way) == -1 && way.firstNode().equals(node)) + else if (RouteUtils.isOnewayForBicycles(way) == -1 && Objects.equals(way.firstNode(), node)) return false; return true; @@ -266,7 +271,7 @@ private Node checkVaildityOfWays(Way way, int nexidx) { // TODO: Fix typo: vaild if (WayUtils.isNonSplitRoundAbout(way)) { nexWayDelete = false; for (Node n : way.getNodes()) { - if (super.wayToReachAfterGap.firstNode().equals(n) || super.wayToReachAfterGap.lastNode().equals(n)) { + if (Objects.equals(super.wayToReachAfterGap.firstNode(), n) || Objects.equals(super.wayToReachAfterGap.lastNode(), n)) { node = n; super.currentNode = n; } @@ -305,12 +310,12 @@ void findNextWayAfterDownload(Way way, Node node1, Node node2) { parentWays.addAll(findNextWay(way, node2)); } directroutes = getDirectRouteBetweenWaysByLookingAtOtherRouteRelations(super.currentWay, super.wayToReachAfterGap); - if (directroutes == null || directroutes.size() == 0) { + if (directroutes == null || directroutes.isEmpty()) { super.showOption0 = false; } else { super.showOption0 = true; } - if (directroutes != null && directroutes.size() > 0 && !super.shorterRoutes && parentWays.size() > 0 + if (directroutes != null && !directroutes.isEmpty() && !super.shorterRoutes && !parentWays.isEmpty() && super.notice == null) { displayFixVariantsWithOverlappingWays(directroutes); return; @@ -341,15 +346,16 @@ List> getDirectRouteBetweenWaysByLookingAtOtherRouteRelations(Way curr r1 = new ArrayList<>(Utils.filteredCollection(current.getReferrers(), Relation.class)); r2 = new ArrayList<>(Utils.filteredCollection(next.getReferrers(), Relation.class)); } catch (Exception e) { + Logging.error(e); return list; } List rel = new ArrayList<>(); //checking whether relations you are getting are bicycle routes or not - String value = super.relation.get("route"); + String value = super.relation.get(ROUTE); for (Relation R1 : r1) { - if (r2.contains(R1) && value.equals(R1.get("route"))) + if (r2.contains(R1) && value.equals(R1.get(ROUTE))) rel.add(R1); } rel.remove(super.relation); @@ -359,8 +365,10 @@ List> getDirectRouteBetweenWaysByLookingAtOtherRouteRelations(Way curr boolean alreadyPresent = false; if (lst != null) { for (List l : list) { - if (l.containsAll(lst)) + if (l.containsAll(lst)) { alreadyPresent = true; + break; + } } if (!alreadyPresent) list.add(lst); @@ -370,8 +378,10 @@ List> getDirectRouteBetweenWaysByLookingAtOtherRouteRelations(Way curr if (lst != null) { alreadyPresent = false; for (List l : list) { - if (l.containsAll(lst)) + if (l.containsAll(lst)) { alreadyPresent = true; + break; + } } if (!alreadyPresent) list.add(lst); @@ -386,15 +396,15 @@ List searchWayFromOtherRelations(Relation r, Way current, Way next, boolean List lst = new ArrayList<>(); boolean canAdd = false; Way prev = null; - for (int i = 0; i < member.size(); i++) { - if (member.get(i).isWay()) { - Way w = member.get(i).getWay(); + for (RelationMember relationMember : member) { + if (relationMember.isWay()) { + Way w = relationMember.getWay(); if (!reverse) { if (w.equals(current)) { lst.clear(); canAdd = true; prev = w; - } else if (w.equals(next) && lst.size() > 0) { + } else if (w.equals(next) && !lst.isEmpty()) { return lst; } else if (canAdd) { if (findNumberOfCommonNodes(w, prev) != 0) { @@ -409,7 +419,7 @@ List searchWayFromOtherRelations(Relation r, Way current, Way next, boolean lst.clear(); canAdd = true; prev = w; - } else if (w.equals(current) && lst.size() > 0) { + } else if (w.equals(current) && !lst.isEmpty()) { Collections.reverse(lst); return lst; } else if (canAdd) { @@ -463,7 +473,7 @@ List removeInvalidWaysFromParentWays(List parentWays, Node node, Way w w1.setKeys(w.getKeys()); w2.setKeys(w.getKeys()); - if (!w.hasTag("junction", "roundabout")) { + if (!w.hasTag(JUNCTION, ROUNDABOUT)) { waysToBeRemoved.add(w); waysToBeAdded.add(w1); waysToBeAdded.add(w2); @@ -509,7 +519,7 @@ List removeInvalidWaysFromParentWays(List parentWays, Node node, Way w w1.setKeys(w.getKeys()); w2.setKeys(w.getKeys()); - if (!w.hasTag("junction", "roundabout")) { + if (!w.hasTag(JUNCTION, ROUNDABOUT)) { waysToBeRemoved.add(w); if (w1.containsNode(node)) waysToBeAdded.add(w1); @@ -527,19 +537,19 @@ List removeInvalidWaysFromParentWays(List parentWays, Node node, Way w waysToBeRemoved.clear(); for (Way w : parentWays) { - if (WayUtils.findNumberOfCommonFirstLastNodes(way, w) != 1 && !w.hasTag("junction", "roundabout")) { + if (WayUtils.findNumberOfCommonFirstLastNodes(way, w) != 1 && !w.hasTag(JUNCTION, ROUNDABOUT)) { waysToBeRemoved.add(w); } } // check if any of them belong to roundabout, if yes then show ways accordingly parentWays.stream() - .filter(it -> it.hasTag("junction", "roundabout") + .filter(it -> it.hasTag(JUNCTION, ROUNDABOUT) && WayUtils.findNumberOfCommonFirstLastNodes(way, it) == 1 && it.lastNode().equals(node)) .forEach(waysToBeRemoved::add); // check mode of transport, also check if there is no loop - if (super.relation.hasTag("route", "bicycle")) { + if (super.relation.hasTag(ROUTE, BICYCLE)) { parentWays.stream().filter(it -> !WayUtils.isSuitableForBicycle(it)).forEach(waysToBeRemoved::add); } @@ -551,7 +561,7 @@ List removeInvalidWaysFromParentWays(List parentWays, Node node, Way w // check restrictions parentWays.stream().filter(it -> isRestricted(it, way, node)).forEach(waysToBeRemoved::add); for (Way w : parentWays) { - if (IsWaythere.get(w) != null) { + if (isWaythere.get(w) != null) { waysToBeRemoved.add(w); } } @@ -574,32 +584,32 @@ public void backTrack(Way way, int idx) { for (Way w : allWays) { if (!w.equals(super.currentWay)) { if (!WayUtils.isOneWay(w)) { - if (relation.hasTag("route", "bus")) { + if (relation.hasTag(ROUTE, "bus")) { if (WayUtils.isSuitableForBuses(w)) { fixVariants.add(w); } - } else if (relation.hasTag("route", "bicycle")) { + } else if (relation.hasTag(ROUTE, BICYCLE)) { if (WayUtils.isSuitableForBicycle(w)) { fixVariants.add(w); } } } else { if (w.firstNode().equals(nod)) { - if (relation.hasTag("route", "bus")) { + if (relation.hasTag(ROUTE, "bus")) { if (WayUtils.isSuitableForBuses(w)) { fixVariants.add(w); } - } else if (relation.hasTag("route", "bicycle")) { + } else if (relation.hasTag(ROUTE, BICYCLE)) { if (WayUtils.isSuitableForBicycle(w)) { fixVariants.add(w); } } } else { - if (relation.hasTag("route", "bus")) { + if (relation.hasTag(ROUTE, "bus")) { if (RouteUtils.isOnewayForPublicTransport(w) == 0) { fixVariants.add(w); } - } else if (relation.hasTag("route", "bicycle")) { + } else if (relation.hasTag(ROUTE, BICYCLE)) { if (RouteUtils.isOnewayForBicycles(w) == 0) { fixVariants.add(w); } @@ -610,7 +620,7 @@ public void backTrack(Way way, int idx) { } } super.currentNode = nod; - if (fixVariants.size() > 0) { + if (!fixVariants.isEmpty()) { displayBacktrackFixVariant(fixVariants, idx); } else { backTrack(way, idx + 1); @@ -687,7 +697,7 @@ void getNextWayAfterSelection(List ways) { temp.add(w.firstNode()); if (!v.isFirstLastNode(w.lastNode())) temp.add(w.lastNode()); - if (temp.size() != 0) { + if (!temp.isEmpty()) { w1 = v; breakNode = new ArrayList<>(temp); break; @@ -772,7 +782,7 @@ void getNextWayAfterSelection(List ways) { super.currentNode = getOtherNode(nextw, node2); } } - if (Isthere.get(super.currentNode) != null && Isthere.get(super.currentNode) >= 3) { + if (isThere.get(super.currentNode) != null && isThere.get(super.currentNode) >= 3) { super.currentIndex++; if (super.currentIndex <= super.members.size() - 1) { assignRolesafterloop(super.currentNode); @@ -813,16 +823,16 @@ void addNewWays(List ways, int i) { for (int k = 0; k < ways.size(); k++) { c.add(new RelationMember(s, ways.get(k))); // check if the way that is getting added is already present or not - if (!super.waysAlreadyPresent.containsKey(ways.get(k)) && IsWaythere.get(ways.get(k)) == null) { + if (!super.waysAlreadyPresent.containsKey(ways.get(k)) && isWaythere.get(ways.get(k)) == null) { super.waysAlreadyPresent.put(ways.get(k), 1); for (Node node : ways.get(k).getNodes()) { - if (Isthere.get(node) == null || Isthere.get(node) == 0) { - Isthere.put(node, 1); + if (isThere.get(node) == null || isThere.get(node) == 0) { + isThere.put(node, 1); } else { - Isthere.put(node, Isthere.get(node) + 1); + isThere.put(node, isThere.get(node) + 1); } } - IsWaythere.put(ways.get(k), 1); + isWaythere.put(ways.get(k), 1); } else { deleteWayAfterIndex(ways.get(k), i); } @@ -847,9 +857,9 @@ void assignRolesafterloop(Node jointNode) { String s = ""; if (w.firstNode().equals(jointNode)) { node = w.lastNode(); - s = "backward"; + s = BACKWARD; } else { - s = "forward"; + s = FORWARD; node = w.firstNode(); } idxlst[0] = idx; @@ -861,12 +871,12 @@ void assignRolesafterloop(Node jointNode) { if (w.firstNode().equals(node)) { node = w.lastNode(); node1 = w.firstNode(); - s = "backward"; + s = BACKWARD; // roles[idx]=s; } else { node = w.firstNode(); node1 = w.lastNode(); - s = "forward"; + s = FORWARD; // roles[idx]=s; } idxlst[0] = idx; @@ -896,7 +906,7 @@ void fixgapAfterlooping(int idx) { .filter(Objects::nonNull) .map(it -> findNextWay(current, it)) .flatMap(Collection::stream) - .filter(it -> IsWaythere.get(it) == null) + .filter(it -> isWaythere.get(it) == null) .mapToDouble(it -> WayUtils.calcDistanceSqToFirstOrLastWayNode(it.lastNode(), super.wayToReachAfterGap)) .min() .orElse(-Double.MAX_VALUE) @@ -941,11 +951,11 @@ void removeCurrentEdge() { int j = super.currentIndex; Way curr = super.currentWay; Node n = null; - if (IsWaythere.get(curr) != null) { - IsWaythere.put(curr, null); + if (isWaythere.get(curr) != null) { + isWaythere.put(curr, null); } for (Node node : curr.getNodes()) { - Isthere.put(node, Isthere.get(node) - 1); + isThere.put(node, isThere.get(node) - 1); } int prevInd = getPreviousWayIndex(j); @@ -972,9 +982,9 @@ void removeCurrentEdge() { } super.currentNode = n; - IsWaythere.put(w, null); + isWaythere.put(w, null); for (Node node : w.getNodes()) { - Isthere.put(node, Isthere.get(node) - 1); + isThere.put(node, isThere.get(node) - 1); } callNextWay(super.currentIndex); } else { @@ -990,12 +1000,12 @@ void RemoveWayAfterSelection(List wayIndices, Character chr) { int[] lst = wayIndices.stream().mapToInt(Integer::intValue).toArray(); for (int i = 0; i < lst.length; i++) { Way way = super.members.get(i).getWay(); - if (IsWaythere.get(way) != null) { - IsWaythere.put(way, null); + if (isWaythere.get(way) != null) { + isWaythere.put(way, null); } for (Node node : way.getNodes()) { - if (Isthere.get(node) != null) { - Isthere.put(node, Isthere.get(node) - 1); + if (isThere.get(node) != null) { + isThere.put(node, isThere.get(node) - 1); } } } @@ -1115,9 +1125,9 @@ void makeNodesZeros() { Way n = super.members.get(i).getWay(); Node f = n.firstNode(); Node l = n.lastNode(); - Isthere.put(f, 0); - Isthere.put(l, 0); - IsWaythere.put(n, null); + isThere.put(f, 0); + isThere.put(l, 0); + isWaythere.put(n, null); } } }