Changes in / [6161:6168] in josm


Ignore:
Location:
/trunk/src/org/openstreetmap/josm
Files:
14 edited

Legend:

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

    r6161 r6168  
    684684                Point p4 = mv.getPoint(newN2en);
    685685
    686                 EastNorth normalUnitVector = getNormalUniVector();
     686                Point2D normalUnitVector = getNormalUniVector();
    687687
    688688                if (mode == Mode.extrude || mode == Mode.create_new) {
     
    753753    }
    754754
    755     private EastNorth getNormalUniVector() {
    756         double fac = 1.0 / activeMoveDirection.en.distance(0,0);
     755    private Point2D getNormalUniVector() {
     756        double fac = 1.0 / activeMoveDirection.en.length();
    757757        // mult by factor to get unit vector.
    758         EastNorth normalUnitVector = new EastNorth(activeMoveDirection.en.getX() * fac, activeMoveDirection.en.getY() * fac);
     758        Point2D normalUnitVector = new Point2D.Double(activeMoveDirection.en.getX() * fac, activeMoveDirection.en.getY() * fac);
    759759
    760760        // Check to see if our new N1 is in a positive direction with respect to the normalUnitVector.
     
    762762        if (newN1en != null && ((newN1en.getX() > initialN1en.getX()) != (normalUnitVector.getX() > -0.0))) {
    763763            // If not, use a sign-flipped version of the normalUnitVector.
    764             normalUnitVector = new EastNorth(-normalUnitVector.getX(), -normalUnitVector.getY());
     764            normalUnitVector = new Point2D.Double(-normalUnitVector.getX(), -normalUnitVector.getY());
    765765        }
    766766
     
    771771    }
    772772
    773     private void drawAngleSymbol(Graphics2D g2, Point2D center, EastNorth normal, boolean mirror) {
     773    private void drawAngleSymbol(Graphics2D g2, Point2D center, Point2D normal, boolean mirror) {
    774774        // EastNorth units per pixel
    775775        double factor = 1.0/g2.getTransform().getScaleX();
  • /trunk/src/org/openstreetmap/josm/command/Command.java

    r6161 r6168  
    1616
    1717import org.openstreetmap.josm.Main;
    18 import org.openstreetmap.josm.data.coor.LatLon;
    1918import org.openstreetmap.josm.data.osm.Node;
    2019import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    222221    private static boolean isOutlying(OsmPrimitive osm, Area area) {
    223222        if (osm instanceof Node && !osm.isNewOrUndeleted()) {
    224             LatLon coor = ((Node) osm).getCoor();
    225             return coor != null && !area.contains(coor);
     223            return !((Node) osm).getCoor().isIn(area);
    226224        } else if (osm instanceof Way) {
    227225            for (Node n : ((Way) osm).getNodes()) {
  • /trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r6161 r6168  
    77import java.util.Collection;
    88import java.util.HashSet;
    9 import java.util.List;
    109
    1110import javax.swing.Icon;
  • /trunk/src/org/openstreetmap/josm/data/Bounds.java

    r6161 r6168  
    206206            LatLon result = new LatLon(minLat, minLon-360.0).getCenter(getMax());
    207207            if (result.lon() < -180.0) {
    208                 result.setLocation(result.lon()+360.0, result.lat());
     208                result = new LatLon(result.lat(), result.lon() + 360.0);
    209209            }
    210210            return result;
  • /trunk/src/org/openstreetmap/josm/data/Preferences.java

    r6161 r6168  
    963963        List<List<String>> prop = arrayProperties.get(key);
    964964        if (prop != null) {
    965             @SuppressWarnings("unchecked")
     965            @SuppressWarnings({ "unchecked", "rawtypes" })
    966966            Collection<Collection<String>> prop_cast = (Collection) prop;
    967967            return prop_cast;
     
    974974        List<List<String>> prop = arrayProperties.get(key);
    975975        if (prop != null) {
    976             @SuppressWarnings("unchecked")
     976            @SuppressWarnings({ "unchecked", "rawtypes" })
    977977            Collection<Collection<String>> prop_cast = (Collection) prop;
    978978            return prop_cast;
     
    982982
    983983    public boolean putArray(String key, Collection<Collection<String>> value) {
    984         boolean changed = false;
     984        //boolean changed = false;
    985985
    986986        List<List<String>> oldValue = null;
  • /trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java

    r6161 r6168  
    3333    }
    3434
    35     public final void setCoor(LatLon coor) {
    36         setLocation(coor.lon(), coor.lat());
    37         proj = null;
    38     }
    39 
    40     public final void setEastNorth(EastNorth eastNorth) {
    41         proj = Main.getProjection();
    42         this.eastNorth = eastNorth;
    43         LatLon l = proj.eastNorth2latlon(eastNorth);
    44         setLocation(l.lon(), l.lat());
    45     }
    46 
    4735    /**
    4836     * Replies the projected east/north coordinates.
  • /trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java

    r6161 r6168  
    22package org.openstreetmap.josm.data.coor;
    33
    4 import java.awt.geom.Point2D;
    54import java.io.Serializable;
    65
     
    1514 * EastNorth.
    1615 *
    17  * @author imi
     16 * @since 6162
    1817 */
    19 abstract class Coordinate extends Point2D implements Serializable {
     18abstract class Coordinate implements Cloneable, Serializable {
    2019
    21     protected double x;
    22     protected double y;
     20    protected final double x;
     21    protected final double y;
    2322
    2423    /**
     
    3231    }
    3332
    34     @Override
    3533    public double getX() {
    3634        return x;
    3735    }
    3836
    39     @Override
    4037    public double getY() {
    4138        return y;
    4239    }
    4340
    44     @Override
    45     public void setLocation (double x, double y) {
    46         this.x = x;
    47         this.y = y;
     41    /**
     42     * Returns the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}.
     43     *
     44     * @param coor the specified coordinate to be measured against this {@code Coordinate}
     45     * @return the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}
     46     * @since 6166
     47     */
     48    protected final double distance(final Coordinate coor) {
     49        return distance(coor.x, coor.y);
     50    }
     51   
     52    /**
     53     * Returns the euclidean distance from this {@code Coordinate} to a specified coordinate.
     54     *
     55     * @param px the X coordinate of the specified point to be measured against this {@code Coordinate}
     56     * @param py the Y coordinate of the specified point to be measured against this {@code Coordinate}
     57     * @return the euclidean distance from this {@code Coordinate} to a specified coordinate
     58     * @since 6166
     59     */
     60    public final double distance(final double px, final double py) {
     61        final double dx = this.x-px;
     62        final double dy = this.y-py;
     63        return Math.sqrt(dx*dx + dy*dy);
     64    }
     65   
     66    /**
     67     * Returns the square of the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}.
     68     *
     69     * @param coor the specified coordinate to be measured against this {@code Coordinate}
     70     * @return the square of the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}
     71     * @since 6166
     72     */
     73    protected final double distanceSq(final Coordinate coor) {
     74        return distanceSq(coor.x, coor.y);
     75    }
     76
     77    /**
     78     * Returns the square of euclidean distance from this {@code Coordinate} to a specified coordinate.
     79     *
     80     * @param px the X coordinate of the specified point to be measured against this {@code Coordinate}
     81     * @param py the Y coordinate of the specified point to be measured against this {@code Coordinate}
     82     * @return the square of the euclidean distance from this {@code Coordinate} to a specified coordinate
     83     * @since 6166
     84     */
     85    public final double distanceSq(final double px, final double py) {
     86        final double dx = this.x-px;
     87        final double dy = this.y-py;
     88        return dx*dx + dy*dy;
    4889    }
    4990
     
    64105        if (this == obj)
    65106            return true;
    66         if (!super.equals(obj))
    67             return false;
    68107        if (getClass() != obj.getClass())
    69108            return false;
  • /trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r6161 r6168  
    4444    }
    4545
    46     public double distance(EastNorth en2) {
    47         return Math.sqrt((this.x-en2.x)*(this.x-en2.x) + (this.y-en2.y)*(this.y-en2.y));
     46    /**
     47     * Returns the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}.
     48     *
     49     * @param en the specified coordinate to be measured against this {@code EastNorth}
     50     * @return the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}
     51     * @since 6166
     52     */
     53    public double distance(final EastNorth en) {
     54        return super.distance(en);
     55    }
     56   
     57    /**
     58     * Returns the square of the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}.
     59     *
     60     * @param en the specified coordinate to be measured against this {@code EastNorth}
     61     * @return the square of the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}
     62     * @since 6166
     63     */
     64    public double distanceSq(final EastNorth en) {
     65        return super.distanceSq(en);
    4866    }
    4967
     68    /**
     69     * Counts length (distance from [0,0]) of this.
     70     *
     71     * @return length of this
     72     */
     73    public double length(){
     74        return Math.sqrt(x*x + y*y);
     75    }
     76   
    5077    /**
    5178     * Returns the heading, in radians, that you have to use to get from
     
    103130        return (Math.abs(x - other.x) < e && Math.abs(y - other.y) < e);
    104131    }
     132
     133    @Override
     134    public EastNorth clone() {
     135        return new EastNorth(x, y);
     136    }
    105137}
  • /trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r6161 r6168  
    1111import static org.openstreetmap.josm.tools.I18n.trc;
    1212
     13import java.awt.geom.Area;
    1314import java.text.DecimalFormat;
    1415import java.text.NumberFormat;
     
    2627 */
    2728public class LatLon extends Coordinate {
    28 
    2929
    3030    /**
     
    219219    public boolean isWithin(Bounds b) {
    220220        return b.contains(this);
     221    }
     222
     223    /**
     224     * Check if this is contained in given area or area is null.
     225     *
     226     * @param a Area
     227     * @return <code>true</code> if this is contained in given area or area is null.
     228     */
     229    public boolean isIn(Area a) {
     230        return a == null || a.contains(x, y);
    221231    }
    222232
     
    286296    }
    287297
     298    /**
     299     * Returns the euclidean distance from this {@code LatLon} to a specified {@code LatLon}.
     300     *
     301     * @param ll the specified coordinate to be measured against this {@code LatLon}
     302     * @return the euclidean distance from this {@code LatLon} to a specified {@code LatLon}
     303     * @since 6166
     304     */
     305    public double distance(final LatLon ll) {
     306        return super.distance(ll);
     307    }
     308   
     309    /**
     310     * Returns the square of the euclidean distance from this {@code LatLon} to a specified {@code LatLon}.
     311     *
     312     * @param ll the specified coordinate to be measured against this {@code LatLon}
     313     * @return the square of the euclidean distance from this {@code LatLon} to a specified {@code LatLon}
     314     * @since 6166
     315     */
     316    public double distanceSq(final LatLon ll) {
     317        return super.distanceSq(ll);
     318    }
     319   
    288320    @Override public String toString() {
    289321        return "LatLon[lat="+lat()+",lon="+lon()+"]";
     
    363395        return true;
    364396    }
     397
     398    @Override
     399    public LatLon clone() {
     400        return new LatLon(x, y);
     401    }
    365402}
  • /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r6161 r6168  
    13421342        boolean initial = true;
    13431343        for (Node n : w.getNodes()) {
    1344             Point2D p = n.getEastNorth();
     1344            EastNorth p = n.getEastNorth();
    13451345            if (p != null) {
    13461346                if (initial) {
  • /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r6161 r6168  
    1818import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
    1919import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
     20import org.openstreetmap.josm.data.coor.EastNorth;
    2021import org.openstreetmap.josm.data.osm.DataSet;
    2122import org.openstreetmap.josm.data.osm.Node;
     
    213214            boolean initial = true;
    214215            for (Node n : nodes) {
    215                 Point2D p = n.getEastNorth();
     216                EastNorth p = n.getEastNorth();
    216217                if (p != null) {
    217218                    if (initial) {
  • /trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java

    r6161 r6168  
    150150                List<OsmPrimitive> highlight = new ArrayList<OsmPrimitive>();
    151151
    152                 if (headWays == 0 && (downloadedArea == null || downloadedArea.contains(head.getCoor()))) {
     152                if (headWays == 0 && head.getCoor().isIn(downloadedArea)) {
    153153                    highlight.add(head);
    154154                }
    155                 if (tailWays == 0 && (downloadedArea == null || downloadedArea.contains(tail.getCoor()))) {
     155                if (tailWays == 0 && tail.getCoor().isIn(downloadedArea)) {
    156156                    highlight.add(tail);
    157157                }
  • /trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r6161 r6168  
    293293
    294294            for (Node n : found_nodes) {
    295                 if (!nearby(n, dist) ||
    296                         (ds_area != null && !ds_area.contains(n.getCoor()))) {
     295                if (!nearby(n, dist) || !n.getCoor().isIn(ds_area)) {
    297296                    continue;
    298297                }
  • /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r6161 r6168  
    341341
    342342    public final void setCoor(LatLon coor) {
    343         if(this.coor == null) {
    344             this.coor = new CachedLatLon(coor);
    345         } else {
    346             this.coor.setCoor(coor);
    347         }
     343        this.coor = new CachedLatLon(coor);
    348344    }
    349345
     
    353349
    354350    public final void setEastNorth(EastNorth eastNorth) {
    355         coor.setEastNorth(eastNorth);
     351        this.coor = new CachedLatLon(eastNorth);
    356352    }
    357353
Note: See TracChangeset for help on using the changeset viewer.