*/
@Override
public void write(ClusterWritable clusterWritable) throws IOException {
StringBuilder line = new StringBuilder();
Cluster cluster = clusterWritable.getValue();
Color rgb = getColor(cluster.getId());
String topTerms = "";
if (dictionary != null) {
topTerms = getTopTerms(cluster.getCenter(), dictionary, numTopFeatures);
}
String clusterLabel = String.valueOf(cluster.getId()) + "_" + topTerms;
//do some positioning so that items are visible and grouped together
//TODO: put in a real layout algorithm
float x = lastX + 1000;
float y = lastY;
if (x > (1000 + posStep)) {
y = lastY + 1000;
x = 0;
}
line.append(createNode(clusterLabel, rgb, x, y));
List<WeightedVectorWritable> points = clusterIdToPoints.get(cluster.getId());
if (points != null) {
for (WeightedVectorWritable point : points) {
Vector theVec = point.getVector();
double distance = 1;
if (measure != null) {
distance = measure.distance(cluster.getCenter().getLengthSquared(), cluster.getCenter(), theVec) * 500; //scale the distance
}
String vecStr;
int angle = random.nextInt(360); //pick an angle at random and then scale along that angle
double angleRads = Math.toRadians(angle);