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


Ignore:
Timestamp:
2015-07-01T19:51:35+02:00 (9 years ago)
Author:
bastiK
Message:

applied #11628 - Added documentation to EastNorth, changed x - y = y.sub(x) to x.subtract(y) and minor code style improvements. (patch by michael2402, partially applied)

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

Legend:

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

    r8540 r8549  
    474474                    // nothing here
    475475                } else if (mode == Mode.translate) {
    476                     EastNorth movement1 = initialN1en.sub(newN1en);
    477                     EastNorth movement2 = initialN2en.sub(newN2en);
     476                    EastNorth movement1 = newN1en.subtract(initialN1en);
     477                    EastNorth movement2 = newN2en.subtract(initialN2en);
    478478                    // move nodes to new position
    479479                    if (moveCommand == null || moveCommand2 == null) {
     
    734734
    735735        EastNorth initialMouseEn = Main.map.mapView.getEastNorth(initialMousePos.x, initialMousePos.y);
    736         EastNorth mouseMovement = initialMouseEn.sub(mouseEn);
     736        EastNorth mouseMovement = mouseEn.subtract(initialMouseEn);
    737737
    738738        double bestDistance = Double.POSITIVE_INFINITY;
     
    782782        else
    783783            //return distance form base to target position
    784             return intersectionPoint.sub(targetPos);
     784            return targetPos.subtract(intersectionPoint);
    785785    }
    786786
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r8447 r8549  
    6969     */
    7070    public MoveCommand(Node node, LatLon position) {
    71         this(Collections.singleton((OsmPrimitive) node), node.getEastNorth().sub(Projections.project(position)));
     71        this(Collections.singleton((OsmPrimitive) node), Projections.project(position).subtract(node.getEastNorth()));
    7272    }
    7373
  • trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r8510 r8549  
    2525    }
    2626
    27     public EastNorth add(double dx, double dy) {
    28         return new EastNorth(x+dx, y+dy);
     27    /**
     28     * Adds an offset to this {@link EastNorth} instance and returns the result.
     29     * @param dEast The offset to add in east direction.
     30     * @param dNorth The offset to add in north direction.
     31     * @return The result.
     32     */
     33    public EastNorth add(double dEast, double dNorth) {
     34        return new EastNorth(east()+dEast, north()+dNorth);
    2935    }
    3036
     37    /**
     38     * Adds the coordinates of an other EastNorth instance to this one.
     39     * @param other The other instance.
     40     * @return The new EastNorth position.
     41     */
    3142    public EastNorth add(EastNorth other) {
    3243        return new EastNorth(x+other.x, y+other.y);
     44    }
     45
     46    /**
     47     * Subtracts the coordinates of this EastNorth instance from the other one.
     48     * <p>
     49     * This produces result = en2 - this.
     50     * @param en2 The instance to subtract this one from.
     51     * @return The new EastNorth position.
     52     */
     53    @Deprecated
     54    public EastNorth sub(EastNorth en2) {
     55        return en2.subtract(this);
     56    }
     57
     58    /**
     59     * Subtracts an east/north value from this point.
     60     * @param other The other value to subtract from this.
     61     * @return A point with the new coordinates.
     62     */
     63    public EastNorth subtract(EastNorth other) {
     64        return new EastNorth(x-other.x, y-other.y);
    3365    }
    3466
     
    3769    }
    3870
     71    /**
     72     * Does a linear interpolation between two EastNorth instances.
     73     * @param en2 The other EstNort instance.
     74     * @param proportion The proportion the other instance influences the result.
     75     * @return The new {@link EastNorth} position.
     76     */
    3977    public EastNorth interpolate(EastNorth en2, double proportion) {
    4078        return new EastNorth(this.x + proportion * (en2.x - this.x),
     
    4280    }
    4381
     82    /**
     83     * Gets the center between two {@link EastNorth} instances.
     84     * @param en2 The other instance.
     85     * @return The center between this and the other instance.
     86     */
    4487    public EastNorth getCenter(EastNorth en2) {
    4588        return new EastNorth((this.x + en2.x)/2.0, (this.y + en2.y)/2.0);
     
    101144    }
    102145
    103     public EastNorth sub(EastNorth en) {
    104         return new EastNorth(en.east() - east(), en.north() - north());
    105     }
    106 
    107146    /**
    108147     * Returns an EastNorth representing the this EastNorth rotated around
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSortUtils.java

    r8510 r8549  
    4141            EastNorth en3 = w.getNode(2).getEastNorth();
    4242            if (en1 != null && en2 != null && en3 != null) {
    43                 en1 = en1.sub(en2);
    44                 en2 = en2.sub(en3);
     43                en1 = en2.subtract(en1);
     44                en2 = en3.subtract(en2);
    4545                return en1.north() * en2.east() - en2.north() * en1.east() > 0 ? ROUNDABOUT_LEFT : ROUNDABOUT_RIGHT;
    4646            }
Note: See TracChangeset for help on using the changeset viewer.