private void addBandCheckBoxes(DefaultMutableTreeNode root, List<TreePath> selectedPaths, Map<String, Integer> groupNodeMap) { final Set<Map.Entry<Band, String>> allBands = allBandsMap.entrySet(); for (Map.Entry<Band, String> bandEntry : allBands) { final Band band = bandEntry.getKey(); if (autoGrouping != null) { final int bandIndex = autoGrouping.indexOf(band.getName()); if (bandIndex >= 0) { final String groupName = autoGrouping.get(bandIndex)[0]; final Integer index = groupNodeMap.get(groupName); final DefaultMutableTreeNode groupNode = (DefaultMutableTreeNode) root.getChildAt(index); final DefaultMutableTreeNode groupChild = new DefaultMutableTreeNode(bandEntry.getValue()); if (selectedBandsMap.containsValue(bandEntry.getValue())) { selectedPaths.add(new TreePath(new Object[]{root, groupNode, groupChild})); } groupNode.add(groupChild); } else { addToRoot(root, selectedPaths, bandEntry, band); } } else { addToRoot(root, selectedPaths, bandEntry, band); } } }
private void addTiePointGridCheckBoxes(DefaultMutableTreeNode root, List<TreePath> selectedPaths, Map<String, Integer> groupNodeMap) { final Set<Map.Entry<TiePointGrid, String>> allGrids = allGridsMap.entrySet(); for (Map.Entry<TiePointGrid, String> gridEntry : allGrids) { final TiePointGrid grid = gridEntry.getKey(); if (autoGrouping != null) { final int gridIndex = autoGrouping.indexOf(grid.getName()); if (gridIndex >= 0) { final String groupName = autoGrouping.get(gridIndex)[0]; final Integer index = groupNodeMap.get(groupName); final DefaultMutableTreeNode groupNode = (DefaultMutableTreeNode) root.getChildAt(index); final DefaultMutableTreeNode groupChild = new DefaultMutableTreeNode(gridEntry.getValue()); if (selectedGridsMap.containsKey(grid)) { selectedPaths.add(new TreePath(new Object[]{root, groupNode, groupChild})); } groupNode.add(groupChild); } else { addToRoot(root, selectedPaths, gridEntry, grid); } } else { addToRoot(root, selectedPaths, gridEntry, grid); } } }
private static ProductNode group(ProductNodeGroup<? extends RasterDataNode> bandGroup, Product.AutoGrouping autoGrouping) { HashMap<String, ProductNodeGroup<ProductNode>> subGroupMap = new HashMap<String, ProductNodeGroup<ProductNode>>(); ProductNodeGroup<ProductNode> newGroup = new ProductNodeGroup<ProductNode>(null, bandGroup.getName(), false); newGroup.setDescription(bandGroup.getDescription()); final int count = bandGroup.getNodeCount(); for (int i = 0; i < count; i++) { RasterDataNode band = bandGroup.get(i); String bandName = band.getName(); int groupPathIndex = autoGrouping.indexOf(bandName); if (groupPathIndex >= 0) { // todo - this is still wrong, must support group separators ('/') for nested groups (nf 20100622) String subGroupName = createGroupName(autoGrouping.get(groupPathIndex)); ProductNodeGroup<ProductNode> subGroup = subGroupMap.get(subGroupName); if (subGroup == null) { subGroup = new ProductNodeGroup<ProductNode>(null, subGroupName, false); subGroupMap.put(subGroupName, subGroup); newGroup.add(subGroup); } subGroup.add(band); } else { newGroup.add(band); } } return newGroup; }
final Product.AutoGrouping autoGrouping = currentProduct.getAutoGrouping(); if (autoGrouping != null) { final int selectedSpectrumIndex = autoGrouping.indexOf(getCurrentView().getRaster().getName()); spectra = new DisplayableSpectrum[autoGrouping.size() + 1]; final Iterator<String[]> iterator = autoGrouping.iterator(); for (SpectrumBand availableSpectralBand : availableSpectralBands) { final String bandName = availableSpectralBand.getName(); final int spectrumIndex = autoGrouping.indexOf(bandName); if (spectrumIndex != -1) { spectra[spectrumIndex].addBand(availableSpectralBand);
assertArrayEquals(new String []{"L_21_err"}, autoGrouping.get(9)); assertEquals(0, autoGrouping.indexOf("L_1_CAM1")); assertEquals(0, autoGrouping.indexOf("L_1_CAM5")); assertEquals(1, autoGrouping.indexOf("L_1_err_CAM1")); assertEquals(1, autoGrouping.indexOf("L_1_err_CAM5")); assertEquals(2, autoGrouping.indexOf("L_2_CAM1")); assertEquals(2, autoGrouping.indexOf("L_2_CAM5")); assertEquals(3, autoGrouping.indexOf("L_2_err_CAM1")); assertEquals(3, autoGrouping.indexOf("L_2_err_CAM5")); assertEquals(4, autoGrouping.indexOf("L_10_CAM1")); assertEquals(4, autoGrouping.indexOf("L_10_CAM5")); assertEquals(5, autoGrouping.indexOf("L_10_err_CAM1")); assertEquals(5, autoGrouping.indexOf("L_10_err_CAM5")); assertEquals(6, autoGrouping.indexOf("L_11_CAM1")); assertEquals(6, autoGrouping.indexOf("L_11_CAM5")); assertEquals(7, autoGrouping.indexOf("L_11_err_CAM1")); assertEquals(7, autoGrouping.indexOf("L_11_err_CAM5")); assertEquals(8, autoGrouping.indexOf("L_21_CAM1")); assertEquals(8, autoGrouping.indexOf("L_21_CAM5")); assertEquals(9, autoGrouping.indexOf("L_21_err_CAM1")); assertEquals(9, autoGrouping.indexOf("L_21_err_CAM5"));
private void addBandToSpectra(Band band) { DisplayableSpectrum[] allSpectra = productToAllSpectraMap.get(getCurrentProduct()); Product.AutoGrouping autoGrouping = currentProduct.getAutoGrouping(); if (autoGrouping != null) { final int bandIndex = autoGrouping.indexOf(band.getName()); final DisplayableSpectrum spectrum; if (bandIndex != -1) { spectrum = allSpectra[bandIndex]; } else { spectrum = allSpectra[allSpectra.length - 1]; } spectrum.addBand(new SpectrumBand(band, spectrum.isSelected())); } else { allSpectra[0].addBand(new SpectrumBand(band, true)); } }