Ejemplo n.º 1
0
 /*
  * Update a function.
  */
 private void updatePlot(
     Function oldFunc, String newExpr[], Color3f newColor, String[] bounds, float[] stepSize)
     throws IllegalExpressionException {
   // Try evaluating the function.
   Function newFunc = createNewFunction(newExpr, newColor, bounds, stepSize);
   newFunc.setView(oldFunc.getView());
   funcList.set(funcList.indexOf(oldFunc), newFunc);
   updateReferences(newFunc);
   FunctionLabel label = map.get(oldFunc);
   label.setMother(newFunc);
   map.remove(oldFunc);
   map.put(newFunc, label);
   setSelected(newFunc);
   plotter.removePlot(oldFunc);
   spawnNewPlotterThread(newFunc);
 }
Ejemplo n.º 2
0
  public void setSelected(Function f) {
    try {

      ACTIVE_FUNCTION = f;
      if (f != selectedFunction) {
        // Deselection.
        if (selectedFunction != null && selectedFunction == templateFunc) {
          for (int i = 0; i < input.length; i++) {
            input[i].setBackground(NORMAL_COLOR);
          }
        } else if (selectedFunction != null) {
          FunctionLabel label = map.get(selectedFunction);
          if (label != null) label.setSelected(false);
        }
        selectedFunction = f;

        // Selection of input fields.
        if (selectedFunction != null && selectedFunction == templateFunc) {
          for (int i = 0; i < input.length; i++) {
            input[i].setBackground(SELECTED_COLOR);
          }

          updateReferences(selectedFunction);
        }
      }

      // Needed for picking. The caret might not be active,
      if (selectedFunction != null && selectedFunction != templateFunc) {
        FunctionLabel selectedLabel = map.get(selectedFunction);
        updateReferences(selectedFunction);
        selectedLabel.setSelected(true);
      }
    } catch (IllegalExpressionException e) {

    }
  }