/** * @return the number of elements contained in this element. */ public int getNumElements() { if (elements == null) { return 0; } return elements.getNodeCount(); }
/** * @return the number of bands contained in this product. */ public int getNumBands() { return bandGroup.getNodeCount(); }
@Override public int getRowCount() { ProductNodeGroup<Mask> maskGroup = getMaskGroup(); return maskGroup != null ? maskGroup.getNodeCount() : 0; }
@Override public boolean evaluate(BindingContext bindingContext) { Boolean propertyValue = bindingContext.getPropertySet().getValue(PROPERTY_NAME_USE_ROI_MASK); if (roiMaskComboBox.getItemCount() > 0 && roiMaskComboBox.getSelectedIndex() < 0) { roiMaskComboBox.setSelectedIndex(0); } return Boolean.TRUE.equals(propertyValue) && product != null && product.getMaskGroup().getNodeCount() > 0; }
private static Placemark[] getValidGcps(ProductNodeGroup<Placemark> gcpGroup) { final List<Placemark> gcpList = new ArrayList<Placemark>(gcpGroup.getNodeCount()); for (int i = 0; i < gcpGroup.getNodeCount(); i++) { final Placemark p = gcpGroup.get(i); final PixelPos pixelPos = p.getPixelPos(); final GeoPos geoPos = p.getGeoPos(); if (pixelPos != null && pixelPos.isValid() && geoPos != null && geoPos.isValid()) { gcpList.add(p); } } return gcpList.toArray(new Placemark[gcpList.size()]); }
void updateEnablement() { boolean hasMasks = (product != null && product.getMaskGroup().getNodeCount() > 0); boolean canSelectMasks = hasMasks && useRoiCheckBox.isSelected(); useRoiCheckBox.setEnabled(hasMasks); maskNameSearchField.setEnabled(canSelectMasks); maskNameList.setEnabled(canSelectMasks); selectAllCheckBox.setEnabled(canSelectMasks && maskNameList.getCheckBoxListSelectedIndices().length < maskNameList.getModel().getSize()); selectNoneCheckBox.setEnabled(canSelectMasks && maskNameList.getCheckBoxListSelectedIndices().length > 0); refreshButton.setEnabled(raster != null); }
private Placemark getPlacemarkAt(final int selectedRow) { Placemark placemark = null; if (product != null) { if (selectedRow > -1 && selectedRow < getPlacemarkGroup(product).getNodeCount()) { placemark = getPlacemarkGroup(product).get(selectedRow); } } return placemark; }
private void handleMasklessProduct(Product product) { if (product != null && product.getMaskGroup().getNodeCount() == 0) { try { bindingContext.getPropertySet().getProperty("useRoiMask").setValue(Boolean.FALSE); } catch (ValidationException e) { throw new IllegalStateException("Cannot come here"); } } }
@Test public void initialState() { assertEquals(2, vectorDataGroup.getNodeCount()); assertEquals(0, maskGroup.getNodeCount()); }
@Test public void testMaskGroupIsInitiallyEmpty() throws Exception { final Product p = new Product("P", "T", 1, 1); assertEquals(0, p.getMaskGroup().getNodeCount()); }
private static void registerMaskSymbols(WritableNamespace namespace, Product product, String namePrefix) { for (int i = 0; i < product.getMaskGroup().getNodeCount(); i++) { final Mask mask = product.getMaskGroup().get(i); final String symbolName = namePrefix + mask.getName(); namespace.registerSymbol(new RasterDataSymbol(symbolName, mask)); } }
Placemark[] getDisplayedPins() { if (isShowingSpectraForSelectedPins() && getCurrentView() != null) { return getCurrentView().getSelectedPins(); } else if (isShowingSpectraForAllPins() && getCurrentProduct() != null) { ProductNodeGroup<Placemark> pinGroup = getCurrentProduct().getPinGroup(); return pinGroup.toArray(new Placemark[pinGroup.getNodeCount()]); } else { return new Placemark[0]; } }
protected void addFlagCodingsToProduct(Product product) { final ProductNodeGroup<FlagCoding> flagCodingGroup = getSourceProduct().getFlagCodingGroup(); for (int i = 0; i < flagCodingGroup.getNodeCount(); i++) { FlagCoding sourceFlagCoding = flagCodingGroup.get(i); FlagCoding destFlagCoding = new FlagCoding(sourceFlagCoding.getName()); destFlagCoding.setDescription(sourceFlagCoding.getDescription()); cloneFlags(sourceFlagCoding, destFlagCoding); product.getFlagCodingGroup().add(destFlagCoding); } }
protected void addIndexCodingsToProduct(Product product) { final ProductNodeGroup<IndexCoding> indexCodingGroup = getSourceProduct().getIndexCodingGroup(); for (int i = 0; i < indexCodingGroup.getNodeCount(); i++) { IndexCoding sourceIndexCoding = indexCodingGroup.get(i); IndexCoding destIndexCoding = new IndexCoding(sourceIndexCoding.getName()); destIndexCoding.setDescription(sourceIndexCoding.getDescription()); cloneIndexes(sourceIndexCoding, destIndexCoding); product.getIndexCodingGroup().add(destIndexCoding); } }
@Test public void testMaskIsRemovedWhenVdnIsRemoved() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); p.getVectorDataGroup().add(node); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id1")); assertEquals(1, p.getMaskGroup().getNodeCount()); p.getVectorDataGroup().remove(node); assertEquals(0, p.getMaskGroup().getNodeCount()); } }
@Test public void testMaskIsAddedWhenPinIsAddedForTheFirstTime() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getPinGroup().add(Placemark.createPointPlacemark(PinDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("pins")); }
@Test public void testMaskIsAddedWhenFeatureIsAddedForTheFirstTime() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); p.getVectorDataGroup().add(node); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id")); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("V")); }
@Test public void testMaskIsAddedWhenNonEmptyVdnIsAdded() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id")); p.getVectorDataGroup().add(node); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("V")); }
@Test public void testVectorDataGroup() throws TransformException, FactoryException { Product p = new Product("p", "pt", 512, 512); assertEquals(2, p.getVectorDataGroup().getNodeCount()); SimpleFeatureType pinType = Placemark.createPinFeatureType(); SimpleFeatureType gcpType = Placemark.createGcpFeatureType(); p.getVectorDataGroup().add(new VectorDataNode("My Pins", pinType)); p.getVectorDataGroup().add(new VectorDataNode("My GCPs", gcpType)); assertEquals(4, p.getVectorDataGroup().getNodeCount()); testVectorData(p, "My Pins", pinType); testVectorData(p, "My GCPs", gcpType); }
@Test public void testMaskIsRemovedWhenAllFeaturesAreRemoved() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); p.getVectorDataGroup().add(node); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id1")); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id2")); node.getFeatureCollection().clear(); assertEquals(0, p.getMaskGroup().getNodeCount()); }