Пример #1
0
  /**
   * Respond to <code>ControlEvent</code>s.
   *
   * @param e <code>ControlEvent</code> to respond to
   */
  protected void handleControlChanged(ControlEvent e) {
    checkHistoryMatrix();

    NavigatedDisplay navDisplay = getNavigatedDisplay();

    if ((lastVerticalRangeUnit != null) && (lastVerticalRange != null)) {
      if (!(Misc.equals(lastVerticalRangeUnit, navDisplay.getVerticalRangeUnit())
          && Arrays.equals(lastVerticalRange, navDisplay.getVerticalRange()))) {
        verticalRangeChanged();
      }
    }

    lastVerticalRangeUnit = navDisplay.getVerticalRangeUnit();
    lastVerticalRange = navDisplay.getVerticalRange();
    super.handleControlChanged(e);
  }
Пример #2
0
  /**
   * Set the vertical range unit from the preference
   *
   * @param nd navigated display to set the unit on
   * @throws RemoteException problem with remote display
   * @throws VisADException problem with local display
   */
  protected void setVerticalRangeUnitPreference(NavigatedDisplay nd)
      throws VisADException, RemoteException {
    Unit u = null;

    try {
      u =
          ucar.visad.Util.parseUnit(
              getIdv().getObjectStore().get(IdvConstants.PREF_VERTICALUNIT, "m"));
    } catch (Exception exc) {
      u = null;
    }

    if (u != null) {
      double[] range = nd.getVerticalRange();
      Unit defaultUnit = nd.getVerticalRangeUnit();

      if (!u.equals(defaultUnit) && Unit.canConvert(u, defaultUnit)) {
        range = u.toThis(range, defaultUnit);
        nd.setVerticalRangeUnit(u);
        nd.setVerticalRange(range[0], range[1]);
      }
    }
  }