- Timestamp:
- 2021-03-20T11:50:08+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r16629 r17594 20 20 import java.util.stream.Collectors; 21 21 22 import javax.swing.JCheckBox; 22 23 import javax.swing.JComboBox; 23 24 import javax.swing.JOptionPane; … … 25 26 import javax.swing.JScrollPane; 26 27 28 import org.openstreetmap.josm.data.coor.LatLon; 27 29 import org.openstreetmap.josm.data.imagery.DefaultLayer; 28 30 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 203 205 private static LayerSelection askToSelectLayers(WMSImagery wms) { 204 206 final WMSLayerTree tree = new WMSLayerTree(); 205 tree.updateTree(wms);206 207 207 208 Collection<String> wmsFormats = wms.getFormats(); … … 209 210 formats.setSelectedItem(wms.getPreferredFormat()); 210 211 formats.setToolTipText(tr("Select image format for WMS layer")); 212 213 JCheckBox checkBounds = new JCheckBox(tr("Show only layers for current view"), true); 214 Runnable updateTree = () -> { 215 LatLon latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView() 216 ? MainApplication.getMap().mapView.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()) 217 : null; 218 tree.setCheckBounds(latLon); 219 tree.updateTree(wms); 220 System.out.println(wms); 221 }; 222 checkBounds.addActionListener(ignore -> updateTree.run()); 223 updateTree.run(); 211 224 212 225 if (!GraphicsEnvironment.isHeadless()) { … … 217 230 final JPanel panel = new JPanel(new GridBagLayout()); 218 231 panel.add(scrollPane, GBC.eol().fill()); 232 panel.add(checkBounds, GBC.eol().fill(GBC.HORIZONTAL)); 219 233 panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL)); 220 234 dialog.setContent(panel); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/WMSLayerTree.java
r13824 r17594 4 4 import java.awt.Component; 5 5 import java.util.Collection; 6 import java.util.Comparator; 6 7 import java.util.LinkedList; 7 8 import java.util.List; … … 16 17 import javax.swing.tree.TreePath; 17 18 19 import org.openstreetmap.josm.data.coor.LatLon; 18 20 import org.openstreetmap.josm.data.imagery.LayerDetails; 19 21 import org.openstreetmap.josm.io.imagery.WMSImagery; … … 27 29 private final JTree layerTree = new JTree(treeData); 28 30 private final List<LayerDetails> selectedLayers = new LinkedList<>(); 31 private LatLon checkBounds = null; 29 32 30 33 /** … … 60 63 } 61 64 65 /** 66 * Set coordinate to check {@linkplain LayerDetails#getBounds() layer bounds} 67 * when {@linkplain #updateTree updating the tree}. 68 * @param checkBounds the coordinate 69 */ 70 public void setCheckBounds(LatLon checkBounds) { 71 this.checkBounds = checkBounds; 72 } 73 62 74 void addLayersToTreeData(MutableTreeNode parent, Collection<LayerDetails> layers) { 63 75 for (LayerDetails layerDetails : layers.stream() 64 .sorted((l1, l2) -> -1 * l1.toString().compareTo(l2.toString())) 76 .filter(l -> checkBounds == null || l.getBounds() == null || l.getBounds().contains(checkBounds)) 77 .sorted(Comparator.comparing(LayerDetails::toString).reversed()) 65 78 .toArray(LayerDetails[]::new) 66 79 ) { … … 89 102 public void updateTreeList(Collection<LayerDetails> layers) { 90 103 addLayersToTreeData(getTreeRootNode(), layers); 104 treeData.nodeStructureChanged(getTreeRootNode()); 91 105 getLayerTree().expandRow(0); 92 106 getLayerTree().expandRow(1);
Note:
See TracChangeset
for help on using the changeset viewer.