Exemplo n.º 1
0
 /** check for flow mappings; does not allow flow mapping through CoordinateSystem */
 private String findFlow(
     ShadowTupleType shadow,
     DisplayImpl display,
     DisplayTupleType[] tuples,
     int[] flowToComponent) {
   ShadowRealType[] components = shadow.getRealComponents();
   for (int i = 0; i < components.length; i++) {
     int num_flow_per_real = 0;
     Enumeration maps = components[i].getSelectedMapVector().elements();
     while (maps.hasMoreElements()) {
       ScalarMap map = (ScalarMap) maps.nextElement();
       DisplayRealType dreal = map.getDisplayScalar();
       DisplayTupleType tuple = dreal.getTuple();
       if (Display.DisplayFlow1Tuple.equals(tuple) || Display.DisplayFlow2Tuple.equals(tuple)) {
         if (tuples[0] != null) {
           if (!tuples[0].equals(tuple)) {
             return multipleFlowTuples;
           }
         } else {
           tuples[0] = tuple;
         }
         num_flow_per_real++;
         if (num_flow_per_real > 1) {
           return multipleFlowMapping;
         }
         int index = dreal.getTupleIndex();
         flowToComponent[index] = i;
         directMap[index] = map;
       } else if (Display.DisplayFlow1SphericalTuple.equals(tuple)
           || Display.DisplayFlow2SphericalTuple.equals(tuple)) {
         if (tuples[0] != null) {
           if (!tuples[0].equals(tuple)) {
             return multipleFlowTuples;
           }
         } else {
           tuples[0] = tuple;
           coord = tuple.getCoordinateSystem();
         }
         num_flow_per_real++;
         if (num_flow_per_real > 1) {
           return multipleFlowMapping;
         }
         int index = dreal.getTupleIndex();
         flowToComponent[index] = i;
         directMap[index] = map;
       }
     } // while (maps.hasMoreElements())
   }
   return null;
 }
Exemplo n.º 2
0
 /**
  * Initialize the lat/lon scalar maps
  *
  * @throws RemoteException On badness
  * @throws VisADException On badness
  */
 public void initLatLonMap() throws VisADException, RemoteException {
   if (latMap != null) {
     return;
   }
   if (getDisplayMaster() == null) {
     return;
   }
   boolean callScale = (latMap == null);
   DisplayImpl display = (DisplayImpl) getDisplayMaster().getDisplay();
   // find spatial maps for Latitude and Longitude
   latMap = null;
   lonMap = null;
   Vector scalar_map_vector = display.getMapVector();
   Enumeration en = scalar_map_vector.elements();
   while (en.hasMoreElements()) {
     ScalarMap map = (ScalarMap) en.nextElement();
     DisplayRealType real = map.getDisplayScalar();
     DisplayTupleType tuple = real.getTuple();
     if ((tuple != null)
         && (tuple.equals(Display.DisplaySpatialCartesianTuple)
             || ((tuple.getCoordinateSystem() != null)
                 && tuple
                     .getCoordinateSystem()
                     .getReference()
                     .equals(Display.DisplaySpatialCartesianTuple)))) { // Spatial
       if (RealType.Latitude.equals(map.getScalar())) {
         latMap = map;
       } else if (RealType.Longitude.equals(map.getScalar())) {
         lonMap = map;
       }
     }
   }
   if (callScale) {
     setScale(baseScale);
   }
 }
Exemplo n.º 3
0
  public static boolean isByRefUsable(DataDisplayLink link, ShadowType shadow)
      throws VisADException, RemoteException {
    ShadowFunctionOrSetType shadowType = (ShadowFunctionOrSetType) shadow.getAdaptedShadowType();
    CoordinateSystem dataCoordinateSystem = null;
    FlatField fltField = null;
    int num_images = 1;
    FieldImpl field = (FieldImpl) link.getData();
    if (!(field instanceof FlatField)) {
      num_images = field.getDomainSet().getLength();
      if (1
          == num_images) { // If there is a single image in the animation dont do anything, simply
                           // return true
        return true;
      }
      shadowType = (ShadowFunctionOrSetType) shadowType.getRange();
      fltField = (FlatField) field.getSample(0);
      dataCoordinateSystem = fltField.getDomainCoordinateSystem();
    } else {
      dataCoordinateSystem = ((FlatField) field).getDomainCoordinateSystem();
      return true;
    }

    // cs might be cached
    if (dataCoordinateSystem instanceof CachingCoordinateSystem) {
      dataCoordinateSystem =
          ((CachingCoordinateSystem) dataCoordinateSystem).getCachedCoordinateSystem();
    }

    ShadowRealType[] DomainComponents = shadowType.getDomainComponents();
    ShadowRealTupleType Domain = shadowType.getDomain();
    ShadowRealTupleType domain_reference = Domain.getReference();
    ShadowRealType[] DC = DomainComponents;

    if (domain_reference != null && domain_reference.getMappedDisplayScalar()) {
      DC = shadowType.getDomainReferenceComponents();
    }

    DisplayTupleType spatial_tuple = null;
    for (int i = 0; i < DC.length; i++) {
      java.util.Enumeration maps = DC[i].getSelectedMapVector().elements();
      ScalarMap map = (ScalarMap) maps.nextElement();
      DisplayRealType real = map.getDisplayScalar();
      spatial_tuple = real.getTuple();
    }

    CoordinateSystem coord = spatial_tuple.getCoordinateSystem();

    if (coord instanceof CachingCoordinateSystem) {
      coord = ((CachingCoordinateSystem) coord).getCachedCoordinateSystem();
    }

    boolean useLinearTexture = false;
    if (coord instanceof InverseLinearScaledCS) {
      InverseLinearScaledCS invCS = (InverseLinearScaledCS) coord;
      useLinearTexture = (invCS.getInvertedCoordinateSystem()).equals(dataCoordinateSystem);
    }

    /**
     * if useLinearTexture is true at this point, it's true for the first image of a sequence with
     * numimages > 1. We'll have to assume that byRef will apply until below is resolved.
     */

    /**
     * more consideration/work needed here. CoordinateSystems might be equal even if they aren't the
     * same transform (i,j) -> (lon,lat) if (!useLinearTexture) { //If DisplayCoordinateSystem !=
     * DataCoordinateSystem if (num_images > 1) { //Its an animation int lengths[] =
     * ((visad.GriddedSet) fltField.getDomainSet()).getLengths(); int data_width = lengths[0]; int
     * data_height = lengths[1]; for (int i = 1; i < num_images; i++) {//Playing safe: go down the
     * full sequence to find if the full set is Geostaionary or NOT FlatField ff = (FlatField)
     * field.getSample(i); //Quicker Approach would be to just compare only the first two images in
     * the sequence. But that may not be safe. CoordinateSystem dcs =
     * ff.getDomainCoordinateSystem(); // dcs might be cached if (dcs instanceof
     * CachingCoordinateSystem) { dcs = ((CachingCoordinateSystem) dcs).getCachedCoordinateSystem();
     * } int[] lens = ((visad.GriddedSet) ff.getDomainSet()).getLengths(); if (lens[0] != data_width
     * || lens[1] != data_height || ( (dcs != null) && (dataCoordinateSystem != null) &&
     * !dcs.equals(dataCoordinateSystem))) { useLinearTexture = false; break; } } } }
     */
    return useLinearTexture;
  }