コード例 #1
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * Center the view managers in the list to the given point
  *
  * @param el Point to center to
  * @param viewManagers ViewManagers to center
  * @throws RemoteException On badness
  * @throws VisADException On badness
  */
 public void center(EarthLocation el, List viewManagers) throws VisADException, RemoteException {
   for (int i = 0; i < viewManagers.size(); i++) {
     ViewManager viewManager = (ViewManager) viewManagers.get(i);
     if (!(viewManager instanceof MapViewManager)) {
       continue;
     }
     NavigatedDisplay navDisplay =
         (NavigatedDisplay) ((MapViewManager) viewManager).getMapDisplay();
     navDisplay.center(el);
   }
 }
コード例 #2
0
ファイル: NavigatedViewManager.java プロジェクト: ethanrd/IDV
  /**
   * 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);
  }