Changeset 635 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2008-05-12T16:53:28+02:00 (16 years ago)
Author:
framm
Message:
  • graphics fix by Daniel Naber.

-> closes #736

File:
1 edited

Legend:

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

    r627 r635  
    77import java.awt.Color;
    88import java.awt.Graphics;
     9import java.awt.Graphics2D;
    910import java.awt.Point;
     11import java.awt.Transparency;
    1012import java.awt.event.ComponentAdapter;
    1113import java.awt.event.ComponentEvent;
    1214import java.awt.event.KeyEvent;
     15import java.awt.image.BufferedImage;
    1316import java.util.ArrayList;
    1417import java.util.Collection;
     
    199202                if (center == null)
    200203                        return; // no data loaded yet.
    201                 g.setColor(Preferences.getPreferencesColor("background", Color.BLACK));
    202                 g.fillRect(0, 0, getWidth(), getHeight());
     204               
     205                BufferedImage bim = new BufferedImage(getWidth(), getHeight(), Transparency.OPAQUE);
     206                Graphics2D tempG = bim.createGraphics();
     207                tempG.setColor(Preferences.getPreferencesColor("background", Color.BLACK));
     208                tempG.fillRect(0, 0, getWidth(), getHeight());
    203209
    204210                for (int i = layers.size()-1; i >= 0; --i) {
    205211                        Layer l = layers.get(i);
    206212                        if (l.visible && l != getActiveLayer())
    207                                 l.paint(g, this);
     213                                l.paint(tempG, this);
    208214                }
    209215               
    210216                if (getActiveLayer() != null && getActiveLayer().visible)
    211                         getActiveLayer().paint(g, this);
     217                        getActiveLayer().paint(tempG, this);
    212218
    213219                for (MapViewPaintable mvp : temporaryLayers) {
    214                         mvp.paint(g, this);
     220                        mvp.paint(tempG, this);
    215221                }
    216222               
    217223                // draw world borders
    218                 g.setColor(Color.WHITE);
     224                tempG.setColor(Color.WHITE);
    219225                Bounds b = new Bounds();
    220226                Point min = getPoint(getProjection().latlon2eastNorth(b.min));
     
    225231                int y2 = Math.max(min.y, max.y);
    226232                if (x1 > 0 || y1 > 0 || x2 < getWidth() || y2 < getHeight())
    227                         g.drawRect(x1, y1, x2-x1+1, y2-y1+1);
     233                        tempG.drawRect(x1, y1, x2-x1+1, y2-y1+1);
    228234               
    229235                if (playHeadMarker != null)
    230                         playHeadMarker.paint(g, this);
    231 
     236                        playHeadMarker.paint(tempG, this);
     237
     238                g.drawImage(bim, 0, 0, null);
    232239                super.paint(g);
    233240        }
Note: See TracChangeset for help on using the changeset viewer.