/** * Create an external name from the given name. * If the given name contains character which are not valid in an external name * the name is escaped with single quotes. * <p>The method simply delgates to {@link Tokenizer#createExternalName(String)}. * * @param name the name * @return a valid external name */ public static String createExternalName(final String name) { return Tokenizer.createExternalName(name); }
if (!existingBands.contains(selectedBand)) { final String name = selectedBand.getName(); final String expression = Tokenizer.createExternalName(name); addRow(variablesTable, new Object[]{name, expression}); } else {
private void addTargetBands(Product product) { for (Variable outputVariable : variables) { Band band = product.addBand(outputVariable.getName(), ProductData.TYPE_FLOAT32); band.setDescription(outputVariable.getExpression()); final String countBandName = getCountBandName(outputVariable); band.setValidPixelExpression(String.format("%s > 0", Tokenizer.createExternalName(countBandName))); Band countBand = product.addBand(countBandName, ProductData.TYPE_INT32); countBand.setDescription(String.format("Count of %s", outputVariable.getName())); } if (conditions != null) { for (Condition condition : conditions) { if (condition.isOutput()) { Band band = product.addBand(condition.getName(), ProductData.TYPE_INT32); band.setDescription(condition.getExpression()); } } } }
@Override public void actionPerformed(ActionEvent e) { final Product product = getMaskForm().getProduct(); final String[] rasterNames = StringUtils.addArrays(product.getBandNames(), product.getTiePointGridNames()); final RangeEditorDialog.Model model = new RangeEditorDialog.Model(rasterNames); model.setMinValue(0.0); model.setMaxValue(1.0); model.setRasterName(rasterNames[0]); final RangeEditorDialog rangeEditorDialog = new RangeEditorDialog(getWindow(e), model); if (rangeEditorDialog.show() == AbstractDialog.ID_OK) { final Mask mask = createNewMask(Mask.RangeType.INSTANCE); final String externalName = Tokenizer.createExternalName(model.getRasterName()); mask.setDescription(model.getMinValue() + " <= " + externalName + " <= " + model.getMaxValue()); final PropertyContainer imageConfig = mask.getImageConfig(); imageConfig.setValue(Mask.RangeType.PROPERTY_NAME_MINIMUM, model.getMinValue()); imageConfig.setValue(Mask.RangeType.PROPERTY_NAME_MAXIMUM, model.getMaxValue()); imageConfig.setValue(Mask.RangeType.PROPERTY_NAME_RASTER, externalName); imageConfig.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { final String oldText = evt.getOldValue().toString(); final String newText = evt.getNewValue().toString(); mask.setDescription(mask.getDescription().replace(oldText, newText)); } }); getMaskForm().addMask(mask); } }