简体   繁体   中英

mouseEntered a JUNG2 vertex

I am looking for the "correct" way to show a custom Component as a popup when I mouseover a Vertex in JUNG2.

This question is essentially the same as

Jung2: How to implement displaying details of a node on mouse over of a Node?

but that person seems to be content with a simple tooltip popup, whereas I am not.

NOTE: I am currently using an implementation of PluggableGraphMouse with a MouseMotionListener plugin which does something like this (I have Note objects as vertices):

    @Override
    public void mouseMoved(MouseEvent e) {
        Note note = graphVisualiser.getPickSupport().getVertex(getGraphLayout(), e.getX(), e.getY());
        if (note != null && note != lastMouseOverNote) {
            lastMouseOverNote = note;
            // my handling code here
        }
    }

It works when I mouse over a vertex, and I can also expand on the above to turn off the popup when the mouse goes away, but I am concerned that this approach is incredibly inefficient: it is essentially checking to see if I'm mousing over a vertex every time the mouse moves.

I'd rather have a Listener approach - is there a way to register mouseEntered / mouseExited event to the vertices? (from what I can tell, this is all happening through raw painting and there is no Component that I could register with).

因为顶点是作为图元绘制的,并且没有鼠标移动的侦听器,所以只能这样做,因为只能进行选择/取消选择。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM