简体   繁体   English

在JUNG中滚动时如何移动图形边缘

[英]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. 我正在使用JUNG 2.0直观地绘制有向无环图,并添加了自定义EdgeRenderer来以各种颜色渲染边缘。 The actual edges are drawn by invoking the drawLine() and drawPolyline() methods on a RenderContext object. 通过在RenderContext对象上调用drawLine()drawPolyline()方法来绘制实际边缘。

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. 除了手动滚动添加了VisualizationViewer对象的GraphZoomScrollPane之外,所有操作GraphZoomScrollPane按预期进行:顶点将按预期滚动,但边缘线完全位于屏幕上的同一位置。 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.) (如果有帮助,使用CrossoverScalingControl 缩放可以很好地工作,并且边缘在正确的位置处会越来越大。)

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. 如果您可以在问题中提供更多有关实际调用draw * Line()的上下文,以及它与JUNG的区别如何,那么可能很容易确定确切的修复方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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