Пример #1
0
  /** Handle an animation time change */
  protected void animationTimeChanged() {
    super.animationTimeChanged();

    if (cursorReadoutWindow != null) {
      cursorReadoutWindow.updateReadout();
    }
  }
Пример #2
0
  /**
   * An implementation of the the DisplayListener interface. This method turns on/off the wait
   * cursor when it gets a WAIT_ON or WAIT_OFF event. It also, when it receives a FRAME_DONE event
   * for the fist time, calls <code>firstFrameDone</code> on the {@link DisplayControl}s
   *
   * @param de The <code>DisplayEvent</code>
   * @throws RemoteException
   * @throws VisADException
   */
  public void displayChanged(DisplayEvent de) throws VisADException, RemoteException {
    if (getIsDestroyed()) {
      return;
    }

    int eventId = de.getId();
    InputEvent inputEvent = de.getInputEvent();

    if ((inputEvent instanceof MouseEvent) && (eventId == DisplayEvent.MOUSE_PRESSED)) {
      mousePressedTime = System.currentTimeMillis();
      getViewpointControl().setAutoRotate(false);
      startMoveMatrix = getProjectionControl().getMatrix();

      MouseEvent mouseEvent = (MouseEvent) inputEvent;

      mouseStartPoint = new Point(mouseEvent.getX(), mouseEvent.getY());

      if ((mouseEvent.getClickCount() > 1) && mouseEvent.isShiftDown()) {
        NavigatedDisplay navDisplay = getNavigatedDisplay();
        double[] box =
            navDisplay.getSpatialCoordinatesFromScreen(mouseEvent.getX(), mouseEvent.getY());

        navDisplay.center(navDisplay.getEarthLocation(box));
      }
    }

    if ((eventId == DisplayEvent.MOUSE_PRESSED) || (eventId == DisplayEvent.MOUSE_DRAGGED)) {
      mouseMovedTime = System.currentTimeMillis();

      MouseEvent mouseEvent = (MouseEvent) inputEvent;
      int[][][] functionMap = getMaster().getMouseFunctionMap();

      if (functionMap != null) {
        int ctrlIdx = (GuiUtils.isControlKey(mouseEvent) ? 1 : 0);
        int shiftIdx = (mouseEvent.isShiftDown() ? 1 : 0);
        int mouseIdx =
            ((SwingUtilities.isLeftMouseButton(mouseEvent)
                    && !SwingUtilities.isRightMouseButton(mouseEvent))
                ? 0
                : (SwingUtilities.isMiddleMouseButton(mouseEvent)
                    ? 1
                    : ((SwingUtilities.isRightMouseButton(mouseEvent)
                            && !SwingUtilities.isLeftMouseButton(mouseEvent))
                        ? 2
                        : 1)));
        int function = functionMap[mouseIdx][ctrlIdx][shiftIdx];

        if (function == MouseHelper.CURSOR_TRANSLATE) {
          if (cursorReadoutWindow == null) {
            cursorReadoutWindow = new CursorReadoutWindow(this);
          }

          cursorReadoutWindow.handleMousePressedOrDragged(mouseEvent);
        }
      }
    } else if (eventId == DisplayEvent.MOUSE_RELEASED) {
      MouseEvent mouseEvent = (MouseEvent) inputEvent;

      if (cursorReadoutWindow != null) {
        cursorReadoutWindow.handleMouseReleased(mouseEvent);
        cursorReadoutWindow = null;
      }

      Point mouseStart = mouseStartPoint;

      if (mouseStart != null) {
        Point toPoint = new Point(mouseEvent.getX(), mouseEvent.getY());
        double distance = GuiUtils.distance(mouseStart.x, mouseStart.y, toPoint.x, toPoint.y);
        long deltaTime = System.currentTimeMillis() - mouseMovedTime;

        if (System.currentTimeMillis() - mousePressedTime > 0) {
          double speed = distance / (System.currentTimeMillis() - mousePressedTime);

          if ((distance > 50) && (deltaTime < 200) && (speed > 0.5)) {
            double[] endMatrix = getProjectionControl().getMatrix();

            mouseFlicked(mouseStart, toPoint, startMoveMatrix, endMatrix, speed);
          }
        }
      }

      mouseMovedTime = -1;
    }

    super.displayChanged(de);
  }