public FlatField getImageDataFrom(final float channel) { FlatField imageData = null; try { MultiDimensionSubset select = null; Hashtable table = dataChoice.getProperties(); Enumeration keys = table.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key instanceof MultiDimensionSubset) { select = (MultiDimensionSubset) table.get(key); } } HashMap subset = select.getSubset(); imageData = data.getImage(channel, subset); uniqueRangeType = RealType.getRealType(rangeType.getName() + "_" + cnt++); imageData = changeRangeType(imageData, uniqueRangeType); } catch (Exception e) { LogUtil.logException("MultiSpectralDisplay.getImageDataFrom", e); } return imageData; }
// TODO: generalize this so that you can grab the image data for any // channel public FlatField getImageData() { try { if ((imageExpired) || (image == null)) { imageExpired = false; MultiDimensionSubset select = null; Hashtable table = dataChoice.getProperties(); Enumeration keys = table.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key instanceof MultiDimensionSubset) { select = (MultiDimensionSubset) table.get(key); } } HashMap subset = select.getSubset(); image = data.getImage(waveNumber, subset); image = changeRangeType(image, uniqueRangeType); } } catch (Exception e) { LogUtil.logException("MultiSpectralDisplay.getImageData", e); } return image; }
private void init() throws VisADException, RemoteException { HydraDataSource source = (HydraDataSource) dataChoice.getDataSource(); // TODO revisit this, may want to move method up to base class HydraDataSource if (source instanceof SuomiNPPDataSource) { data = ((SuomiNPPDataSource) source).getMultiSpectralData(dataChoice); } if (source instanceof MultiSpectralDataSource) { data = ((MultiSpectralDataSource) source).getMultiSpectralData(dataChoice); } waveNumber = data.init_wavenumber; try { spectrum = data.getSpectrum(new int[] {1, 1}); } catch (Exception e) { LogUtil.logException("MultiSpectralDisplay.init", e); } domainSet = (Gridded1DSet) spectrum.getDomainSet(); initialRangeX = getXRange(domainSet); initialRangeY = data.getDataRange(); domainType = getDomainType(spectrum); rangeType = getRangeType(spectrum); master = new XYDisplay(DISP_NAME, domainType, rangeType); setDisplayMasterAttributes(master); // set up the x- and y-axis xmap = new ScalarMap(domainType, Display.XAxis); ymap = new ScalarMap(rangeType, Display.YAxis); xmap.setRange(initialRangeX[0], initialRangeX[1]); ymap.setRange(initialRangeY[0], initialRangeY[1]); display = master.getDisplay(); display.addMap(xmap); display.addMap(ymap); display.addDisplayListener(this); new RubberBandBox(this, xmap, ymap); if (displayControl == null) { // - add in a ref for the default spectrum, ie no DisplayControl DataReferenceImpl spectrumRef = new DataReferenceImpl(hashCode() + "_spectrumRef"); spectrumRef.setData(spectrum); addRef(spectrumRef, Color.WHITE); } if (data.hasBandNames()) { bandSelectComboBox = new JComboBox(data.getBandNames().toArray()); bandSelectComboBox.setSelectedItem(data.init_bandName); bandSelectComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String bandName = (String) bandSelectComboBox.getSelectedItem(); if (bandName == null) return; HashMap<String, Float> bandMap = data.getBandNameMap(); if (bandMap == null) return; if (!bandMap.containsKey(bandName)) return; setWaveNumber(bandMap.get(bandName)); } }); } }