public PropagateUncertaintyDialog(VirtualBand virtualBand) { super(SnapApp.getDefault().getMainFrame(), Bundle.CTL_PropagateUncertaintyDialog_Title(), ID_OK_CANCEL_HELP, "propagateUncertainty"); Assert.notNull(virtualBand, "virtualBand"); this.sourceBand = virtualBand; bindingContext = createBindingContext(); bandName = virtualBand.getName() + "_unc"; order = 1; initUI(); }
private void addVirtualBand(final String operation, final String name_prefix, final String expression, final String unit, final double nodatavalue) { final VirtualBand virtBand = new VirtualBand(name_prefix, ProductData.TYPE_FLOAT32, sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight(), expression); virtBand.setUnit(unit); virtBand.setDescription(name_prefix + ' ' + operation + ' ' + unit); virtBand.setNoDataValueUsed(true); virtBand.setNoDataValue(nodatavalue); final Band srcBand = sourceProduct.getBand(virtBand.getName()); if (srcBand != null) { sourceProduct.removeBand(srcBand); } sourceProduct.addBand(virtBand); ProductUtils.copyBand(name_prefix, sourceProduct, targetProduct, true); }
@Override protected void onOK() { String uncertaintyExpression = targetExprArea.getText(); Product targetProduct = sourceBand.getProduct(); int width = sourceBand.getRasterWidth(); int height = sourceBand.getRasterHeight(); ProductNodeGroup<Band> bandGroup = targetProduct.getBandGroup(); VirtualBand uncertaintyBand = new VirtualBand(getBandName(), ProductData.TYPE_FLOAT32, width, height, uncertaintyExpression); uncertaintyBand.setDescription("Uncertainty propagated from band " + sourceBand.getName() + " = " + sourceBand.getExpression()); uncertaintyBand.setUnit(sourceBand.getUnit()); uncertaintyBand.setNoDataValue(Double.NaN); uncertaintyBand.setNoDataValueUsed(true); uncertaintyBand.setValidPixelExpression(sourceBand.getValidPixelExpression()); ProductUtils.copySpectralBandProperties(sourceBand, uncertaintyBand); bandGroup.add(uncertaintyBand); sourceBand.addAncillaryVariable(uncertaintyBand, relation); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(targetProduct); if (undoManager != null) { undoManager.addEdit(new UndoableProductNodeInsertion<>(bandGroup, uncertaintyBand)); } hide(); uncertaintyBand.setModified(true); if (SnapApp.getDefault().getPreferences().getBoolean(BandMathsDialog.PREF_KEY_AUTO_SHOW_NEW_BANDS, true)) { OpenImageViewAction.openImageView(uncertaintyBand); } }
private BindingContext createBindingContext() { final PropertyContainer container = PropertyContainer.createObjectBacked(this); final BindingContext context = new BindingContext(container); PropertyDescriptor descriptor; descriptor = container.getDescriptor(PROPERTY_NAME_BAND_NAME); descriptor.setDisplayName("Uncertainty band name"); descriptor.setDescription("The name for the new uncertainty band."); descriptor.setNotEmpty(true); descriptor.setValidator(new ProductNodeNameValidator(sourceBand.getProduct())); descriptor.setDefaultValue(getDefaultBandName(sourceBand.getName() + "_unc")); descriptor = container.getDescriptor(PROPERTY_NAME_ORDER); descriptor.setDisplayName("Order of Taylor polynomial"); descriptor.setDescription("The number of Taylor series expansion terms used for the Standard Combined Uncertainty (GUM 1995)."); descriptor.setDefaultValue(1); descriptor.setValueSet(new ValueSet(new Integer[]{1, 2, 3})); descriptor = container.getDescriptor(PROPERTY_NAME_RELATION); descriptor.setDisplayName("Relation name of ancillary bands"); descriptor.setDescription("Relation name of ancillary variables that represent uncertainties (NetCDF-U 'rel' attribute)."); descriptor.setDefaultValue("uncertainty"); descriptor.setNotNull(true); descriptor.setNotEmpty(true); container.setDefaultValues(); PropertyChangeListener targetExprUpdater = evt -> { updateTargetExprArea(); }; context.addPropertyChangeListener(PROPERTY_NAME_ORDER, targetExprUpdater); context.addPropertyChangeListener(PROPERTY_NAME_RELATION, targetExprUpdater); return context; }