コード例 #1
0
 @Override
 public String[] getTargetVarNames(AggregatorConfig aggregatorConfig) {
   Config config = (Config) aggregatorConfig;
   String targetName =
       StringUtils.isNotNullAndNotEmpty(config.targetName) ? config.targetName : config.varName;
   int percentage = getEffectivePercentage(config.percentage);
   return createFeatureNames(targetName, "p" + percentage);
 }
コード例 #2
0
 @Override
 public Aggregator createAggregator(VariableContext varCtx, AggregatorConfig aggregatorConfig) {
   Config config = (Config) aggregatorConfig;
   String targetName =
       StringUtils.isNotNullAndNotEmpty(config.targetName) ? config.targetName : config.varName;
   int effectivePercentage = getEffectivePercentage(config.percentage);
   return new AggregatorPercentile(varCtx, config.varName, targetName, effectivePercentage);
 }
コード例 #3
0
 @Override
 protected boolean verifyUserInput() {
   String expression =
       variableItem.variableConfig.getExpr() != null
           ? variableItem.variableConfig.getExpr().trim()
           : "";
   if (StringUtils.isNullOrEmpty(expression)) {
     JOptionPane.showMessageDialog(
         getParent(), "The source band could not be created. The expression is empty.");
     return false;
   }
   String variableName =
       variableItem.variableConfig.getName() != null
           ? variableItem.variableConfig.getName().trim()
           : "";
   if (StringUtils.isNullOrEmpty(variableName)) {
     JOptionPane.showMessageDialog(
         getParent(), "The source band could not be created. The name is empty.");
     return false;
   }
   if (newVariable && contextProduct.containsBand(variableName)) {
     String message =
         String.format(
             "A source band or band with the name '%s' is already defined", variableName);
     JOptionPane.showMessageDialog(getParent(), message);
     return false;
   }
   try {
     BandArithmetic.getValidMaskExpression(expression, new Product[] {contextProduct}, 0, null);
   } catch (ParseException e) {
     String errorMessage =
         "The source band could not be created.\nThe expression could not be parsed:\n"
             + e.getMessage(); /*I18N*/
     JOptionPane.showMessageDialog(getParent(), errorMessage);
     return false;
   }
   return true;
 }