Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter labels of graph using gephi-toolkit-0.9.1 #22

Closed
mari-mari opened this issue Jun 2, 2017 · 3 comments
Closed

Filter labels of graph using gephi-toolkit-0.9.1 #22

mari-mari opened this issue Jun 2, 2017 · 3 comments

Comments

@mari-mari
Copy link

Hi, I would like the resulting graph to contain all nodes, but to show labels only for those with degree>1000.
Call of exportToLabelVisible(query) changes labels of nodes to be not visible (node.isVisible() is false), but the resulting graph in the file still has labels for all the nodes.

FilterController filterController = Lookup.getDefault().lookup(FilterController.class); 
DegreeRangeFilter degreeFilter = new DegreeRangeFilter(); 
degreeFilter.init(graphModel.getGraph()); 
degreeFilter.setRange(new Range(1000, Integer.MAX_VALUE));     
Query query = filterController.createQuery(degreeFilter); 
       
 
filterController.exportToLabelVisible(query);
//filterController.filterVisible(query);
   
GraphView view = graphModel.getGraphVisible().getView();             
graphModel.setVisibleView(view);
  

PNGExporter pngExporter = (PNGExporter) ec.getExporter("png");
ec.exportFile(new File("FILE.png"), pngExporter);

I know how to do that in desktop app, but really stuck with the toolkit. I would appreciate any help.

@eduramiba
Copy link
Member

I think you will need to refresh preview with the preview controller before export

@mari-mari
Copy link
Author

mari-mari commented Jun 3, 2017

Thanks for the reply.
I tried refreshing preview, did not work for me :/

filterController.exportToLabelVisible(query);
GraphView view = graphModel.getGraphVisible().getView();             
graphModel.setVisibleView(view);
Lookup.getDefault().lookup(PreviewController.class).refreshPreview(workspace);
// here goes export

However, I solved the problem in a pretty dirty way, by iterating through all nodes and setting labels to empty string if a nodes' textProperties set to not visible:

NodeIterable nodes = graphModel.getGraph().getNodes();

filterController.exportToLabelVisible(query);
for (Node n : nodes) {
    if (!n.getTextProperties().isVisible()) {
        n.setLabel("");
    } 
}
//here goes export

@eduramiba
Copy link
Member

Right, this is the correct approach with visible labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants