private static String getAvailableMaskName(String name, ProductNodeGroup<Mask> maskGroup) { int index = 1; String foundName = name; while (maskGroup.contains(foundName)) { foundName = name + "_" + index; } return foundName; } }
static String findUniqueVectorDataNodeName(String suggestedName, ProductNodeGroup<VectorDataNode> vectorDataGroup) { String name = suggestedName; int index = 1; while (vectorDataGroup.contains(name)) { name = suggestedName + "_" + index; index++; } return name; }
/** * Checks whether this node has an element with the given name. * * @param name the attribute name * * @return <code>true</code> if so */ public boolean containsAttribute(String name) { return attributes != null && attributes.contains(name); }
private static String getAvailableMaskName(String name, ProductNodeGroup<Mask> maskGroup) { int index = 1; String foundName = name; while (maskGroup.contains(foundName)) { foundName = name + "_" + index; } return foundName; }
private static void deleteMaskFromGroup(ProductNodeGroup<Mask> group, Mask mask) { if (group.contains(mask)) { group.remove(mask); } }
private DialogData(ProductNodeGroup<VectorDataNode> vectorGroup) { String defaultPrefix = getDefaultVectorDataNodeName() + "_"; name = defaultPrefix + (numItems++); while (vectorGroup.contains(name)) { name = defaultPrefix + (numItems++); } description = ""; } }
/** * Tests if a element with the given name is contained in this element. * * @param name the name, must not be <code>null</code> * * @return <code>true</code> if a element with the given name is contained in this element, <code>false</code> * otherwise */ public boolean containsElement(String name) { Guardian.assertNotNullOrEmpty("name", name); return elements != null && elements.contains(name); }
/** * Tests if a tie-point grid with the given name is contained in this product. * * @param name the name, must not be <code>null</code> * * @return <code>true</code> if a tie-point grid with the given name is contained in this product, * <code>false</code> otherwise */ public boolean containsTiePointGrid(final String name) { Guardian.assertNotNullOrEmpty("name", name); return tiePointGridGroup.contains(name); }
/** * Tests if a band with the given name is contained in this product. * * @param name the name, must not be <code>null</code> * * @return <code>true</code> if a band with the given name is contained in this product, <code>false</code> * otherwise * * @throws IllegalArgumentException if the given name is <code>null</code> or empty. */ public boolean containsBand(final String name) { Guardian.assertNotNullOrEmpty("name", name); return bandGroup.contains(name); }
@Override public void validateValue(Property property, Object value) throws ValidationException { String name = (String) value; if (product.getVectorDataGroup().contains(name)) { final String pattern = "A vector data container with name ''{0}'' already exists.\n" + "Please choose another one."; throw new ValidationException(MessageFormat.format(pattern, name)); } } }
private boolean isRequiredRasterMissing(String requiredGrid) { return !getSourceProduct().getTiePointGridGroup().contains(requiredGrid); }
private String getNewMaskName(ProductNodeGroup<Mask> maskGroup) { String possibleName = DEFAULT_MASK_NAME_PREFIX + maskGroup.getNodeCount(); for (int i = 0; i <= maskGroup.getNodeCount(); i++) { possibleName = DEFAULT_MASK_NAME_PREFIX + (maskGroup.getNodeCount() + i + 1); if (!maskGroup.contains(possibleName)) { break; } } return possibleName; } }
/** * Tests if a raster data node with the given name is contained in this product. Raster data nodes can be bands or * tie-point grids. * * @param name the name, must not be <code>null</code> * * @return <code>true</code> if a raster data node with the given name is contained in this product, * <code>false</code> otherwise */ public boolean containsRasterDataNode(final String name) { return containsBand(name) || containsTiePointGrid(name) || getMaskGroup().contains(name); }
@Override public void handleLayerPropertyChanged(Layer layer, PropertyChangeEvent event) { if ("visible".equals(event.getPropertyName())) { final Object value = layer.getConfiguration().getValue("mask"); if (value instanceof Mask) { Mask mask = (Mask) value; final ProductNodeGroup<Mask> overlayMaskGroup = getRaster().getOverlayMaskGroup(); if (layer.isVisible()) { if (!overlayMaskGroup.contains(mask)) { overlayMaskGroup.add(mask); } } else { overlayMaskGroup.remove(mask); } } } } }
private static void setFlagCoding(Band band, FlagCoding flagCoding, boolean rename, String pattern) { if (flagCoding != null) { String flagCodingName = flagCoding.getName(); if (rename) { flagCodingName = pattern.replace(SOURCE_NAME_REFERENCE, flagCodingName); } final Product product = band.getProduct(); if (!product.getFlagCodingGroup().contains(flagCodingName)) { addFlagCoding(product, flagCoding, flagCodingName); } band.setSampleCoding(product.getFlagCodingGroup().get(flagCodingName)); } }
private static void setIndexCoding(Band band, IndexCoding indexCoding, boolean rename, String pattern) { if (indexCoding != null) { String indexCodingName = indexCoding.getName(); if (rename) { indexCodingName = pattern.replace(SOURCE_NAME_REFERENCE, indexCodingName); } final Product product = band.getProduct(); if (!product.getIndexCodingGroup().contains(indexCodingName)) { addIndexCoding(product, indexCoding, indexCodingName); } band.setSampleCoding(product.getIndexCodingGroup().get(indexCodingName)); } }
public static Layer createLayer(RasterDataNode raster, Mask mask) { final MaskLayerType type = LayerTypeRegistry.getLayerType(MaskLayerType.class); final PropertySet configuration = type.createLayerConfig(null); configuration.setValue(MaskLayerType.PROPERTY_NAME_MASK, mask); final Layer layer = type.createLayer(null, configuration); layer.setVisible(raster.getOverlayMaskGroup().contains(mask)); return layer; }
private static void setFlagCoding(Band band, FlagCoding flagCoding) { if (flagCoding != null) { final String flagCodingName = flagCoding.getName(); final Product product = band.getProduct(); if (!product.getFlagCodingGroup().contains(flagCodingName)) { addFlagCoding(product, flagCoding); } band.setSampleCoding(product.getFlagCodingGroup().get(flagCodingName)); } }
@Test public void testSampleCodingPreservedInSubset() throws IOException { final ProductSubsetDef subsetDef = new ProductSubsetDef(); subsetDef.setNodeNames(new String[]{INDEX_CODED_BAND_NAME}); final Product subset = ProductSubsetBuilder.createProductSubset(product, subsetDef, "subset", ""); assertTrue(subset.getBandGroup().contains(INDEX_CODED_BAND_NAME)); assertFalse(subset.getBandGroup().contains(COLORED_BAND_NAME)); assertTrue(subset.getIndexCodingGroup().contains(INDEX_CODING_NAME)); }
@Test public void testSampleCodingRemovedInSubset() throws IOException { final ProductSubsetDef subsetDef = new ProductSubsetDef(); subsetDef.setNodeNames(new String[]{COLORED_BAND_NAME}); final Product subset = ProductSubsetBuilder.createProductSubset(product, subsetDef, "subset", ""); assertFalse(subset.getBandGroup().contains(INDEX_CODED_BAND_NAME)); assertTrue(subset.getBandGroup().contains(COLORED_BAND_NAME)); assertFalse(subset.getIndexCodingGroup().contains(INDEX_CODING_NAME)); }