Changeset 10115 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-04-07T00:02:22+02:00 (8 years ago)
Author:
Don-vip
Message:

fix coverity 1011666, 1011667, 1011836, 1011837, 1011838

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

Legend:

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

    r10001 r10115  
    763763        }
    764764        return bestMovement;
    765 
    766 
    767765    }
    768766
     
    10261024                Point p4 = mv.getPoint(newN2en);
    10271025
    1028                 Point2D normalUnitVector = getNormalUniVector();
     1026                Point2D normalUnitVector = activeMoveDirection != null ? getNormalUniVector() : null;
    10291027
    10301028                if (mode == Mode.extrude || mode == Mode.create_new) {
     
    10331031                    // Draw rectangle around new area.
    10341032                    GeneralPath b = new GeneralPath();
    1035                     b.moveTo(p1.x, p1.y); b.lineTo(p3.x, p3.y);
    1036                     b.lineTo(p4.x, p4.y); b.lineTo(p2.x, p2.y);
     1033                    b.moveTo(p1.x, p1.y);
     1034                    b.lineTo(p3.x, p3.y);
     1035                    b.lineTo(p4.x, p4.y);
     1036                    b.lineTo(p2.x, p2.y);
    10371037                    b.lineTo(p1.x, p1.y);
    10381038                    g2.draw(b);
     
    10421042                        drawReferenceSegment(g2, mv, dualAlignSegment1);
    10431043                        drawReferenceSegment(g2, mv, dualAlignSegment2);
    1044                     } else if (activeMoveDirection != null) {
     1044                    } else if (activeMoveDirection != null && normalUnitVector != null) {
    10451045                        // Draw reference way
    10461046                        drawReferenceSegment(g2, mv, activeMoveDirection);
     
    10521052                            double headingMoveDir = Math.atan2(normalUnitVector.getY(), normalUnitVector.getX());
    10531053                            double headingDiff = headingRefWS - headingMoveDir;
    1054                             if (headingDiff < 0) headingDiff += 2 * Math.PI;
     1054                            if (headingDiff < 0)
     1055                                headingDiff += 2 * Math.PI;
    10551056                            boolean mirrorRA = Math.abs(headingDiff - Math.PI) > 1e-5;
    10561057                            Point pr1 = mv.getPoint(activeMoveDirection.p1);
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r9576 r10115  
    4949     */
    5050    public static WindowGeometry centerOnScreen(Dimension extent, String preferenceKey) {
    51         Rectangle size = preferenceKey != null ? getScreenInfo(preferenceKey)
    52             : getFullScreenInfo();
     51        Rectangle size = preferenceKey != null ? getScreenInfo(preferenceKey) : getFullScreenInfo();
    5352        Point topLeft = new Point(
    5453                size.x + Math.max(0, (size.width - extent.width) /2),
     
    117116     */
    118117    public WindowGeometry(Rectangle rect) {
    119         this.topLeft = rect.getLocation();
    120         this.extent = rect.getSize();
     118        this(rect.getLocation(), rect.getSize());
    121119    }
    122120
     
    426424     */
    427425    private static Rectangle getScreenInfo(Rectangle g) {
    428         GraphicsEnvironment ge = GraphicsEnvironment
    429                 .getLocalGraphicsEnvironment();
    430         GraphicsDevice[] gs = ge.getScreenDevices();
     426        GraphicsDevice[] gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    431427        int intersect = 0;
    432428        Rectangle bounds = null;
     
    446442                    is = b.intersection(g);
    447443                    s = is.width * is.height;
    448                     if (bounds == null || intersect < s) {
     444                    if (intersect < s) {
    449445                        intersect = s;
    450446                        bounds = b;
     
    460456            }
    461457        }
    462         return bounds;
     458        return bounds != null ? bounds : g;
    463459    }
    464460
Note: See TracChangeset for help on using the changeset viewer.