private ClustererBuilder getBuilder(Clusterer clusterer) { for (ClustererBuilder b : Lookup.getDefault().lookupAll(ClustererBuilder.class)) { if (b.getClustererClass().equals(clusterer.getClass())) { return b; } } return null; }
private void writeColumns(Clusterer clusterer) { Cluster[] clusters = clusterer.getClusters(); if (clusters != null && clusters.length > 0) { ClustererBuilder builder = getBuilder(clusterer); AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel(); String id = "clustering_" + builder.getName(); String title = "Clustering (" + builder.getName() + ")"; AttributeColumn col = am.getNodeTable().getColumn(id); if (col == null) { col = am.getNodeTable() .addColumn(id, title, AttributeType.INT, AttributeOrigin.COMPUTED, null); StatusDisplayer.getDefault() .setStatusText("A new column \"" + title + "\" has been created"); } for (int i = 0; i < clusters.length; i++) { Integer clusterId = new Integer(i); for (Node n : clusters[i].getNodes()) { n.getNodeData().getAttributes().setValue(col.getIndex(), clusterId); } } } }