简体   繁体   中英

How to move graph edges when scrolling in JUNG

I'm using JUNG 2.0 to visually render a directed acyclic graph, and have added a custom EdgeRenderer to render edges in a variety of colors. The actual edges are drawn by invoking the drawLine() and drawPolyline() methods on a RenderContext object.

All works as it should, except when I manually scroll the GraphZoomScrollPane to which my VisualizationViewer object is added: then the vertices scroll as expected, but the edge lines stay exactly in the same spot on the screen. That is to say:

This is correct

This is what happens when I scroll

How can I get the edges to actually scroll with?

(If it helps, zooming with a CrossoverScalingControl works perfectly fine, and the edges grow larger and smaller in their correct positions.)

It sounds like you're drawing the edges in the wrong coordinate space. There are two coordinate systems: layout coordinates and rendering coordinates. You need to make sure you use the right ones in the right context (and in particular, that you use the same coordinate system for the vertices as you are for the edges).

If you can provide a little bit more context in your question about how you're actually invoking draw*Line(), and how that differs from how JUNG does it, it will probably be easier to establish exactly what you need to fix.

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