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


Ignore:
Timestamp:
2008-11-18T08:40:49+01:00 (16 years ago)
Author:
framm
Message:
  • some changes regarding the "hatched download area": now also works for areas where server returns no data; colour preference is now called "outside downloaded area", not "downloaded Area"; changing the colour now invalidates the prepared pattern so that restart is not required; pattern is now transparent (patch from Stephan Knauss) so WMS and other layers are visible below. Fixes #1762, #1754, partly #1756
Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r746 r1082  
    1111import org.openstreetmap.josm.actions.DownloadAction;
    1212import org.openstreetmap.josm.data.osm.DataSet;
     13import org.openstreetmap.josm.data.osm.DataSource;
    1314import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1415import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
    1516import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1617import org.openstreetmap.josm.io.BoundingBoxDownloader;
     18import org.openstreetmap.josm.data.Bounds;
     19import org.openstreetmap.josm.data.coor.LatLon;
    1720import org.xml.sax.SAXException;
     21
    1822
    1923/**
     
    2226 */
    2327public class DownloadOsmTask implements DownloadTask {
     28
     29    private static Bounds currentBounds;
    2430
    2531        private static class Task extends PleaseWaitRunnable {
     
    4147                        if (dataSet == null)
    4248                                return; // user cancelled download or error occoured
    43                         if (dataSet.allPrimitives().isEmpty())
     49                        if (dataSet.allPrimitives().isEmpty()) {
    4450                                errorMessage = tr("No data imported.");
     51                // need to synthesize a download bounds lest the visual indication of downloaded
     52                // area doesn't work
     53                dataSet.dataSources.add(new DataSource(currentBounds, "OpenStreetMap server"));
     54            }
     55
    4556                        OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer"), null);
    4657                        if (newLayer)
     
    6980   
    7081                Task task = new Task(action != null && (action.dialog == null || action.dialog.newLayer.isSelected()), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon));
     82        currentBounds = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));
    7183                Main.worker.execute(task);
    7284    }
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r1073 r1082  
    178178        }
    179179
    180         synchronized public Map<String, String> getDefaults()
    181         {
     180        synchronized public Map<String, String> getDefaults() {
    182181                return defaults;
    183182        }
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r1065 r1082  
    165165                        Main.pref.save();
    166166                }
    167                
     167
     168        // TODO remove this in early 2009 - just here to weed out color setting we don't use any more
     169        Main.pref.put("downloaded Area", null);
    168170
    169171                String localeName = null; //The locale to use
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r1078 r1082  
    77import static org.openstreetmap.josm.tools.I18n.trn;
    88
     9import java.awt.AlphaComposite;
    910import java.awt.Color;
    1011import java.awt.Component;
     12import java.awt.Composite;
    1113import java.awt.Graphics;
    1214import java.awt.Graphics2D;
     
    128130     * a paint texture for non-downloaded area
    129131     */
    130     private TexturePaint hatched;
     132    private static TexturePaint hatched;
    131133   
     134    static {
     135        createHatchTexture();
     136    }
     137
     138    /**
     139     * Initialize the hatch pattern used to paint the non-downloaded area
     140     */
     141    public static void createHatchTexture() {
     142        BufferedImage bi = new BufferedImage(15, 15, BufferedImage.TYPE_INT_ARGB);
     143        Graphics2D big = bi.createGraphics();
     144        big.setColor(Main.pref.getColor(marktr("background"), Color.BLACK));
     145        Composite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
     146        big.setComposite(comp);
     147        big.fillRect(0,0,15,15);
     148        big.setColor(Main.pref.getColor(marktr("outside downloaded area"), Color.YELLOW));
     149        big.drawLine(0,15,15,0);
     150        Rectangle r = new Rectangle(0, 0, 15,15);
     151        hatched = new TexturePaint(bi, r);
     152    }
     153
    132154    /**
    133155     * Construct a OsmDataLayer.
     
    137159        this.data = data;
    138160        this.associatedFile = associatedFile;
    139        
    140         BufferedImage bi = new BufferedImage(15, 15, BufferedImage.TYPE_INT_RGB);
    141         Graphics2D big = bi.createGraphics();
    142         big.setColor(Main.pref.getColor(marktr("background"), Color.BLACK));
    143         big.fillRect(0,0,15,15);
    144         big.setColor(Main.pref.getColor(marktr("downloaded Area"), Color.YELLOW));
    145         big.drawLine(0,15,15,0);
    146         Rectangle r = new Rectangle(0, 0, 15,15);
    147         hatched = new TexturePaint(bi, r);
    148161    }
    149162
  • trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java

    r1053 r1082  
    3030import org.openstreetmap.josm.Main;
    3131import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
     32import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3233import org.openstreetmap.josm.tools.ColorHelper;
    3334import org.openstreetmap.josm.tools.GBC;
     
    172173                        Main.pref.put("color." + name, ColorHelper.color2html(col));
    173174                }
     175        org.openstreetmap.josm.gui.layer.OsmDataLayer.createHatchTexture();
    174176    }
    175177}
Note: See TracChangeset for help on using the changeset viewer.