Ignore:
Timestamp:
2018-04-27T00:06:11+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm16230 - add robustness when drawing image

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java

    r34021 r34169  
    249249
    250250            // Draw picture
    251             g.drawImage(image, -image.getWidth(null) / 2, -image.getHeight(null) / 2, null);
     251            int width = image.getWidth(null);
     252            int height = image.getHeight(null);
     253            try {
     254                g.drawImage(image, -width / 2, -height / 2, null);
     255            } catch (RuntimeException e) {
     256                Logging.error(e);
     257            }
    252258
    253259            // Draw additional rectangle for the active pic layer
     
    255261                g.setColor(new Color(0xFF0000));
    256262                g.drawRect(
    257                     -image.getWidth(null) / 2,
    258                     -image.getHeight(null) / 2,
    259                     image.getWidth(null),
    260                     image.getHeight(null)
     263                    -width / 2,
     264                    -height / 2,
     265                    width,
     266                    height
    261267                );
    262268            }
     
    283289            }
    284290        } else {
    285             // TODO: proper logging
    286             System.out.println("PicLayerAbstract::paint - general drawing error (image is null or Graphics not 2D");
     291            Logging.error("PicLayerAbstract::paint - general drawing error (image is null or Graphics not 2D");
    287292        }
    288293    }
Note: See TracChangeset for help on using the changeset viewer.