Search in sources :

Example 1 with FxMouseManager

use of org.graphstream.ui.fx_viewer.util.FxMouseManager in project gs-ui-javafx by graphstream.

the class DemoViewerFxEdgeSelection method main.

public static void main(String[] args) {
    System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
    Graph graph = new MultiGraph("main graph");
    viewPanel = (FxViewPanel) graph.display(true).getDefaultView();
    FxViewer view = (FxViewer) viewPanel.getViewer();
    view.getDefaultView().setMouseManager(new FxMouseManager(EnumSet.of(InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE)));
    ViewerPipe pipe = view.newViewerPipe();
    // graph.setAttribute( "ui.quality" );
    graph.setAttribute("ui.antialias");
    pipe.addViewerListener(new DemoViewerFxEdgeSelection());
    for (String nodeId : new String[] { "A", "B", "C" }) {
        Node node = graph.addNode(nodeId);
        node.setAttribute("ui.label", nodeId);
    }
    graph.addEdge("AB", "A", "B", true);
    graph.addEdge("BC", "B", "C", true);
    graph.addEdge("CA", "C", "A", true);
    graph.setAttribute("ui.stylesheet", styleSheet);
    float color = 0;
    float dir = 0.01f;
    while (loop) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        pipe.pump();
        color += dir;
        if (color > 1) {
            color = 1;
            dir = -dir;
        } else if (color < 0) {
            color = 0;
            dir = -dir;
        }
        showSelection(graph);
    }
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) Graph(org.graphstream.graph.Graph) MultiGraph(org.graphstream.graph.implementations.MultiGraph) FxMouseManager(org.graphstream.ui.fx_viewer.util.FxMouseManager) Node(org.graphstream.graph.Node) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Aggregations

Graph (org.graphstream.graph.Graph)1 Node (org.graphstream.graph.Node)1 MultiGraph (org.graphstream.graph.implementations.MultiGraph)1 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)1 FxMouseManager (org.graphstream.ui.fx_viewer.util.FxMouseManager)1 ViewerPipe (org.graphstream.ui.view.ViewerPipe)1