コード例 #1
0
ファイル: StormTrackChart.java プロジェクト: ethanrd/IDV
  /**
   * _more_
   *
   * @param stormTrack _more_
   * @param param _more_
   * @return _more_
   */
  protected LineState makeLine(StormTrack stormTrack, StormParam param) {
    List<Real> values = new ArrayList<Real>();
    List<DateTime> times = stormTrack.getTrackTimes();
    List<StormTrackPoint> trackPoints = stormTrack.getTrackPoints();
    double min = 0;
    double max = 0;
    Unit unit = null;
    for (int pointIdx = 0; pointIdx < times.size(); pointIdx++) {
      Real value = trackPoints.get(pointIdx).getAttribute(param);
      if (value == null) {
        continue;
      }
      if (unit == null) {
        unit = ((RealType) value.getType()).getDefaultUnit();
      }
      values.add(value);
      double dvalue = value.getValue();
      //            System.err.print(","+dvalue);
      if ((pointIdx == 0) || (dvalue > max)) {
        max = dvalue;
      }
      if ((pointIdx == 0) || (dvalue < min)) {
        min = dvalue;
      }
    }
    if (values.size() == 0) {
      return null;
    }
    //        System.err.println("");
    String paramLabel = param.toString();
    String label = stormTrack.getWay().toString(); // +":" + paramLabel;
    LineState lineState = new LineState();
    lineState.setRangeIncludesZero(true);
    if (stormTrack.getWay().isObservation()) {
      lineState.setWidth(2);
    } else {
      lineState.setWidth(1);
    }
    lineState.setRange(new Range(min, max));
    lineState.setChartName(paramLabel);
    lineState.setAxisLabel("[" + unit + "]");

    //        System.err.println (param + " " +  StormDataSource.TYPE_STORMCATEGORY);
    if (Misc.equals(param, StormDataSource.PARAM_STORMCATEGORY)) {
      //            lineState.setShape(LineState.LINETYPE_BAR);
      lineState.setLineType(LineState.LINETYPE_BAR);
      lineState.setLineType(LineState.LINETYPE_AREA);
    } else {
      lineState.setLineType(LineState.LINETYPE_SHAPES_AND_LINES);
      lineState.setShape(LineState.SHAPE_LARGEPOINT);
    }

    lineState.setColor(stormDisplayState.getWayDisplayState(stormTrack.getWay()).getColor());
    lineState.setName(label);
    lineState.setTrack(times, values);
    return lineState;
  }
コード例 #2
0
ファイル: FormulaUtil.java プロジェクト: jon4than/visad
 /** evaluate the extract function */
 public static Data extract(visad.Field f, Real r) {
   Data d = null;
   try {
     d = f.extract((int) r.getValue());
   } catch (VisADException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   } catch (RemoteException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   }
   return d;
 }
コード例 #3
0
ファイル: FormulaUtil.java プロジェクト: jon4than/visad
 /** evaluate the dot operator */
 public static Data dot(TupleIface t, Real r) {
   Data d = null;
   try {
     d = t.getComponent((int) r.getValue());
   } catch (VisADException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   } catch (RemoteException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   }
   return d;
 }
コード例 #4
0
ファイル: FormulaUtil.java プロジェクト: jon4than/visad
 /** evaluate the bracket function; e.g., A1[5] or A1[A2] */
 public static Data brackets(visad.Field f, Real r) {
   Data value = null;
   try {
     RealType rt = (RealType) r.getType();
     value = f.getSample((int) r.getValue());
   } catch (VisADException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   } catch (RemoteException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   }
   return value;
 }
コード例 #5
0
ファイル: TransectGlyph.java プロジェクト: RickKohrs/IDV
 /**
  * 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));
       }
     }
   }
 }
コード例 #6
0
ファイル: TransectGlyph.java プロジェクト: RickKohrs/IDV
 /**
  * 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));
     }
   }
 }
コード例 #7
0
ファイル: DisplayConventions.java プロジェクト: Unidata/IDV
  /**
   * Find pre-determined contouring values for this parameter by name from the paramdefaults.xml
   * file, or compute reasonable values of contouring values from the data itself. min no contour
   * line below this value; base a contour line must have this value (even if not seen), other
   * values are this value +/- some multiple of the interval; max no contour with greater value than
   * this; interval if negative, means show dashed lines below base value.
   *
   * @param paramName variable name from the data source
   * @param rangeType one of them ViaAD RealType thingys for the data
   * @param displayUnit the unit the data will appear on screen
   * @param range The range
   * @param contourInfo Default contour info
   * @return a ContourInfo object with appropriate contouring values
   */
  public ContourInfo findContourInfo(
      String paramName,
      RealType rangeType,
      Unit displayUnit,
      Range range,
      ContourInfo contourInfo) {

    // make an empty ContourInfo object
    if (contourInfo == null) {
      contourInfo = new ContourInfo(Double.NaN, Double.NaN, Double.NaN, Double.NaN);
    }

    // Find pre-determined contour values for this parameter name
    ContourInfo dflt = getParamDefaultsEditor().getParamContourInfo(paramName);

    if (dflt != null) {
      // Set pre-determined values into local data "contourInfo"
      // System.out.println("  DC: findContourInfo got params contouring values "+ dflt.toString()
      // );
      contourInfo.setIfDefined(dflt);
    }

    if (contourInfo.isDefined()) {
      return contourInfo;
    }

    float min = 0.0f;
    float max = 1100.0f;

    float clBase = Float.NaN;
    float clInterval = Float.NaN;
    float clMin = Float.NaN;
    float clMax = Float.NaN;

    try {
      // convert data's max/min values from native units to display units
      // as seen by user in plots; use VisAD methods
      if (Unit.canConvert(rangeType.getDefaultUnit(), displayUnit)) {
        Real dispVal = new Real(rangeType, range.min);
        min = (float) dispVal.getValue(displayUnit);
        dispVal = new Real(rangeType, range.max);
        max = (float) dispVal.getValue(displayUnit);
      } else {
        min = (float) range.min;
        max = (float) range.max;
      }

      // use data max and min values in display units to find appropriate
      // workable values for contour interval, base, min, and max.

      double span = Math.abs(max - min);

      // GEMPAK alogrithm for 5 to 10 contours in a field from grcval.f
      int scale = (int) (Math.log(span) / Math.log(10));
      if (span < 1) {
        scale = scale - 1;
      }
      double cscale = Math.pow(10, scale);
      double crange = span / cscale;
      int nrange = (int) crange;
      double rint = (nrange + 1) * .1 * cscale;
      if (Double.isInfinite(rint)) {
        rint = span;
      }

      if ((span <= 300.0) && (span > 5.0)) {
          /* typical case */
        clInterval = (float) rint;
        clMin = clBase = clInterval * ((int) (min / clInterval));
        clMax = clInterval * (1 + (int) (max / clInterval));
      } else if (span <= 5.0) { // for max-min less than 5
        clInterval = (float) rint;
        clMin = clBase = min;
        clMax = max;
      } else { // for really big ranges, span > 300 make ints
        clInterval = (float) ((int) rint);
        clMin = clBase = (float) ((int) min);
        clMax = (float) ((int) max);
      }
      clMax = clMax + clInterval;
      clMin = clMin - clInterval;

    } catch (Exception exp) {
      logException("Set contour levels for " + paramName, exp);
    }

    // this should never be true; must be a leftover
    if (clInterval == 0.0f) {
      // System.out.println("  DC: findContourInfo got default contour interval of 20.0");
      clInterval = 20.0f;
    }

    // IF any contouring values were not supplied by the parameter-name-based
    // information; then load in the computed values made here.

    if (!contourInfo.getIntervalDefined() && (contourInfo.getLevelsString() == null)) {
      contourInfo.setInterval(clInterval);
    }

    if (!contourInfo.getBaseDefined()) {
      contourInfo.setBase(clBase);
    }

    if (!contourInfo.getMinDefined()) {
      contourInfo.setMin(clMin);
    }

    if (!contourInfo.getMaxDefined()) {
      contourInfo.setMax(clMax);
    }

    return contourInfo;
  }
コード例 #8
0
ファイル: DisplayConventions.java プロジェクト: Unidata/IDV
 /**
  * Format an Altitude
  *
  * @param alt The altitude
  * @return The formatted alt
  */
 public String formatAltitude(Real alt) {
   return formatDistance(alt.getValue());
 }
コード例 #9
0
ファイル: DisplayConventions.java プロジェクト: Unidata/IDV
 /**
  * Format an lat or lon with cardinal id (N,S,E,W)
  *
  * @param latorlon The lat or lon
  * @param type (LATITUDE or LONGITUDE)
  * @return The formatted lat or lon
  */
 public String formatLatLonCardinal(Real latorlon, int type) {
   return formatLatLonCardinal(latorlon.getValue(), type);
 }
コード例 #10
0
ファイル: DisplayConventions.java プロジェクト: Unidata/IDV
 /**
  * Format an lat or lon
  *
  * @param latorlon The lat or lon
  * @return The formatted lat or lon
  */
 public String formatLatLon(Real latorlon) {
   return formatLatLon(latorlon.getValue());
 }
コード例 #11
0
ファイル: TransectGlyph.java プロジェクト: RickKohrs/IDV
  /**
   * 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);
  }