Changeset 32038 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-01-31T19:14:35+01:00 (9 years ago)
Author:
nokutu
Message:

Fixed Mapillary filter dialog layout

File:
1 edited

Legend:

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

    r31837 r32038  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.FlowLayout;
    7 import java.awt.GridLayout;
     6import java.awt.*;
    87import java.awt.event.ActionEvent;
    98import java.awt.event.KeyEvent;
     
    3837 * @author nokutu
    3938 * @see MapillaryFilterChooseSigns
    40  *
    4139 */
    4240public class MapillaryFilterDialog extends ToggleDialog implements MapillaryDataListener {
     
    4644  private static MapillaryFilterDialog instance;
    4745
    48   private static final String[] TIME_LIST = { tr("All"), tr("Years"), tr("Months"), tr("Days") };
    49 
    50   /** Spinner to choose the range of dates. */
     46  private static final String[] TIME_LIST = {tr("All"), tr("Years"), tr("Months"), tr("Days")};
     47
     48  /**
     49   * Spinner to choose the range of dates.
     50   */
    5151  private final SpinnerNumberModel spinner;
    5252
     
    6363  private final MapillaryFilterChooseSigns signFilter = MapillaryFilterChooseSigns.getInstance();
    6464
    65   /** The list of sign names */
    66   private static final String[] SIGN_TAGS = { "prohibitory_speed_limit",
    67       "priority_stop", "other_give_way", "mandatory_roundabout",
    68       "other_no_entry", "prohibitory_no_traffic_both_ways",
    69       "danger_intersection", "mandatory_go", "mandatory_keep",
    70       "danger_priority_next_intersection", "danger_uneven_road",
    71       "prohibitory_no_parking", "prohibitory_on_overtaking",
    72       "danger_pedestrian_crossing", "prohibitory_no_u_turn",
    73       "prohibitory_noturn" };
    74   /** The {@link JCheckBox} where the respective tag should be searched */
    75   private final JCheckBox[] SIGN_CHECKBOXES = { this.signFilter.maxSpeed,
    76       this.signFilter.stop, this.signFilter.giveWay,
    77       this.signFilter.roundabout, this.signFilter.access,
    78       this.signFilter.access, this.signFilter.intersection,
    79       this.signFilter.direction, this.signFilter.direction,
    80       this.signFilter.intersection, this.signFilter.uneven,
    81       this.signFilter.noParking, this.signFilter.noOvertaking,
    82       this.signFilter.crossing, this.signFilter.noTurn, this.signFilter.noTurn };
     65  /**
     66   * The list of sign names
     67   */
     68  private static final String[] SIGN_TAGS = {"prohibitory_speed_limit",
     69          "priority_stop", "other_give_way", "mandatory_roundabout",
     70          "other_no_entry", "prohibitory_no_traffic_both_ways",
     71          "danger_intersection", "mandatory_go", "mandatory_keep",
     72          "danger_priority_next_intersection", "danger_uneven_road",
     73          "prohibitory_no_parking", "prohibitory_on_overtaking",
     74          "danger_pedestrian_crossing", "prohibitory_no_u_turn",
     75          "prohibitory_noturn"};
     76  /**
     77   * The {@link JCheckBox} where the respective tag should be searched
     78   */
     79  private final JCheckBox[] SIGN_CHECKBOXES = {this.signFilter.maxSpeed,
     80          this.signFilter.stop, this.signFilter.giveWay,
     81          this.signFilter.roundabout, this.signFilter.access,
     82          this.signFilter.access, this.signFilter.intersection,
     83          this.signFilter.direction, this.signFilter.direction,
     84          this.signFilter.intersection, this.signFilter.uneven,
     85          this.signFilter.noParking, this.signFilter.noOvertaking,
     86          this.signFilter.crossing, this.signFilter.noTurn, this.signFilter.noTurn};
    8387
    8488  private MapillaryFilterDialog() {
    8589    super(tr("Mapillary filter"), "mapillaryfilter.png",
    86         tr("Open Mapillary filter dialog"), Shortcut.registerShortcut(
    87             tr("Mapillary filter"), tr("Open Mapillary filter dialog"),
    88             KeyEvent.VK_M, Shortcut.NONE), 200);
     90            tr("Open Mapillary filter dialog"), Shortcut.registerShortcut(
     91                    tr("Mapillary filter"), tr("Open Mapillary filter dialog"),
     92                    KeyEvent.VK_M, Shortcut.NONE), 200);
    8993
    9094    this.signChooser.setEnabled(false);
     
    112116
    113117    JPanel panel = new JPanel();
    114     JPanel col1 = new JPanel(new GridLayout(2, 1));
    115     col1.add(this.downloaded);
    116     col1.add(fromPanel);
    117     panel.add(col1);
    118     JPanel col2 = new JPanel(new GridLayout(2, 1));
    119     col2.add(this.imported);
    120     col2.add(userSearchPanel);
    121     panel.add(col2);
    122     JPanel col3 = new JPanel(new GridLayout(2, 1));
    123     col3.add(this.onlySigns);
    124     col3.add(signChooserPanel);
    125     panel.add(col3);
    126 
    127     createLayout(panel, true, Arrays.asList(new SideButton[] { updateButton, resetButton }));
     118    panel.setLayout(new GridBagLayout());
     119    GridBagConstraints c = new GridBagConstraints();
     120    c.anchor = GridBagConstraints.LINE_START;
     121    panel.add(this.downloaded, c);
     122    c.gridx = 1;
     123    panel.add(this.imported, c);
     124    c.gridx = 0;
     125    c.gridy = 1;
     126    c.gridwidth = 2;
     127    panel.add(fromPanel, c);
     128    c.gridy = 2;
     129    panel.add(userSearchPanel, c);
     130    c.gridwidth = 1;
     131    c.gridy = 3;
     132    panel.add(this.onlySigns, c);
     133    c.gridx = 1;
     134    panel.add(signChooserPanel, c);
     135
     136    createLayout(panel, true, Arrays.asList(new SideButton[]{updateButton, resetButton}));
    128137  }
    129138
     
    191200        }
    192201        if (!"".equals(user.getText())
    193             && !this.user.getText().equals(((MapillaryImage) img).getUser())) {
     202                && !this.user.getText().equals(((MapillaryImage) img).getUser())) {
    194203          img.setVisible(false);
    195204          continue;
     
    199208      Long currentTime = currentTime();
    200209      long[] timeFactor = new long[]{
    201           31_536_000_000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year
    202           2_592_000_000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month
    203           86_400_000 // = 24 * 60 * 60 * 1000 = number of ms in a day
     210              31_536_000_000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year
     211              2_592_000_000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month
     212              86_400_000 // = 24 * 60 * 60 * 1000 = number of ms in a day
    204213      };
    205214      for (int i = 1; i <= 3; i++) {
    206215        if (TIME_LIST[i].equals(time.getSelectedItem())
    207             && img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * timeFactor[i - 1]
    208         ) {
     216                && img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * timeFactor[i - 1]
     217                ) {
    209218          img.setVisible(false);
    210219        }
     
    217226   * Checks if the image fulfills the sign conditions.
    218227   *
    219    * @param img
    220    *          The {@link MapillaryAbstractImage} object that is going to be
    221    *          checked.
     228   * @param img The {@link MapillaryAbstractImage} object that is going to be
     229   *            checked.
    222230   * @return {@code true} if it fulfills the conditions; {@code false}
    223    *         otherwise.
     231   * otherwise.
    224232   */
    225233  private boolean checkSigns(MapillaryImage img) {
     
    307315   *
    308316   * @author nokutu
    309    *
    310317   */
    311318  private class SignChooserAction extends AbstractAction {
     
    321328      JPanel dialog = MapillaryFilterChooseSigns.getInstance();
    322329      JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE,
    323           JOptionPane.OK_CANCEL_OPTION);
     330              JOptionPane.OK_CANCEL_OPTION);
    324331      JDialog dlg = pane.createDialog(Main.parent, tr("Choose signs"));
    325332      dlg.setVisible(true);
Note: See TracChangeset for help on using the changeset viewer.