Changeset 7966 in josm
- Timestamp:
- 2015-01-13T23:35:32+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r7937 r7966 11 11 import java.util.ArrayList; 12 12 import java.util.Collection; 13 import java.util.Collections; 14 import java.util.Comparator; 13 15 import java.util.Iterator; 14 16 import java.util.List; 15 import java.util.Set;16 import java.util.TreeSet;17 18 17 import javax.swing.Action; 19 18 import javax.swing.JComponent; … … 21 20 import javax.swing.JMenuItem; 22 21 import javax.swing.JPopupMenu; 23 import javax.swing.MenuElement;24 22 import javax.swing.event.MenuEvent; 25 23 import javax.swing.event.MenuListener; 26 27 24 import org.openstreetmap.josm.Main; 28 25 import org.openstreetmap.josm.actions.AddImageryLayerAction; … … 46 43 public class ImageryMenu extends JMenu implements LayerChangeListener { 47 44 45 /** 46 * Compare ImageryInfo objects alphabetically by name. 47 * 48 * ImageryInfo objects are normally sorted by country code first 49 * (for the preferences). We don't want this in the imagery menu. 50 */ 51 public static Comparator<ImageryInfo> alphabeticImageryComparator = new Comparator<ImageryInfo>() { 52 @Override 53 public int compare(ImageryInfo ii1, ImageryInfo ii2) { 54 return ii1.getName().toLowerCase().compareTo(ii2.getName().toLowerCase()); 55 } 56 }; 57 48 58 private Action offsetAction = new JosmAction( 49 59 tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false) { … … 134 144 135 145 // for each configured ImageryInfo, add a menu entry. 136 for (final ImageryInfo u : ImageryLayerInfo.instance.getLayers()) { 146 final List<ImageryInfo> savedLayers = new ArrayList<>(ImageryLayerInfo.instance.getLayers()); 147 Collections.sort(savedLayers, alphabeticImageryComparator); 148 for (final ImageryInfo u : savedLayers) { 137 149 addDynamic(new AddImageryLayerAction(u)); 138 150 } … … 143 155 MapView mv = Main.map.mapView; 144 156 LatLon pos = mv.getProjection().eastNorth2latlon(mv.getCenter()); 145 final Set<ImageryInfo> inViewLayers = new TreeSet<>();157 final List<ImageryInfo> inViewLayers = new ArrayList<>(); 146 158 147 159 for (ImageryInfo i : ImageryLayerInfo.instance.getDefaultLayers()) { … … 167 179 } 168 180 if (!inViewLayers.isEmpty()) { 181 Collections.sort(inViewLayers, alphabeticImageryComparator); 169 182 addDynamicSeparator(); 170 183 for (ImageryInfo i : inViewLayers) {
Note:
See TracChangeset
for help on using the changeset viewer.