コード例 #1
0
  private void arrowKeyUp(KeyUpEvent event) {
    if (!diagramPane.getPopupMenu().isShowing()) {
      int x = 0;
      int y = 0;

      if (event.isLeftArrow()) {
        x = Parameters.MOVEX;
      } else if (event.isRightArrow()) {
        x = -Parameters.MOVEX;
      } else if (event.isUpArrow()) {
        y = Parameters.MOVEY;
      } else if (event.isDownArrow()) {
        y = -Parameters.MOVEY;
      }

      diagramPane.translate(x, y);
      diagramPane.update();
    }
  }
コード例 #2
0
  private void mouseWheel(MouseWheelEvent event) {
    if (diagramPane.getPopupMenu().isShowing() || ignoreMouseWheelEvent) return;

    Timer stopIgnoringEventTimer =
        new Timer() {

          @Override
          public void run() {
            ignoreMouseWheelEvent = false;
          }
        };
    ignoreMouseWheelEvent = true;
    stopIgnoringEventTimer.schedule(250);

    Point scrollPoint = new Point(event.getX(), event.getY());

    if (event.getDeltaY() < 0) {
      diagramPane.zoomIn(scrollPoint);
    } else if (event.getDeltaY() > 0) {
      diagramPane.zoomOut(scrollPoint);
    }

    diagramPane.update();
  }