private FlatField changeRangeType(FlatField image, RealType newRangeType) throws VisADException, RemoteException { FunctionType ftype = (FunctionType) image.getType(); FlatField new_image = new FlatField(new FunctionType(ftype.getDomain(), newRangeType), image.getDomainSet()); new_image.setSamples(image.getFloats(false), false); return new_image; }
public String toString() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return "Cannot get cached FlatField"; } return fld.toString(); }
public Unit[] getDomainUnits() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return null; } return fld.getDomainUnits(); }
public float[][] getFloats(boolean copy) throws VisADException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.getFloats(copy); }
/** * unpack an array of floats from field sample values according to the RangeSet-s; returns a copy */ public float[][] unpackFloats() throws VisADException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.unpackFloats(); }
public boolean isMissing() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return true; } return fld.isMissing(); }
public Field extract(int component) throws VisADException, RemoteException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.extract(component); }
public Set getDomainSet() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return null; } return fld.getDomainSet(); }
public Unit[] getDefaultRangeUnits() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return null; } return fld.getDefaultRangeUnits(); }
public double[] getValues(int index) throws VisADException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.getValues(index); }
public CoordinateSystem getDomainCoordinateSystem() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return null; } return fld.getDomainCoordinateSystem(); }
public CoordinateSystem[] getRangeCoordinateSystem(int component) throws TypeException { FlatField fld = getAdaptedFlatField(); if (fld == null) { return null; } return fld.getRangeCoordinateSystem(component); }
public int getLength() { FlatField fld = getAdaptedFlatField(); if (fld == null) { return 0; } return fld.getLength(); }
public Data unary(int op, MathType new_type, int sampling_mode, int error_mode) throws VisADException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.unary(op, new_type, sampling_mode, error_mode); }
public Data getSample(int index) throws VisADException, RemoteException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.getSample(index); }
public Field domainFactor(RealType factor) throws VisADException, RemoteException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.domainFactor(factor); }
public DataShadow computeRanges(ShadowType type, DataShadow shadow) throws VisADException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.computeRanges(type, shadow); }
public Data binary(Data data, int op, int sampling_mode, int error_mode) throws VisADException, RemoteException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.binary(data, op, sampling_mode, error_mode); }
public Field resample(Set set, int sampling_mode, int error_mode) throws VisADException, RemoteException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.resample(set, sampling_mode, error_mode); }
public Data adjustSamplingError(Data error, int error_mode) throws VisADException, RemoteException { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } return fld.adjustSamplingError(error, error_mode); }
public String longString(String pre) { FlatField fld = getAdaptedFlatField(); if (fld == null) { return pre + "Cannot get cached FlatField"; } try { return fld.longString(pre); } catch (VisADException e) { return pre + e.getMessage(); } }
/** * Clones this instance. This implementation violates the general <code> * clone()</code> contract in that the returned object will compare unequal to this instance. As * such, this method should probably not be invoked. * * @return A clone of this instance. */ public Object clone() { /* * This implementation should probably just throw a * CloneNotSupportedException but can't because FlatField.clone() doesn't. */ FlatField fld = getAdaptedFlatField(); if (fld == null) { return null; } return fld.clone(); }
void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType[] time = {RealType.Time}; RealType[] types = {RealType.Latitude, RealType.Longitude}; RealTupleType earth_location = new RealTupleType(types); RealType vis_radiance = RealType.getRealType("vis_radiance"); RealType ir_radiance = RealType.getRealType("ir_radiance"); RealType[] types2 = {vis_radiance, ir_radiance}; RealTupleType radiance = new RealTupleType(types2); FunctionType image_tuple = new FunctionType(earth_location, radiance); RealType[] types4 = {ir_radiance, vis_radiance}; RealTupleType ecnaidar = new RealTupleType(types4); FunctionType image_bumble = new FunctionType(earth_location, ecnaidar); RealTupleType time_type = new RealTupleType(time); FunctionType time_images = new FunctionType(time_type, image_tuple); int size = 64; FlatField imaget1 = FlatField.makeField(image_tuple, size, false); FlatField wasp = FlatField.makeField(image_bumble, size, false); int ntimes1 = 4; double start = new DateTime(1999, 122, 57060).getValue(); Set time_set = new Linear1DSet(time_type, start, start + 3600.0 * (ntimes1 - 1.0), ntimes1); FieldImpl image_sequence = new FieldImpl(time_images, time_set); FlatField temp = imaget1; Real[] reals30 = { new Real(vis_radiance, (float) size / 4.0f), new Real(ir_radiance, (float) size / 8.0f) }; RealTuple val = new RealTuple(reals30); for (int i = 0; i < ntimes1; i++) { image_sequence.setSample(i, temp); temp = (FlatField) temp.add(val); } dpys[0].addMap(new ScalarMap(RealType.Latitude, Display.YAxis)); dpys[0].addMap(new ScalarMap(RealType.Longitude, Display.XAxis)); dpys[0].addMap(new ScalarMap(vis_radiance, Display.Red)); dpys[0].addMap(new ScalarMap(ir_radiance, Display.Green)); dpys[0].addMap(new ConstantMap(0.5, Display.Blue)); dpys[0].addMap(new ScalarMap(RealType.Time, Display.ZAxis)); GraphicsModeControl mode = dpys[0].getGraphicsModeControl(); mode.setScaleEnable(true); DataReference ref_image_sequence = new DataReferenceImpl("ref_big_tuple"); ref_image_sequence.setData(image_sequence); dpys[0].addReference(ref_image_sequence, null); }
// type 'java Parallel' to run this application public static void main(String args[]) throws VisADException, RemoteException, IOException { RealType index = RealType.getRealType("index"); RealType[] coords = new RealType[NCOORDS]; for (int i = 0; i < NCOORDS; i++) { coords[i] = RealType.getRealType("coord" + i); } RealTupleType range = new RealTupleType(coords); FunctionType ftype = new FunctionType(index, range); Integer1DSet index_set = new Integer1DSet(NROWS); float[][] samples = new float[NCOORDS][NROWS]; for (int i = 0; i < NCOORDS; i++) { for (int j = 0; j < NROWS; j++) { samples[i][j] = (float) Math.random(); } } FlatField data = new FlatField(ftype, index_set); data.setSamples(samples, false); // create a 2-D Display using Java3D DisplayImpl display = new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D()); parallel(display, data); // create JFrame (i.e., a window) for display and slider JFrame frame = new JFrame("Parallel Coordinates VisAD Application"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // create JPanel in JFrame JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentY(JPanel.TOP_ALIGNMENT); panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); frame.getContentPane().add(panel); // add display to JPanel panel.add(display.getComponent()); // set size of JFrame and make it visible frame.setSize(500, 500); frame.setVisible(true); }
public void setSample(RealTuple domain, Data range) throws VisADException, RemoteException { if (adaptedFlatFields == null) { throw new VisADException("Cannot access serialized FileFlatField"); } synchronized (adaptedFlatFields) { FlatField fld = getAdaptedFlatField(); if (fld == null) { throw new VisADException("Cannot get cached FlatField"); } adaptedFlatFieldDirty[adaptedFlatFieldIndex] = true; fld.setSample(domain, range); } }
void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType x = RealType.getRealType("x"); RealType y = RealType.getRealType("y"); Unit super_degree = CommonUnit.degree.scale(2.5); RealType lon = RealType.getRealType("lon", super_degree); RealType radius = RealType.getRealType("radius"); RealTupleType cartesian = new RealTupleType(x, y); PolarCoordinateSystem polar_coord_sys = new PolarCoordinateSystem(cartesian); RealTupleType polar = new RealTupleType(lon, radius, polar_coord_sys, null); RealType vis_radiance = RealType.getRealType("vis_radiance"); RealType ir_radiance = RealType.getRealType("ir_radiance"); RealType[] types2 = {vis_radiance, ir_radiance}; RealTupleType radiance = new RealTupleType(types2); FunctionType image_polar = new FunctionType(polar, radiance); Unit[] units = {super_degree, null}; Linear2DSet domain_set = new Linear2DSet(polar, 0.0, 60.0, 61, 0.0, 60.0, 61, polar_coord_sys, units, null); FlatField imaget1 = new FlatField(image_polar, domain_set); FlatField.fillField(imaget1, 1.0, 30.0); dpys[0].addMap(new ScalarMap(x, Display.XAxis)); dpys[0].addMap(new ScalarMap(y, Display.YAxis)); dpys[0].addMap(new ScalarMap(vis_radiance, Display.Green)); dpys[0].addMap(new ConstantMap(0.5, Display.Red)); dpys[0].addMap(new ConstantMap(0.0, Display.Blue)); DataReferenceImpl ref_imaget1 = new DataReferenceImpl("ref_imaget1"); ref_imaget1.setData(imaget1); dpys[0].addReference(ref_imaget1, null); }
// TODO: needs work public boolean setWaveNumber(final float val) { if (data == null) return false; if (waveNumber == val) return true; try { if (spectrum == null) { spectrum = data.getSpectrum(new int[] {1, 1}); } Gridded1DSet domain = (Gridded1DSet) spectrum.getDomainSet(); int[] idx = domain.valueToIndex(new float[][] {{val}}); float[][] tmp = domain.indexToValue(idx); float channel = tmp[0][0]; setSelectorValue(channelSelector, channel); imageExpired = true; } catch (Exception e) { LogUtil.logException("MultiSpectralDisplay.setDisplayedWaveNum", e); return false; } waveNumber = val; if (data.hasBandNames()) { String name = data.getBandNameFromWaveNumber(waveNumber); bandSelectComboBox.setSelectedItem(name); } return true; }
void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType[] types = {RealType.Latitude, RealType.Longitude}; RealTupleType earth_location = new RealTupleType(types); RealType vis_radiance = RealType.getRealType("vis_radiance"); RealType ir_radiance = RealType.getRealType("ir_radiance"); RealType[] types2 = {vis_radiance, ir_radiance}; RealTupleType radiance = new RealTupleType(types2); FunctionType image_tuple = new FunctionType(earth_location, radiance); int size = 64; FlatField imaget1 = FlatField.makeField(image_tuple, size, false); dpys[0].addMap(new ScalarMap(RealType.Latitude, Display.YAxis)); dpys[0].addMap(new ScalarMap(RealType.Longitude, Display.XAxis)); dpys[0].addMap(new ScalarMap(ir_radiance, Display.Green)); dpys[0].addMap(new ScalarMap(vis_radiance, Display.RGB)); dpys[0].addMap(new ScalarMap(ir_radiance, Display.ZAxis)); dpys[0].addMap(new ConstantMap(0.5, Display.Blue)); dpys[0].addMap(new ConstantMap(0.5, Display.Red)); ScalarMap map1contour; map1contour = new ScalarMap(vis_radiance, Display.IsoContour); dpys[0].addMap(map1contour); if (uneven) { ContourControl control = (ContourControl) map1contour.getControl(); float[] levs = {10.0f, 12.0f, 14.0f, 16.0f, 24.0f, 32.0f, 40.0f}; control.setLevels(levs, 15.0f, true); control.enableLabels(true); } DataReferenceImpl ref_imaget1 = new DataReferenceImpl("ref_imaget1"); ref_imaget1.setData(imaget1); dpys[0].addReference(ref_imaget1, null); }
/** * Create the charts * * @throws RemoteException On badness * @throws VisADException On badness */ public void loadData() throws VisADException, RemoteException { createChart(); List dataChoiceWrappers = getDataChoiceWrappers(); try { for (int dataSetIdx = 0; dataSetIdx < plot.getDatasetCount(); dataSetIdx++) { MyHistogramDataset dataset = (MyHistogramDataset) plot.getDataset(dataSetIdx); dataset.removeAllSeries(); } // dataset.removeAllSeries(); Hashtable props = new Hashtable(); props.put(TrackDataSource.PROP_TRACKTYPE, TrackDataSource.ID_TIMETRACE); for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx++) { DataChoiceWrapper wrapper = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx); DataChoice dataChoice = wrapper.getDataChoice(); FlatField data = getFlatField((FieldImpl) dataChoice.getData(null, props)); Unit unit = ucar.visad.Util.getDefaultRangeUnits((FlatField) data)[0]; double[][] samples = data.getValues(false); double[] actualValues = filterData(samples[0], getTimeValues(samples, data))[0]; NumberAxis domainAxis = new NumberAxis(wrapper.getLabel(unit)); XYItemRenderer renderer; if (stacked) { renderer = new StackedXYBarRenderer(); } else { renderer = new XYBarRenderer(); } plot.setRenderer(paramIdx, renderer); Color c = wrapper.getColor(paramIdx); domainAxis.setLabelPaint(c); renderer.setSeriesPaint(0, c); MyHistogramDataset dataset = new MyHistogramDataset(); dataset.setType(HistogramType.FREQUENCY); dataset.addSeries(dataChoice.getName() + " [" + unit + "]", actualValues, bins); plot.setDomainAxis(paramIdx, domainAxis, false); plot.mapDatasetToDomainAxis(paramIdx, paramIdx); plot.setDataset(paramIdx, dataset); } } catch (Exception exc) { LogUtil.logException("Error creating data set", exc); return; } }
/** 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); }