예제 #1
0
  private void removePoint(GeoPoint oldPoint) {

    // remove dependent algorithms (e.g. segments) from update sets of
    // objects further up (e.g. polygon) the tree
    ArrayList algoList = oldPoint.getAlgorithmList();
    for (int k = 0; k < algoList.size(); k++) {
      AlgoElement algo = (AlgoElement) algoList.get(k);
      for (int j = 0; j < input.length; j++) input[j].removeFromUpdateSets(algo);
    }

    // remove old point
    oldPoint.setParentAlgorithm(null);

    // remove dependent segment algorithm that are part of this polygon
    // to make sure we don't remove the polygon as well
    for (int k = 0; k < algoList.size(); k++) {
      AlgoElement algo = (AlgoElement) algoList.get(k);
      // make sure we don't remove the polygon as well
      if (algo instanceof AlgoJoinPointsSegment
          && ((AlgoJoinPointsSegment) algo).getPoly() == poly) {
      } else {
        algo.remove();
      }
    }

    algoList.clear();
    // remove point
    oldPoint.doRemove();
  }
예제 #2
0
  /** Ensure that the pointList holds n points. */
  private void updatePointsArray(int n) {

    GeoPoint[] oldPoints = points;
    int oldPointsLength = oldPoints == null ? 0 : oldPoints.length;
    // System.out.println("update points: " + n + "  old length: " + oldPointsLength);

    // new points
    points = new GeoPoint[n];

    // reuse old points
    for (int i = 0; i < oldPointsLength; i++) {
      if (i < points.length) {
        // reuse old point
        points[i] = oldPoints[i];
      } else {
        removePoint(oldPoints[i]);
      }
    }

    // create new points if needed
    for (int i = oldPointsLength; i < points.length; i++) {
      GeoPoint newPoint = new GeoPoint(cons);
      newPoint.setCoords(0, 0, 1); // set defined
      newPoint.setParentAlgorithm(this);
      newPoint.setEuclidianVisible(true);
      newPoint.setAuxiliaryObject(true);
      points[i] = newPoint;
    }
  }