@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("");
  }
Esempio n. 2
0
  @Test
  public void testParameterModelParsingSpecialValues() {
    Gaussian gaussian = new Gaussian();
    ParameterModel parameterModel =
        new ParameterModel(createMockModelRoot(), mock(FunctionModel.class), gaussian, 0);

    parameterModel.setParameterValue("Min Double");
    assertEquals(-Double.MAX_VALUE, parameterModel.getParameterValue(), 0);
    parameterModel.setParameterValue("Max Double");
    assertEquals(Double.MAX_VALUE, parameterModel.getParameterValue(), 0);
  }
 @Override
 public void run() {
   FunctionModelElement model = viewer.getSelectedFunctionModel();
   if (model instanceof ParameterModel) {
     ParameterModel parameterModel = (ParameterModel) model;
     IParameter fittedParameter = parameterModel.getFittedParameter();
     if (fittedParameter != null) {
       parameterModel.setParameterValue(fittedParameter.getValue());
       viewer.refresh(parameterModel.getParameter());
     }
   }
 }
Esempio n. 4
0
  @Test
  public void testParameterModel() {
    Gaussian gaussian = new Gaussian();
    ParameterModel parameterModel =
        new ParameterModel(createMockModelRoot(), mock(FunctionModel.class), gaussian, 0);

    parameterModel.setParameterValue("123.4");
    assertEquals(123.4, parameterModel.getParameterValue(), 0);
    assertEquals(null, parameterModel.getParameterValueError());
    parameterModel.setParameterLowerLimit("-456.7");
    assertEquals(-456.7, parameterModel.getParameterLowerLimit(), 0);
    assertEquals(null, parameterModel.getParameterLowerLimitError());
    parameterModel.setParameterUpperLimit("789.1");
    assertEquals(789.1, parameterModel.getParameterUpperLimit(), 0);
    assertEquals(null, parameterModel.getParameterUpperLimitError());

    parameterModel.setParameterValue("invalid1");
    assertEquals(123.4, parameterModel.getParameterValue(), 0);
    assertEquals("invalid1", parameterModel.getParameterValueError());
    parameterModel.setParameterLowerLimit("invalid2");
    assertEquals(-456.7, parameterModel.getParameterLowerLimit(), 0);
    assertEquals("invalid2", parameterModel.getParameterLowerLimitError());
    parameterModel.setParameterUpperLimit("invalid3");
    assertEquals(789.1, parameterModel.getParameterUpperLimit(), 0);
    assertEquals("invalid3", parameterModel.getParameterUpperLimitError());
  }