Changeset 32920 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-09-03T22:06:48+02:00 (8 years ago)
Author:
donvip
Message:

fix error-prone warnings

Location:
applications/editors/josm/plugins/alignways
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAlgnSegment.java

    r30737 r32920  
    2626/**
    2727 * @author tilusnet <tilusnet@gmail.com>
    28  * 
     28 *
    2929 * The segment to be aligned to the reference segment. Actions it can do:
    3030 *         - remember its selected pivot point
     
    3232 *         - rotate itself
    3333 *         - paint itself and its selected pivot point
    34  * 
     34 *
    3535 */
    3636public class AlignWaysAlgnSegment extends AlignWaysSegment {
     
    109109     * Returns the EastNorth of the specified pivot point pp. It always returns
    110110     * up-to-date data from dataset. Assumes segment is not null.
    111      * 
     111     *
    112112     * @param pp
    113113     *            The pivot location
     
    177177     * Given a Node (usually an endpoint), it will return a collection of way segments that are adjacently
    178178     * connected to it. The current alignee waysegment is not added to the collection.
    179      * 
     179     *
    180180     * @param node The Node (endpoint) to analyse.
    181181     * @return The collection of the adjacent waysegments.
     
    194194            Point pnew = new Point();
    195195            pnew.setLocation(x, y);
    196             WaySegment ws = Main.map.mapView.getNearestWaySegment(pnew, OsmPrimitive.isUsablePredicate);
     196            WaySegment ws = Main.map.mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable);
    197197            if (ws != null &&  !ws.equals(this.segment) &&
    198198                    (ws.getFirstNode().equals(node) || ws.getSecondNode().equals(node))) {
     
    211211     * The node is normally a valid endpoint of the segment.
    212212     * If it isn't, null may be returned.
    213      * 
     213     *
    214214     * @param node The (endpoint) node.
    215215     * @return Collection of the adjacent way segments.
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysMode.java

    r32466 r32920  
    11/**
    2  * 
     2 *
    33 */
    44package com.tilusnet.josm.plugins.alignways;
     
    2929 * @author tilusnet <tilusnet@gmail.com>
    3030 * Handles the state machine and user interaction (mouse clicks).
    31  * 
     31 *
    3232 */
    3333public class AlignWaysMode extends MapMode /* implements MapViewPaintable */{
     
    209209
    210210        Main.pref.put("alignways.showtips", !atp.isChkBoxSelected());
    211 
    212     }
    213 
     211    }
    214212
    215213    private void showWhatsNew() {
     
    226224        wnDialog.dispose();
    227225
    228         Main.pref.put("alignways.majorver", new Integer(AlignWaysPlugin.AlignWaysMajorVersion).toString());
    229 
     226        Main.pref.put("alignways.majorver", Integer.toString(AlignWaysPlugin.AlignWaysMajorVersion));
    230227    }
    231228
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegment.java

    r32160 r32920  
    11/**
    2  * 
     2 *
    33 */
    44package com.tilusnet.josm.plugins.alignways;
     
    2323/**
    2424 * @author tilusnet <tilusnet@gmail.com>
    25  * 
     25 *
    2626 */
    2727public class AlignWaysSegment implements MapViewPaintable {
     
    6060            segmentEndPoints.add(node1);
    6161            segmentEndPoints.add(node2);
    62 
    6362        }
    6463    }
    6564
    6665    protected WaySegment getNearestWaySegment(Point p) {
    67 
    68         return mapview.getNearestWaySegment(p, OsmPrimitive.isUsablePredicate);
    69 
     66        return mapview.getNearestWaySegment(p, OsmPrimitive::isUsable);
    7067    }
    7168
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysWhatsNewPanel.java

    r30345 r32920  
    11/**
    2  * 
     2 *
    33 */
    44package com.tilusnet.josm.plugins.alignways;
     
    4646        newItem2 = new javax.swing.JLabel();
    4747
    48         lblWhatsNew.setText("<html><div style=\"font-family: sans-serif; font-weight: bold; font-style: italic;\"><span style=\"font-size: large;\"><span style=\"font-size: x-large;\">" 
    49                             + tr("What''s new...") 
     48        lblWhatsNew.setText("<html><div style=\"font-family: sans-serif; font-weight: bold; font-style: italic;\"><span style=\"font-size: large;\"><span style=\"font-size: x-large;\">"
     49                            + tr("What''s new...")
    5050                            + "</span></div></html>");
    5151
     
    5353
    5454        newItem1.setText("<html><div style=\"font-family: sans-serif;\"><ul style=\"margin-left: 20px;\"><li>"
    55                          + tr("Added <b>angle preserving</b> aligning mode") 
     55                         + tr("Added <b>angle preserving</b> aligning mode")
    5656                         + "</li></ul></div></html>");
    5757
     
    6767        btnHelpItem1.setPreferredSize(new java.awt.Dimension(69, 25));
    6868        btnHelpItem1.addActionListener(new java.awt.event.ActionListener() {
     69            @Override
    6970            public void actionPerformed(java.awt.event.ActionEvent evt) {
    7071                btnHelpItem1ActionPerformed(evt);
     
    136137          } catch (URISyntaxException ex) {
    137138                Logger.getLogger(AlignWaysWhatsNewPanel.class.getName()).log(Level.SEVERE, null, ex);
    138           } catch (IOException e) { 
     139          } catch (IOException e) {
    139140              JOptionPane.showMessageDialog(this, e, tr("Errr..."), JOptionPane.WARNING_MESSAGE);
    140141          }
    141         } else { 
     142        } else {
    142143             JOptionPane.showMessageDialog(this, tr("Browser not supported."), tr("Errr..."), JOptionPane.WARNING_MESSAGE);
    143144        }
    144145    }
    145    
     146
    146147    /*** End of Matisse generated code section ***/
    147148
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/geometry/AlignWaysGeomLine.java

    r30345 r32920  
    11package com.tilusnet.josm.plugins.alignways.geometry;
    22
     3import java.util.Objects;
    34
    45/**
     
    131132    /**
    132133     * Get the Y coordinate on the line of a point with the given X coordinate.
    133      * 
    134      * @param X The x-coordinate of the given point.
     134     *
     135     * @param x The x-coordinate of the given point.
    135136     * @return The calculated y-coordinate or Double.NaN if the line is vertical.
    136137     */
    137     public Double getYonLine(double X) {
    138 
    139         Double Y = new Double((-coef_a*X - coef_c)/coef_b);
    140 
    141         if (Y.isInfinite() || Y.isNaN())
     138    public Double getYonLine(double x) {
     139
     140        Double y = Double.valueOf((-coef_a*x - coef_c)/coef_b);
     141
     142        if (y.isInfinite() || y.isNaN())
    142143            // Vertical line
    143144            return Double.NaN;
    144145        else
    145             return Y;
    146 
    147     }
    148 
     146            return y;
     147    }
    149148
    150149    /**
    151150     * Get the X coordinate on the line of a point with the given Y coordinate.
    152      * 
    153      * @param Y The y-coordinate of the given point.
     151     *
     152     * @param y The y-coordinate of the given point.
    154153     * @return The calculated x-coordinate or Double.NaN if the line is horizontal.
    155154     */
    156     public Double getXonLine(double Y) {
    157 
    158         Double X = new Double((-coef_b*Y - coef_c)/coef_a);
    159 
    160         if (X.isInfinite() || X.isNaN())
     155    public Double getXonLine(double y) {
     156
     157        Double x = Double.valueOf((-coef_b*y - coef_c)/coef_a);
     158
     159        if (x.isInfinite() || x.isNaN())
    161160            // Horizontal line
    162161            return Double.NaN;
    163162        else
    164             return X;
    165 
     163            return x;
    166164    }
    167165
     
    184182    }
    185183
     184    @Override
     185    public int hashCode() {
     186        return Objects.hash(coef_a, coef_b, coef_c);
     187    }
     188
    186189    public boolean isPointOnLine(AlignWaysGeomPoint awPt) {
    187190        // Method:
     
    189192        // 2. check getIntersectionStatus of the two lines
    190193        // 3. if status is LINES_OVERLAP, the point os one the line, otherwise not
    191        
     194
    192195        // Need an arbitrary point on this line; let it be (x, y)
    193196        Double x = 0.0;
    194197        Double y = getYonLine(x);
    195198        if (y.isNaN()) y = 0.0;
    196        
     199
    197200        AlignWaysGeomLine line2 = new AlignWaysGeomLine(awPt, new AlignWaysGeomPoint(x, y));
    198201        getIntersection(line2);
     
    201204        else
    202205            return false;
    203        
     206
    204207    }
    205208
Note: See TracChangeset for help on using the changeset viewer.