简体   繁体   English

JGraphX在另一个顶点中放置一个顶点

[英]JGraphX Drop a Vertex in another Vertex

I try to create a GraphicEditor. 我尝试创建一个GraphicEditor。 I use a JTree and Drag & Drop to create Vertexes on a graphcomponent, but I don't know how to drop a created Vertex into another Vertex. 我使用JTree和拖放操作在graphcomponent上创建顶点,但是我不知道如何将创建的顶点拖放到另一个顶点中。 How can I specify a Vertex as a Droptarget? 如何将顶点指定为Droptarget?

Thanks very much for you help! 非常感谢您的帮助!

Erik 埃里克

The mxGraph class has boolean method isValidDropTarget(Object cell, Object[] cells) . mxGraph类具有boolean方法isValidDropTarget(Object cell, Object[] cells) You can override this method and add a return condition such as 您可以覆盖此方法并添加返回条件,例如

if (((mxCell)cell).isVertex())
{
    return true;
}

For this you would have to extend the mxGraph class and in your program use that instead of the default implementation, or you can modify the sources, depending on how you set JGraph to your application. 为此,您必须扩展mxGraph类,并在程序中使用它而不是默认实现,或者可以修改源,具体取决于如何将JGraph设置为应用程序。

Additionally, the Swimlane style vertex should allow dropping on top of it by default. 此外,默认情况下, Swimlane样式顶点应允许放在其顶部。

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

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