Ejemplo n.º 1
0
 /**
  * Distributes a "bounding box changed" from one DownloadSelection object to the others, so they
  * may update or clear their input fields.
  *
  * @param eventSource - the DownloadSelection object that fired this notification.
  */
 public void boundingBoxChanged(Bounds b, DownloadSelection eventSource) {
   this.currentBounds = b;
   for (DownloadSelection s : downloadSelections) {
     if (s != eventSource) {
       s.setDownloadArea(currentBounds);
     }
   }
   updateSizeCheck();
 }
Ejemplo n.º 2
0
  protected final JPanel buildMainPanel() {
    JPanel pnl = new JPanel();
    pnl.setLayout(new GridBagLayout());

    // adding the download tasks
    pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5, 5, 1, 5));
    cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), true);
    cbDownloadOsmData.setToolTipText(
        tr("Select to download OSM data in the selected download area."));
    pnl.add(cbDownloadOsmData, GBC.std().insets(1, 5, 1, 5));
    cbDownloadGpxData = new JCheckBox(tr("Raw GPS data"));
    cbDownloadGpxData.setToolTipText(
        tr("Select to download GPS traces in the selected download area."));
    pnl.add(cbDownloadGpxData, GBC.eol().insets(5, 5, 1, 5));

    // hook for subclasses
    buildMainPanelAboveDownloadSelections(pnl);

    slippyMapChooser = new SlippyMapChooser();

    // predefined download selections
    downloadSelections.add(slippyMapChooser);
    downloadSelections.add(new BookmarkSelection());
    downloadSelections.add(new BoundingBoxSelection());
    downloadSelections.add(new PlaceSelection());
    downloadSelections.add(new TileSelection());

    // add selections from plugins
    PluginHandler.addDownloadSelection(downloadSelections);

    // now everybody may add their tab to the tabbed pane
    // (not done right away to allow plugins to remove one of
    // the default selectors!)
    for (DownloadSelection s : downloadSelections) {
      s.addGui(this);
    }

    pnl.add(tpDownloadAreaSelectors, GBC.eol().fill());

    try {
      tpDownloadAreaSelectors.setSelectedIndex(Main.pref.getInteger("download.tab", 0));
    } catch (Exception ex) {
      Main.pref.putInteger("download.tab", 0);
    }

    Font labelFont = sizeCheck.getFont();
    sizeCheck.setFont(labelFont.deriveFont(Font.PLAIN, labelFont.getSize()));

    cbNewLayer = new JCheckBox(tr("Download as new layer"));
    cbNewLayer.setToolTipText(
        tr(
            "<html>Select to download data into a new data layer.<br>"
                + "Unselect to download into the currently active data layer.</html>"));

    cbStartup = new JCheckBox(tr("Open this dialog on startup"));
    cbStartup.setToolTipText(
        tr(
            "<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>You can open it manually from File menu or toolbar.</html>"));
    cbStartup.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Main.pref.put("download.autorun", cbStartup.isSelected());
          }
        });

    pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
    pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));

    pnl.add(sizeCheck, GBC.eol().anchor(GBC.EAST).insets(5, 5, 5, 2));

    if (!ExpertToggleAction.isExpert()) {
      JLabel infoLabel =
          new JLabel(
              tr(
                  "Use left click&drag to select area, arrows or right mouse button to scroll map, wheel or +/- to zoom."));
      pnl.add(infoLabel, GBC.eol().anchor(GBC.SOUTH).insets(0, 0, 0, 0));
    }
    return pnl;
  }