Example #1
0
  /**
   * set the default sampling; this is an unavoidable violation of MathType immutability - a
   * RealTupleType must be an argument (directly or through a SetType) to the constructor of its
   * default Set; this method throws an Exception if getDefaultSet has previously been invoked
   */
  public synchronized void setDefaultSet(Set sampling) throws VisADException {
    if (sampling.getDimension() != getDimension()) {
      throw new SetException("RealTupleType.setDefaultSet: dimensions don't match");
    }
    if (DefaultSetEverAccessed) {
      throw new TypeException("RealTupleType: DefaultSet already accessed" + " so cannot change");
    }
    DefaultSet = sampling;

    /* WLH 4 Feb 98 copied from constructor */
    if (DefaultSet != null && !Unit.canConvertArray(DefaultSet.getSetUnits(), DefaultUnits)) {
      throw new UnitException(
          "RealTupleType: default Set Units must be " + "convertable with default Units");
    }
    if (DefaultCoordinateSystem != null && DefaultSet != null) {
      CoordinateSystem cs = DefaultSet.getCoordinateSystem();
      if (cs != null && !cs.getReference().equals(DefaultCoordinateSystem.getReference())) {
        throw new CoordinateSystemException(
            "RealTupleType: Default coordinate system "
                + DefaultCoordinateSystem.getReference()
                + " must match"
                + " default set CoordinateSystem "
                + (cs == null ? null : cs.getReference()));
      }
      if (!Unit.canConvertArray(
          DefaultCoordinateSystem.getCoordinateSystemUnits(), DefaultSet.getSetUnits())) {
        throw new UnitException(
            "RealTupleType: CoordinateSystem Units must be "
                + "convertable with default Set Units");
      }
    }
  }
Example #2
0
 /**
  * array of component types; default CoordinateSystem for values of this type (including Function
  * domains) and may be null; default Set used when this type is a FunctionType domain and may be
  * null
  */
 public RealTupleType(RealType[] types, CoordinateSystem coord_sys, Set set)
     throws VisADException {
   super(types);
   if (coord_sys != null && types.length != coord_sys.getDimension()) {
     throw new CoordinateSystemException("RealTupleType: bad CoordinateSystem dimension");
   }
   DefaultCoordinateSystem = coord_sys;
   DefaultSet = set;
   DefaultSetEverAccessed = false;
   setDefaultUnits(types);
   if (DefaultCoordinateSystem != null
       && !Unit.canConvertArray(
           DefaultCoordinateSystem.getCoordinateSystemUnits(), DefaultUnits)) {
     throw new UnitException(
         "RealTupleType: CoordinateSystem Units must be " + "convertable with default Units");
   }
   if (DefaultSet != null && !Unit.canConvertArray(DefaultSet.getSetUnits(), DefaultUnits)) {
     throw new UnitException(
         "RealTupleType: default Set Units must be " + "convertable with default Units");
   }
   if (DefaultCoordinateSystem != null && DefaultSet != null) {
     CoordinateSystem cs = DefaultSet.getCoordinateSystem();
     if (cs != null && !cs.getReference().equals(DefaultCoordinateSystem.getReference())) {
       throw new CoordinateSystemException(
           "RealTupleType: Default coordinate system "
               + (coord_sys == null ? null : coord_sys.getReference())
               + " must match"
               + " default set CoordinateSystem "
               + (cs == null ? null : cs.getReference()));
     }
     if (!Unit.canConvertArray(
         DefaultCoordinateSystem.getCoordinateSystemUnits(), DefaultSet.getSetUnits())) {
       throw new UnitException(
           "RealTupleType: CoordinateSystem Units must be "
               + "convertable with default Set Units");
     }
   }
 }
Example #3
0
 /** trusted constructor for initializers */
 RealTupleType(RealType[] types, CoordinateSystem coord_sys, boolean b) {
   super(types, b);
   DefaultCoordinateSystem = coord_sys;
   DefaultSet = null;
   DefaultSetEverAccessed = false;
   setDefaultUnits(types);
   if (DefaultCoordinateSystem != null
       && !Unit.canConvertArray(
           DefaultCoordinateSystem.getCoordinateSystemUnits(), DefaultUnits)) {
     throw new VisADError(
         "RealTupleType (trusted): CoordinateSystem Units "
             + "must be convertable with default Units");
   }
 }
 /**
  * construct a CoordinateSystem that whose transforms invert the transforms of inverse (i.e.,
  * toReference and fromReference are switched); for example, this could be used to define
  * Cartesian coordinates releative to a refernce in spherical coordinates
  */
 public InverseCoordinateSystem(RealTupleType reference, CoordinateSystem inv)
     throws VisADException {
   super(reference, inv.getReference().getDefaultUnits());
   inverse = inv;
   dimension = reference.getDimension();
   Unit[] inv_units = inv.getCoordinateSystemUnits();
   Unit[] ref_units = reference.getDefaultUnits();
   if (inv_units.length != dimension) {
     throw new CoordinateSystemException("InverseCoordinateSystem: " + "dimensions don't match");
   }
   for (int i = 0; i < inv_units.length; i++) {
     if ((inv_units[i] == null && ref_units[i] != null)
         || (inv_units[i] != null && !inv_units[i].equals(ref_units[i]))) {
       throw new CoordinateSystemException(
           "InverseCoordinateSystem: "
               + "Units don't match "
               + i
               + " "
               + inv_units[i]
               + " "
               + ref_units[i]);
     }
   }
 }