@Test public void testCreateSpectraFromUngroupedBands_noUnits() throws Exception { final Band band_1 = new Band("cfsvbzt", ProductData.TYPE_INT8, 1, 1); final Band band_2 = new Band("cgvg", ProductData.TYPE_INT8, 1, 1); final Band band_3 = new Band("hbhn", ProductData.TYPE_INT8, 1, 1); final Band band_4 = new Band("nhbjz", ProductData.TYPE_INT8, 1, 1); final Band band_5 = new Band("tjbu", ProductData.TYPE_INT8, 1, 1); SpectrumBand[] spectrumBands = new SpectrumBand[]{new SpectrumBand(band_1, false), new SpectrumBand(band_2, false), new SpectrumBand(band_3, false), new SpectrumBand(band_4, false), new SpectrumBand(band_5, false) }; final DisplayableSpectrum[] spectraFromUngroupedBands = SpectrumTopComponent.createSpectraFromUngroupedBands(spectrumBands, 1, 0); assertNotNull(spectraFromUngroupedBands); assertEquals(1, spectraFromUngroupedBands.length); final Band[] spectralBands = spectraFromUngroupedBands[0].getSpectralBands(); assertEquals(DisplayableSpectrum.DEFAULT_SPECTRUM_NAME, spectraFromUngroupedBands[0].getName()); assertEquals(5, spectralBands.length); assertSame(band_1, spectralBands[0]); assertSame(band_2, spectralBands[1]); assertSame(band_3, spectralBands[2]); assertSame(band_4, spectralBands[3]); assertSame(band_5, spectralBands[4]); }
static DisplayableSpectrum[] createSpectraFromUngroupedBands(SpectrumBand[] ungroupedBands, int symbolIndex, int strokeIndex) { List<String> knownUnits = new ArrayList<>(); List<DisplayableSpectrum> displayableSpectrumList = new ArrayList<>(); DisplayableSpectrum defaultSpectrum = new DisplayableSpectrum("tbd", -1); for (SpectrumBand ungroupedBand : ungroupedBands) { final String unit = ungroupedBand.getOriginalBand().getUnit(); if (StringUtils.isNullOrEmpty(unit)) { defaultSpectrum.addBand(ungroupedBand); } else if (knownUnits.contains(unit)) { displayableSpectrumList.get(knownUnits.indexOf(unit)).addBand(ungroupedBand); } else { knownUnits.add(unit); final DisplayableSpectrum spectrum = new DisplayableSpectrum("Bands measured in " + unit, symbolIndex++); spectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex++)); spectrum.addBand(ungroupedBand); displayableSpectrumList.add(spectrum); } } if (strokeIndex == 0) { defaultSpectrum.setName(DisplayableSpectrum.DEFAULT_SPECTRUM_NAME); } else { defaultSpectrum.setName(DisplayableSpectrum.REMAINING_BANDS_NAME); } defaultSpectrum.setSymbolIndex(symbolIndex); defaultSpectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex)); displayableSpectrumList.add(defaultSpectrum); return displayableSpectrumList.toArray(new DisplayableSpectrum[displayableSpectrumList.size()]); }
SpectrumTopComponent extends ToolTopComponent { static DisplayableSpectrum[] createSpectraFromUngroupedBands(SpectrumBand[] ungroupedBands, int symbolIndex, int strokeIndex) { List<String> knownUnits = new ArrayList<>(); List<DisplayableSpectrum> displayableSpectrumList = new ArrayList<>(); DisplayableSpectrum defaultSpectrum = new DisplayableSpectrum("tbd", -1); for (SpectrumBand ungroupedBand : ungroupedBands) { final String unit = ungroupedBand.getOriginalBand().getUnit(); if (StringUtils.isNullOrEmpty(unit)) { defaultSpectrum.addBand(ungroupedBand); } else if (knownUnits.contains(unit)) { displayableSpectrumList.get(knownUnits.indexOf(unit)).addBand(ungroupedBand); } else { knownUnits.add(unit); final DisplayableSpectrum spectrum = new DisplayableSpectrum("Bands measured in " + unit, symbolIndex++); spectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex++)); spectrum.addBand(ungroupedBand); displayableSpectrumList.add(spectrum); } } if (strokeIndex == 0) { defaultSpectrum.setName(DisplayableSpectrum.DEFAULT_SPECTRUM_NAME); } else { defaultSpectrum.setName(DisplayableSpectrum.REMAINING_BANDS_NAME); } defaultSpectrum.setSymbolIndex(symbolIndex); defaultSpectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex)); displayableSpectrumList.add(defaultSpectrum); return displayableSpectrumList.toArray(new DisplayableSpectrum[displayableSpectrumList.size()]); } }
SpectrumTopComponent extends ToolTopComponent { static DisplayableSpectrum[] createSpectraFromUngroupedBands(SpectrumBand[] ungroupedBands, int symbolIndex, int strokeIndex) { List<String> knownUnits = new ArrayList<>(); List<DisplayableSpectrum> displayableSpectrumList = new ArrayList<>(); DisplayableSpectrum defaultSpectrum = new DisplayableSpectrum("tbd", -1); for (SpectrumBand ungroupedBand : ungroupedBands) { final String unit = ungroupedBand.getOriginalBand().getUnit(); if (StringUtils.isNullOrEmpty(unit)) { defaultSpectrum.addBand(ungroupedBand); } else if (knownUnits.contains(unit)) { displayableSpectrumList.get(knownUnits.indexOf(unit)).addBand(ungroupedBand); } else { knownUnits.add(unit); final DisplayableSpectrum spectrum = new DisplayableSpectrum("Bands measured in " + unit, symbolIndex++); spectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex++)); spectrum.addBand(ungroupedBand); displayableSpectrumList.add(spectrum); } } if (strokeIndex == 0) { defaultSpectrum.setName(DisplayableSpectrum.DEFAULT_SPECTRUM_NAME); } else { defaultSpectrum.setName(DisplayableSpectrum.REMAINING_BANDS_NAME); } defaultSpectrum.setSymbolIndex(symbolIndex); defaultSpectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex)); displayableSpectrumList.add(defaultSpectrum); return displayableSpectrumList.toArray(new DisplayableSpectrum[displayableSpectrumList.size()]); } SpectrumTopComponent(); }
SpectrumTopComponent extends ToolTopComponent { static DisplayableSpectrum[] createSpectraFromUngroupedBands(SpectrumBand[] ungroupedBands, int symbolIndex, int strokeIndex) { List<String> knownUnits = new ArrayList<>(); List<DisplayableSpectrum> displayableSpectrumList = new ArrayList<>(); DisplayableSpectrum defaultSpectrum = new DisplayableSpectrum("tbd", -1); for (SpectrumBand ungroupedBand : ungroupedBands) { final String unit = ungroupedBand.getOriginalBand().getUnit(); if (StringUtils.isNullOrEmpty(unit)) { defaultSpectrum.addBand(ungroupedBand); } else if (knownUnits.contains(unit)) { displayableSpectrumList.get(knownUnits.indexOf(unit)).addBand(ungroupedBand); } else { knownUnits.add(unit); final DisplayableSpectrum spectrum = new DisplayableSpectrum("Bands measured in " + unit, symbolIndex++); spectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex++)); spectrum.addBand(ungroupedBand); displayableSpectrumList.add(spectrum); } } if (strokeIndex == 0) { defaultSpectrum.setName(DisplayableSpectrum.DEFAULT_SPECTRUM_NAME); } else { defaultSpectrum.setName(DisplayableSpectrum.REMAINING_BANDS_NAME); } defaultSpectrum.setSymbolIndex(symbolIndex); defaultSpectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex)); displayableSpectrumList.add(defaultSpectrum); return displayableSpectrumList.toArray(new DisplayableSpectrum[displayableSpectrumList.size()]); } SpectrumTopComponent(); @Override HelpCtx getHelpCtx(); boolean showsValidCursorSpectra(); }
SpectrumTopComponent extends ToolTopComponent { static DisplayableSpectrum[] createSpectraFromUngroupedBands(SpectrumBand[] ungroupedBands, int symbolIndex, int strokeIndex) { List<String> knownUnits = new ArrayList<>(); List<DisplayableSpectrum> displayableSpectrumList = new ArrayList<>(); DisplayableSpectrum defaultSpectrum = new DisplayableSpectrum("tbd", -1); for (SpectrumBand ungroupedBand : ungroupedBands) { final String unit = ungroupedBand.getOriginalBand().getUnit(); if (StringUtils.isNullOrEmpty(unit)) { defaultSpectrum.addBand(ungroupedBand); } else if (knownUnits.contains(unit)) { displayableSpectrumList.get(knownUnits.indexOf(unit)).addBand(ungroupedBand); } else { knownUnits.add(unit); final DisplayableSpectrum spectrum = new DisplayableSpectrum("Bands measured in " + unit, symbolIndex++); spectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex++)); spectrum.addBand(ungroupedBand); displayableSpectrumList.add(spectrum); } } if (strokeIndex == 0) { defaultSpectrum.setName(DisplayableSpectrum.DEFAULT_SPECTRUM_NAME); } else { defaultSpectrum.setName(DisplayableSpectrum.REMAINING_BANDS_NAME); } defaultSpectrum.setSymbolIndex(symbolIndex); defaultSpectrum.setLineStyle(SpectrumStrokeProvider.getStroke(strokeIndex)); displayableSpectrumList.add(defaultSpectrum); return displayableSpectrumList.toArray(new DisplayableSpectrum[displayableSpectrumList.size()]); } SpectrumTopComponent(); @Override HelpCtx getHelpCtx(); boolean showsValidCursorSpectra(); static final String ID; }