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

can not retrieving mouse-clicks in Graphstream #360

Open
kiendao515 opened this issue Apr 19, 2021 · 3 comments
Open

can not retrieving mouse-clicks in Graphstream #360

kiendao515 opened this issue Apr 19, 2021 · 3 comments

Comments

@kiendao515
Copy link

I try to do the same as the tutorial "Retrieving mouse clicks on the viewer" in graphstream ,I have added some nodes and edges but there is no thing to happen.

`public Clicks() {
// We do as usual to display a graph. This
// connect the graph outputs to the viewer.
// The viewer is a sink of the graph.
Graph graph = new SingleGraph("Clicks");
Viewer viewer = graph.display();
graph.addNode("a");
graph.addNode("b");
graph.addNode("c");
graph.addEdge("ab","a","b");
graph.addEdge("bc","c","b");
// The default action when closing the view is to quit
// the program.
viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.HIDE_ONLY);

    // We connect back the viewer to the graph,
    // the graph becomes a sink for the viewer.
    // We also install us as a viewer listener to
    // intercept the graphic events.
    ViewerPipe fromViewer = viewer.newViewerPipe();
    fromViewer.addViewerListener(this);
    fromViewer.addSink(graph);

    // Then we need a loop to do our work and to wait for events.
    // In this loop we will need to call the
    // pump() method before each use of the graph to copy back events
    // that have already occurred in the viewer thread inside
    // our thread.

    while(loop) {
        fromViewer.pump(); // or fromViewer.blockingPump(); in the nightly builds

        // here your simulation code.

        // You do not necessarily need to use a loop, this is only an example.
        // as long as you call pump() before using the graph. pump() is non
        // blocking.  If you only use the loop to look at event, use blockingPump()
        // to avoid 100% CPU usage. The blockingPump() method is only available from
        // the nightly builds.
    }
}

public void viewClosed(String id) {
    loop = false;
}

public void buttonPushed(String id) {
    System.out.println("Button pushed on node "+id);
}

public void buttonReleased(String id) {
    System.out.println("Button released on node "+id);
}

public void mouseLeft(String arg0) {}

public void mouseOver(String arg0) {}`
@geert3
Copy link

geert3 commented Jun 21, 2021

I'm also not getting the above basic node click example to work.
Also view.findGraphicElementAt() is inaccurate and doesn't find the proper graph node given MouseEvent coordinates. Mostly it returns null. When clicking randomly, it sometimes finds a node but it is never anywhere near the cursor.
Any help would be appreciated.

@geert3
Copy link

geert3 commented Jun 21, 2021

Seems to be the same as issue 301, i.e. due to Java9+ HDPI settings. Adding -Dsun.java2d.uiScale=100% fixes the bad coordinates but makes the application scale to barely readable font size.

@legolie
Copy link

legolie commented May 21, 2022

I have the same problem, any solution ?

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

3 participants