Changeset 34183 in osm
- Timestamp:
- 2018-05-10T09:01:33+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/EdgeSelectionAction.java
r34117 r34183 41 41 private Cursor selectionCursor; 42 42 private Cursor waySelectCursor; 43 private List<Way> edgeList; 43 44 44 45 public EdgeSelectionAction() { … … 47 48 ImageProvider.getCursor("normal", "selection")); 48 49 highlighted = new HashSet<>(); 50 edgeList = new ArrayList<>(); 49 51 50 52 selectionCursor = ImageProvider.getCursor("normal", "selection"); … … 133 135 134 136 @Override 135 137 public void mouseClicked(MouseEvent e) { 136 138 137 139 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 138 140 Way initial = MainApplication.getMap().mapView.getNearestWay(e.getPoint(), OsmPrimitive::isUsable); 139 if (initial != null) { 140 List<Way> edge = getEdgeFromWay(initial, getModeOfTravel()); 141 ds.setSelected(edge); 142 AutoScaleAction.zoomTo( 141 updateKeyModifiers(e); 142 if(!shift && !ctrl) { 143 /* 144 * remove all previous selection and just add the latest selection 145 */ 146 edgeList.clear(); 147 ds.clearSelection(); 148 if (initial != null) { 149 List<Way> edge = getEdgeFromWay(initial, getModeOfTravel()); 150 for(Way way:edge) { 151 if (!edgeList.contains(way)) 152 edgeList.add(way); 153 } 154 edgeList.addAll(edge); 155 ds.setSelected(edgeList); 156 AutoScaleAction.zoomTo( 157 edge.stream() 158 .map(w -> (OsmPrimitive) w) 159 .collect(Collectors.toList())); 160 } 161 162 } else if (!shift && ctrl) { 163 /* 164 * toggle mode where we can individually select and deselect the edges 165 */ 166 List<Way> edge = getEdgeFromWay(initial, getModeOfTravel()); 167 if (edgeList.containsAll(edge)) { 168 System.out.println(edgeList.size()); 169 for(Way way:edge) { 170 if (edgeList.contains(way)) 171 edgeList.remove(way); 172 } 173 } else { 174 for(Way way:edge) { 175 if (!edgeList.contains(way)) 176 edgeList.add(way); 177 } 178 } 179 ds.clearSelection(); 180 ds.setSelected(edgeList); 181 AutoScaleAction.zoomTo( 143 182 edge.stream() 144 183 .map(w -> (OsmPrimitive) w) 145 .collect(Collectors.toList())); 146 } else 147 ds.clearSelection(); 184 .collect(Collectors.toList()) 185 ); 186 } else if (shift && !ctrl) { 187 /* 188 * add new selection to existing edges 189 */ 190 if (initial != null) { 191 List<Way> edge = getEdgeFromWay(initial, getModeOfTravel()); 192 for(Way way:edge) { 193 if (!edgeList.contains(way)) 194 edgeList.add(way); 195 } 196 edgeList.addAll(edge); 197 ds.setSelected(edgeList); 198 AutoScaleAction.zoomTo( 199 edge.stream() 200 .map(w -> (OsmPrimitive) w) 201 .collect(Collectors.toList())); 202 } 203 } 204 148 205 } 149 206 … … 183 240 MainApplication.getMap().mapView.removeMouseMotionListener(this); 184 241 } 242 185 243 }
Note:
See TracChangeset
for help on using the changeset viewer.