예제 #1
0
  /**
   * Set <CODE>Vector</CODE> of <CODE>String</CODE>s describing the cursor location from the cursor
   * location; this is invoked when the cursor location changes or the cursor display status changes
   */
  public void setCursorStringVector() {
    synchronized (cursorStringVector) {
      cursorStringVector.removeAllElements();
      float[][] cursor = new float[3][1];
      double[] cur = getCursor();
      cursor[0][0] = (float) cur[0];
      cursor[1][0] = (float) cur[1];
      cursor[2][0] = (float) cur[2];
      Enumeration maps = display.getMapVector().elements();
      while (maps.hasMoreElements()) {
        try {
          ScalarMap map = (ScalarMap) maps.nextElement();
          DisplayRealType dreal = map.getDisplayScalar();
          DisplayTupleType tuple = dreal.getTuple();
          int index = dreal.getTupleIndex();
          if (tuple != null
              && (tuple.equals(Display.DisplaySpatialCartesianTuple)
                  || (tuple.getCoordinateSystem() != null
                      && tuple
                          .getCoordinateSystem()
                          .getReference()
                          .equals(Display.DisplaySpatialCartesianTuple)))) {
            float[] fval = new float[1];
            if (tuple.equals(Display.DisplaySpatialCartesianTuple)) {
              fval[0] = cursor[index][0];
            } else {
              float[][] new_cursor = tuple.getCoordinateSystem().fromReference(cursor);
              fval[0] = new_cursor[index][0];
            }
            float[] dval = map.inverseScaleValues(fval);
            RealType real = (RealType) map.getScalar();

            // WLH 31 Aug 2000
            Real r = new Real(real, dval[0]);
            Unit overrideUnit = map.getOverrideUnit();
            Unit rtunit = real.getDefaultUnit();
            // units not part of Time string
            // DRM 2003-08-19: don't check for equality since toString
            // may be different
            if (overrideUnit != null
                && // !overrideUnit.equals(rtunit) &&
                (!Unit.canConvert(rtunit, CommonUnit.secondsSinceTheEpoch)
                    || rtunit.getAbsoluteUnit().equals(rtunit))) {
              dval[0] = (float) overrideUnit.toThis((double) dval[0], rtunit);
              r = new Real(real, dval[0], overrideUnit);
            }
            String valueString = r.toValueString();

            // WLH 27 Oct 2000
            String s = map.getScalarName() + " = " + valueString;
            // String s = real.getName() + " = " + valueString;

            cursorStringVector.addElement(s);
          } // end if (tuple != null && ...)
        } catch (VisADException e) {
        }
      } // end while(maps.hasMoreElements())
    } // end synchronized (cursorStringVector)
    render_trigger();
  }
예제 #2
0
 /**
  * Return <CODE>true</CODE> if <CODE>type</CODE> is legal for this <CODE>DisplayRenderer</CODE>;
  * for example, 2-D <CODE>DisplayRenderer</CODE>s use this to disallow mappings to <I>ZAxis</I>
  * and <I>Latitude</I>.
  *
  * @param type The mapping type to check.
  * @return <CODE>true</CODE> if <CODE>type</CODE> is legal.
  */
 public boolean legalDisplayScalar(DisplayRealType type) {
   // First check to see if it is a member of the default list
   for (int i = 0; i < Display.DisplayRealArray.length; i++) {
     if (Display.DisplayRealArray[i].equals(type)) return true;
   }
   // if we get here, it's not one of the defaults.  See if it has
   // a CS that transforms to a default that we know how to handle
   if (type.getTuple() != null && type.getTuple().getCoordinateSystem() != null) {
     RealTupleType ref = type.getTuple().getCoordinateSystem().getReference();
     if (ref.equals(Display.DisplaySpatialCartesianTuple)
         || ref.equals(Display.DisplayRGBTuple)
         || ref.equals(Display.DisplayFlow1Tuple)
         || ref.equals(Display.DisplayFlow2Tuple)) return true;
   }
   return false;
 }