/** * Removes the given band from this product. * * @param band the band to be removed, ignored if <code>null</code> * * @return {@code true} if removed succesfully, otherwise {@code false} */ public boolean removeBand(final Band band) { return bandGroup.remove(band); }
@Test public void maskGroupIsNotCoupledWithEmptyVectorDataGroups() { final VectorDataNode v = new VectorDataNode("V", Placemark.createGeometryFeatureType()); vectorDataGroup.add(v); assertEquals(3, vectorDataGroup.getNodeCount()); assertEquals(0, maskGroup.getNodeCount()); assertSame(v, vectorDataGroup.get(2)); assertFalse(maskGroup.contains(v.getName())); final VectorDataNode u = new VectorDataNode("U", Placemark.createGeometryFeatureType()); vectorDataGroup.add(0, u); assertEquals(4, vectorDataGroup.getNodeCount()); assertEquals(0, maskGroup.getNodeCount()); assertSame(u, vectorDataGroup.get(0)); assertSame(v, vectorDataGroup.get(3)); assertFalse(maskGroup.contains(u.getName())); assertFalse(maskGroup.contains(v.getName())); vectorDataGroup.remove(u); assertEquals(3, vectorDataGroup.getNodeCount()); assertEquals(0, maskGroup.getNodeCount()); assertFalse(vectorDataGroup.contains(u)); assertSame(v, vectorDataGroup.get(2)); assertFalse(maskGroup.contains(u.getName())); assertFalse(maskGroup.contains(v.getName())); vectorDataGroup.removeAll(); assertEquals(2, vectorDataGroup.getNodeCount()); assertEquals(0, maskGroup.getNodeCount()); }
/** * Removes the given element from this element. * * @param element the element to be removed, ignored if <code>null</code> * * @return true, if so */ public boolean removeElement(MetadataElement element) { return element != null && elements != null && elements.remove(element); }
/** * Removes the tie-point grid from this product. * * @param tiePointGrid the tie-point grid to be removed, ignored if <code>null</code> * * @return <code>true</code> if node could be removed */ public boolean removeTiePointGrid(final TiePointGrid tiePointGrid) { return tiePointGridGroup.remove(tiePointGrid); }
/** * Removes the given attribute from this annotation. If an attribute with the same name already exists, the method * does nothing. * * @param attribute the attribute to be removed, <code>null</code> is ignored * * @return <code>true</code> if it was removed */ public boolean removeAttribute(MetadataAttribute attribute) { return attribute != null && attributes != null && attributes.remove(attribute); }
private static void deleteMaskFromGroup(ProductNodeGroup<Mask> group, Mask mask) { if (group.contains(mask)) { group.remove(mask); } }
private boolean _remove(Placemark placemark) { synchronized (placemarkMap) { final boolean removed = super.remove(placemark); if (removed) { placemarkMap.remove(placemark.getFeature()); } return removed; } }
/** * Removes all nodes from this group. */ public void removeAll() { final ProductNode[] nodes = toArray(); for (ProductNode node : nodes) { remove((T) node); } }
@Override public boolean remove(VectorDataNode vectorDataNode) { Assert.notNull(vectorDataNode, "node"); return !vectorDataNode.isPermanent() && super.remove(vectorDataNode); }
private void handleMaskRemoved(ProductNodeEvent event) { final Mask mask = (Mask) event.getSourceNode(); final Band[] bands = getBands(); for (Band band : bands) { band.getOverlayMaskGroup().remove(mask); } final TiePointGrid[] tiePointGrids = getTiePointGrids(); for (TiePointGrid tiePointGrid : tiePointGrids) { tiePointGrid.getOverlayMaskGroup().remove(mask); } }
private void handleVectorDataNodeRemoved(ProductNodeEvent event) { final Mask mask = getMask((VectorDataNode) event.getSourceNode()); if (mask != null) { getMaskGroup().remove(mask); } }
void removeMask(Mask mask) { getProduct().getMaskGroup().remove(mask); fireTableDataChanged(); }
@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); } } } } }
@Override public void actionPerformed(ActionEvent e) { if (plotAreaSelectionTool != null) { plotAreaSelectionTool.removeAnnotation(); } Product product = pagePanel.getProduct(); if (product != null) { Mask mask = product.getMaskGroup().get(maskName); if (mask != null) { product.getMaskGroup().remove(mask); } } } });
private void handleFeatureCollectionChange(ProductNodeEvent event) { final VectorDataNode sourceNode = (VectorDataNode) event.getSourceNode(); final Mask mask = getMask(sourceNode); if (sourceNode.getFeatureCollection().size() > 0) { if (mask == null) { addMask(sourceNode); } } else { if (mask != null) { getMaskGroup().remove(mask); } } }
private void handleFlagCoding(Band sourceBand, Band targetBand, boolean renameComponents, String renamePattern) { if(sourceBand.getFlagCoding() != null) { targetBand.getProduct().getFlagCodingGroup().remove(targetBand.getFlagCoding()); targetBand.setSampleCoding(null); } setFlagCoding(targetBand, sourceBand.getFlagCoding(), renameComponents, renamePattern); }
private void handleIndexCoding(Band sourceBand, Band targetBand, boolean renameComponents, String renamePattern) { if(sourceBand.getIndexCoding() != null) { targetBand.getProduct().getIndexCodingGroup().remove(targetBand.getIndexCoding()); targetBand.setSampleCoding(null); } setIndexCoding(targetBand, sourceBand.getIndexCoding(), renameComponents, renamePattern); }
private void exchangeVDN(SimpleFeatureType featureType, FeatureStatisticsWriter featureStatisticsWriter) { final VectorDataNode originalVDN = featureType2VDN.get(featureType); final VectorDataNode vectorDataNode = createVectorDataNode(featureStatisticsWriter, originalVDN); final ProductNodeGroup<VectorDataNode> vectorDataNodeGroup = provider.getVectorDataNodeGroup(); vectorDataNodeGroup.remove(originalVDN); originalVDN.dispose(); vectorDataNodeGroup.add(vectorDataNode); final JInternalFrame internalFrame = VisatApp.getApp().findInternalFrame(originalVDN); if (internalFrame != null) { try { internalFrame.setClosed(true); } catch (PropertyVetoException ignored) { // ok } } final ProductSceneView sceneView = VisatApp.getApp().getSelectedProductSceneView(); if (sceneView != null) { sceneView.setLayersVisible(vectorDataNode); } }
@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()); } }
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()); }