You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I set SHOW_NODE_LABELS to true on the preview model, it is not persisted when saved to a gephi file and then opened in the UI. If I export to pdf if works, but not when I save to a gephi file.
Please advise what I am doing wrong, or if this is a bug. Many thanks
var pc = Lookup.getDefault().lookup(ProjectController.class);
pc.newProject();
Workspace workspace = pc.getCurrentWorkspace();
var graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
var n0 = graphModel.factory().newNode("n0");
n0.setLabel("Node 0");
var n1 = graphModel.factory().newNode("n1");
n1.setLabel("Node 1");
var e1 = graphModel.factory().newEdge(n1, n0, 1, true);
var directedGraph = graphModel.getDirectedGraph();
directedGraph.addNode(n0);
directedGraph.addNode(n1);
directedGraph.addEdge(e1);
System.out.println("Nodes " + directedGraph.getNodeCount());
var appearanceController = Lookup.getDefault().lookup(AppearanceController.class);
var appearanceModel = appearanceController.getModel();
// Rank color by Degree
Function degreeRanking = appearanceModel.getNodeFunction(graphModel.defaultColumns()
.degree(), RankingElementColorTransformer.class);
RankingElementColorTransformer degreeTransformer = degreeRanking.getTransformer();
degreeTransformer.setColors(new Color[]{new Color(0xFEF0D9), new Color(0xB30000)});
degreeTransformer.setColorPositions(new float[]{0f, 1f});
appearanceController.transform(degreeRanking);
// Get Centrality
GraphDistance distance = new GraphDistance();
distance.setDirected(true);
distance.execute(graphModel);
// Rank size by centrality
Column centralityColumn = graphModel.getNodeTable().getColumn(GraphDistance.BETWEENNESS);
Function centralityRanking = appearanceModel.getNodeFunction(centralityColumn, RankingNodeSizeTransformer.class);
RankingNodeSizeTransformer centralityTransformer = (RankingNodeSizeTransformer) centralityRanking.getTransformer();
centralityTransformer.setMinSize(3);
centralityTransformer.setMaxSize(10);
appearanceController.transform(centralityRanking);
// Rank label size - set a multiplier size
Function centralityRanking2 = appearanceModel.getNodeFunction(centralityColumn, RankingLabelSizeTransformer.class);
RankingLabelSizeTransformer labelSizeTransformer = (RankingLabelSizeTransformer) centralityRanking2.getTransformer();
labelSizeTransformer.setMinSize(1);
labelSizeTransformer.setMaxSize(3);
appearanceController.transform(centralityRanking2);
var previewController = Lookup.getDefault().lookup(PreviewController.class);
var previewModel = previewController.getModel();
previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE);
previewController.refreshPreview();
var file = new File("preview-issue.gephi");
file.createNewFile(); // to get around a bug in 0.10.1
pc.saveProject(pc.getCurrentProject(), file);
The text was updated successfully, but these errors were encountered:
Hi,
When I set SHOW_NODE_LABELS to true on the preview model, it is not persisted when saved to a gephi file and then opened in the UI. If I export to pdf if works, but not when I save to a gephi file.
Please advise what I am doing wrong, or if this is a bug. Many thanks
The text was updated successfully, but these errors were encountered: