Iterator<Cluster<Model>> ci = clustering.getAllClusters().iterator();
for(int cnum = 0; cnum < clustering.getAllClusters().size(); cnum++) {
Cluster<?> clus = ci.next();
final DBIDs ids = clus.getIDs();
if(alpha >= Double.POSITIVE_INFINITY) {
GrahamScanConvexHull2D hull = new GrahamScanConvexHull2D();
for(DBID clpnum : ids) {
double[] projP = proj.fastProjectDataToRenderSpace(rel.get(clpnum));
hull.add(new Vector(projP));
}
Polygon chres = hull.getHull();
// Plot the convex hull:
if(chres != null && chres.size() > 1) {
SVGPath path = new SVGPath(chres);
// Approximate area (using bounding box)
double hullarea = SpatialUtil.volume(chres);
final double relativeArea = (projarea - hullarea) / projarea;
final double relativeSize = (double) ids.size() / rel.size();
opacity = Math.sqrt(relativeSize * relativeArea);
Element hulls = path.makeElement(svgp);
addCSSClasses(svgp, cnum, opacity);
SVGUtil.addCSSClass(hulls, CLUSTERHULL + cnum);
layer.appendChild(hulls);
}
}
else {
ArrayList<Vector> ps = new ArrayList<Vector>(ids.size());
for(DBID clpnum : ids) {
double[] projP = proj.fastProjectDataToRenderSpace(rel.get(clpnum));
ps.add(new Vector(projP));
}
List<Polygon> polys = (new AlphaShape(ps, alpha * Projection.SCALE)).compute();