JUNG(Java Graph):如何防止顶点和边缘标签重叠? [英] JUNG (Java Graph): How to prevent Vertex- and Edge-Labels from overlapping?

查看:76
本文介绍了JUNG(Java Graph):如何防止顶点和边缘标签重叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用荣格绘制图表(我的意思是图表不是图表!)。问题是顶点和边缘标签与顶点和边缘重叠。这导致了奇怪的外观图。问题不是绑定到特定的布局算法(尽管我一直在使用FRLayout)。



有没有可能告诉JUNG防止这些重叠?我希望这已经实现了,唯一的问题是找到正确的选项!

解决方案

对Jung2之前不熟悉)。

Jung的优势之一是它的可扩展性和易扩展性。 Jung允许你插入各种转换器(简单的渲染属性),渲染器(更复杂的渲染)等等,以在缺省不正确时自定义行为。这些通常安装在RenderContext上(您可以从VisualizationViewer获得)。



另一方面,它的缺点是它的复杂性和缺乏体面的文档。如果你打算做任何中度到重度的定制,你需要深入Jung的源代码。



例如,顶点标签渲染可以通过自定义插入一个新的顶点标签渲染器(Renderer.VertexLabel接口)。例如,您可以实例化BasicVertexLabelRenderer并指定不同的位置(北,西,中心等)。你可以把你的标签放在中心位置,如果你愿意把形状改变成比圆形更大的东西(这样做,安装你自己的顶点形状变换器 - 一个变形器的实例)。或者,您可以创建您自己的此接口的自定义实现,从而在标签文本下呈现背景。



您也可以安装您自己的Renderer.EdgeLabel版本(请参阅Jung的BasicEdgeLabelRenderer)来自定义边缘标签的位置。


I'm currently using Jung to draw graphs (I really mean graphs not charts!). The problem is that Vertex and Edge Labels are overlapping with the Vertexes and the Edges. This leads into strange looking graphs. The Problem is not bound to a specific Layout-Algorithm (though I've been using FRLayout).

Are there any possibilities to tell JUNG to prevent these overlappings? I hoped this is already implemented and the only problem is to find the right options!

解决方案

(The following answer assumes Jung2; I'm not familiar with pre-Jung2).

One of Jung's strengths is that it is very extensible, and easily extended. Jung allows you to plug in various transformers (simple rendering properties), renderers (more complex rendering), and so forth, to customize the behavior when the default isn't quite right. These are typically installed on the RenderContext (which you can get from your VisualizationViewer).

On the flip side, its drawbacks are its complexity and lack of decent documentation. If you're going to do any moderate to heavy customization, you'll need to dig into the Jung source.

For example, the vertex label rendering can be customized by plugging in a new vertex label renderer (Renderer.VertexLabel interface). For example, you can instantiate BasicVertexLabelRenderer and specifying a different position (north, west, center, etc.). You could put your label at the center, if you are willing to change the shape into something larger than that circle (to do so, install your own vertex shape transformer -- an instance of Transformer). Alternatively, you could create your own custom implementation of this interface which renders a background under the label text.

You could also install your own tweaked version of Renderer.EdgeLabel (see Jung's BasicEdgeLabelRenderer) to customize the positioning of the edge label.

这篇关于JUNG(Java Graph):如何防止顶点和边缘标签重叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆