Changeset 31805 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-12-10T22:11:32+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Fix #12044 (Duplicate give way in MapillaryFilterChooseSigns dialog)

Location:
applications/editors/josm/plugins/mapillary
Files:
1 edited
1 moved

Legend:

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

    r31797 r31805  
    1818 *
    1919 */
    20 public class MapillaryFilterChooseSigns extends JPanel {
     20public final class MapillaryFilterChooseSigns extends JPanel {
    2121
    2222  private static final long serialVersionUID = -3513805549022406720L;
     
    5050
    5151  private MapillaryFilterChooseSigns() {
    52     this.maxSpeed.setSelected(true);
    53     this.stop.setSelected(true);
    54     this.giveWay.setSelected(true);
    55     this.roundabout.setSelected(true);
    56     this.access.setSelected(true);
    57     this.intersection.setSelected(true);
    58     this.direction.setSelected(true);
    59     this.uneven.setSelected(true);
    60     this.noParking.setSelected(true);
    61     this.noOvertaking.setSelected(true);
    62     this.crossing.setSelected(true);
    63     this.noTurn.setSelected(true);
     52    addCheckBoxWithLabel(this, maxSpeed, true, "signs/speed.png", tr("Speed limit"));
     53    addCheckBoxWithLabel(this, stop, true, "signs/stop.png", tr("Stop"));
     54    addCheckBoxWithLabel(this, giveWay, true, "signs/right_of_way.png", tr("Give way"));
     55    addCheckBoxWithLabel(this, roundabout, true, "signs/roundabout_right.png", tr("Roundabout"));
     56    addCheckBoxWithLabel(this, access, true, "signs/no_entry.png", tr("No entry"));
     57    addCheckBoxWithLabel(this, intersection, true, "signs/intersection_danger.png", tr("Intersection danger"));
     58    addCheckBoxWithLabel(this, direction, true, "signs/only_straight_on.png", tr("Mandatory direction (any)"));
     59    addCheckBoxWithLabel(this, uneven, true, "signs/uneven.png", tr("Uneven road"));
     60    addCheckBoxWithLabel(this, noParking, true, "signs/no_parking.png", tr("No parking"));
     61    addCheckBoxWithLabel(this, noOvertaking, true, "signs/no_overtaking.png", tr("No overtaking"));
     62    addCheckBoxWithLabel(this, crossing, true, "signs/crossing.png", tr("Pedestrian crossing"));
     63    addCheckBoxWithLabel(this, noTurn, true, "signs/no_turn.png", tr("No turn"));
    6464
    65     // Max speed sign
    66     JPanel maxspeedPanel = new JPanel();
    67     JLabel maxspeedLabel = new JLabel(tr("Speed limit"));
    68     maxspeedLabel.setIcon(new ImageProvider("signs/speed.png").get());
    69     maxspeedPanel.add(maxspeedLabel);
    70     maxspeedPanel.add(this.maxSpeed);
    71     this.add(maxspeedPanel);
     65    setPreferredSize(new Dimension(600, 150));
     66  }
    7267
    73     // Stop sign
    74     JPanel stopPanel = new JPanel();
    75     JLabel stopLabel = new JLabel(tr("Stop"));
    76     stopLabel.setIcon(new ImageProvider("signs/stop.png").get());
    77     stopPanel.add(stopLabel);
    78     stopPanel.add(this.stop);
    79     this.add(stopPanel);
     68  private void addCheckBoxWithLabel(final JPanel parentPanel, final JCheckBox checkBox,
     69      final boolean isSelected, final String iconPath,  final String labelText) {
     70    final JPanel checkBoxPanel = new JPanel();
     71    final JLabel checkBoxLabel = new JLabel(labelText);
    8072
    81     // Give way sign
    82     JPanel giveWayPanel = new JPanel();
    83     JLabel giveWayLabel = new JLabel(tr("Give way"));
    84     giveWayLabel.setIcon(new ImageProvider("signs/right_of_way.png").get());
    85     giveWayPanel.add(giveWayLabel);
    86     giveWayPanel.add(this.giveWay);
    87     this.add(giveWayPanel);
    88 
    89     // Roundabout sign
    90     JPanel roundaboutPanel = new JPanel();
    91     JLabel roundaboutLabel = new JLabel(tr("Give way"));
    92     roundaboutLabel.setIcon(new ImageProvider("signs/roundabout_right.png")
    93         .get());
    94     roundaboutPanel.add(roundaboutLabel);
    95     roundaboutPanel.add(this.roundabout);
    96     this.add(roundaboutPanel);
    97 
    98     // No entry sign
    99     JPanel noEntryPanel = new JPanel();
    100     JLabel noEntryLabel = new JLabel(tr("No entry"));
    101     noEntryLabel.setIcon(new ImageProvider("signs/no_entry.png").get());
    102     noEntryPanel.add(noEntryLabel);
    103     noEntryPanel.add(this.access);
    104     this.add(noEntryPanel);
    105 
    106     // Danger intersection
    107     JPanel intersectionPanel = new JPanel();
    108     JLabel intersectionLabel = new JLabel(tr("Intersection danger"));
    109     intersectionLabel
    110         .setIcon(new ImageProvider("signs/intersection_danger.png").get());
    111     intersectionPanel.add(intersectionLabel);
    112     intersectionPanel.add(this.intersection);
    113     this.add(intersectionPanel);
    114 
    115     // Mandatory direction
    116     JPanel directionPanel = new JPanel();
    117     JLabel directionLabel = new JLabel(tr("Mandatory direction (any)"));
    118     directionLabel.setIcon(new ImageProvider("signs/only_straight_on.png")
    119         .get());
    120     directionPanel.add(directionLabel);
    121     directionPanel.add(this.direction);
    122     this.add(directionPanel);
    123 
    124     // No turn
    125     JPanel noTurnPanel = new JPanel();
    126     JLabel noTurnLabel = new JLabel(tr("No turn"));
    127     noTurnLabel.setIcon(new ImageProvider("signs/no_turn.png").get());
    128     noTurnPanel.add(noTurnLabel);
    129     noTurnPanel.add(this.noTurn);
    130     this.add(noTurnPanel);
    131 
    132     // Uneven road
    133     JPanel unevenPanel = new JPanel();
    134     JLabel unevenLabel = new JLabel(tr("Uneven road"));
    135     unevenLabel.setIcon(new ImageProvider("signs/uneaven.png").get());
    136     unevenPanel.add(unevenLabel);
    137     unevenPanel.add(this.uneven);
    138     this.add(unevenPanel);
    139 
    140     // No parking
    141     JPanel noParkingPanel = new JPanel();
    142     JLabel noParkingLabel = new JLabel(tr("No parking"));
    143     noParkingLabel.setIcon(new ImageProvider("signs/no_parking.png").get());
    144     noParkingPanel.add(noParkingLabel);
    145     noParkingPanel.add(this.noParking);
    146     this.add(noParkingPanel);
    147 
    148     // No overtaking
    149     JPanel noOvertakingPanel = new JPanel();
    150     JLabel noOvertakingLabel = new JLabel(tr("No overtaking"));
    151     noOvertakingLabel.setIcon(new ImageProvider("signs/no_overtaking.png")
    152         .get());
    153     noOvertakingPanel.add(noOvertakingLabel);
    154     noOvertakingPanel.add(this.noOvertaking);
    155     this.add(noOvertakingPanel);
    156 
    157     // Pedestrian crossing
    158     JPanel crossingPanel = new JPanel();
    159     JLabel crossingLabel = new JLabel(tr("Pedestrian crossing"));
    160     crossingLabel.setIcon(new ImageProvider("signs/crossing.png").get());
    161     crossingPanel.add(crossingLabel);
    162     crossingPanel.add(this.crossing);
    163     this.add(crossingPanel);
    164 
    165     this.setPreferredSize(new Dimension(600, 150));
     73    checkBoxLabel.setIcon(new ImageProvider(iconPath).get());
     74    checkBoxLabel.setLabelFor(checkBox);
     75    checkBoxPanel.add(checkBoxLabel);
     76    checkBox.setSelected(isSelected);
     77    checkBoxPanel.add(checkBox);
     78    parentPanel.add(checkBoxPanel);
    16679  }
    16780
     
    16982   * Return the unique instance of the class.
    17083   *
    171    * @return THe unique instance of the class.
     84   * @return the unique instance of the class.
    17285   */
    173   public static MapillaryFilterChooseSigns getInstance() {
     86  public static synchronized MapillaryFilterChooseSigns getInstance() {
    17487    if (instance == null)
    17588      instance = new MapillaryFilterChooseSigns();
Note: See TracChangeset for help on using the changeset viewer.