Changeset 31397 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-07-21T16:34:33+02:00 (9 years ago)
Author:
nokutu
Message:

Improved filters, you can set since when images are valid.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r31389 r31397  
    1818import javax.swing.JOptionPane;
    1919import javax.swing.JPanel;
     20import javax.swing.JSpinner;
    2021import javax.swing.JTextField;
     22import javax.swing.SpinnerModel;
     23import javax.swing.SpinnerNumberModel;
     24import javax.swing.SwingUtilities;
    2125
    2226import org.openstreetmap.josm.Main;
     
    4448  private static MapillaryFilterDialog INSTANCE;
    4549
    46   private final static String[] TIME_LIST = { tr("All time"), tr("This year"),
    47       tr("This month"), tr("This week") };
    48 
    49   private final static int ROWS = 0;
    50   private final static int COLUMNS = 3;
    51 
    52   private final JPanel panel = new JPanel(new GridLayout(ROWS, COLUMNS));
     50  private final static String[] TIME_LIST = { tr("All"), tr("Years"),
     51      tr("Months"), tr("Days") };
     52
     53  private final JPanel panel = new JPanel();
     54
     55  /** Spinner to choose the range of dates. */
     56  public SpinnerNumberModel spinner;
    5357
    5458  private final JCheckBox imported = new JCheckBox("Imported images");
     
    96100    JPanel fromPanel = new JPanel();
    97101    fromPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    98     fromPanel.add(new JLabel("From"));
     102    fromPanel.add(new JLabel("Not older than: "));
     103    spinner = new SpinnerNumberModel(1, 0, 10000, 1);
     104    fromPanel.add(new JSpinner(spinner));
    99105    time = new JComboBox<>(TIME_LIST);
    100106    fromPanel.add(time);
     
    110116    downloaded.setSelected(true);
    111117
    112     panel.add(downloaded);
    113     panel.add(imported);
    114     panel.add(onlySigns);
    115     panel.add(fromPanel);
    116     panel.add(userSearchPanel);
    117     panel.add(signChooserPanel);
     118    JPanel col1 = new JPanel(new GridLayout(2,1));
     119    col1.add(downloaded);
     120    col1.add(fromPanel);
     121    panel.add(col1);
     122    JPanel col2 = new JPanel(new GridLayout(2,1));
     123    col2.add(imported);
     124    col2.add(userSearchPanel);
     125    panel.add(col2);
     126    JPanel col3 = new JPanel(new GridLayout(2,1));
     127    col3.add(onlySigns);
     128    col3.add(signChooserPanel);
     129    panel.add(col3);
    118130
    119131    createLayout(panel, true,
     
    152164    user.setText("");
    153165    time.setSelectedItem(TIME_LIST[0]);
     166    spinner.setValue(1);
    154167    refresh();
    155168  }
     
    193206      Long currentTime = currentTime();
    194207      if (time.getSelectedItem() == TIME_LIST[1]) {
    195         if ((currentTime - img.getCapturedAt()) / (24 * 60 * 60 * 1000) > 365) {
     208        if (img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue()
     209            * 365 * 24 * 60 * 60 * 1000) {
    196210          img.setVisible(false);
    197211          continue;
     
    199213      }
    200214      if (time.getSelectedItem() == TIME_LIST[2]) {
    201         if ((currentTime - img.getCapturedAt()) / (24 * 60 * 60 * 1000) > 30) {
     215        if (img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * 30 * 24
     216            * 60 * 60 * 1000) {
    202217          img.setVisible(false);
    203218          continue;
     
    205220      }
    206221      if (time.getSelectedItem() == TIME_LIST[3]) {
    207         if ((currentTime - img.getCapturedAt()) / (24 * 60 * 60 * 1000) > 7) {
     222        if (img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * 60
     223            * 60 * 1000) {
    208224          img.setVisible(false);
    209225          continue;
Note: See TracChangeset for help on using the changeset viewer.