@Override
  public void mouseDown(int constrainedX, int constrainedY, MouseEvent e) {
    originalX = e.getX();
    originalY = e.getY();
    tempX = constrainedX;
    tempY = constrainedY;

    // 0. check, whether a handle is selected
    lastSelectedFigure = null;
    currentHandle = view.getHandle(originalX, originalY, e);
    if (currentHandle != null) {
      currentHandle.startInteraction(constrainedX, constrainedY, e, view);
      return;
    }

    // 1. check, whether mouse position is near by an already
    //    selected figure; in this case keep selection
    if (!isNearSelected(originalX, originalY)) {

      // 2. if click is outside of existing selection then
      //    deselect all figures - except if shift is down
      //    (modifier used to extend selection)
      if (!e.isShiftDown()) {
        view.clearSelection();
      }

      // 3. look for new figures (which are not already
      //    selected) and select them. Only one figure.
      List<Figure> figures = new LinkedList<Figure>();
      for (Figure f : view.getModel().getFigures()) {
        figures.add(0, f);
      }
      for (Figure f : figures) {
        if (f.contains(originalX, originalY) && !view.getSelection().contains(f)) {
          view.addToSelection(f);
          lastSelectedFigure = f;
          break;
        }
      }

      // 4. if dragging mouse for spanning a selection, remember starting position (sx0, sy0) and
      // initialize
      //    current position (sx1, sy1).
      if (lastSelectedFigure == null && !e.isShiftDown()) {
        sx0 = originalX;
        sy0 = originalY;
        sx1 = originalX;
        sy1 = originalY;
        selMode = true;
      }
    }
    view.repaint();
  }