Changeset 10250 in josm


Ignore:
Timestamp:
2016-05-18T17:44:31+02:00 (3 years ago)
Author:
Don-vip
Message:

findbugs - UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR

Location:
trunk/src/org/openstreetmap/josm
Files:
20 edited

Legend:

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

    r9983 r10250  
    441441        private final Set<NodePair> edges;
    442442        private int numUndirectedEges;
    443         private Map<Node, List<NodePair>> successors;
    444         private Map<Node, List<NodePair>> predecessors;
     443        private final Map<Node, List<NodePair>> successors = new LinkedHashMap<>();
     444        private final Map<Node, List<NodePair>> predecessors = new LinkedHashMap<>();
    445445
    446446        protected void rememberSuccessor(NodePair pair) {
     
    482482        protected void prepare() {
    483483            Set<NodePair> undirectedEdges = new LinkedHashSet<>();
    484             successors = new LinkedHashMap<>();
    485             predecessors = new LinkedHashMap<>();
     484            successors.clear();
     485            predecessors.clear();
    486486
    487487            for (NodePair pair: edges) {
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r10001 r10250  
    420420     */
    421421    private static class WayData {
    422         public final List<Node> wayNodes;             // The assigned way
    423         public final int nSeg;            // Number of Segments of the Way
    424         public final int nNode;           // Number of Nodes of the Way
    425         public Direction[] segDirections; // Direction of the segments
     422        public final List<Node> wayNodes;       // The assigned way
     423        public final int nSeg;                  // Number of Segments of the Way
     424        public final int nNode;                 // Number of Nodes of the Way
     425        public final Direction[] segDirections; // Direction of the segments
    426426        // segment i goes from node i to node (i+1)
    427427        public EastNorth segSum;          // (Vector-)sum of all horizontal segments plus the sum of all vertical
     
    433433            this.nNode = wayNodes.size();
    434434            this.nSeg = nNode - 1;
     435            this.segDirections = new Direction[nSeg];
    435436        }
    436437
     
    448449                en[i] = wayNodes.get(i).getEastNorth();
    449450            }
    450             segDirections = new Direction[nSeg];
    451451            Direction direction = pInitialDirection;
    452452            segDirections[0] = direction;
  • trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java

    r10131 r10250  
    120120    private static final class OverpassDownloadDialog extends DownloadDialog {
    121121
    122         private HistoryComboBox overpassWizard;
    123         private JosmTextArea overpassQuery;
     122        private final HistoryComboBox overpassWizard = new HistoryComboBox();
     123        private final JosmTextArea overpassQuery = new JosmTextArea("", 8, 80);
    124124        private static OverpassDownloadDialog instance;
    125125        private static final CollectionProperty OVERPASS_WIZARD_HISTORY = new CollectionProperty("download.overpass.wizard",
     
    151151
    152152            final String tooltip = tr("Builds an Overpass query using the Overpass Turbo query wizard");
    153             overpassWizard = new HistoryComboBox();
    154153            overpassWizard.setToolTipText(tooltip);
    155154            overpassWizard.getEditorComponent().addFocusListener(disableActionsFocusListener);
     
    178177            pnl.add(overpassWizard, GBC.eol().fill(GBC.HORIZONTAL));
    179178
    180             overpassQuery = new JosmTextArea("", 8, 80);
    181179            overpassQuery.setFont(GuiHelper.getMonospacedFont(overpassQuery));
    182180            overpassQuery.addFocusListener(disableActionsFocusListener);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractChangesetDownloadTask.java

    r10129 r10250  
    127127     */
    128128    public final Future<?> download() {
    129         return Main.worker.submit(downloadTaskRunnable);
     129        return downloadTaskRunnable != null ? Main.worker.submit(downloadTaskRunnable) : null;
    130130    }
    131131
    132132    @Override
    133133    public final Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) {
    134         return Main.worker.submit(downloadTaskRunnable);
     134        return downloadTaskRunnable != null ? Main.worker.submit(downloadTaskRunnable) : null;
    135135    }
    136136
    137137    @Override
    138138    public final void cancel() {
    139         downloadTaskRunnable.cancel();
     139        if (downloadTaskRunnable != null) {
     140            downloadTaskRunnable.cancel();
     141        }
    140142    }
    141143
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/ChangesetContentDownloadTask.java

    r10124 r10250  
    2626 */
    2727public class ChangesetContentDownloadTask extends AbstractChangesetDownloadTask {
    28 
    29     private final DownloadTask downloadTask;
    3028
    3129    class DownloadTask extends RunnableDownloadTask {
     
    129127            throw new IllegalArgumentException(
    130128                    MessageFormat.format("Expected integer value > 0 for parameter ''{0}'', got ''{1}''", "changesetId", changesetId));
    131         downloadTask = new DownloadTask(parent, Collections.singleton(changesetId));
    132         setDownloadTask(downloadTask);
     129        setDownloadTask(new DownloadTask(parent, Collections.singleton(changesetId)));
    133130    }
    134131
     
    142139     */
    143140    public ChangesetContentDownloadTask(Component parent, Collection<Integer> changesetIds) {
    144         downloadTask = new DownloadTask(parent, changesetIds);
    145         setDownloadTask(downloadTask);
     141        setDownloadTask(new DownloadTask(parent, changesetIds));
    146142    }
    147143
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/ChangesetHeaderDownloadTask.java

    r10164 r10250  
    2727 */
    2828public class ChangesetHeaderDownloadTask extends AbstractChangesetDownloadTask {
    29 
    30     private final DownloadTask downloadTask;
    3129
    3230    class DownloadTask extends RunnableDownloadTask {
     
    112110     */
    113111    public ChangesetHeaderDownloadTask(Component dialogParent, Collection<Integer> ids, boolean includeDiscussion) {
    114         downloadTask = new DownloadTask(dialogParent, ids, includeDiscussion);
    115         setDownloadTask(downloadTask);
     112        setDownloadTask(new DownloadTask(dialogParent, ids, includeDiscussion));
    116113    }
    117114
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/ChangesetQueryTask.java

    r10129 r10250  
    2626 */
    2727public class ChangesetQueryTask extends AbstractChangesetDownloadTask {
    28 
    29     private final DownloadTask downloadTask;
    3028
    3129    class DownloadTask extends RunnableDownloadTask {
     
    134132    public ChangesetQueryTask(Component parent, ChangesetQuery query) {
    135133        CheckParameterUtil.ensureParameterNotNull(query, "query");
    136         downloadTask = new DownloadTask(parent, query);
    137         setDownloadTask(downloadTask);
     134        setDownloadTask(new DownloadTask(parent, query));
    138135    }
    139136}
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r10228 r10250  
    5151    private ProgressMonitor progressMonitor;
    5252
    53     private void addDownloadTask(DownloadTask dt, Rectangle2D td, int i, int n) {
     53    private void addDownloadTask(ProgressMonitor progressMonitor, DownloadTask dt, Rectangle2D td, int i, int n) {
    5454        ProgressMonitor childProgress = progressMonitor.createSubTaskMonitor(1, false);
    5555        childProgress.setCustomText(tr("Download {0} of {1} ({2} left)", i, n, n - i));
     
    8282            i++;
    8383            if (osmData) {
    84                 addDownloadTask(new DownloadOsmTask(), td, i, n);
     84                addDownloadTask(progressMonitor, new DownloadOsmTask(), td, i, n);
    8585            }
    8686            if (gpxData) {
    87                 addDownloadTask(new DownloadGpsTask(), td, i, n);
     87                addDownloadTask(progressMonitor, new DownloadGpsTask(), td, i, n);
    8888            }
    8989        }
  • trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java

    r9371 r10250  
    6363    public void undoCommand() {
    6464        relation.setMember(position, new RelationMember(oldRole, relation.getMember(position).getMember()));
    65         relation.setModified(oldModified);
     65        if (oldModified != null) {
     66            relation.setModified(oldModified);
     67        }
    6668    }
    6769
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java

    r10242 r10250  
    103103    public void loadGridShiftFile(InputStream in, boolean loadAccuracy) throws IOException {
    104104        byte[] b8 = new byte[8];
    105         boolean bigEndian = true;
    106105        fromEllipsoid = "";
    107106        toEllipsoid = "";
     
    111110        if (!"NUM_OREC".equals(overviewHeaderCountId))
    112111            throw new IllegalArgumentException("Input file is not an NTv2 grid shift file");
     112        boolean bigEndian;
    113113        readBytes(in, b8);
    114114        overviewHeaderCount = NTV2Util.getIntBE(b8, 0);
     
    204204     */
    205205    public boolean gridShiftForward(NTV2GridShift gs) {
    206         // Try the last sub grid first, big chance the coord is still within it
    207         NTV2SubGrid subGrid = lastSubGrid.getSubGridForCoord(gs.getLonPositiveWestSeconds(), gs.getLatSeconds());
     206        NTV2SubGrid subGrid = null;
     207        if (lastSubGrid != null) {
     208            // Try the last sub grid first, big chance the coord is still within it
     209            subGrid = lastSubGrid.getSubGridForCoord(gs.getLonPositiveWestSeconds(), gs.getLatSeconds());
     210        }
    208211        if (subGrid == null) {
    209             subGrid = getSubGrid(gs.getLonPositiveWestSeconds(), gs.getLatSeconds());
    210         }
    211         if (subGrid == null)
     212            subGrid = getSubGrid(topLevelSubGrid, gs.getLonPositiveWestSeconds(), gs.getLatSeconds());
     213        }
     214        if (subGrid == null) {
    212215            return false;
    213         else {
     216        } else {
    214217            subGrid.interpolateGridShift(gs);
    215218            gs.setSubGridName(subGrid.getSubGridName());
     
    251254
    252255    /**
    253      * Find the finest SubGrid containing the coordinate, specified
    254      * in Positive West Seconds
    255      *
     256     * Find the finest SubGrid containing the coordinate, specified in Positive West Seconds
     257     * @param topLevelSubGrid top level subgrid
    256258     * @param lon Longitude in Positive West Seconds
    257259     * @param lat Latitude in Seconds
    258260     * @return The SubGrid found or null
    259261     */
    260     private NTV2SubGrid getSubGrid(double lon, double lat) {
     262    private static NTV2SubGrid getSubGrid(NTV2SubGrid[] topLevelSubGrid, double lon, double lat) {
    261263        NTV2SubGrid sub = null;
    262264        for (int i = 0; i < topLevelSubGrid.length; i++) {
  • trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java

    r10235 r10250  
    44import org.openstreetmap.josm.data.projection.Ellipsoid;
    55import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
     6import org.openstreetmap.josm.tools.CheckParameterUtil;
    67
    78/**
     
    8485    @Override
    8586    public void initialize(ProjParameters params) throws ProjectionConfigurationException {
     87        CheckParameterUtil.ensureParameterNotNull(params, "params");
     88        CheckParameterUtil.ensureParameterNotNull(params.ellps, "params.ellps");
    8689        e2 = params.ellps.e2;
    8790        e = params.ellps.e;
  • trunk/src/org/openstreetmap/josm/data/projection/proj/LonLat.java

    r10001 r10250  
    66import org.openstreetmap.josm.data.Bounds;
    77import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
     8import org.openstreetmap.josm.tools.CheckParameterUtil;
    89
    910/**
     
    2627    @Override
    2728    public void initialize(ProjParameters params) throws ProjectionConfigurationException {
     29        CheckParameterUtil.ensureParameterNotNull(params, "params");
     30        CheckParameterUtil.ensureParameterNotNull(params.ellps, "params.ellps");
    2831        a = params.ellps.a;
    2932    }
  • trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java

    r9970 r10250  
    66import org.openstreetmap.josm.data.Bounds;
    77import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
     8import org.openstreetmap.josm.tools.CheckParameterUtil;
    89
    910/**
     
    119120    public void initialize(ProjParameters params) throws ProjectionConfigurationException {
    120121        super.initialize(params);
     122        CheckParameterUtil.ensureParameterNotNull(params, "params");
     123        CheckParameterUtil.ensureParameterNotNull(params.ellps, "params.ellps");
    121124        eb2 = params.ellps.eb2;
    122125        latitudeOfOrigin = params.lat0 == null ? 0 : Math.toRadians(params.lat0);
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r10181 r10250  
    123123
    124124            if (selected) {
    125                 g.setColor(getHighlightColor());
     125                g.setColor(getHighlightColor(color));
    126126                g.fillOval(p.x - 5, p.y - 5, 10, 10);
    127127            }
     
    146146        int deg = (int) Math.toDegrees(t);
    147147        if (selected) {
    148             g.setColor(getHighlightColor());
     148            g.setColor(getHighlightColor(color));
    149149            int[] x = new int[] {(int) (p1.x + cosT), (int) (p2.x + cosT),
    150150                                 (int) (p2.x - cosT), (int) (p1.x - cosT)};
     
    260260    /**
    261261     * Gets the color to draw highlight markers with.
     262     * @param color severity color
    262263     * @return The color.
    263264     */
    264     private Color getHighlightColor() {
     265    private static Color getHighlightColor(Color color) {
    265266        return new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (color.getAlpha() * .4));
    266267    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r8510 r10250  
    4040
    4141    /** All way segments, grouped by cells */
    42     private Map<Point2D, List<WaySegment>> cellSegments;
     42    private final Map<Point2D, List<WaySegment>> cellSegments = new HashMap<>(1000);
    4343    /** The already detected errors */
    44     private Set<WaySegment> errorSegments;
     44    private final Set<WaySegment> errorSegments = new HashSet<>();
    4545    /** The already detected ways in error */
    46     private Map<List<Way>, List<WaySegment>> seenWays;
     46    private final Map<List<Way>, List<WaySegment>> seenWays = new HashMap<>(50);
    4747
    4848    /**
     
    188188    public void startTest(ProgressMonitor monitor) {
    189189        super.startTest(monitor);
    190         cellSegments = new HashMap<>(1000);
    191         errorSegments = new HashSet<>();
    192         seenWays = new HashMap<>(50);
     190        cellSegments.clear();
     191        errorSegments.clear();
     192        seenWays.clear();
    193193    }
    194194
     
    196196    public void endTest() {
    197197        super.endTest();
    198         cellSegments = null;
    199         errorSegments = null;
    200         seenWays = null;
     198        cellSegments.clear();
     199        errorSegments.clear();
     200        seenWays.clear();
    201201    }
    202202
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r10241 r10250  
    620620                }));
    621621            }
    622             Rectangle bounds = button.getBounds();
    623             menu.show(button, bounds.x + bounds.width, 0);
     622            if (button != null) {
     623                Rectangle bounds = button.getBounds();
     624                menu.show(button, bounds.x + bounds.width, 0);
     625            }
    624626        }
    625627    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r9992 r10250  
    397397        }
    398398
    399         protected boolean isLastFilterValid() {
     399        protected final boolean isLastFilterValid() {
    400400            return lastFilter != null && filterModel.getFilters().contains(lastFilter);
    401401        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r10234 r10250  
    738738         * @param layer the layer which is removed
    739739         */
    740         protected void onRemoveLayer(Layer layer) {
     740        private void onRemoveLayer(Layer layer) {
    741741            if (layer == null)
    742742                return;
     
    762762         * @param layer the layer
    763763         */
    764         protected void onAddLayer(Layer layer) {
     764        private void onAddLayer(Layer layer) {
    765765            if (layer == null)
    766766                return;
     
    768768            fireTableDataChanged();
    769769            int idx = getLayers().indexOf(layer);
    770             layerList.setRowHeight(idx, Math.max(16, layer.getIcon().getIconHeight()));
     770            if (layerList != null) {
     771                layerList.setRowHeight(idx, Math.max(16, layer.getIcon().getIconHeight()));
     772            }
    771773            selectionModel.setSelectionInterval(idx, idx);
    772774            ensureSelectedIsVisible();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r10217 r10250  
    10101010            public void actionPerformed(ActionEvent e) {
    10111011                try {
    1012                     recentTags.ignoreTag(tag, tagsToIgnore);
    1013                     PROPERTY_TAGS_TO_IGNORE.put(tagsToIgnore.writeToString());
     1012                    if (tagsToIgnore != null) {
     1013                        recentTags.ignoreTag(tag, tagsToIgnore);
     1014                        PROPERTY_TAGS_TO_IGNORE.put(tagsToIgnore.writeToString());
     1015                    }
    10141016                } catch (SearchCompiler.ParseError parseError) {
    10151017                    throw new IllegalStateException(parseError);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r10217 r10250  
    232232     */
    233233    private Direction determineDirection(int refI, final Direction refDirection, int k, boolean reversed) {
    234         if (refI < 0 || k < 0 || refI >= members.size() || k >= members.size())
    235             return NONE;
    236         if (refDirection == NONE)
     234        if (members == null || refI < 0 || k < 0 || refI >= members.size() || k >= members.size() || refDirection == NONE)
    237235            return NONE;
    238236
Note: See TracChangeset for help on using the changeset viewer.