Changeset 1083 in josm


Ignore:
Timestamp:
2008-11-18T16:52:54+01:00 (15 years ago)
Author:
framm
Message:
  • don't draw hatched pattern if the layer is inactive or contains no data bounds
File:
1 edited

Legend:

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

    r1082 r1083  
    175175     */
    176176    @Override public void paint(final Graphics g, final MapView mv) {
    177         boolean inactive = Main.map.mapView.getActiveLayer() != this && Main.pref.getBoolean("draw.data.inactive_color", true);
     177        boolean active = Main.map.mapView.getActiveLayer() == this;
     178        boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true);
    178179        boolean virtual = !inactive && Main.map.mapView.useVirtualNodes();
    179         if (Main.pref.getBoolean("draw.data.downloaded_area", true)) {
     180       
     181        // draw the hatched area for non-downloaded region. only draw if we're the active
     182        // and bounds are defined; don't draw for inactive layers or loaded GPX files etc
     183        if (active && Main.pref.getBoolean("draw.data.downloaded_area", true) && !data.dataSources.isEmpty()) {
    180184            // initialize area with current viewport
    181             Area b = new Area(Main.map.mapView.getBounds());
    182 
     185            Rectangle b = Main.map.mapView.getBounds();
     186            // on some platforms viewport bounds seem to be offset from the left,
     187            // over-grow it just to be sure
     188            b.grow(100, 100);
     189            Area a = new Area(b);
     190           
    183191            // now succesively subtract downloaded areas
    184192            for (DataSource src : data.dataSources) {
     
    189197                    Point p2 = mv.getPoint(en2);
    190198                    Rectangle r = new Rectangle(Math.min(p1.x, p2.x),Math.min(p1.y, p2.y),Math.abs(p2.x-p1.x),Math.abs(p2.y-p1.y));
    191                     b.subtract(new Area(r));
     199                    a.subtract(new Area(r));
    192200                }
    193201            }
     
    195203            // paint remainder
    196204            ((Graphics2D)g).setPaint(hatched);
    197             ((Graphics2D)g).fill(b);
     205            ((Graphics2D)g).fill(a);
    198206        }
    199207   
Note: See TracChangeset for help on using the changeset viewer.