Example #1
0
  /**
   * Set the {@link ucar.visad.display.DisplayMaster}
   *
   * @param master The display master
   */
  protected void setDisplayMaster(DisplayMaster master) {
    super.setDisplayMaster(master);

    try {
      NavigatedDisplay navDisplay = (NavigatedDisplay) master;

      if (tmpVertRangeUnit != null) {
        navDisplay.setVerticalRangeUnit(tmpVertRangeUnit);
      }

      if (tmpVerticalRange != null) {
        navDisplay.setVerticalRange(tmpVerticalRange[0], tmpVerticalRange[1]);
      }

      navDisplay.setCursorStringOn(false);
      final RubberBandBox rbb = navDisplay.getRubberBandBox();
      if (rbb != null) {
        rbb.addAction(
            new ActionImpl("Box Change") {
              public void doAction() throws VisADException, RemoteException {
                Gridded2DSet bounds = rbb.getBounds();
                if (bounds != null) {
                  rubberBandBoxChanged();
                }
              }
            });
      }
    } catch (Exception e) {
      logException("setDisplayMaster", e);
    }
  }
Example #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]);
      }
    }
  }