Пример #1
0
    public void mousePressed(MouseEvent event) {
      int x = event.getX() / panel.getZoom();
      int y = event.getY() / panel.getZoom();

      try {
        if (event.isControlDown() || SwingUtilities.isRightMouseButton(event)) {
          // treat right-clicks and control-left-clicks as the same (for Mac users)
          if (event.isShiftDown()) {
            list.deleteAll(x, y);
          } else {
            list.delete(x, y);
          }
        } else {
          if (event.isShiftDown()) {
            list.lower(x, y);
          } else {
            list.raise(x, y);
          }
        }

        // repaint all of the tiles
        panel.clear();
        Graphics g = panel.getGraphics();
        list.drawAll(g);
      } catch (RuntimeException e) {
        if (CATCH_EXCEPTIONS) {
          e.printStackTrace(System.err);
        } else {
          throw e;
        }
      }
    }