コード例 #1
0
ファイル: ScalarQuantity.java プロジェクト: RickKohrs/IDV
  /**
   * Indicates if a VisAD MathType is compatible with this instance. A RealType is compatible if its
   * {@link RealType#equalsExceptNameButUnits} method returns true when given the return value of
   * {@link #getRealType()} and if this quantity has no coordinate system transformation. A
   * RealTupleType is compatible if its {@link RealTupleType#equalsExceptNameButUnits} method
   * returns true when given the return value of {@link #getRealTupleType()} and if the coordinate
   * system transformations are compatible. A SetType is compatible if its RealTupleType is
   * compatible. A FunctionType is compatible if the MathType of its range is compatible. All other
   * MathTypes are incompatible.
   *
   * @param type The VisAD MathType to examine for compatibility.
   * @return <code>true</code> if and only if the MathType is compatible with this instance.
   * @throws VisADException VisAD failure.
   */
  public boolean isCompatible(MathType type) throws VisADException {

    boolean isCompatible;

    if (type instanceof RealType) {
      isCompatible =
          ((RealType) type).equalsExceptNameButUnits(realType)
              && (getRealTupleType().getCoordinateSystem() == null);
    } else if (type instanceof RealTupleType) {
      RealTupleType thisTupleType = getRealTupleType();
      RealTupleType thatTupleType = (RealTupleType) type;

      if (!thatTupleType.equalsExceptNameButUnits(thisTupleType)) {
        isCompatible = false;
      } else {
        CoordinateSystem thisCS = thisTupleType.getCoordinateSystem();
        CoordinateSystem thatCS = thatTupleType.getCoordinateSystem();

        isCompatible =
            ((thisCS == null)
                ? thatCS == null
                : thisCS.getReference().equalsExceptNameButUnits(thatCS.getReference()));
      }
    } else if (type instanceof SetType) {
      isCompatible = isCompatible(((SetType) type).getDomain());
    } else if (type instanceof FunctionType) {
      isCompatible = isCompatible(((FunctionType) type).getRange());
    } else {
      isCompatible = false;
    }

    return isCompatible;
  }
コード例 #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;
 }