Пример #1
0
  /**
   * Constructor
   *
   * @param points an array of points
   */
  public GPointsArray(GPointsArray points) {
    this.points = new ArrayList<GPoint>(points.getNPoints());

    for (int i = 0; i < points.getNPoints(); i++) {
      this.points.add(new GPoint(points.get(i)));
    }
  }
Пример #2
0
  /**
   * Sets all the points in the array
   *
   * @param pts the new points. The number of points could differ from the original.
   */
  public void set(GPointsArray pts) {
    if (pts.getNPoints() == points.size()) {
      for (int i = 0; i < points.size(); i++) {
        points.get(i).set(pts.get(i));
      }
    } else if (pts.getNPoints() > points.size()) {
      for (int i = 0; i < points.size(); i++) {
        points.get(i).set(pts.get(i));
      }

      for (int i = points.size(); i < pts.getNPoints(); i++) {
        points.add(new GPoint(pts.get(i)));
      }
    } else {
      for (int i = 0; i < pts.getNPoints(); i++) {
        points.get(i).set(pts.get(i));
      }

      points.subList(pts.getNPoints(), points.size()).clear();
    }
  }
Пример #3
0
 /**
  * Adds a new set of points to the array
  *
  * @param pts the new set of points
  */
 public void add(GPointsArray pts) {
   for (int i = 0; i < pts.getNPoints(); i++) {
     points.add(new GPoint(pts.get(i)));
   }
 }