0

I try to set the Style of a Graph after the viewer (FxViewer) is created. This works and I do it just like this

        viewGraph.removeAttribute("ui.stylesheet");
        if(showOnlyMatchingNodesFlag && showOnlyMatchingEdgesFlag) {
            viewGraph.setAttribute("ui.stylesheet", Stylesheets.STYLESHEETONLYMATCHINGALL);
        }

The Graph and view is created this way:

    public Graph newGraph(boolean autoLayout)
{
    this.graph = new SingleGraph("Graph");
    graph.setAttribute("ui.stylesheet", Stylesheets.STYLESHEETALL);
    viewer = new FxViewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    if(autoLayout) {
        setAutolayout();
    }
    panel = (FxViewPanel) viewer.addView(FxViewer.DEFAULT_VIEW_ID, new FxGraphRenderer());
    borderPane.setCenter(panel);
    return graph;
}

public void setAutolayout()
{
    Layout layout = new SpringBox();
    layout.setQuality(0);
    layout.setStabilizationLimit(0.001);
    layout.setForce(1);
    layout.clear();
    viewer.enableAutoLayout(layout);
}

But after zoom with Page-UP the Style defaults again to the stylesheet I used after creation and stays like this. I even tried to create a new viewer after changing the stylesheet but this also doesn't seem to work and results in the same behavior. Is there something else I need to take care of when changing the stylesheet?

Niclas183
  • 1
  • 1
  • The problem was using the visibility-mode: hidden property for hiding certain nodes and edges. When using node.setAttribute( "ui.hide" ) it works even with zoom. – Niclas183 Aug 26 '23 at 13:29

0 Answers0