简体   繁体   English

比较开源java图形绘制框架(JUNG和Prefuse)绘制网络拓扑

[英]comparing open source java graph drawing frameworks(JUNG and Prefuse) for drawing network topology

which of the open source Java graph drawing frameworks to use for a network diagram with the following requirements? 哪个开源Java图形绘制框架用于具有以下要求的网络图? The graph will have less than 1000 nodes. 该图表将少于1000个节点。

1) has parallel edges 1)具有平行边缘
2) directed and undirected edges within a single graph 2)单个图中的有向和无向边
3) nodes represented by images 3)由图像表示的节点
4) user interaction with nodes and edges 4)用户与节点和边缘的交互
5) dynamically adding/deleting nodes and edges 5)动态添加/删除节点和边缘
6) multiple labelling on nodes and edges , different levels of labelling can be turned off/on by users. 6)节点和边缘上的多个标签,用户可以关闭/打开不同的标签级别。 (like drawing in layers and turning off / on a layer) (比如在图层中绘图并关闭/在图层上)
7) different layout algorithms to display star, ring, mesh topologies 7)不同的布局算法,以显示星形,环形,网状拓扑

I evaluated JUNG and Prefuse. 我评估了JUNG和Prefuse。 This is what I found for each of my requirements. 这是我为每个要求找到的。

1) Prefuse cannot display parallel edges while JUNG supports it. 1)当JUNG支持时,Prefuse不能显示平行边缘。 Can prefuse code be manipulated to display parallel edges ? 可以预操作代码来显示平行边缘吗? Since this involves basic data level changes I believe this would be more difficult that the usual customized rendering changes. 由于这涉及基本的数据级别更改,我相信通常的自定义呈现更改会更加困难。

2) I didnt find any reference to combined graph (both directed and undirected edges) in both prefuse and JUNG. 2)我没有在prefuse和JUNG中找到任何对组合图(有向和无向边)的引用。 Does anyone know otherwise? 有没有人知道呢?

3) This seems easy with both Prefuse and JUNG 3)Prefuse和JUNG都很容易

4) Again both prefuse and JUNG provides support for user interaction. 4)prefeuse和JUNG再次为用户交互提供支持。

5) Both prefuse and JUNG supports it. 5)prefuse和JUNG都支持它。 How does each framework perform while redrawing the graph ? 重绘图表时每个框架如何执行? I saw in another post that prefuse does not perform well for dynamic updates ( 我在另一篇文章中看到,prefuse在动态更新方面效果不佳( Prefuse Toolkit: dynamically adding nodes and edges ) Prefuse Toolkit:动态添加节点和边缘

6) This comes down to modifying the graph and redrawing it. 6)这归结为修改图形并重新绘制它。 So the question becomes the same as 5) 所以问题变得与5)相同

7) Both JUNG and prefuse has multiple layout algorithms. 7)JUNG和prefuse都有多种布局算法。 But When I tried to display the same dataset using FruchtermanReingoldLayout in both JUNG and Prefuse I get different displays. 但是当我尝试在JUNG和Prefuse中使用FruchtermanReingoldLayout显示相同的数据集时,我会得到不同的显示。 Any ideas why ? 有什么想法吗? Somehow the layout algorithms in Prefuse seem to display a better layout than in JUNG (rendering is also better I think) though most of the layout algorithms in Prefuse are based on JUNG implementation. 虽然Prefuse中的大多数布局算法都是基于JUNG实现的,Prefuse中的布局算法似乎显示出比JUNG更好的布局(渲染也更好)。 Prefuse layouts such as ForceDirectedLayout/FruchtermanReingoldLayout and CircleLayout directly maps to star,circle, mesh topologies. PreFuse布局(如ForceDirectedLayout / FruchtermanReingoldLayout和CircleLayout)直接映射到星形,圆形,网格拓扑。

Outside of these requirements, prefuse has good support for expressions and query language but looks like it is not actively developed unlike JUNG. 在这些要求之外,prefuse对表达式和查询语言有很好的支持,但看起来它不像JUNG那样积极开发。 which one has better visualization? 哪一个有更好的可视化? Any suggestions on which one will be suitable and how to overcome the shortcomings ? 关于哪一个适合以及如何克服缺点的任何建议?

Any other frameworks out there which I can use ? 我可以使用其他任何框架吗?

I'm one of the creators and maintainers of JUNG, so bear that in mind for the responses below. 我是JUNG的创作者和维护者之一,所以请记住下面的回答。

First, though, I should say that the author of Prefuse is a friend of a friend (and yes, we've met) and he's done a great job. 首先,我应该说,Prefuse的作者是朋友的朋友(是的,我们见过面)并且他做得很好。 I am not experienced with Prefuse, but I've seen some beautiful visualizations created with it. 我对Prefuse没有经验,但我见过用它创建的一些漂亮的可视化。

Here are the answers to those questions for JUNG. 以下是JUNG对这些问题的回答。 Several of them ((1), (2), (4)are demonstrated in PluggableRendererDemo : 其中几个((1),(2),(4)在PluggableRendererDemo中演示:

  1. Supported (you'll need the right data model, not all support parallel edges for performance reasons) 支持(出于性能原因,您需要正确的数据模型,并非所有支持并行边缘)
  2. Supported (again, you need the right data model) 支持(再次,您需要正确的数据模型)
  3. Supported (see ImageShaperDemo ) 支持(参见ImageShaperDemo
  4. Supported (most demos) 支持(大多数演示)
  5. Supported (see GraphEditorDemo ) 支持(参见GraphEditorDemo
  6. Not directly supported, although you can certainly change labels dynamically and use HTML to render complex labels. 不直接支持,虽然您当然可以动态更改标签并使用HTML来呈现复杂标签。
  7. JUNG's layout algorithms are more for general networks (with a few exceptions for trees, etc.). JUNG的布局算法更适用于一般网络(树木等少数例外)。 You can certainly construct your own layout algorithms, however, and many have done so. 但是,您当然可以构建自己的布局算法,并且许多人已经这样做了。

Hope this helps. 希望这可以帮助。

A few years back (2007?) I use prefuse to visualize call data records. 几年前(2007年?)我使用prefuse来显示呼叫数据记录。 I considered prefuse, jung, jgraph and a few others and chose prefuse. 我考虑了prefuse,jung,jgraph和其他一些人,并选择了prefuse。 At first it's a bit hard to wrap my head around prefuse but once I got familiar with it it's really easy (to extend) and fun to use. 起初有点难以将我的头包裹起来,但是一旦我熟悉它,它就非常容易(扩展)和使用起来很有趣。 I guess the same can be said for JUNG but I never tried it. 我想JUNG可以这么说,但我从未尝试过。

1) In prefuse it's very easy to add your own custom renderer for drawing parallel edges - you can subclass the default EdgeRenderer and override the render() method. 1)在prefuse中,添加自己的自定义渲染器以绘制平行边缘非常容易 - 您可以继承默认的EdgeRenderer并覆盖render()方法。 There's no "basic data level changes" needed. 不需要“基本数据级别更改”。 This is all in the view part if you'd like to think of it as an MVC stuff. 如果您想将其视为MVC内容,那么这一切都在视图中。

2) This is not really an issue at all. 2)这根本不是问题。 There are more than one way to do this: 1) You can have two renderers - one for drawing the directed edges and one for drawing the undirected edges and they'll work just fine, and group the edges appropriately. 有多种方法可以做到这一点:1)你可以有两个渲染器 - 一个用于绘制有向边,一个用于绘制无向边,它们可以正常工作,并适当地对边进行分组。 2) Put a flag (add a boolean column in the backing table tuple in prefuse speak) to indicate whether the edge is directed and skip the arrow drawing portion accordingly in the EdgeRender according to that flag. 2)放置一个标志(在prefuse speak中的后备表元组中添加一个布尔列)以指示边缘是否被定向并根据该标志在EdgeRender中相应地跳过箭头绘制部分。

3) This is super easy 3)这非常容易

4) ditto 4)同上

5) The last prefuse release is "prefuse beta release 2007.10.21". 5)最后一个prefuse版本是“prefuse beta release 2007.10.21”。 I used the one before that, which have a possible race condition when adding or deleting nodes dynamically - it was missing a few synchronized keywords I guess. 我之前使用的那个,在动态添加或删除节点时可能存在竞争条件 - 我猜错了一些同步关键字。 I solved that by making sure to stop all the animation and actions (color, size, layout) when adding or removing nodes - also don't forget to update your lucene indexes as well (if you do use its built-in lucene search engine). 我通过确保在添加或删除节点时停止所有动画和操作(颜色,大小,布局)来解决这个问题 - 也不要忘记更新你的lucene索引(如果你使用它内置的lucene搜索引擎)。 The latest one is supposed to solve this race issue but I never had the chance to try it out. 最新的一个应该解决这个种族问题,但我从来没有机会尝试过。

6) Since you mentioned "multiple labelling" I think this not a matter of "modifying the graph and redrawing it" - it's just a matter of customizing your label/edge renderers to draw only the relevant labels so this is not really a big issue. 6)既然你提到了“多重标签”,我认为这不是“修改图形并重新绘制”的问题 - 只需要定制标签/边缘渲染器来绘制相关标签,这不是一个大问题。 。 Also I don't think this is related to 5 at all. 我也不认为这与5有关。

7) I'm not surprised that prefuse and JUNG's rendering of the FruchtermanReingoldLayout are different - there are a few factors that might affect this one of them the starting node where each implementation start the calculation so I wouldn't worry much about this issue. 7)我并不感到惊讶,因为prefuse和JUNG对FruchtermanReingoldLayout的渲染是不同的 - 有一些因素可能会影响其中一个因素,即每个实现开始计算的起始节点,所以我不会担心这个问题。 It's quite easy to try out the different builtin graph layout algorithms in prefuse so you can go ahead and check out which one is closest to what you'd like to have. 在prefuse中尝试不同的内置图形布局算法非常容易,因此您可以继续检查哪一个最接近您想要的内容。 Check out the RadialLayout and BalloonTreeLayout for the star layout. 查看RadialLayout和BalloonTreeLayout的星形布局。 ForceDirectedLayout needs quite a few iterations for the placement of nodes to be "stable". ForceDirectedLayout需要相当多的迭代才能使节点的位置“稳定”。 Note that these iterations is not necessary to be shown so you can run it in the background and render the final result. 请注意,不必显示这些迭代,因此您可以在后台运行它并呈现最终结果。

I haven't use JUNG so I can't comment much on it. 我没有使用JUNG所以我不能对此发表评论。

Based on my experience with prefuse I highly recommend it due to the very well (IMHO) thought-out design and separation of resposibility between the components. 基于我对prefuse的经验,我强烈推荐它,因为非常好(恕我直言)经过深思熟虑的设计和组件之间的可靠性分离。 Jeffrey Heer (prefuse author) really did a good job there. 杰弗里·希尔(prefuse作者)在那里做得很好。

Things to watch out for if you use prefuse (these are the two "sore-thumbs" that I vividly remember when working with prefuse): 如果你使用prefuse需要注意的事项(这些是我在使用prefuse时生动地记住的两个“痛苦的拇指”):

1) There's a bug where when zooming out, the node labels are not zoomed out appropriately such that it overflows the bounding box of the node which will leave font drawing artifacts when the node moves because the renderer only clears and redraws stuff within the node's bounding box. 1)有一个错误,当缩小时,节点标签没有被适当地缩小,使得它溢出节点的边界框,当节点移动时将留下字体绘制工件,因为渲染器只清除并重绘节点边界内的东西框。 IIRC this is caused by a bug in AWT font metric itself. IIRC这是由AWT字体指标本身的错误引起的。 The workaround is to leave ample margin between the label and the node bounding box. 解决方法是在标签和节点边界框​​之间留出足够的边距。

2) When extending the built-in layouts, you might encounter one or two "scoping issue" where a member of the superclass that you'd like to have access to is given the private attribute instead of protected so the solution is to either modify the library itself or create a new class without inheriting (that can be a bit painful!). 2)扩展内置布局时,您可能会遇到一个或两个“范围问题”,其中您要访问的超类成员被赋予私有属性而不是受保护,因此解决方案是要么修改库本身或创建一个没有继承的新类(这可能有点痛苦!)。 I guess you can say the same for some other java libraries. 我想你可以对其他一些java库说同样的话。 Not everyone have the benefit of hindsight no? 不是每个人都有后见之明的好处吗? :) :)

Since you asked this question about a month ago (at the time of me writing this) I'd like to know what your decision was and how it turned out for you if you went ahead with the implementation. 自从你在一个月前(在我写这篇文章时)提出这个问题以来,我想知道你的决定是什么以及如果你继续实施它的结果。

I know you specified jung and prefuse but... I've had good experience with both TomSawyer and yFiles. 我知道你指定了jung和prefuse但是......我对TomSawyer和yFiles都有很好的经验。 The requirements list you proposed is very basic to these two - and they support much more. 您提出的要求清单对于这两个要求非常基础 - 而且它们支持更多。

Ran. 然。

I like @holygeek's answer. 我喜欢@ holygeek的回答。 Here is my implementation to the solution for 2 (both directed and undirected edges), for Prefuse: 这是我对2的解决方案(有向和无向边)的实现,对于Prefuse:

public class MyRenderFactory implements RendererFactory
{
    private NodeRenderer nodeRenderer = new NodeRenderer();
    private EdgeRenderer defaultEdgeRenderer = new EdgeRenderer();
    private EdgeRenderer undirectedEdgeRenderer = new EdgeRenderer(EdgeRenderer.EdgeType.LINE, EdgeRenderer.EdgeArrowType.NONE);

    public static String directedness = "myEdgeDirectedness";

    public enum EdgeDirected
    {
        directed, undirected;

        public static EdgeDirected fromIsDirected(boolean isDirected)
        {
            if (isDirected)
            {
                return directed;
            }
            return undirected;
        }
    }

    @Override
    public Renderer getRenderer(VisualItem<?> visualItem)
    {
        if (visualItem instanceof EdgeItem)
        {
            if (visualItem.get(directedness).equals(PrefuseGraphConverter.EdgeDirected.undirected))
            {
                return undirectedEdgeRenderer;
            }
            return defaultEdgeRenderer;
        }
        return nodeRenderer;
    }
}

...elsewhere, where the graph is created... ......其他地方,创建图表的地方......

MyRenderFactory.EdgeDirected directedness =
        MyRenderFactory.EdgeDirected.fromIsDirected(myEdge.isDirected());
prefuseEdge.set(MyRenderFactory.directedness, directedness);

我建议也要评估JGraph

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

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