Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
  /** create parallel coordinates display for data */
  public static void parallel(DisplayImpl display, FlatField data)
      throws VisADException, RemoteException {

    FunctionType ftype = (FunctionType) data.getType();
    RealType index = (RealType) ftype.getDomain().getComponent(0);
    RealTupleType range = (RealTupleType) ftype.getRange();
    int ncoords = range.getDimension();
    int nrows = data.getLength();
    Set index_set = data.getDomainSet();
    float[][] samples = data.getFloats(false);

    RealType x = RealType.getRealType("coordinate");
    RealType y = RealType.getRealType("value");
    SetType xy = new SetType(new RealTupleType(x, y));
    FunctionType ptype = new FunctionType(index, xy);
    FieldImpl pfield = new FieldImpl(ptype, index_set);
    for (int j = 0; j < nrows; j++) {
      float[][] locs = new float[2][ncoords];
      for (int i = 0; i < ncoords; i++) {
        locs[0][i] = i;
        locs[1][i] = samples[i][j];
      }
      Gridded2DSet set = new Gridded2DSet(xy, locs, ncoords);
      pfield.setSample(j, set, false);
    }

    // create a DataReference for river system
    DataReference parallel_ref = new DataReferenceImpl("parallel");
    parallel_ref.setData(pfield);

    display.addMap(new ScalarMap(x, Display.XAxis));
    display.addMap(new ScalarMap(y, Display.YAxis));

    // enable axis scales
    display.getGraphicsModeControl().setScaleEnable(true);

    // link display to parallel display
    display.addReference(parallel_ref);
  }