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

org.gephi.preview.spi.PreviewMouseListener receives wrong coordinates. #2561

Closed
kblinichkin opened this issue Jul 16, 2022 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@kblinichkin
Copy link

Given: org.gephi.preview.spi.PreviewMouseListener is implemented and added to the corresponding Renderer in a module.

Expected Behaviour

When clicking on a node of a graph in the Preview Mode, PreviewMouseEvent coordinates received in PreviewMouseListener::mouseClicked(PreviewMouseEvent pme, ...) method correspond to PreviewModel's actual coordinates.

Current Behavior

PreviewMouseEvent coordinates received in PreviewMouseListener::mouseClicked(PreviewMouseEvent pme, ...) method is wrong.
When clicking on a node in the Preview Mode, the coordinates from the mentioned method do not correspond to the coordinates of the corresponding node in the PreviewModel.

Possible Solution

org.gephi.desktop.preview.PreviewSketch.java:

...
private Vector screenPositionToModelPosition(Vector screenPos) {
        Vector center = new Vector(getWidth() / 2f, getHeight() / 2f);
        Vector scaledCenter = Vector.mult(center, target.getScaling());
        Vector scaledTrans = Vector.sub(center, scaledCenter);

        Vector modelPos = new Vector(screenPos.x, screenPos.y);
        modelPos.sub(scaledTrans);
        modelPos.mult(scaleFactor); // <---- This line is missing
        modelPos.div(target.getScaling());
        modelPos.sub(target.getTranslate());
        return modelPos;
}
...

Steps to Reproduce

  1. Implement org.gephi.preview.spi.PreviewMouseListener according to the documentation and add it to some module.
  2. Install the module.
  3. Build/load some graph.
  4. Go to the Preview Mode and click on some node of the graph.
  5. Check if coordinates received in PreviewMouseListener::mouseClicked method correspond to the actual box of the node being clicked.

Context

It doesn't affect me directly because I fixed it for my own purpose.
However it's a bug for further development of Gephi Platform.

Your Environment

  • Version used: Gephi 0.9.6
  • Operating System: MacOS, M1.
@mbastian mbastian self-assigned this Jul 17, 2022
@mbastian mbastian added this to the 0.9.7 milestone Jul 17, 2022
@mbastian
Copy link
Member

Hi @kblinichkin and thanks for the detailed report. Nice find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants