Ejemplo n.º 1
0
    private void build() {
      filter = new JosmTextField(30);
      filter.setColumns(10);
      filter.getDocument().addDocumentListener(this);

      selectionList = new JList<>(data.toArray(new String[0]));
      selectionList.setModel(model = new ProjectionCodeListModel());
      JScrollPane scroll = new JScrollPane(selectionList);
      scroll.setPreferredSize(new Dimension(200, 214));

      this.setLayout(new GridBagLayout());
      this.add(filter, GBC.eol().weight(1.0, 0.0));
      this.add(scroll, GBC.eol());
    }
Ejemplo n.º 2
0
  private JPanel buildFilterPanel() {
    // copied from PluginPreference
    JPanel pnl = new JPanel(new GridBagLayout());
    pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    GridBagConstraints gc = new GridBagConstraints();

    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 0.0;
    gc.insets = new Insets(0, 0, 0, 5);
    pnl.add(new JLabel(tr("Search:")), gc);

    gc.gridx = 1;
    gc.weightx = 1.0;
    pnl.add(filterField, gc);
    filterField.setToolTipText(tr("Enter a search expression"));
    SelectAllOnFocusGainedDecorator.decorate(filterField);
    filterField.getDocument().addDocumentListener(new FilterFieldAdapter());
    pnl.setMaximumSize(new Dimension(300, 10));
    return pnl;
  }
Ejemplo n.º 3
0
  protected void build() {
    setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    // the checkbox for the default UL
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weightx = 1.0;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.gridwidth = 4;
    add(buildDefultServerUrlPanel(), gc);

    // the input field for the URL
    gc.gridx = 0;
    gc.gridy = 1;
    gc.gridwidth = 1;
    gc.weightx = 0.0;
    gc.insets = new Insets(0, 0, 0, 3);
    add(lblApiUrl = new JLabel(tr("OSM Server URL:")), gc);

    gc.gridx = 1;
    gc.weightx = 1.0;
    add(tfOsmServerUrl = new JosmTextField(), gc);
    SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl);
    valOsmServerUrl = new ApiUrlValidator(tfOsmServerUrl);
    valOsmServerUrl.validate();
    ApiUrlPropagator propagator = new ApiUrlPropagator();
    tfOsmServerUrl.addActionListener(propagator);
    tfOsmServerUrl.addFocusListener(propagator);

    gc.gridx = 2;
    gc.weightx = 0.0;
    add(lblValid = new JLabel(), gc);

    gc.gridx = 3;
    gc.weightx = 0.0;
    ValidateApiUrlAction actTest = new ValidateApiUrlAction();
    tfOsmServerUrl.getDocument().addDocumentListener(actTest);
    add(btnTest = new SideButton(actTest), gc);
  }
Ejemplo n.º 4
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    // Construct the list of loaded GPX tracks
    Collection<Layer> layerLst = Main.map.mapView.getAllLayers();
    GpxDataWrapper defaultItem = null;
    for (Layer cur : layerLst) {
      if (cur instanceof GpxLayer) {
        GpxLayer curGpx = (GpxLayer) cur;
        GpxDataWrapper gdw =
            new GpxDataWrapper(curGpx.getName(), curGpx.data, curGpx.data.storageFile);
        gpxLst.add(gdw);
        if (cur == yLayer.gpxLayer) {
          defaultItem = gdw;
        }
      }
    }
    for (GpxData data : loadedGpxData) {
      gpxLst.add(new GpxDataWrapper(data.storageFile.getName(), data, data.storageFile));
    }

    if (gpxLst.isEmpty()) {
      gpxLst.add(new GpxDataWrapper(tr("<No GPX track loaded yet>"), null, null));
    }

    JPanel panelCb = new JPanel();

    panelCb.add(new JLabel(tr("GPX track: ")));

    cbGpx = new JosmComboBox<>(gpxLst.toArray(new GpxDataWrapper[0]));
    if (defaultItem != null) {
      cbGpx.setSelectedItem(defaultItem);
    }
    cbGpx.addActionListener(statusBarUpdaterWithRepaint);
    panelCb.add(cbGpx);

    JButton buttonOpen = new JButton(tr("Open another GPX trace"));
    buttonOpen.addActionListener(new LoadGpxDataActionListener());
    panelCb.add(buttonOpen);

    JPanel panelTf = new JPanel(new GridBagLayout());

    String prefTimezone = Main.pref.get("geoimage.timezone", "0:00");
    if (prefTimezone == null) {
      prefTimezone = "0:00";
    }
    try {
      timezone = parseTimezone(prefTimezone);
    } catch (ParseException e) {
      timezone = 0;
    }

    tfTimezone = new JosmTextField(10);
    tfTimezone.setText(formatTimezone(timezone));

    try {
      delta = parseOffset(Main.pref.get("geoimage.delta", "0"));
    } catch (ParseException e) {
      delta = 0;
    }
    delta = delta / 1000; // milliseconds -> seconds

    tfOffset = new JosmTextField(10);
    tfOffset.setText(Long.toString(delta));

    JButton buttonViewGpsPhoto =
        new JButton(
            tr("<html>Use photo of an accurate clock,<br>" + "e.g. GPS receiver display</html>"));
    buttonViewGpsPhoto.setIcon(ImageProvider.get("clock"));
    buttonViewGpsPhoto.addActionListener(new SetOffsetActionListener());

    JButton buttonAutoGuess = new JButton(tr("Auto-Guess"));
    buttonAutoGuess.setToolTipText(tr("Matches first photo with first gpx point"));
    buttonAutoGuess.addActionListener(new AutoGuessActionListener());

    JButton buttonAdjust = new JButton(tr("Manual adjust"));
    buttonAdjust.addActionListener(new AdjustActionListener());

    JLabel labelPosition = new JLabel(tr("Override position for: "));

    int numAll = getSortedImgList(true, true).size();
    int numExif = numAll - getSortedImgList(false, true).size();
    int numTagged = numAll - getSortedImgList(true, false).size();

    cbExifImg =
        new JCheckBox(tr("Images with geo location in exif data ({0}/{1})", numExif, numAll));
    cbExifImg.setEnabled(numExif != 0);

    cbTaggedImg =
        new JCheckBox(tr("Images that are already tagged ({0}/{1})", numTagged, numAll), true);
    cbTaggedImg.setEnabled(numTagged != 0);

    labelPosition.setEnabled(cbExifImg.isEnabled() || cbTaggedImg.isEnabled());

    boolean ticked = yLayer.thumbsLoaded || Main.pref.getBoolean("geoimage.showThumbs", false);
    cbShowThumbs = new JCheckBox(tr("Show Thumbnail images on the map"), ticked);
    cbShowThumbs.setEnabled(!yLayer.thumbsLoaded);

    int y = 0;
    GBC gbc = GBC.eol();
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(panelCb, gbc);

    gbc = GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 12);
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(new JSeparator(SwingConstants.HORIZONTAL), gbc);

    gbc = GBC.std();
    gbc.gridx = 0;
    gbc.gridy = y;
    panelTf.add(new JLabel(tr("Timezone: ")), gbc);

    gbc = GBC.std().fill(GBC.HORIZONTAL);
    gbc.gridx = 1;
    gbc.gridy = y++;
    gbc.weightx = 1.;
    panelTf.add(tfTimezone, gbc);

    gbc = GBC.std();
    gbc.gridx = 0;
    gbc.gridy = y;
    panelTf.add(new JLabel(tr("Offset:")), gbc);

    gbc = GBC.std().fill(GBC.HORIZONTAL);
    gbc.gridx = 1;
    gbc.gridy = y++;
    gbc.weightx = 1.;
    panelTf.add(tfOffset, gbc);

    gbc = GBC.std().insets(5, 5, 5, 5);
    gbc.gridx = 2;
    gbc.gridy = y - 2;
    gbc.gridheight = 2;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0.5;
    panelTf.add(buttonViewGpsPhoto, gbc);

    gbc = GBC.std().fill(GBC.BOTH).insets(5, 5, 5, 5);
    gbc.gridx = 2;
    gbc.gridy = y++;
    gbc.weightx = 0.5;
    panelTf.add(buttonAutoGuess, gbc);

    gbc.gridx = 3;
    panelTf.add(buttonAdjust, gbc);

    gbc = GBC.eol().fill(GBC.HORIZONTAL).insets(0, 12, 0, 0);
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(new JSeparator(SwingConstants.HORIZONTAL), gbc);

    gbc = GBC.eol();
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(labelPosition, gbc);

    gbc = GBC.eol();
    gbc.gridx = 1;
    gbc.gridy = y++;
    panelTf.add(cbExifImg, gbc);

    gbc = GBC.eol();
    gbc.gridx = 1;
    gbc.gridy = y++;
    panelTf.add(cbTaggedImg, gbc);

    gbc = GBC.eol();
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(cbShowThumbs, gbc);

    final JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
    statusBarText = new JLabel(" ");
    statusBarText.setFont(statusBarText.getFont().deriveFont(8));
    statusBar.add(statusBarText);

    tfTimezone.addFocusListener(repaintTheMap);
    tfOffset.addFocusListener(repaintTheMap);

    tfTimezone.getDocument().addDocumentListener(statusBarUpdater);
    tfOffset.getDocument().addDocumentListener(statusBarUpdater);
    cbExifImg.addItemListener(statusBarUpdaterWithRepaint);
    cbTaggedImg.addItemListener(statusBarUpdaterWithRepaint);

    statusBarUpdater.updateStatusBar();

    outerPanel = new JPanel(new BorderLayout());
    outerPanel.add(statusBar, BorderLayout.PAGE_END);

    if (!GraphicsEnvironment.isHeadless()) {
      syncDialog =
          new ExtendedDialog(
              Main.parent,
              tr("Correlate images with GPX track"),
              new String[] {tr("Correlate"), tr("Cancel")},
              false);
      syncDialog.setContent(panelTf, false);
      syncDialog.setButtonIcons(new String[] {"ok", "cancel"});
      syncDialog.setupDialog();
      outerPanel.add(syncDialog.getContentPane(), BorderLayout.PAGE_START);
      syncDialog.setContentPane(outerPanel);
      syncDialog.pack();
      syncDialog.addWindowListener(new SyncDialogWindowListener());
      syncDialog.showDialog();
    }
  }