public void showVoronoi() {
    voronoi = new Voronoi();
    for (String btsID : BTS2Location.keySet()) {
      Location location = BTS2Location.get(btsID);
      float xy[] = this.map.getScreenPositionFromLocation(location);
      if (xy[0] > width * 2
          || xy[0] < -(width * 2)
          || xy[1] > height * 2
          || xy[1] < -(height * 2)) {
        // avoid errors in toxiclib
        continue;
      }
      try {
        voronoi.addPoint(new Vec2D(xy[0], xy[1]));
      } catch (Exception e) {
        logger.debug(e);
      }
    }

    noFill();
    stroke(0xFF40a6dd);
    strokeWeight(1);

    for (Polygon2D polygon : voronoi.getRegions()) {
      gfx.polygon2D(polygon);
    }

    fill(255, 0, 255);
    noStroke();
    for (Vec2D c : voronoi.getSites()) {
      ellipse(c.x, c.y, 5, 5);
    }
  }
  public void calculateVoronoi() {

    voronoi = new Voronoi();

    for (PVector i : points) {
      voronoi.addPoint(new Vec2D(i.x, i.y));
    }

    interactionHandler.actionHook(this, HandlerActions.UPDATE_GRID);
  }
  public void draw(PGraphics i_context) {

    i_context.background(255);

    i_context.noFill();
    i_context.stroke(0);

    List<Polygon2D> polys;

    if (gridType == VoronoiDelaunayGrid.DELAUNAY) {
      polys = new ArrayList<Polygon2D>();
      for (Triangle2D t : voronoi.getTriangles()) {
        polys.add(t.toPolygon2D());
      }
    } else polys = voronoi.getRegions();

    for (Polygon2D poly : polys) {

      Polygon2D clipped = clip.clipPolygon(poly);

      i_context.beginShape();
      for (Vec2D pt : clipped.vertices) {
        i_context.vertex(pt.x, pt.y);
      }

      Vec2D pt = clipped.vertices.get(0);
      i_context.vertex(pt.x, pt.y);
      i_context.endShape();
    }

    for (PVector pos : points) {
      i_context.fill(255, 0, 0);
      i_context.stroke(255, 0, 0);
      i_context.ellipse(pos.x, pos.y, 2, 2);
    }
  }