private String createDescription(Band computedBand) { if (computedBand instanceof VirtualBand) { VirtualBand virtualBand = (VirtualBand) computedBand; String oldDescription = virtualBand.getDescription(); String newDescription = oldDescription == null ? "" : oldDescription.trim(); String formerExpressionDescription = "(expression was '" + virtualBand.getExpression() + "')"; newDescription = newDescription.isEmpty() ? formerExpressionDescription : newDescription + " " + formerExpressionDescription; return newDescription; } else { return computedBand.getDescription(); } }
MultiLevelImage createSourceImage(Band computedBand, Band realBand) { if (computedBand instanceof VirtualBand) { return VirtualBand.createSourceImage(realBand, ((VirtualBand) computedBand).getExpression()); }else { return computedBand.getSourceImage(); } }
private static List<RasterDataNode> getReferencedVirtualBands(final RasterDataNode node) { final Product product = node.getProduct(); final List<RasterDataNode> rasterList = new ArrayList<RasterDataNode>(); if (product != null) { for (int i = 0; i < product.getNumBands(); i++) { final Band band = product.getBandAt(i); if (band instanceof VirtualBand) { final VirtualBand virtualBand = (VirtualBand) band; if (isNodeReferencedByExpression(node, virtualBand.getExpression())) { rasterList.add(virtualBand); } } } } return rasterList; }
static Product findFirstExpressionSourceProduct(Product productToBeClosed, Set<Product> productsStillOpen) { for (Product openProduct : productsStillOpen) { Band[] bands = openProduct.getBands(); for (Band band : bands) { if (band instanceof VirtualBand) { VirtualBand virtualBand = (VirtualBand) band; try { RasterDataNode[] nodes = openProduct.getRefRasterDataNodes(virtualBand.getExpression()); for (RasterDataNode node : nodes) { if (productToBeClosed.equals(node.getProduct())) { return openProduct; } } } catch (ParseException e) { // ok } } } } return null; } }
private String generateUncertaintyExpression() throws ParseException, UnsupportedOperationException { StandardUncertaintyGenerator propagator = new StandardUncertaintyGenerator(order, false); return propagator.generateUncertainty(sourceBand.getProduct(), relation, sourceBand.getExpression()); }
private String createToolTip(final Band band) { StringBuilder tooltip = new StringBuilder(); append(tooltip, band.getDescription()); if (band.getSpectralWavelength() > 0.0) { append(tooltip, String.format("%s nm", band.getSpectralWavelength())); if (band.getSpectralBandwidth() > 0.0) { append(tooltip, String.format("+/-%s nm", 0.5 * band.getSpectralBandwidth())); } } append(tooltip, String.format("%d x %d pixels", band.getRasterWidth(), band.getRasterHeight())); if (band instanceof VirtualBand) { append(tooltip, String.format("Expr.: %s", ((VirtualBand) band).getExpression())); } if (band.getUnit() != null) { append(tooltip, String.format(" (%s)", band.getUnit())); } return tooltip.toString(); }
private static String getExpression(RasterDataNode raster) { Product product = raster.getProduct(); if (product != null) { if (product.containsBand(raster.getName())) { return raster.getName(); } else { if (raster instanceof VirtualBand) { return ((VirtualBand) raster).getExpression(); } } } return null; }
expressions.add(virtualBand.getExpression());
sourceExprArea.setEditable(false); sourceExprArea.setEnabled(false); sourceExprArea.setText(sourceBand.getExpression());
String expression = srcBand.getExpression();
if(vBand instanceof VirtualBand) { final VirtualBand virtBand = (VirtualBand)vBand; String expression = virtBand.getExpression().replaceAll(trgBand.getName(), newBandName); virtBand.setExpression(expression);
@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); } }