Пример #1
0
  /**
   * The animation changed. Handle the change.
   *
   * @param evt The event
   */
  private void handleAnimationPropertyChange(PropertyChangeEvent evt) {
    //        System.err.println ("Handlechange:" +evt.getPropertyName());
    if (evt.getPropertyName().equals(Animation.ANI_VALUE)) {
      debug("handleAnimationPropertyChange value :" + evt.getPropertyName());
      Real eventValue = (Real) evt.getNewValue();
      // if there's nothing to do, return;
      if ((eventValue == null) || eventValue.isMissing()) {
        return;
      }

      /** The Animation associated with this widget */
      DateTime time = null;
      try {
        time = new DateTime(eventValue);
      } catch (VisADException ve) {;
      }
      final DateTime theDateTime = time;
      final int theIndex = ((anime != null) ? anime.getCurrent() : -1);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              boolean oldValue = ignoreTimesCbxEvents;
              try {
                ignoreTimesCbxEvents = true;
                //                        synchronized (timesCbxMutex) {
                xcnt++;

                timesCbx.setSelectedItem(theDateTime);
                //                        }
                if ((boxPanel != null) && (theIndex >= 0)) {
                  boxPanel.setOnIndex(theIndex);
                }
                timesCbx.repaint();
              } finally {
                ignoreTimesCbxEvents = oldValue;
              }
            }
          });
      shareValue();
    } else if (evt.getPropertyName().equals(Animation.ANI_SET)) {
      if (ignoreAnimationSetChange) {
        return;
      }
      updateIndicatorInner((Set) evt.getNewValue(), true);
    }
  }
Пример #2
0
 /**
  * Add to the properties list
  *
  * @param comps List of label/widgets
  * @param compMap Optional mapping to hold components for later access
  */
 protected void getPropertiesComponents(List comps, Hashtable compMap) {
   super.getPropertiesComponents(comps, compMap);
   startTextFld = new JTextField(startText, 5);
   endTextFld = new JTextField(endText, 5);
   comps.add(GuiUtils.rLabel("Start Label:"));
   comps.add(GuiUtils.left(startTextFld));
   comps.add(GuiUtils.rLabel("End Label:"));
   comps.add(GuiUtils.left(endTextFld));
   maxDistanceFld = null;
   tvm = null;
   if (viewDescriptor != null) {
     VMManager vmManager = control.getControlContext().getIdv().getVMManager();
     List vms = vmManager.getViewManagers(TransectViewManager.class);
     tvm = (TransectViewManager) VMManager.findViewManagerInList(viewDescriptor, vms);
     if ((tvm != null) && (maxDataDistance != null)) {
       maxDistanceFld =
           new JTextField(maxDataDistance.getValue() + " [" + maxDataDistance.getUnit() + "]", 15);
       maxDistanceFld.setToolTipText("Maximum distance shown. e.g.: value[unit]");
       comps.add(GuiUtils.rLabel("Max distance:"));
       comps.add(GuiUtils.left(maxDistanceFld));
     }
   }
 }
Пример #3
0
 /**
  * Check if we need to show/hide the max data distance box
  *
  * @throws RemoteException On badness
  * @throws VisADException On badness
  */
 public void checkBoxVisibility() throws VisADException, RemoteException {
   if (maxDistanceBox == null) {
     return;
   }
   if ((maxDataDistance == null) || !super.isVisible()) {
     maxDistanceBox.setVisible(false);
   } else {
     double km = maxDataDistance.getValue(CommonUnit.meter) / 1000.0;
     if (km > 2000) {
       maxDistanceBox.setVisible(false);
     } else {
       if (control != null) {
         maxDistanceBox.setVisible(control.shouldBeVisible(this));
       }
     }
   }
 }
Пример #4
0
  /**
   * Handle glyph moved
   *
   * @throws RemoteException On badness
   * @throws VisADException On badness
   */
  public void updateLocation() throws VisADException, RemoteException {
    super.updateLocation();
    if (points.size() < 2) {
      return;
    }
    if (showText) {
      setText(startTextDisplayable, 0, startText, startTextType);
      setText(endTextDisplayable, 1, endText, endTextType);
    }

    checkBoxVisibility();
    if ((maxDataDistance == null) || (maxDistanceBox == null)) {
      return;
    }
    double km = maxDataDistance.getValue(CommonUnit.meter) / 1000.0;
    if (km > 2000) {
      return;
    }

    EarthLocation p1 = (EarthLocation) points.get(0);
    EarthLocation p2 = (EarthLocation) points.get(1);

    MathType mathType = RealTupleType.LatitudeLongitudeAltitude;

    Bearing baseBearing =
        Bearing.calculateBearing(
            p1.getLatitude().getValue(),
            p1.getLongitude().getValue(),
            p2.getLatitude().getValue(),
            p2.getLongitude().getValue(),
            null);

    double baseAngle = baseBearing.getAngle();

    LatLonPointImpl[] llps =
        new LatLonPointImpl[] {
          Bearing.findPoint(
              p1.getLatitude().getValue(),
              p1.getLongitude().getValue(),
              baseAngle + 90.0,
              km,
              null),
          Bearing.findPoint(
              p2.getLatitude().getValue(),
              p2.getLongitude().getValue(),
              baseAngle + 90.0,
              km,
              null),
          Bearing.findPoint(
              p2.getLatitude().getValue(), p2.getLongitude().getValue(), baseAngle - 90, km, null),
          Bearing.findPoint(
              p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle - 90, km, null),
          Bearing.findPoint(
              p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle + 90.0, km, null)
        };

    float[][] lineVals = getPointValues();
    float alt = lineVals[2][0];
    lineVals = new float[3][llps.length];
    for (int i = 0; i < lineVals[0].length; i++) {
      lineVals[0][i] = (float) llps[i].getLatitude();
      lineVals[1][i] = (float) llps[i].getLongitude();
    }

    float[][] tmp = new float[3][];

    for (int i = 0; i < lineVals[0].length - 1; i++) {
      tmp[0] =
          Misc.merge(
              tmp[0],
              Misc.interpolate(
                  2 + getNumInterpolationPoints(), lineVals[0][i], lineVals[0][i + 1]));
      tmp[1] =
          Misc.merge(
              tmp[1],
              Misc.interpolate(
                  2 + getNumInterpolationPoints(), lineVals[1][i], lineVals[1][i + 1]));
    }

    tmp[2] = new float[tmp[0].length];
    lineVals = tmp;

    for (int i = 0; i < lineVals[0].length; i++) {
      lineVals[2][i] = alt;
    }

    Data theData = new Gridded3DSet(mathType, lineVals, lineVals[0].length);
    maxDistanceBox.setData(theData);
  }