Beispiel #1
0
  /** Loads all current values from the parameter file for fitness functions. */
  private void load() {

    int n;

    for (int i = 0; i < param.FunctionSet.TREE_FUNCTIONS.size(); i++) {
      n = (Integer) param.FunctionSet.TREE_FUNCTIONS.get(i);
      treeBox[n].setSelected(true);
    }

    for (int i = 0; i < param.FunctionSet.SHAPE_FUNCTIONS.size(); i++) {
      n = (Integer) param.FunctionSet.SHAPE_FUNCTIONS.get(i) / 2;
      shapeBox[n].setSelected(true);
    }

    for (int i = 0; i < param.FunctionSet.MATH_FUNCTIONS.size(); i++) {
      n = (Integer) param.FunctionSet.MATH_FUNCTIONS.get(i);
      mathBox[n].setSelected(true);
    }

    for (int i = 0; i < param.FunctionSet.TEXTURE_FUNCTIONS.size(); i++) {
      n = (Integer) param.FunctionSet.TEXTURE_FUNCTIONS.get(i);
      textureBox[n].setSelected(true);
    }

    if (param.Parameters.ALPHA) alpha.setSelected(true);
    radius.setText(param.FunctionSet.RADIUS + "");
  };
Beispiel #2
0
  /** Method called when 'quit' is pressed. Saves all current parameters. */
  private void quit() {

    int n;

    if (getInt(radius) != -1) param.FunctionSet.RADIUS = getInt(radius);

    // Check that at least one root function is selected
    boolean treeselect = false;
    boolean shapeselect = true;
    boolean textureselect = true;

    for (int i = 0; i < treeBox.length; i++) {
      if (treeBox[i].isSelected()) treeselect = true;
    }

    // Check that if a shape root function is selected, at least one shape
    // is as well
    if (treeBox[1].isSelected()) {
      shapeselect = false;
      for (int i = 0; i < shapeBox.length; i++) {
        if (shapeBox[i].isSelected()) shapeselect = true;
      }
    }

    // Check that at least one texture terminal is selected if one non-
    // terminal texture is selected
    if (rT8.isSelected() || rT1.isSelected() || rT2.isSelected()) {
      textureselect = false;
      for (int i = 2; i <= 6; i++) if (textureBox[i].isSelected()) textureselect = true;
    }

    // If no errors, save progress
    if (treeselect && shapeselect && textureselect) {

      param.FunctionSet.TREE_FUNCTIONS = new LinkedList<Integer>();
      for (int i = 0; i < treeBox.length; i++) {
        if (treeBox[i].isSelected()) param.FunctionSet.TREE_FUNCTIONS.add(i);
      }

      param.FunctionSet.SHAPE_FUNCTIONS = new LinkedList<Integer>();
      for (int i = 0; i < shapeBox.length; i++) {
        if (shapeBox[i].isSelected()) {
          param.FunctionSet.SHAPE_FUNCTIONS.add(i * 2);
          param.FunctionSet.SHAPE_FUNCTIONS.add(i * 2 + 1);
        }
      }

      param.FunctionSet.MATH_FUNCTIONS = new LinkedList<Integer>();
      for (int i = 0; i < mathBox.length; i++) {
        if (mathBox[i].isSelected()) param.FunctionSet.MATH_FUNCTIONS.add(i);
      }

      param.FunctionSet.TEXTURE_FUNCTIONS = new LinkedList<Integer>();
      for (int i = 0; i < textureBox.length; i++) {
        if (textureBox[i].isSelected()) param.FunctionSet.TEXTURE_FUNCTIONS.add(i);
      }

      param.Parameters.ALPHA = alpha.isSelected();
    }

    exit();
  };