Пример #1
0
  private DeleteParameters getDeleteParameters(MouseEvent e, int modifiers) {
    updateKeyModifiers(modifiers);

    DeleteParameters result = new DeleteParameters();

    result.nearestNode =
        Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive.isSelectablePredicate);
    if (result.nearestNode == null) {
      result.nearestSegment =
          Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive.isSelectablePredicate);
      if (result.nearestSegment != null) {
        if (shift) {
          result.mode = DeleteMode.segment;
        } else if (ctrl) {
          result.mode = DeleteMode.way_with_references;
        } else {
          result.mode = alt ? DeleteMode.way : DeleteMode.way_with_nodes;
        }
      } else {
        result.mode = DeleteMode.none;
      }
    } else if (ctrl) {
      result.mode = DeleteMode.node_with_references;
    } else {
      result.mode = DeleteMode.node;
    }

    return result;
  }
Пример #2
0
  private DeleteParameters getDeleteParameters(MouseEvent e, int modifiers) {
    // Note: CTRL is the only modifier that is checked in MouseMove, don't
    // forget updating it there
    boolean ctrl = (modifiers & ActionEvent.CTRL_MASK) != 0;
    boolean shift = (modifiers & ActionEvent.SHIFT_MASK) != 0;
    boolean alt = (modifiers & (ActionEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0;

    DeleteParameters result = new DeleteParameters();

    result.nearestNode =
        Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive.isSelectablePredicate);
    if (result.nearestNode == null) {
      result.nearestSegment =
          Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive.isSelectablePredicate);
      if (result.nearestSegment != null) {
        if (shift) {
          result.mode = DeleteMode.segment;
        } else if (ctrl) {
          result.mode = DeleteMode.way_with_references;
        } else {
          result.mode = alt ? DeleteMode.way : DeleteMode.way_with_nodes;
        }
      } else {
        result.mode = DeleteMode.none;
      }
    } else if (ctrl) {
      result.mode = DeleteMode.node_with_references;
    } else {
      result.mode = DeleteMode.node;
    }

    return result;
  }