Changeset 2884 in josm for trunk


Ignore:
Timestamp:
2010-01-23T16:47:01+01:00 (10 years ago)
Author:
jttt
Message:

Get mouse position in marker layer only when necessary (speed optimization)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r2626 r2884  
    154154
    155155    @Override public void paint(Graphics2D g, MapView mv, Bounds box) {
    156         boolean mousePressedTmp = mousePressed;
    157         Point mousePos = mv.getMousePosition();
    158156        String mkrTextShow = Main.pref.get("marker.show "+getName(), "show");
    159 
    160157        g.setColor(getColor(getName()));
    161158
    162         for (Marker mkr : data) {
    163             if (mousePos != null && mkr.containsPoint(mousePos)) {
    164                 mkr.paint(g, mv, mousePressedTmp, mkrTextShow);
    165                 mousePressedTmp = false;
    166             } else {
     159        if (mousePressed) {
     160            boolean mousePressedTmp = mousePressed;
     161            Point mousePos = mv.getMousePosition(); // Get mouse position only when necessary (it's the slowest part of marker layer painting)
     162            for (Marker mkr : data) {
     163                if (mousePos != null && mkr.containsPoint(mousePos)) {
     164                    mkr.paint(g, mv, mousePressedTmp, mkrTextShow);
     165                    mousePressedTmp = false;
     166                }
     167            }
     168        } else {
     169            for (Marker mkr : data) {
    167170                mkr.paint(g, mv, false, mkrTextShow);
    168171            }
Note: See TracChangeset for help on using the changeset viewer.