Ejemplo n.º 1
0
  @Override
  public StyledString getStyledText(Object element) {
    if (element instanceof AddNewFunctionModel) {
      return new StyledString("Add new function", StyledString.COUNTER_STYLER);
    } else if (element instanceof SetFunctionModel) {
      return new StyledString("Set function", StyledString.COUNTER_STYLER);
    } else if (element instanceof FunctionModel) {
      FunctionModel functionModel = (FunctionModel) element;
      IFunction function = functionModel.getFunction();
      if (function instanceof JexlExpressionFunction) {
        return getJexlStyledText((JexlExpressionFunction) function);
      } else {
        return new StyledString(function.getName());
      }
    } else if (element instanceof OperatorModel) {
      OperatorModel operatorModel = (OperatorModel) element;
      IOperator operator = operatorModel.getOperator();
      return new StyledString(operator.getName());
    } else if (element instanceof ParameterModel) {
      ParameterModel parameterModel = (ParameterModel) element;
      return new StyledString(parameterModel.getParameter().getName());
    }

    return new StyledString("");
  }
Ejemplo n.º 2
0
  @Override
  public void updateParameters() {
    params.clear();
    for (int i = 0; i < 2; i++) {
      IFunction f = getFunction(i);
      if (f == null) continue;
      for (int j = 0, jmax = f.getNoOfParameters(); j < jmax; j++) {
        IParameter p = f.getParameter(j);
        boolean add = true;
        for (IParameter param : params) {
          if (p == param) {
            add = false;
            break;
          }
        }
        if (add) {
          params.add(p);
        }
      }
    }
    setDirty(true);

    if (parent != null) {
      parent.updateParameters();
    }
  }
Ejemplo n.º 3
0
  @Override
  public String toString() {
    StringBuffer out = new StringBuffer();
    if (fa != null) {
      out.append(String.format("Function 0 - \n"));
      out.append(fa.toString());
      out.append('\n');
    }
    if (fb != null) {
      out.append(String.format("Function 1 - \n"));
      out.append(fb.toString());
      out.append('\n');
    }

    return out.length() == 0 ? OPERATOR_NO_FUNCTIONS : out.substring(0, out.length() - 1);
  }
Ejemplo n.º 4
0
 @Override
 public void removeFunction(int index) {
   switch (index) {
     case 0:
       fa.setParentOperator(null);
       fa = fb;
       fb = null;
       break;
     case 1:
       fb.setParentOperator(null);
       fb = null;
       break;
     default:
       throw new IndexOutOfBoundsException("Can not remove this index as it is not 0 or 1");
   }
   updateParameters();
 }
Ejemplo n.º 5
0
 @Override
 public void setFunction(int index, IFunction function) {
   switch (index) {
     case 0:
       fa = function;
       break;
     case 1:
       fb = function;
       break;
     default:
       throw new IndexOutOfBoundsException("Can not set this index as it is not 0 or 1");
   }
   if (function != null) function.setParentOperator(this);
   updateParameters();
 }