validPixelExpression = null; overlayMasks = new ProductNodeGroup<Mask>(this, "overlayMasks", false); roiMasks = new ProductNodeGroup<Mask>(this, "roiMasks", false);
/** * Adds the given element to this element. * * @param element the element to added, ignored if <code>null</code> */ public void addElement(MetadataElement element) { if (element == null) { return; } if (elements == null) { elements = new ProductNodeGroup<MetadataElement>(this, "elements", true); } elements.add(element); }
/** * Adds an attribute to this node. * * @param attribute the attribute to be added, <code>null</code> is ignored */ public void addAttribute(MetadataAttribute attribute) { if (attribute == null) { return; } if (attributes == null) { attributes = new ProductNodeGroup<MetadataAttribute>(this, "attributes", true); } attributes.add(attribute); }
/** * Adds the given element to this element at index. * * @param element the element to added, ignored if <code>null</code> * @param index where to put it */ public void addElementAt(MetadataElement element, int index) { if (element == null) { return; } if (elements == null) { elements = new ProductNodeGroup<MetadataElement>(this, "elements", true); } elements.add(index, element); }
this.metadataRoot.setOwner(this); this.bandGroup = new ProductNodeGroup<>(this, "bands", true); this.tiePointGridGroup = new ProductNodeGroup<>(this, "tie_point_grids", true); this.bitmaskDefGroup = new ProductNodeGroup<>(this, "bitmask_defs", true); this.vectorDataGroup = new VectorDataNodeProductNodeGroup(); this.indexCodingGroup = new ProductNodeGroup<>(this, "index_codings", true); this.flagCodingGroup = new ProductNodeGroup<>(this, "flag_codings", true); this.maskGroup = new ProductNodeGroup<>(this, "masks", true); groups = new ProductNodeGroup<>(this, "groups", false); groups.add(bandGroup); groups.add(tiePointGridGroup);
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; }
@Test public void testAddAndRemoveGroup() throws Exception { final Product p = new Product("n", "t", 10, 10); final ProductNodeGroup<ProductNodeGroup> groups = p.getGroups(); assertNotNull(groups); int nodeCount0 = groups.getNodeCount(); final TracingProductNodeListener listener = new TracingProductNodeListener(); final int eventCount0 = listener.events.size(); p.addProductNodeListener(listener); final ProductNodeGroup<MetadataElement> spectra = new ProductNodeGroup<MetadataElement>(p, "spectra", true); groups.add(spectra); assertEquals(groups.getNodeCount(), nodeCount0 + 1); assertEquals(listener.events.size(), eventCount0 + 1); assertSame(spectra, p.getGroup("spectra")); spectra.add(new MetadataElement("radiance")); assertEquals(listener.events.size(), eventCount0 + 2); spectra.add(new MetadataElement("reflectance")); assertEquals(listener.events.size(), eventCount0 + 3); }
public void testOwnership() { MetadataElement root = new MetadataElement("root"); MetadataElement child = new MetadataElement("child"); ProductNodeGroup<MetadataElement> referencingGroup = new ProductNodeGroup<MetadataElement>(null, "metadataElements", false); child.setOwner(root); assertSame(root, child.getOwner()); referencingGroup.add(child); assertEquals(true, referencingGroup.contains(child)); assertSame(root, child.getOwner()); referencingGroup.remove(child); assertEquals(false, referencingGroup.contains(child)); assertSame(root, child.getOwner()); ProductNodeGroup<MetadataElement> owningGroup = new ProductNodeGroup<MetadataElement>(null, "metadataElements", true); child.setOwner(root); assertSame(root, child.getOwner()); owningGroup.add(child); assertEquals(true, owningGroup.contains(child)); assertSame(owningGroup, child.getOwner()); owningGroup.remove(child); assertEquals(false, owningGroup.contains(child)); assertSame(null, child.getOwner()); }