Ticket #3313: work_around_openjdk_bug.patch

File work_around_openjdk_bug.patch, 2.4 KB (added by xeen, 16 years ago)
  • 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        }
     392
    382393        lat = max; max = b.max.lon();
    383394        for(; lon <= max; lon += 1.0)
    384395        {
    385396            p = getPoint(new LatLon(lat, lon >= max ? max : lon));
    386             path.lineTo(p.x, p.y);
     397            // OpenJDK…
     398            if(p.y < 0 || p.x < 0) {
     399                path.moveTo(Math.max(p.x, 0), p.y);
     400            } else {
     401                path.lineTo(Math.min(p.x, w), p.y);
     402            }
    387403        }
    388404        lon = max; max = b.min.lat();
    389405        for(; lat >= max; lat -= 1.0)
    390406        {
    391407            p = getPoint(new LatLon(lat <= max ? max : lat, lon));
    392             path.lineTo(p.x, p.y);
     408            // OpenJDK…
     409            if(p.x > w || p.y < 0) {
     410                path.moveTo(p.x, Math.max(p.y, 0));
     411            } else {
     412                path.lineTo(p.x, Math.min(p.y, h));
     413            }
    393414        }
    394415        lat = max; max = b.min.lon();
    395416        for(; lon >= max; lon -= 1.0)
    396417        {
    397418            p = getPoint(new LatLon(lat, lon <= max ? max : lon));
    398             path.lineTo(p.x, p.y);
     419            // OpenJDK…
     420            if(p.y > h || p.x > w) {
     421                path.moveTo(Math.min(p.x, w), p.y);
     422            } else {
     423                path.lineTo(Math.max(p.x, 0), p.y);
     424            }
    399425        }
    400426
    401427        if (playHeadMarker != null) {
    402428            playHeadMarker.paint(tempG, this);
    403429        }
     430
    404431        tempG.draw(path);
    405432
    406433        g.drawImage(offscreenBuffer, 0, 0, null);