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); }