graphstream / gs-ui-javafx

GraphStream JavaFX user interface
http://graphstream-project.org/
Other
42 stars 12 forks source link

graph.setAttribute("ui.stylesheet", css) and FxViewer #17

Closed KEN-00 closed 5 years ago

KEN-00 commented 5 years ago

I have create a graph and set the css using graph.setAttribute("ui.stylesheet", css), and created a FxViewPanel. The graph is displayed properly, but it seems that the css is not working.

Code:

public static FxViewPanel createGraphPanel(Graph graph) throws MalformedURLException {
        String css = FXUtils.getCss(FXUtils.GRAPH_CSS_FILE_PATH);
                graph.setAttribute("ui.stylesheet", new URL(css));
        FxViewer viewer = new FxViewer(stateGraph, 
                FxViewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
        viewer.enableAutoLayout();
        FxViewPanel graphPanel = (FxViewPanel) viewer.addDefaultView(false, new FxGraphRenderer());
        return graphPanel;
    }

CSS:

graph {
    fill-color: red;
    fill-mode: plain;
    text-style:normal;
    text-mode:normal;
    text-background-mode:plain;
}

node {
    size: 10px;
    shape: circle ;
    fill-color: green;
    stroke-mode: plain;
    stroke-color: yellow;
}

node:clicked {
    fill-color: red;
}

Error:

Mar 13, 2019 10:50:42 PM org.graphstream.ui.graphicGraph.GraphicGraph attributeChanged
WARNING: Error with stylesheet specification what to do with 'file:/C:/Users/cfchiu6/git/awtu/resource/style/graph.css'.
pigne commented 5 years ago

Pseudo-classes (node:clicked) are not supported in the css selectors. Only classes are (node.clicked). You can set a class in a node with attributes (node.setAttribute("ui.class", "clicked")).

KEN-00 commented 5 years ago

Pseudo-classes (node:clicked) are not supported in the css selectors. Only classes are (node.clicked). You can set a class in a node with attributes (node.setAttribute("ui.class", "clicked")).

Hi @pigne , I have changed the css yet the same error message is shown T^T