简体   繁体   English

具有输入和输出端口的GraphStream节点

[英]GraphStream nodes with input and output ports

I'd like to model a graph in GraphStream and render it with its Viewer, but my nodes need to have distinct input and output ports (preferably on the left-hand and right-hand side of the node box, respectively), and edges should connect with those ports rather than the node center. 我想在GraphStream中为图形建模并使用其Viewer对其进行渲染,但是我的节点需要具有不同的输入和输出端口(最好分别在节点框的左侧和右侧)和边缘应该与那些端口而不是节点中心连接。

Is that even possible in GraphStream ? GraphStream中甚至可能吗? If not, is there another Java library that can be used? 如果没有,是否还有另一个可以使用的Java库? I know GraphViz Dot allows this, but I'd rather not call that by command line since that introduces an external dependency that's not part of my project. 我知道GraphViz Dot允许这样做,但是我不希望通过命令行来调用它,因为这会引入一个外部依赖项,这不是我的项目的一部分。

EDIT : an example of the kind of thing I want to render (but for a very different domain): 编辑 :我想渲染的东西的一个例子(但是对于一个非常不同的域): 在此处输入图片说明

I'm perfectly willing to do the rendering myself, but of course I still need routing and coordinates for the nodes and edges. 我非常愿意自己进行渲染,但是当然我仍然需要节点和边的路由和坐标。

There is no way in GraphStream yet to declare anchors, handles, or ports on the nodes. GraphStream中尚无办法在节点上声明锚点,句柄或端口。

However, since you want your edges tighten on the left and right sides of the nodes, then you might want to the give the "freeplan" CSS property a try. 但是,由于您希望边缘在节点的左侧和右侧变紧,因此您可能需要尝试使用“ freeplan” CSS属性。 See the example below and especially the "stylesheet" attribute on the graph: 请参见下面的示例,尤其是图表上的“样式表”属性:

Graph graph = new SingleGraph("FreePlane");
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
graph.display();
graph.setAttribute("stylesheet", "node { "
        + "     shape: rounded-box; "
        + "     padding: 5px; "
        + "     fill-color: white; "
        + "     stroke-mode: plain; "
        + "     size-mode: fit; "
        + "} "
        + "edge { "
        + "     shape: freeplane; "
        + "}");
graph.addAttribute("ui.quality");
graph.addAttribute("ui.antialias");

Node a = graph.addNode("A");
Node b = graph.addNode("B");
graph.addEdge("AB", "A", "B");
Node c = graph.addNode("C");
graph.addEdge("BC", "B", "C"); 

a.addAttribute("ui.label", "node A");
b.addAttribute("ui.label", "node B");
c.addAttribute("ui.label", "node C");

That would give you something like that : 那会给你这样的东西: 此代码产生的窗口的片段

I wasn't able to achieve this with graphstream, but such functionality is supported by other frameworks like: 我无法使用graphstream实现此功能,但其他框架支持此类功能,例如:

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

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