Changeset 11226 in josm for trunk


Ignore:
Timestamp:
2016-11-09T00:27:35+01:00 (3 years ago)
Author:
michael2402
Message:

MapView: Allow public access to paintLayer.

This allows plugins like the areaselector to access the drawing code of the map view.

See https://github.com/JOSM/areaselector/issues/25

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r11173 r11226  
    420420    }
    421421
    422     private void paintLayer(Layer layer, Graphics2D g, Bounds box) {
     422    /**
     423     * Paints the given layer to the graphics object, using the current state of this map view.
     424     * @param layer The layer to draw.
     425     * @param g A graphics object. It should have the width and height of this component
     426     * @throws IllegalArgumentException If the layer is not part of this map view.
     427     * @since 11226
     428     */
     429    public void paintLayer(Layer layer, Graphics2D g) {
    423430        try {
    424431            LayerPainter painter = registeredLayers.get(layer);
     
    435442            g.setPaintMode();
    436443        } catch (RuntimeException t) {
    437             BugReport.intercept(t).put("layer", layer).put("bounds", box).warn();
     444            BugReport.intercept(t).put("layer", layer).warn();
    438445        }
    439446    }
     
    480487        Graphics2D tempG = offscreenBuffer.createGraphics();
    481488        tempG.setClip(g.getClip());
    482         Bounds box = getLatLonBounds(g.getClipBounds());
    483489
    484490        if (!canUseBuffer || nonChangedLayersBuffer == null) {
     
    493499
    494500            for (int i = 0; i < nonChangedLayersCount; i++) {
    495                 paintLayer(visibleLayers.get(i), g2, box);
     501                paintLayer(visibleLayers.get(i), g2);
    496502            }
    497503        } else {
     
    501507                g2.setClip(g.getClip());
    502508                for (int i = nonChangedLayers.size(); i < nonChangedLayersCount; i++) {
    503                     paintLayer(visibleLayers.get(i), g2, box);
     509                    paintLayer(visibleLayers.get(i), g2);
    504510                }
    505511            }
     
    514520
    515521        for (int i = nonChangedLayersCount; i < visibleLayers.size(); i++) {
    516             paintLayer(visibleLayers.get(i), tempG, box);
     522            paintLayer(visibleLayers.get(i), tempG);
    517523        }
    518524
    519525        try {
    520             drawTemporaryLayers(tempG, box);
     526            drawTemporaryLayers(tempG, getLatLonBounds(g.getClipBounds()));
    521527        } catch (RuntimeException e) {
    522528            BugReport.intercept(e).put("temporaryLayers", temporaryLayers).warn();
Note: See TracChangeset for help on using the changeset viewer.