I've got a function which filters the graph and auto-lays it out. The trouble is, the filtering doesn't complete before it starts the layout. This is probably very basic, but what would be a good way to wait for filtering to complete before proceeding with the autolayout? It seems with FilterController's filterVisible(Query) method it spins off a new Thread, but I'm not sure how to deal with it. Here's what I've got going:
Code: Select all
public void filter() {
Partition<Node> categoryPartition = partitionController.buildPartition(nodeCategory, graph);
String[] categories = new String[]{"SOURCE", "SCORED", "BRIDGE"};
Query categoryQuery = FilterUtils.createNodeQuery(categoryPartition, categories);
Query distQuery = FilterUtils.createNeighborhoodQuery(source, 1);
Query query = FilterUtils.unionQueries(new Query[]{categoryQuery, distQuery});
filterController.filterVisible(query);
}
public void layout() {
AutoLayout layout = new AutoLayout(1, TimeUnit.SECONDS);
layout.setGraphModel(graphModel);
ForceAtlasLayout forceDirectedLayout = new ForceAtlasLayout(null);
AutoLayout.DynamicProperty repulsionProperty =
AutoLayout.createDynamicProperty("forceAtlas.repulsionStrength.name",
5000D, 0f);
layout.addLayout(forceDirectedLayout, 1f,
new AutoLayout.DynamicProperty[]{repulsionProperty});
layout.execute();
}
Code: Select all
public void execute() {
Progress.setDisplayName(progressTicket, "Analytic running...");
Progress.start(progressTicket);
Progress.progress(progressTicket, "Loading graph into Gephi...");
performImport();
Progress.progress(progressTicket, "Filtering graph...");
filter();
Progress.progress(progressTicket, "Laying out graph...");
layout();
//and so forth...
}