Example #1
0
  /**
   * Creates new random element algo
   *
   * @param cons
   * @param label
   * @param geoList
   */
  public AlgoRandomElement(Construction cons, String label, GeoList geoList) {
    super(cons);
    this.geoList = geoList;

    // init return element as copy of first list element
    if (geoList.size() > 0) {
      element = geoList.get(0).copyInternal(cons);
    } else if (geoList.getTypeStringForXML() != null) {
      // if the list was non-empty at some point before saving, get the
      // same type of geo
      // saved in XML from 4.1.131.0
      element = kernel.createGeoElement(cons, geoList.getTypeStringForXML());
    }

    // desperate case: empty list
    else {
      // saved in XML from 4.0.18.0
      element = cons.getOutputGeo();
    }

    setInputOutput();
    compute();
    element.setLabel(label);
    cons.addRandomGeo(element);
  }