Changeset 12517 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-07-26T23:18:38+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r12504 r12517 26 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 27 import org.openstreetmap.josm.gui.util.HighlightHelper; 28 import org.openstreetmap.josm.gui.util.Modifier Listener;28 import org.openstreetmap.josm.gui.util.ModifierExListener; 29 29 import org.openstreetmap.josm.tools.CheckParameterUtil; 30 30 import org.openstreetmap.josm.tools.ImageProvider; … … 45 45 * @author imi 46 46 */ 47 public class DeleteAction extends MapMode implements Modifier Listener {47 public class DeleteAction extends MapMode implements ModifierExListener { 48 48 // Cache previous mouse event (needed when only the modifier keys are pressed but the mouse isn't moved) 49 49 private MouseEvent oldEvent; … … 113 113 Main.map.mapView.addMouseMotionListener(this); 114 114 // This is required to update the cursors when ctrl/shift/alt is pressed 115 Main.map.keyDetector.addModifier Listener(this);115 Main.map.keyDetector.addModifierExListener(this); 116 116 } 117 117 … … 121 121 Main.map.mapView.removeMouseListener(this); 122 122 Main.map.mapView.removeMouseMotionListener(this); 123 Main.map.keyDetector.removeModifier Listener(this);123 Main.map.keyDetector.removeModifierExListener(this); 124 124 removeHighlighting(); 125 125 } … … 188 188 * segments for the given pointer position (via MouseEvent) and modifiers. 189 189 * @param e current mouse event 190 * @param modifiers mouse modifiers, not necessarly taken from the given mouse event190 * @param modifiers extended mouse modifiers, not necessarly taken from the given mouse event 191 191 */ 192 192 private void addHighlighting(MouseEvent e, int modifiers) { … … 242 242 * 243 243 * @param e current mouse event 244 * @param modifiers mouse modifiers, not necessarly taken from the given mouse event244 * @param modifiers extended mouse modifiers, not necessarly taken from the given mouse event 245 245 */ 246 246 private void updateCursor(MouseEvent e, int modifiers) { … … 278 278 */ 279 279 private void giveUserFeedback(MouseEvent e) { 280 giveUserFeedback(e, e.getModifiers ());280 giveUserFeedback(e, e.getModifiersEx()); 281 281 } 282 282 … … 359 359 360 360 private DeleteParameters getDeleteParameters(MouseEvent e, int modifiers) { 361 updateKeyModifiers (modifiers);361 updateKeyModifiersEx(modifiers); 362 362 363 363 DeleteParameters result = new DeleteParameters(); … … 419 419 */ 420 420 @Override 421 public void modifiers Changed(int modifiers) {421 public void modifiersExChanged(int modifiers) { 422 422 if (oldEvent == null) 423 423 return; -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r12425 r12517 63 63 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 64 64 import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; 65 import org.openstreetmap.josm.gui.util.Modifier Listener;65 import org.openstreetmap.josm.gui.util.ModifierExListener; 66 66 import org.openstreetmap.josm.tools.Geometry; 67 67 import org.openstreetmap.josm.tools.ImageProvider; … … 73 73 * Mapmode to add nodes, create and extend ways. 74 74 */ 75 public class DrawAction extends MapMode implements MapViewPaintable, DataSelectionListener, KeyPressReleaseListener, Modifier Listener {75 public class DrawAction extends MapMode implements MapViewPaintable, DataSelectionListener, KeyPressReleaseListener, ModifierExListener { 76 76 77 77 /** … … 279 279 280 280 Main.map.keyDetector.addKeyListener(this); 281 Main.map.keyDetector.addModifier Listener(this);281 Main.map.keyDetector.addModifierExListener(this); 282 282 ignoreNextKeyRelease = true; 283 283 } … … 299 299 removeHighlighting(); 300 300 Main.map.keyDetector.removeKeyListener(this); 301 Main.map.keyDetector.removeModifier Listener(this);301 Main.map.keyDetector.removeModifierExListener(this); 302 302 } 303 303 … … 306 306 */ 307 307 @Override 308 public void modifiers Changed(int modifiers) {308 public void modifiersExChanged(int modifiers) { 309 309 if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable()) 310 310 return; 311 updateKeyModifiers (modifiers);311 updateKeyModifiersEx(modifiers); 312 312 computeHelperLine(); 313 313 addHighlighting(); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r12512 r12517 54 54 import org.openstreetmap.josm.gui.util.GuiHelper; 55 55 import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; 56 import org.openstreetmap.josm.gui.util.Modifier Listener;56 import org.openstreetmap.josm.gui.util.ModifierExListener; 57 57 import org.openstreetmap.josm.tools.Geometry; 58 58 import org.openstreetmap.josm.tools.ImageProvider; … … 62 62 * Makes a rectangle from a line, or modifies a rectangle. 63 63 */ 64 public class ExtrudeAction extends MapMode implements MapViewPaintable, KeyPressReleaseListener, Modifier Listener {64 public class ExtrudeAction extends MapMode implements MapViewPaintable, KeyPressReleaseListener, ModifierExListener { 65 65 66 66 enum Mode { extrude, translate, select, create_new, translate_node } … … 296 296 ignoreNextKeyRelease = true; 297 297 Main.map.keyDetector.addKeyListener(this); 298 Main.map.keyDetector.addModifier Listener(this);298 Main.map.keyDetector.addModifierExListener(this); 299 299 } 300 300 … … 325 325 dualAlignCheckboxMenuItem.getAction().setEnabled(false); 326 326 Main.map.keyDetector.removeKeyListener(this); 327 Main.map.keyDetector.removeModifier Listener(this);327 Main.map.keyDetector.removeModifierExListener(this); 328 328 super.exitMode(); 329 329 } … … 337 337 */ 338 338 @Override 339 public void modifiers Changed(int modifiers) {339 public void modifiersExChanged(int modifiers) { 340 340 if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable()) 341 341 return; 342 updateKeyModifiers (modifiers);342 updateKeyModifiersEx(modifiers); 343 343 if (mode == Mode.select) { 344 344 Main.map.mapView.setNewCursor(ctrl ? cursorTranslate : alt ? cursorCreateNew : shift ? cursorCreateNodes : cursor, this); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r11978 r12517 46 46 import org.openstreetmap.josm.gui.layer.Layer; 47 47 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 48 import org.openstreetmap.josm.gui.util.Modifier Listener;48 import org.openstreetmap.josm.gui.util.ModifierExListener; 49 49 import org.openstreetmap.josm.tools.ImageProvider; 50 50 import org.openstreetmap.josm.tools.Pair; … … 55 55 */ 56 56 public class ImproveWayAccuracyAction extends MapMode implements 57 SelectionChangedListener, Modifier Listener {57 SelectionChangedListener, ModifierExListener { 58 58 59 59 private static final String CROSSHAIR = "crosshair"; … … 150 150 DataSet.addSelectionListener(this); 151 151 152 Main.map.keyDetector.addModifier Listener(this);152 Main.map.keyDetector.addModifierExListener(this); 153 153 } 154 154 … … 167 167 DataSet.removeSelectionListener(this); 168 168 169 Main.map.keyDetector.removeModifier Listener(this);169 Main.map.keyDetector.removeModifierExListener(this); 170 170 temporaryLayer.invalidate(); 171 171 } … … 344 344 // ------------------------------------------------------------------------- 345 345 @Override 346 public void modifiers Changed(int modifiers) {346 public void modifiersExChanged(int modifiers) { 347 347 if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable()) { 348 348 return; 349 349 } 350 updateKeyModifiers (modifiers);350 updateKeyModifiersEx(modifiers); 351 351 updateCursorDependentObjectsIfNeeded(); 352 352 updateCursor(); -
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r12483 r12517 151 151 152 152 protected void updateKeyModifiers(InputEvent e) { 153 updateKeyModifiers (e.getModifiers());153 updateKeyModifiersEx(e.getModifiersEx()); 154 154 } 155 155 156 156 protected void updateKeyModifiers(MouseEvent e) { 157 updateKeyModifiers(e.getModifiers()); 158 } 159 157 updateKeyModifiersEx(e.getModifiersEx()); 158 } 159 160 /** 161 * Update internal ctrl, alt, shift mask from given modifiers mask. 162 * @param modifiers event modifiers mask 163 * @deprecated use {@link #updateKeyModifiersEx} instead 164 */ 165 @Deprecated 160 166 protected void updateKeyModifiers(int modifiers) { 161 167 ctrl = (modifiers & ActionEvent.CTRL_MASK) != 0; 162 168 alt = (modifiers & (ActionEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0; 163 169 shift = (modifiers & ActionEvent.SHIFT_MASK) != 0; 170 } 171 172 /** 173 * Update internal ctrl, alt, shift mask from given extended modifiers mask. 174 * @param modifiers event extended modifiers mask 175 * @since 12516 176 */ 177 protected void updateKeyModifiersEx(int modifiers) { 178 ctrl = (modifiers & InputEvent.CTRL_DOWN_MASK) != 0; 179 alt = (modifiers & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK)) != 0; 180 shift = (modifiers & InputEvent.SHIFT_DOWN_MASK) != 0; 164 181 } 165 182 -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r12108 r12517 47 47 import org.openstreetmap.josm.gui.layer.Layer; 48 48 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 49 import org.openstreetmap.josm.gui.util.Modifier Listener;49 import org.openstreetmap.josm.gui.util.ModifierExListener; 50 50 import org.openstreetmap.josm.tools.CheckParameterUtil; 51 51 import org.openstreetmap.josm.tools.Geometry; … … 90 90 * @author Ole Jørgen Brønner (olejorgenb) 91 91 */ 92 public class ParallelWayAction extends MapMode implements Modifier Listener {92 public class ParallelWayAction extends MapMode implements ModifierExListener { 93 93 94 94 private static final CachingProperty<BasicStroke> HELPER_LINE_STROKE = new StrokeProperty(prefKey("stroke.hepler-line"), "1").cached(); … … 173 173 174 174 //// Needed to update the mouse cursor if modifiers are changed when the mouse is motionless 175 Main.map.keyDetector.addModifier Listener(this);175 Main.map.keyDetector.addModifierExListener(this); 176 176 sourceWays = new LinkedHashSet<>(getLayerManager().getEditDataSet().getSelectedWays()); 177 177 for (Way w : sourceWays) { … … 188 188 Main.map.statusLine.setDist(-1); 189 189 Main.map.statusLine.repaint(); 190 Main.map.keyDetector.removeModifier Listener(this);190 Main.map.keyDetector.removeModifierExListener(this); 191 191 removeWayHighlighting(sourceWays); 192 192 pWays = null; … … 216 216 217 217 @Override 218 public void modifiers Changed(int modifiers) {218 public void modifiersExChanged(int modifiers) { 219 219 if (Main.map == null || mv == null || !mv.isActiveLayerDrawable()) 220 220 return; … … 229 229 private boolean updateModifiersState(int modifiers) { 230 230 boolean oldAlt = alt, oldShift = shift, oldCtrl = ctrl; 231 updateKeyModifiers (modifiers);231 updateKeyModifiersEx(modifiers); 232 232 return oldAlt != alt || oldShift != shift || oldCtrl != ctrl; 233 233 } … … 275 275 public void mousePressed(MouseEvent e) { 276 276 requestFocusInMapView(); 277 updateModifiersState(e.getModifiers ());277 updateModifiersState(e.getModifiersEx()); 278 278 // Other buttons are off limit, but we still get events. 279 279 if (e.getButton() != MouseEvent.BUTTON1) … … 300 300 @Override 301 301 public void mouseReleased(MouseEvent e) { 302 updateModifiersState(e.getModifiers ());302 updateModifiersState(e.getModifiersEx()); 303 303 // Other buttons are off limit, but we still get events. 304 304 if (e.getButton() != MouseEvent.BUTTON1) … … 355 355 return; 356 356 357 boolean modifiersChanged = updateModifiersState(e.getModifiers ());357 boolean modifiersChanged = updateModifiersState(e.getModifiersEx()); 358 358 updateFlagsChangeableAlways(); 359 359 -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12316 r12517 49 49 import org.openstreetmap.josm.gui.util.GuiHelper; 50 50 import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; 51 import org.openstreetmap.josm.gui.util.Modifier Listener;51 import org.openstreetmap.josm.gui.util.ModifierExListener; 52 52 import org.openstreetmap.josm.tools.ImageProvider; 53 53 import org.openstreetmap.josm.tools.Pair; … … 66 66 * feature "selection remove" is disabled on this platform. 67 67 */ 68 public class SelectAction extends MapMode implements Modifier Listener, KeyPressReleaseListener, SelectionEnded {68 public class SelectAction extends MapMode implements ModifierExListener, KeyPressReleaseListener, SelectionEnded { 69 69 70 70 private static final String NORMAL = "normal"; … … 208 208 virtualManager.init(); 209 209 // This is required to update the cursors when ctrl/shift/alt is pressed 210 Main.map.keyDetector.addModifier Listener(this);210 Main.map.keyDetector.addModifierExListener(this); 211 211 Main.map.keyDetector.addKeyListener(this); 212 212 } … … 219 219 mv.removeMouseMotionListener(this); 220 220 mv.setVirtualNodesEnabled(false); 221 Main.map.keyDetector.removeModifier Listener(this);221 Main.map.keyDetector.removeModifierExListener(this); 222 222 Main.map.keyDetector.removeKeyListener(this); 223 223 removeHighlighting(); … … 225 225 226 226 @Override 227 public void modifiers Changed(int modifiers) {227 public void modifiersExChanged(int modifiers) { 228 228 if (!Main.isDisplayingMapView() || oldEvent == null) return; 229 229 if (giveUserFeedback(oldEvent, modifiers)) { … … 239 239 */ 240 240 private boolean giveUserFeedback(MouseEvent e) { 241 return giveUserFeedback(e, e.getModifiers ());241 return giveUserFeedback(e, e.getModifiersEx()); 242 242 } 243 243 … … 246 246 * Please note that the highlighting for merging while moving is handled via mouseDragged. 247 247 * @param e {@code MouseEvent} which should be used as base for the feedback 248 * @param modifiers define custom keyboard modifiers if the ones from MouseEvent are outdated or similar248 * @param modifiers define custom keyboard extended modifiers if the ones from MouseEvent are outdated or similar 249 249 * @return {@code true} if repaint is required 250 250 */ … … 253 253 mv.getNearestNodeOrWay(e.getPoint(), mv.isSelectablePredicate, true)); 254 254 255 updateKeyModifiers (modifiers);255 updateKeyModifiersEx(modifiers); 256 256 determineMapMode(!c.isEmpty()); 257 257 -
trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java
r11386 r12517 35 35 36 36 private final List<KeyPressReleaseListener> keyListeners = new CopyOnWriteArrayList<>(); 37 @Deprecated 37 38 private final List<ModifierListener> modifierListeners = new CopyOnWriteArrayList<>(); 39 private final List<ModifierExListener> modifierExListeners = new CopyOnWriteArrayList<>(); 38 40 private int previousModifiers; 41 private int previousModifiersEx; 39 42 40 43 private boolean enabled = true; … … 51 54 * Adds an object that wants to receive key modifier changed events. 52 55 * @param l listener to add 53 */ 56 * @deprecated use {@link #addModifierExListener} instead 57 */ 58 @Deprecated 54 59 public void addModifierListener(ModifierListener l) { 55 60 modifierListeners.add(l); … … 57 62 58 63 /** 64 * Adds an object that wants to receive extended key modifier changed events. 65 * @param l listener to add 66 * @since 12516 67 */ 68 public void addModifierExListener(ModifierExListener l) { 69 modifierExListeners.add(l); 70 } 71 72 /** 59 73 * Removes the listener. 60 74 * @param l listener to remove … … 67 81 * Removes the key modifier listener. 68 82 * @param l listener to remove 69 */ 83 * @deprecated use {@link #removeModifierExListener} instead 84 */ 85 @Deprecated 70 86 public void removeModifierListener(ModifierListener l) { 71 87 modifierListeners.remove(l); 88 } 89 90 /** 91 * Removes the extended key modifier listener. 92 * @param l listener to remove 93 * @since 12516 94 */ 95 public void removeModifierExListener(ModifierExListener l) { 96 modifierExListeners.remove(l); 72 97 } 73 98 … … 105 130 if (!modifierListeners.isEmpty()) { 106 131 Main.warn(tr("Some of the key modifier listeners forgot to remove themselves: {0}"), modifierListeners.toString()); 132 } 133 if (!modifierExListeners.isEmpty()) { 134 Main.warn(tr("Some of the key modifier listeners forgot to remove themselves: {0}"), modifierExListeners.toString()); 107 135 } 108 136 try { … … 147 175 148 176 @Override 177 @SuppressWarnings("deprecation") 149 178 public void eventDispatched(AWTEvent e) { 150 179 if (!(e instanceof KeyEvent)) { … … 162 191 } 163 192 193 // check if ctrl, alt, shift extended modifiers are changed 194 int modifEx = ke.getModifiersEx(); 195 if (previousModifiersEx != modifEx) { 196 previousModifiersEx = modifEx; 197 for (ModifierExListener m: modifierExListeners) { 198 m.modifiersExChanged(modifEx); 199 } 200 } 201 164 202 processKeyEvent(ke); 165 203 } -
trunk/src/org/openstreetmap/josm/gui/util/ModifierListener.java
r12304 r12517 6 6 * @since 7217 7 7 * @since 10600 (functional interface) 8 * @deprecated use ModifierExListener instead 8 9 */ 10 @Deprecated 9 11 @FunctionalInterface 10 12 public interface ModifierListener {
Note:
See TracChangeset
for help on using the changeset viewer.