Changeset 12131 in josm for trunk/src


Ignore:
Timestamp:
2017-05-13T01:12:44+02:00 (8 years ago)
Author:
Don-vip
Message:

see #11889, see #11924, see #13387 - use backported versions of Math.toDegrees/toRadians (more accurate and faster) - to revert when migrating to Java 9

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

Legend:

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

    r11978 r12131  
    3333import org.openstreetmap.josm.tools.JosmRuntimeException;
    3434import org.openstreetmap.josm.tools.Shortcut;
     35import org.openstreetmap.josm.tools.Utils;
    3536
    3637/**
     
    6869     * Current policy is to except just everything, no matter how strange the result would be.
    6970     */
    70     private static final double TOLERANCE1 = Math.toRadians(45.);   // within a way
    71     private static final double TOLERANCE2 = Math.toRadians(45.);   // ways relative to each other
     71    private static final double TOLERANCE1 = Utils.toRadians(45.);   // within a way
     72    private static final double TOLERANCE2 = Utils.toRadians(45.);   // ways relative to each other
    7273
    7374    /**
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r12103 r12131  
    7676    private static final Color ORANGE_TRANSPARENT = new Color(Color.ORANGE.getRed(), Color.ORANGE.getGreen(), Color.ORANGE.getBlue(), 128);
    7777
    78     private static final ArrowPaintHelper START_WAY_INDICATOR = new ArrowPaintHelper(Math.toRadians(90), 8);
     78    private static final ArrowPaintHelper START_WAY_INDICATOR = new ArrowPaintHelper(Utils.toRadians(90), 8);
    7979
    8080    static final CachingProperty<Boolean> USE_REPEATED_SHORTCUT
     
    839839
    840840
    841         double curHdg = Math.toDegrees(getCurrentBaseNode().getEastNorth()
     841        double curHdg = Utils.toDegrees(getCurrentBaseNode().getEastNorth()
    842842                .heading(currentMouseEastNorth));
    843843        double baseHdg = -1;
     
    845845            EastNorth en = previousNode.getEastNorth();
    846846            if (en != null) {
    847                 baseHdg = Math.toDegrees(en.heading(getCurrentBaseNode().getEastNorth()));
     847                baseHdg = Utils.toDegrees(en.heading(getCurrentBaseNode().getEastNorth()));
    848848            }
    849849        }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java

    r11747 r12131  
    3030import org.openstreetmap.josm.gui.draw.SymbolShape;
    3131import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     32import org.openstreetmap.josm.tools.Utils;
    3233
    3334class DrawSnapHelper {
     
    377378        LatLon mouseLatLon = Main.map.mapView.getProjection().eastNorth2latlon(snapPoint);
    378379        double distance = this.drawAction.getCurrentBaseNode().getCoor().greatCircleDistance(mouseLatLon);
    379         double hdg = Math.toDegrees(p0.heading(snapPoint));
     380        double hdg = Utils.toDegrees(p0.heading(snapPoint));
    380381        // heading of segment from current to calculated point, not to mouse position
    381382
     
    485486
    486487        double hdg = segmentPoint1.heading(segmentPoint2);
    487         hdg = Math.toDegrees(hdg);
     488        hdg = Utils.toDegrees(hdg);
    488489        if (hdg < 0) {
    489490            hdg += 360;
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r11045 r12131  
    88import static java.lang.Math.sin;
    99import static java.lang.Math.sqrt;
    10 import static java.lang.Math.toRadians;
    1110import static org.openstreetmap.josm.data.projection.Ellipsoid.WGS84;
    1211import static org.openstreetmap.josm.tools.I18n.trc;
     12import static org.openstreetmap.josm.tools.Utils.toRadians;
    1313
    1414import java.awt.geom.Area;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r12100 r12131  
    286286    static final int FLAG_OUTERMEMBER_OF_SELECTED = 8;
    287287
    288     private static final double PHI = Math.toRadians(20);
     288    private static final double PHI = Utils.toRadians(20);
    289289    private static final double cosPHI = Math.cos(PHI);
    290290    private static final double sinPHI = Math.sin(PHI);
     
    978978            fromAngle = Math.atan(dy / dx);
    979979        }
    980         double fromAngleDeg = Math.toDegrees(fromAngle);
     980        double fromAngleDeg = Utils.toDegrees(fromAngle);
    981981
    982982        double vx = distanceFromVia * Math.cos(fromAngle);
     
    10011001        if (pFrom.x >= pVia.x && pFrom.y >= pVia.y) {
    10021002            if (!leftHandTraffic) {
    1003                 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90));
    1004                 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90));
     1003                vx2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg - 90));
     1004                vy2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg - 90));
    10051005            } else {
    1006                 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90));
    1007                 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90));
     1006                vx2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg + 90));
     1007                vy2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg + 90));
    10081008            }
    10091009            iconAngle = 270+fromAngleDeg;
     
    10111011        if (pFrom.x < pVia.x && pFrom.y >= pVia.y) {
    10121012            if (!leftHandTraffic) {
    1013                 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg));
    1014                 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg));
     1013                vx2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg));
     1014                vy2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg));
    10151015            } else {
    1016                 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180));
    1017                 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180));
     1016                vx2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg + 180));
     1017                vy2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg + 180));
    10181018            }
    10191019            iconAngle = 90-fromAngleDeg;
     
    10211021        if (pFrom.x < pVia.x && pFrom.y < pVia.y) {
    10221022            if (!leftHandTraffic) {
    1023                 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90));
    1024                 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90));
     1023                vx2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg + 90));
     1024                vy2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg + 90));
    10251025            } else {
    1026                 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90));
    1027                 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90));
     1026                vx2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg - 90));
     1027                vy2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg - 90));
    10281028            }
    10291029            iconAngle = 90+fromAngleDeg;
     
    10311031        if (pFrom.x >= pVia.x && pFrom.y < pVia.y) {
    10321032            if (!leftHandTraffic) {
    1033                 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180));
    1034                 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180));
     1033                vx2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg + 180));
     1034                vy2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg + 180));
    10351035            } else {
    1036                 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg));
    1037                 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg));
     1036                vx2 = distanceFromWay * Math.sin(Utils.toRadians(fromAngleDeg));
     1037                vy2 = distanceFromWay * Math.cos(Utils.toRadians(fromAngleDeg));
    10381038            }
    10391039            iconAngle = 270-fromAngleDeg;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    r11452 r12131  
    3232import org.openstreetmap.josm.gui.NavigatableComponent;
    3333import org.openstreetmap.josm.gui.draw.MapPath2D;
     34import org.openstreetmap.josm.tools.Utils;
    3435
    3536/**
     
    9091
    9192    /** Helper variable for {@link #drawSegment} */
    92     private static final ArrowPaintHelper ARROW_PAINT_HELPER = new ArrowPaintHelper(Math.toRadians(20), 10);
     93    private static final ArrowPaintHelper ARROW_PAINT_HELPER = new ArrowPaintHelper(Utils.toRadians(20), 10);
    9394
    9495    /** Helper variable for {@link #visit(Relation)} */
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r11893 r12131  
    1818import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    1919import org.openstreetmap.josm.gui.MapView;
     20import org.openstreetmap.josm.tools.Utils;
    2021
    2122/**
     
    144145        double cosT = 5 * Math.cos(t);
    145146        double sinT = 5 * Math.sin(t);
    146         int deg = (int) Math.toDegrees(t);
     147        int deg = (int) Utils.toDegrees(t);
    147148        if (selected) {
    148149            g.setColor(getHighlightColor(color));
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r11893 r12131  
    5353import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    5454import org.openstreetmap.josm.tools.ImageProvider;
     55import org.openstreetmap.josm.tools.Utils;
    5556
    5657/**
     
    184185    protected LatLon getNorthWestLatLonOfTile(Point tile, int zoom) {
    185186        double lon = tile.x / Math.pow(2.0, zoom) * 360.0 - 180;
    186         double lat = Math.toDegrees(Math.atan(Math.sinh(Math.PI - (2.0 * Math.PI * tile.y) / Math.pow(2.0, zoom))));
     187        double lat = Utils.toDegrees(Math.atan(Math.sinh(Math.PI - (2.0 * Math.PI * tile.y) / Math.pow(2.0, zoom))));
    187188        return new LatLon(lat, lon);
    188189    }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r12072 r12131  
    589589                    double rightdir = (headdir > 270) ? headdir - 270 : headdir + 90;
    590590
    591                     double ptx = p.x + Math.cos(Math.toRadians(headdir)) * arrowlength;
    592                     double pty = p.y + Math.sin(Math.toRadians(headdir)) * arrowlength;
    593 
    594                     double ltx = p.x + Math.cos(Math.toRadians(leftdir)) * arrowwidth/2;
    595                     double lty = p.y + Math.sin(Math.toRadians(leftdir)) * arrowwidth/2;
    596 
    597                     double rtx = p.x + Math.cos(Math.toRadians(rightdir)) * arrowwidth/2;
    598                     double rty = p.y + Math.sin(Math.toRadians(rightdir)) * arrowwidth/2;
     591                    double ptx = p.x + Math.cos(Utils.toRadians(headdir)) * arrowlength;
     592                    double pty = p.y + Math.sin(Utils.toRadians(headdir)) * arrowlength;
     593
     594                    double ltx = p.x + Math.cos(Utils.toRadians(leftdir)) * arrowwidth/2;
     595                    double lty = p.y + Math.sin(Utils.toRadians(leftdir)) * arrowwidth/2;
     596
     597                    double rtx = p.x + Math.cos(Utils.toRadians(rightdir)) * arrowwidth/2;
     598                    double rty = p.y + Math.sin(Utils.toRadians(rightdir)) * arrowwidth/2;
    599599
    600600                    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java

    r10173 r12131  
    1818import org.openstreetmap.josm.gui.help.HelpUtil;
    1919import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     20import org.openstreetmap.josm.tools.Utils;
    2021
    2122/**
     
    8687        }
    8788        double avglat = latsum / latcnt;
    88         double scale = Math.cos(Math.toRadians(avglat));
     89        double scale = Math.cos(Utils.toRadians(avglat));
    8990        /*
    9091         * Compute buffer zone extents and maximum bounding box size. Note that the maximum we
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r11935 r12131  
    8686    private int hdoprange;
    8787
    88     private static final double PHI = Math.toRadians(15);
     88    private static final double PHI = Utils.toRadians(15);
    8989
    9090    //// Variables used only to check cache validity
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r11756 r12131  
    620620         */
    621621        public static double degree_to_radians(double degree) { // NO_UCD (unused code)
    622             return Math.toRadians(degree);
     622            return Utils.toRadians(degree);
    623623        }
    624624
  • trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java

    r11893 r12131  
    153153            case "ne":
    154154            case "northeast":
    155                 return Math.toRadians(45);
     155                return Utils.toRadians(45);
    156156            case "e":
    157157            case "east":
    158                 return Math.toRadians(90);
     158                return Utils.toRadians(90);
    159159            case "se":
    160160            case "southeast":
    161                 return Math.toRadians(135);
     161                return Utils.toRadians(135);
    162162            case "s":
    163163            case "south":
     
    165165            case "sw":
    166166            case "southwest":
    167                 return Math.toRadians(225);
     167                return Utils.toRadians(225);
    168168            case "w":
    169169            case "west":
    170                 return Math.toRadians(270);
     170                return Utils.toRadians(270);
    171171            case "nw":
    172172            case "northwest":
    173                 return Math.toRadians(315);
     173                return Utils.toRadians(315);
    174174            default:
    175175                throw new IllegalArgumentException("Unexpected cardinal direction " + cardinal);
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r11747 r12131  
    13171317                }
    13181318
    1319                 double radian = Math.toRadians(angle);
     1319                double radian = Utils.toRadians(angle);
    13201320
    13211321                new ImageIcon(img); // load completely
     
    13461346
    13471347                // rotate the graphics about the center point of the icon
    1348                 g2d.rotate(Math.toRadians(originalAngle));
     1348                g2d.rotate(Utils.toRadians(originalAngle));
    13491349
    13501350                g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
Note: See TracChangeset for help on using the changeset viewer.