Ejemplo n.º 1
0
  @Override
  public final void compute() {

    // validate
    size = inputList.size();
    if (!inputList.isDefined() || size == 0) {
      outputList.setUndefined();
      return;
    }

    // convert geoList to sorted array of double
    sortedData = new double[size];
    for (int i = 0; i < size; i++) {
      GeoElement geo = inputList.get(i);
      if (geo.isNumberValue()) {
        NumberValue num = (NumberValue) geo;
        sortedData[i] = num.getDouble();

      } else {
        outputList.setUndefined();
        return;
      }
    }
    Arrays.sort(sortedData);

    // create the z values
    calculateZValues(size);

    // prepare output list. Pre-existing geos will be recycled,
    // but extra geos are removed when outputList is too long
    outputList.setDefined(true);
    for (int i = outputList.size() - 1; i >= size; i--) {
      GeoElement extraGeo = outputList.get(i);
      extraGeo.remove();
      outputList.remove(extraGeo);
    }
    int oldListSize = outputList.size();

    // iterate through the sorted data and create the normal quantile points

    boolean suppressLabelCreation = cons.isSuppressLabelsActive();
    cons.setSuppressLabelCreation(true);

    for (int i = 0; i < sortedData.length; i++) {
      if (i < oldListSize) ((GeoPoint) outputList.get(i)).setCoords(sortedData[i], zValues[i], 1.0);
      else outputList.add(new GeoPoint(cons, null, sortedData[i], zValues[i], 1.0));
    }

    // create qq line segment and add it to the list
    outputList.add(getQQLineSegment());

    cons.setSuppressLabelCreation(suppressLabelCreation);
  }