Ticket #3313: work_around_openjdk_bug.2.patch

File work_around_openjdk_bug.2.patch, 2.4 KB (added by xeen, 15 years ago)

work around unicode not being supported

  • src/org/openstreetmap/josm/gui/MapView.java

     
    370370        double lat = b.min.lat();
    371371        double lon = b.min.lon();
    372372
     373        int w = offscreenBuffer.getWidth();
     374        int h = offscreenBuffer.getHeight();
     375
    373376        Point p = getPoint(b.min);
    374377        path.moveTo(p.x, p.y);
    375378
     
    377380        for(; lat <= max; lat += 1.0)
    378381        {
    379382            p = getPoint(new LatLon(lat >= max ? max : lat, lon));
    380             path.lineTo(p.x, p.y);
     383            // OpenJDK has problems when it should draw out of bounds
     384            // This ensures lineTo only draws into the visible area
     385            if(p.x < 0 || p.y > h) {
     386                path.moveTo(p.x, Math.min(p.y, h));
     387            } else {
     388                path.lineTo(p.x, Math.max(p.y, 0));
     389
     390            }
    381391        }
    382392        lat = max; max = b.max.lon();
    383393        for(; lon <= max; lon += 1.0)
    384394        {
    385395            p = getPoint(new LatLon(lat, lon >= max ? max : lon));
    386             path.lineTo(p.x, p.y);
     396            // OpenJDK...
     397            if(p.y < 0 || p.x < 0) {
     398                path.moveTo(Math.max(p.x, 0), p.y);
     399            } else {
     400                path.lineTo(Math.min(p.x, w), p.y);
     401            }
    387402        }
    388403        lon = max; max = b.min.lat();
    389404        for(; lat >= max; lat -= 1.0)
    390405        {
    391406            p = getPoint(new LatLon(lat <= max ? max : lat, lon));
    392             path.lineTo(p.x, p.y);
     407            // OpenJDK...
     408            if(p.x > w || p.y < 0) {
     409                path.moveTo(p.x, Math.max(p.y, 0));
     410            } else {
     411                path.lineTo(p.x, Math.min(p.y, h));
     412            }
    393413        }
    394414        lat = max; max = b.min.lon();
    395415        for(; lon >= max; lon -= 1.0)
    396416        {
    397417            p = getPoint(new LatLon(lat, lon <= max ? max : lon));
    398             path.lineTo(p.x, p.y);
     418            // OpenJDK...
     419            if(p.y > h || p.x > w) {
     420                path.moveTo(Math.min(p.x, w), p.y);
     421            } else {
     422                path.lineTo(Math.max(p.x, 0), p.y);
     423            }
    399424        }
    400425
    401426        if (playHeadMarker != null) {
    402427            playHeadMarker.paint(tempG, this);
    403428        }
     429
    404430        tempG.draw(path);
    405431
    406432        g.drawImage(offscreenBuffer, 0, 0, null);