Fix some compile warnings

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-07-01 12:04:14 -06:00
rodzic 88ab3ea863
commit 5d81c2906f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
28 zmienionych plików z 112 dodań i 109 usunięć

Wyświetl plik

@ -11,7 +11,6 @@ import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional; import java.util.Optional;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
@ -63,9 +62,9 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
private final List<Destroyable> destroyables; private final List<Destroyable> destroyables;
private PreferencesAction preferenceAction; private final PreferencesAction preferenceAction;
private MapWithAIMenu mapwithaiMenu; private final MapWithAIMenu mapwithaiMenu;
private static final Map<Class<? extends JosmAction>, Boolean> MENU_ENTRIES = new LinkedHashMap<>(); private static final Map<Class<? extends JosmAction>, Boolean> MENU_ENTRIES = new LinkedHashMap<>();
static { static {
@ -86,7 +85,7 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
mapwithaiMenu = new MapWithAIMenu(); mapwithaiMenu = new MapWithAIMenu();
MainApplication.getMenu().addMenu(mapwithaiMenu, "mapwithai:menu", KeyEvent.VK_M, 9, ht("/Plugin/MapWithAI")); MainApplication.getMenu().addMenu(mapwithaiMenu, "mapwithai:menu", KeyEvent.VK_M, 9, ht("/Plugin/MapWithAI"));
for (final Entry<Class<? extends JosmAction>, Boolean> entry : MENU_ENTRIES.entrySet()) { for (final Map.Entry<Class<? extends JosmAction>, Boolean> entry : MENU_ENTRIES.entrySet()) {
if (Arrays.asList(mapwithaiMenu.getMenuComponents()).parallelStream().filter(JMenuItem.class::isInstance) if (Arrays.asList(mapwithaiMenu.getMenuComponents()).parallelStream().filter(JMenuItem.class::isInstance)
.map(JMenuItem.class::cast) .map(JMenuItem.class::cast)
.noneMatch(component -> entry.getKey().equals(component.getAction().getClass()))) { .noneMatch(component -> entry.getKey().equals(component.getAction().getClass()))) {
@ -154,6 +153,8 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
} }
/** /**
* The current version for the plugin
*
* @return The version information of the plugin * @return The version information of the plugin
*/ */
public static String getVersionInfo() { public static String getVersionInfo() {

Wyświetl plik

@ -4,6 +4,8 @@ package org.openstreetmap.josm.plugins.mapwithai.actions;
import static org.openstreetmap.josm.gui.help.HelpUtil.ht; import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.openstreetmap.josm.actions.AdaptableAction; import org.openstreetmap.josm.actions.AdaptableAction;
import org.openstreetmap.josm.actions.AddImageryLayerAction; import org.openstreetmap.josm.actions.AddImageryLayerAction;
@ -50,11 +52,19 @@ public class AddMapWithAILayerAction extends JosmAction implements AdaptableActi
// change toolbar icon from if specified // change toolbar icon from if specified
String icon = info.getIcon(); String icon = info.getIcon();
if (icon != null) { if (icon != null) {
new ImageProvider(icon).setOptional(true).getResourceAsync(result -> { Future<?> future = new ImageProvider(icon).setOptional(true).getResourceAsync(result -> {
if (result != null) { if (result != null) {
GuiHelper.runInEDT(() -> result.attachImageIcon(this)); GuiHelper.runInEDT(() -> result.attachImageIcon(this));
} }
}); });
try {
future.get();
} catch (InterruptedException e) {
Logging.error(e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
Logging.error(e);
}
} else { } else {
try { try {
ImageResource resource = new ImageResource( ImageResource resource = new ImageResource(
@ -104,7 +114,7 @@ public class AddMapWithAILayerAction extends JosmAction implements AdaptableActi
} }
} }
private OsmDataLayer getDataLayer() { private static OsmDataLayer getDataLayer() {
return MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream() return MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
.filter(i -> !(i instanceof MapWithAILayer)).findFirst().orElse(null); .filter(i -> !(i instanceof MapWithAILayer)).findFirst().orElse(null);
} }

Wyświetl plik

@ -40,9 +40,9 @@ import org.openstreetmap.josm.tools.Logging;
public class DataConflationSender implements RunnableFuture<DataSet> { public class DataConflationSender implements RunnableFuture<DataSet> {
private static final int MAX_POLLS = 100; private static final int MAX_POLLS = 100;
private DataSet external; private final DataSet external;
private DataSet osm; private final DataSet osm;
private MapWithAICategory category; private final MapWithAICategory category;
private DataSet conflatedData; private DataSet conflatedData;
private CloseableHttpClient client; private CloseableHttpClient client;
private boolean done; private boolean done;

Wyświetl plik

@ -304,7 +304,7 @@ public class GetDataRunnable extends RecursiveTask<DataSet> {
* Replace tags in a dataset with a set of replacement tags * Replace tags in a dataset with a set of replacement tags
* *
* @param dataSet The dataset with primitives to change * @param dataSet The dataset with primitives to change
* @param map The tags to replace * @param replaceTags The tags to replace
*/ */
public static void replaceTags(DataSet dataSet, Map<Tag, Tag> replaceTags) { public static void replaceTags(DataSet dataSet, Map<Tag, Tag> replaceTags) {
replaceTags.forEach((orig, replace) -> dataSet.allNonDeletedPrimitives().parallelStream() replaceTags.forEach((orig, replace) -> dataSet.allNonDeletedPrimitives().parallelStream()

Wyświetl plik

@ -60,7 +60,7 @@ public final class MapWithAIDataUtils {
public static final String DEFAULT_PAINT_STYLE_RESOURCE_URL = "https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1"; public static final String DEFAULT_PAINT_STYLE_RESOURCE_URL = "https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1";
private static String paintStyleResourceUrl = DEFAULT_PAINT_STYLE_RESOURCE_URL; private static String paintStyleResourceUrl = DEFAULT_PAINT_STYLE_RESOURCE_URL;
private static Pattern TEST_PATTERN = Pattern private static final Pattern TEST_PATTERN = Pattern
.compile("^https?:\\/\\/(www\\.)?localhost[:0-9]*\\/josmfile\\?page=Styles\\/MapWithAI&zip=1$"); .compile("^https?:\\/\\/(www\\.)?localhost[:0-9]*\\/josmfile\\?page=Styles\\/MapWithAI&zip=1$");
private MapWithAIDataUtils() { private MapWithAIDataUtils() {

Wyświetl plik

@ -11,8 +11,9 @@ import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.tools.Destroyable; import org.openstreetmap.josm.tools.Destroyable;
/** /**
* @author Taylor Smock * Add information that is useful for QC/debugging to OSM changesets.
* *
* @author Taylor Smock
*/ */
public class MapWithAIUploadHook implements UploadHook, Destroyable { public class MapWithAIUploadHook implements UploadHook, Destroyable {
private final String version; private final String version;

Wyświetl plik

@ -39,7 +39,13 @@ import org.openstreetmap.josm.tools.Pair;
public abstract class AbstractConflationCommand extends Command { public abstract class AbstractConflationCommand extends Command {
protected Collection<OsmPrimitive> possiblyAffectedPrimitives; protected Collection<OsmPrimitive> possiblyAffectedPrimitives;
public AbstractConflationCommand(DataSet data) { /**
* Creates a new command in the context of a specific data set, without data
* layer
*
* @param data the data set. Must not be null.
*/
protected AbstractConflationCommand(DataSet data) {
super(data); super(data);
} }

Wyświetl plik

@ -1,60 +0,0 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation;
import static org.openstreetmap.josm.tools.I18n.tr;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.openstreetmap.josm.command.Command;
import org.openstreetmap.josm.data.osm.Node;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.data.osm.Relation;
import org.openstreetmap.josm.data.osm.Way;
/**
* This is similar to the ReplaceGeometryUtils.buildUpgradeNodeCommand method
*
* @author Taylor Smock
*
*/
public class MergeBuildingNodeCommand {
/**
* Upgrade a node to a way or multipolygon
*
* @param subjectNode node to be replaced
* @param referenceObject object with greater spatial quality
*/
public static Command buildUpgradeNodeCommand(Node subjectNode, OsmPrimitive referenceObject) {
boolean keepNode = !subjectNode.isNew();
if (keepNode) {
getNewOrNoTagNode(referenceObject);
}
return null;
}
private static Node getNewOrNoTagNode(OsmPrimitive referenceObject) {
List<Node> nodes;
if (referenceObject instanceof Way) {
nodes = ((Way) referenceObject).getNodes();
} else if (referenceObject instanceof Relation) {
nodes = ((Relation) referenceObject).getMemberPrimitives().stream().flatMap(o -> {
if (o instanceof Way) {
return ((Way) o).getNodes().stream();
} else if (o instanceof Node) {
return Stream.of((Node) o);
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
} else if (referenceObject instanceof Node) {
nodes = Collections.singletonList((Node) referenceObject);
} else {
throw new IllegalArgumentException(tr("Unknown OsmPrimitive type"));
}
return nodes.stream().filter(OsmPrimitive::isNew).findAny()
.orElse(nodes.stream().filter(p -> !p.isTagged()).findAny().orElse(nodes.get(0)));
}
}

Wyświetl plik

@ -93,6 +93,8 @@ public class AddNodeToWayCommand extends Command {
} }
/** /**
* Get the node that will be added to a way
*
* @return {@link Node} to add to {@link Way} * @return {@link Node} to add to {@link Way}
*/ */
public Node getToAddNode() { public Node getToAddNode() {
@ -100,6 +102,8 @@ public class AddNodeToWayCommand extends Command {
} }
/** /**
* Get the way that we are modifying
*
* @return {@link Way} that we are adding a {@link Node} to * @return {@link Way} that we are adding a {@link Node} to
*/ */
public Way getWay() { public Way getWay() {
@ -107,6 +111,8 @@ public class AddNodeToWayCommand extends Command {
} }
/** /**
* Get the node that we are adding our node after
*
* @return {@link Node} that we are adding another {@link Node} after. * @return {@link Node} that we are adding another {@link Node} after.
*/ */
public Node getFirstNode() { public Node getFirstNode() {
@ -114,6 +120,8 @@ public class AddNodeToWayCommand extends Command {
} }
/** /**
* Get the node that we are adding our node before
*
* @return {@link Node} that we are adding another {@link Node} before. * @return {@link Node} that we are adding another {@link Node} before.
*/ */
public Node getSecondNode() { public Node getSecondNode() {

Wyświetl plik

@ -148,6 +148,8 @@ public class CreateConnectionsCommand extends Command {
} }
/** /**
* Add third-party commands that are run when conflating data.
*
* @param command A command to run when copying data from the MapWithAI layer * @param command A command to run when copying data from the MapWithAI layer
*/ */
public static void addConflationCommand(Class<? extends AbstractConflationCommand> command) { public static void addConflationCommand(Class<? extends AbstractConflationCommand> command) {
@ -155,6 +157,8 @@ public class CreateConnectionsCommand extends Command {
} }
/** /**
* Get the commands to run when conflating data.
*
* @return A set of commands to run when copying data from the MapWithAI layer * @return A set of commands to run when copying data from the MapWithAI layer
*/ */
public static Set<Class<? extends AbstractConflationCommand>> getConflationCommands() { public static Set<Class<? extends AbstractConflationCommand>> getConflationCommands() {
@ -162,6 +166,8 @@ public class CreateConnectionsCommand extends Command {
} }
/** /**
* Remove a command that runs when conflating data.
*
* @param command The command class to remove * @param command The command class to remove
* @return {@code true} if the conflation command was removed and was present * @return {@code true} if the conflation command was removed and was present
* @see List#remove * @see List#remove

Wyświetl plik

@ -8,7 +8,6 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -154,6 +153,9 @@ public class MapWithAIAddCommand extends Command implements Runnable {
} }
/** /**
* Calculate the number of objects added in this command that are not deleted
* (may not count significantly modified objects as well).
*
* @return The number of MapWithAI objects added in this command that are not * @return The number of MapWithAI objects added in this command that are not
* deleted * deleted
*/ */
@ -170,7 +172,7 @@ public class MapWithAIAddCommand extends Command implements Runnable {
public Collection<String> getSourceTags() { public Collection<String> getSourceTags() {
return sources.entrySet().parallelStream() return sources.entrySet().parallelStream()
.filter(entry -> validPrimitive(editable.getPrimitiveById(entry.getKey()))).map(Entry::getValue) .filter(entry -> validPrimitive(editable.getPrimitiveById(entry.getKey()))).map(Map.Entry::getValue)
.filter(Objects::nonNull).distinct().sorted().collect(Collectors.toList()); .filter(Objects::nonNull).distinct().sorted().collect(Collectors.toList());
} }

Wyświetl plik

@ -12,7 +12,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -179,7 +178,7 @@ public class MergeDuplicateWays extends Command {
public static Command checkForDuplicateWays(Way way1, Way way2) { public static Command checkForDuplicateWays(Way way1, Way way2) {
Command returnCommand = null; Command returnCommand = null;
final Map<Pair<Integer, Node>, Map<Integer, Node>> duplicateNodes = getDuplicateNodes(way1, way2); final Map<Pair<Integer, Node>, Map<Integer, Node>> duplicateNodes = getDuplicateNodes(way1, way2);
final Set<Entry<Pair<Integer, Node>, Map<Integer, Node>>> duplicateEntrySet = duplicateNodes.entrySet(); final Set<Map.Entry<Pair<Integer, Node>, Map<Integer, Node>>> duplicateEntrySet = duplicateNodes.entrySet();
final Set<Pair<Pair<Integer, Node>, Pair<Integer, Node>>> compressed = duplicateNodes.entrySet().stream() final Set<Pair<Pair<Integer, Node>, Pair<Integer, Node>>> compressed = duplicateNodes.entrySet().stream()
.map(entry -> new Pair<Pair<Integer, Node>, Pair<Integer, Node>>(entry.getKey(), .map(entry -> new Pair<Pair<Integer, Node>, Pair<Integer, Node>>(entry.getKey(),
new Pair<Integer, Node>(entry.getValue().entrySet().iterator().next().getKey(), new Pair<Integer, Node>(entry.getValue().entrySet().iterator().next().getKey(),

Wyświetl plik

@ -30,6 +30,10 @@ public class MapWithAIConflationCategory {
} }
} }
private MapWithAIConflationCategory() {
// Hide the constructor
}
/** /**
* Get a conflation URL for a specific category * Get a conflation URL for a specific category
* *

Wyświetl plik

@ -51,7 +51,7 @@ public class MapWithAILayerInfo {
private final List<MapWithAIInfo> layers = Collections.synchronizedList(new ArrayList<>()); private final List<MapWithAIInfo> layers = Collections.synchronizedList(new ArrayList<>());
/** List of layer ids of all usable layers */ /** List of layer ids of all usable layers */
private final Map<String, MapWithAIInfo> layerIds = new HashMap<>(); private final Map<String, MapWithAIInfo> layerIds = new HashMap<>();
private ListenerList<LayerChangeListener> listeners = ListenerList.create(); private final ListenerList<LayerChangeListener> listeners = ListenerList.create();
/** List of all available default layers */ /** List of all available default layers */
static final List<MapWithAIInfo> defaultLayers = new ArrayList<>(); static final List<MapWithAIInfo> defaultLayers = new ArrayList<>();
/** List of all available default layers (including mirrors) */ /** List of all available default layers (including mirrors) */

Wyświetl plik

@ -16,7 +16,6 @@ import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.swing.Action; import javax.swing.Action;
@ -147,7 +146,7 @@ public class MapWithAIMenu extends JMenu {
} }
if (!dynamicNonPhotoItems.isEmpty()) { if (!dynamicNonPhotoItems.isEmpty()) {
addDynamicSeparator(); addDynamicSeparator();
for (Entry<MapWithAICategory, List<JMenuItem>> e : dynamicNonPhotoItems.entrySet()) { for (Map.Entry<MapWithAICategory, List<JMenuItem>> e : dynamicNonPhotoItems.entrySet()) {
MapWithAICategory cat = e.getKey(); MapWithAICategory cat = e.getKey();
List<JMenuItem> list = e.getValue(); List<JMenuItem> list = e.getValue();
if (list.size() > 1) { if (list.size() > 1) {

Wyświetl plik

@ -66,7 +66,7 @@ public class MapWithAIDownloadOptions extends JPanel implements DownloadSelectio
} }
} }
private JComponent[] getJComponents(Component[] components) { private static JComponent[] getJComponents(Component[] components) {
return Stream.of(components).filter(JComponent.class::isInstance).map(JComponent.class::cast) return Stream.of(components).filter(JComponent.class::isInstance).map(JComponent.class::cast)
.toArray(JComponent[]::new); .toArray(JComponent[]::new);
} }

Wyświetl plik

@ -22,7 +22,6 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInf
public class MapWithAIDownloadSourceType implements IDownloadSourceType, LayerChangeListener { public class MapWithAIDownloadSourceType implements IDownloadSourceType, LayerChangeListener {
static final BooleanProperty IS_ENABLED = new BooleanProperty("download.mapwithai.data", false); static final BooleanProperty IS_ENABLED = new BooleanProperty("download.mapwithai.data", false);
JCheckBox cbDownloadMapWithAIData; JCheckBox cbDownloadMapWithAIData;
private static MapWithAIDownloadSourceType INSTANCE;
@Override @Override
public JCheckBox getCheckBox(ChangeListener checkboxChangeListener) { public JCheckBox getCheckBox(ChangeListener checkboxChangeListener) {

Wyświetl plik

@ -15,7 +15,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
import javax.swing.Box; import javax.swing.Box;
@ -64,7 +63,7 @@ public class MapWithAIPreferences extends DefaultTabPreferenceSetting {
private static void fillReplacementTagDisplayData(List<PrefEntry> list) { private static void fillReplacementTagDisplayData(List<PrefEntry> list) {
final Map<String, String> current = new TreeMap<>(MapWithAIPreferenceHelper.getReplacementTags()); final Map<String, String> current = new TreeMap<>(MapWithAIPreferenceHelper.getReplacementTags());
for (final Entry<String, String> entry : current.entrySet()) { for (final Map.Entry<String, String> entry : current.entrySet()) {
list.add( list.add(
new PrefEntry(entry.getKey(), new StringSetting(entry.getValue()), new StringSetting(null), false)); new PrefEntry(entry.getKey(), new StringSetting(entry.getValue()), new StringSetting(null), false));
} }
@ -81,7 +80,7 @@ public class MapWithAIPreferences extends DefaultTabPreferenceSetting {
p.add(panel, GBC.std().fill(GBC.BOTH)); p.add(panel, GBC.std().fill(GBC.BOTH));
} }
private Component getServerList(PreferenceTabbedPane gui) { private static Component getServerList(PreferenceTabbedPane gui) {
return new MapWithAIProvidersPanel(gui, MapWithAIProvidersPanel.Options.SHOW_ACTIVE); return new MapWithAIProvidersPanel(gui, MapWithAIProvidersPanel.Options.SHOW_ACTIVE);
} }
@ -235,17 +234,28 @@ public class MapWithAIPreferences extends DefaultTabPreferenceSetting {
} }
/** /**
* This method returns the checkbox used for deciding if layers should be
* switched.
*
* @return The {@code JCheckBox} for whether or not we are switching layers. * @return The {@code JCheckBox} for whether or not we are switching layers.
*/ */
public JCheckBox getSwitchLayerCheckBox() { public JCheckBox getSwitchLayerCheckBox() {
return switchLayerCheckBox; return switchLayerCheckBox;
} }
/**
* Get the checkbox for merging buildings/addresses
*
* @return The checkbox
*/
public JCheckBox getMergeBuildingAddressCheckBox() { public JCheckBox getMergeBuildingAddressCheckBox() {
return mergeBuildingAddressCheckBox; return mergeBuildingAddressCheckBox;
} }
/** /**
* This is the spinner used to determine maximum additions (and maximum
* selections).
*
* @return {@code JSpinner} for the maximum additions * @return {@code JSpinner} for the maximum additions
*/ */
public JSpinner getMaximumAdditionSpinner() { public JSpinner getMaximumAdditionSpinner() {

Wyświetl plik

@ -148,7 +148,9 @@ class MapWithAIParametersPanel extends JPanel {
} }
/** /**
* @return headers provided by user * HTTP parameters (so {@code ?param1=value1&param2=value2})
*
* @return parameters provided by user
*/ */
public Map<String, Pair<String, Boolean>> getParameters() { public Map<String, Pair<String, Boolean>> getParameters() {
return headers.stream().distinct() return headers.stream().distinct()
@ -156,6 +158,8 @@ class MapWithAIParametersPanel extends JPanel {
} }
/** /**
* These are the current parameters for the info object.
*
* @param parameters The initial parameters to show in the dialog * @param parameters The initial parameters to show in the dialog
*/ */
public void setParameters(JsonArray parameters) { public void setParameters(JsonArray parameters) {
@ -175,6 +179,8 @@ class MapWithAIParametersPanel extends JPanel {
} }
/** /**
* Add a listener to the model ({@code model.addTableModelListener})
*
* @param l A TableModelListener for the backing model * @param l A TableModelListener for the backing model
*/ */
public void addListener(TableModelListener l) { public void addListener(TableModelListener l) {
@ -182,6 +188,8 @@ class MapWithAIParametersPanel extends JPanel {
} }
/** /**
* Get the model that is displayed in the panel.
*
* @return The table model used to display parameters * @return The table model used to display parameters
*/ */
public TableModel getModel() { public TableModel getModel() {

Wyświetl plik

@ -331,7 +331,7 @@ public class MapWithAIProvidersPanel extends JPanel {
defaultModel.addTableModelListener(e -> activeTable.repaint()); defaultModel.addTableModelListener(e -> activeTable.repaint());
activeModel.addTableModelListener(e -> defaultTable.repaint()); activeModel.addTableModelListener(e -> defaultTable.repaint());
setupDefaultTable(this, defaultTable, options, areaListeners); setupDefaultTable(defaultTable, options, areaListeners);
TableColumnModel mod = activeTable.getColumnModel(); TableColumnModel mod = activeTable.getColumnModel();
mod.getColumn(1).setPreferredWidth(800); mod.getColumn(1).setPreferredWidth(800);
@ -436,7 +436,7 @@ public class MapWithAIProvidersPanel extends JPanel {
} }
} }
private static void setupDefaultTable(MapWithAIProvidersPanel panel, JTable defaultTable, Options[] options, private static void setupDefaultTable(JTable defaultTable, Options[] options,
ListenerList<AreaListener> areaListeners) { ListenerList<AreaListener> areaListeners) {
boolean showActive = Stream.of(options).anyMatch(Options.SHOW_ACTIVE::equals); boolean showActive = Stream.of(options).anyMatch(Options.SHOW_ACTIVE::equals);
int tenXWidth = defaultTable.getFontMetrics(defaultTable.getFont()).stringWidth("XXXXXXXXXX"); int tenXWidth = defaultTable.getFontMetrics(defaultTable.getFont()).stringWidth("XXXXXXXXXX");
@ -507,7 +507,9 @@ public class MapWithAIProvidersPanel extends JPanel {
} }
/** /**
* @param The current area to highlight data from * Set the current bounds of the map and the area to select
*
* @param area The current area to highlight data from
*/ */
public void setCurrentBounds(Bounds area) { public void setCurrentBounds(Bounds area) {
this.defaultMap.setBoundingBox(area); this.defaultMap.setBoundingBox(area);
@ -613,12 +615,14 @@ public class MapWithAIProvidersPanel extends JPanel {
} }
private <T> void doCleanupResidualBounds(Map<Integer, T> map, Consumer<T> removalEffect) { private <T> void doCleanupResidualBounds(Map<Integer, T> map, Consumer<T> removalEffect) {
List<Integer> toRemove = new ArrayList<>();
for (Integer i : map.keySet()) { for (Integer i : map.keySet()) {
int viewIndex = defaultTable.convertRowIndexToView(i); int viewIndex = defaultTable.convertRowIndexToView(i);
if (!defaultTable.getSelectionModel().isSelectedIndex(viewIndex)) { if (!defaultTable.getSelectionModel().isSelectedIndex(viewIndex)) {
removalEffect.accept(map.remove(i)); toRemove.add(i);
} }
} }
toRemove.forEach(i -> removalEffect.accept(map.remove(i)));
} }
private void cleanupResidualBounds() { private void cleanupResidualBounds() {

Wyświetl plik

@ -37,7 +37,7 @@ public class ESRISourceReader implements Closeable {
private final MapWithAIInfo source; private final MapWithAIInfo source;
private CachedFile cachedFile; private CachedFile cachedFile;
private boolean fastFail; private boolean fastFail;
private List<MapWithAICategory> ignoreConflationCategories; private final List<MapWithAICategory> ignoreConflationCategories;
private static final String JSON_QUERY_PARAM = "?f=json"; private static final String JSON_QUERY_PARAM = "?f=json";
/** /**

Wyświetl plik

@ -184,7 +184,7 @@ public class MapWithAISourceReader implements Closeable {
} }
} }
return Collections.emptyList(); return new ArrayList<>();
} }
private static Collection<Shape> areaToShapes(java.awt.Shape shape) { private static Collection<Shape> areaToShapes(java.awt.Shape shape) {

Wyświetl plik

@ -45,7 +45,9 @@ public class MapWithAIPluginTest {
private static final String VERSION = "no-such-version"; private static final String VERSION = "no-such-version";
/** /**
* @throws java.lang.Exception * Set up the tests
*
* @throws java.lang.Exception if something goes wrong
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

Wyświetl plik

@ -77,8 +77,6 @@ public class MapWithAIUploadHookTest {
/** /**
* Test method for {@link MapWithAIUploadHook#modifyChangesetTags(Map)}. * Test method for {@link MapWithAIUploadHook#modifyChangesetTags(Map)}.
*
* @throws PluginException
*/ */
@Test @Test
public void testModifyChangesetTags() { public void testModifyChangesetTags() {

Wyświetl plik

@ -216,8 +216,8 @@ public class MapWithAIAddComandTest {
/** /**
* https://josm.openstreetmap.de/ticket/18351 * https://josm.openstreetmap.de/ticket/18351
* *
* @throws InterruptedException * @throws InterruptedException if the thread is interrupted
* @throws InvocationTargetException * @throws InvocationTargetException if some checked exception occurs
*/ */
@Test @Test
public void testRegression18351() throws InvocationTargetException, InterruptedException { public void testRegression18351() throws InvocationTargetException, InterruptedException {

Wyświetl plik

@ -32,7 +32,9 @@ public class MapWithAIPreferencesTest {
private MapWithAIPreferences preferences; private MapWithAIPreferences preferences;
/** /**
* @throws Exception * Set up the test
*
* @throws Exception if something goes wrong with set up
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
@ -42,10 +44,10 @@ public class MapWithAIPreferencesTest {
/** /**
* Test method for {@link MapWithAIPreferences#addGui(PreferenceTabbedPane)}. * Test method for {@link MapWithAIPreferences#addGui(PreferenceTabbedPane)}.
* *
* @throws SecurityException * @throws SecurityException see {@link java.lang.Class#getDeclaredField}
* @throws NoSuchFieldException * @throws NoSuchFieldException see {@link java.lang.Class#getDeclaredField}
* @throws IllegalAccessException * @throws IllegalAccessException see {@link java.lang.reflect.Field#get}
* @throws IllegalArgumentException * @throws IllegalArgumentException see {@link java.lang.reflect.Field#get}
*/ */
@Test @Test
public void testAddGui() public void testAddGui()

Wyświetl plik

@ -31,10 +31,12 @@ public class ReplacementPreferenceTableTest {
public JOSMTestRules rule = new JOSMTestRules().preferences(); public JOSMTestRules rule = new JOSMTestRules().preferences();
ReplacementPreferenceTable test; ReplacementPreferenceTable test;
protected static final class ReplacementPreferenceTableMock extends MockUp<ReplacementPreferenceTable> { static class ReplacementPreferenceTableMock extends MockUp<ReplacementPreferenceTable> {
private boolean set; private boolean set;
/** /**
* Initialize the mock with a preset return value
*
* @param set the return value for * @param set the return value for
* {@link ReplacementPreferenceTableMock#askAddSetting} * {@link ReplacementPreferenceTableMock#askAddSetting}
*/ */
@ -48,7 +50,9 @@ public class ReplacementPreferenceTableTest {
} }
/** /**
* @param set the return value for * Set the return value
*
* @param set the new return value for
* {@link ReplacementPreferenceTableMock#askAddSetting} * {@link ReplacementPreferenceTableMock#askAddSetting}
*/ */
public void setAskAddSetting(boolean set) { public void setAskAddSetting(boolean set) {

Wyświetl plik

@ -194,14 +194,14 @@ public class MapWithAITestRules extends JOSMTestRules {
/** /**
* Replace URL servers with wiremock * Replace URL servers with wiremock
* *
* @param wireMock The wiremock to point to * @param wireMockServer The wiremock to point to
* @param url The URL to fix * @param url The URL to fix
* @return A url that points at the wiremock server * @return A url that points at the wiremock server
*/ */
private static String replaceUrl(WireMockServer wireMock, String url) { private static String replaceUrl(WireMockServer wireMockServer, String url) {
try { try {
URL temp = new URL(url); URL temp = new URL(url);
return wireMock.baseUrl() + temp.getFile(); return wireMockServer.baseUrl() + temp.getFile();
} catch (MalformedURLException error) { } catch (MalformedURLException error) {
Logging.error(error); Logging.error(error);
} }