Java 在JUNG graph中拾取/移动/调整/删除注释
JUNG是否提供从图形中拾取、移动、调整大小或删除对象的功能 编辑: 在考虑(由@sdadas引用)后,确定了以下关注代码(在第126-134行中):Java 在JUNG graph中拾取/移动/调整/删除注释,java,jung,Java,Jung,JUNG是否提供从图形中拾取、移动、调整大小或删除对象的功能 编辑: 在考虑(由@sdadas引用)后,确定了以下关注代码(在第126-134行中): //获取此可视化查看器的RenderContext RenderContext rc=vv.getRenderContext(); //使用默认设置创建新的AnnotationGraphMousePlugin。 //AnnotationGraphMousePlugin类是AbstractGraphMousePlugin的一个子类 //还实现了Mo
//获取此可视化查看器的RenderContext
RenderContext rc=vv.getRenderContext();
//使用默认设置创建新的AnnotationGraphMousePlugin。
//AnnotationGraphMousePlugin类是AbstractGraphMousePlugin的一个子类
//还实现了MouseListener和MouseMotionListener接口。作为
//这样,相应的重写方法将是一个有趣的嵌入位置
//所需行为的逻辑。但是我还是不确定!
注释图形房屋插件注释插件=
新注释GraphMousePlugin(rc);
//使用注释鼠标插件为主视图创建一个GraphMouse。
最终注释ModalGraphMouse graphMouse=
新的AnnotationModalGraphMouse(rc,AnnotationPlugin);
和(第174-180行):
//创建注释控件以允许选择颜色、形状、填充、,
//和z顺序。我们对这些控制措施都不感兴趣。
AnnotationControls AnnotationControls=
新的AnnotationControls(AnnotationPlugin);
根据上面的评论,我最初的问题还是一样的
是的,请看一下。@rkmylo我很抱歉,我的回答太简短了-但我恐怕不能再详细了。虽然可以绘制注释,但拾取、调整大小等可能需要自定义鼠标侦听器和逻辑。保留注释及其坐标的列表,在鼠标单击时检查鼠标是否位于这些注释的域内。如果是,请选择它。。。您可以使用
mouseDragged()
执行类似的操作。
// Get the RenderContext for this visualization viewer
RenderContext<String,Number> rc = vv.getRenderContext();
// Create a new AnnotatingGraphMousePlugin with default settings.
// The AnnotatingGraphMousePlugin class is a subclass of AbstractGraphMousePlugin
// and also implements the interfaces MouseListener and MouseMotionListener. As
// such, the respective overridden methods would be a interesting place to embed
// the logic for the required behavior. However I am still not sure!
AnnotatingGraphMousePlugin<String,Number> annotatingPlugin =
new AnnotatingGraphMousePlugin<String,Number>(rc);
// Create a GraphMouse for the main view, using the annotating mouse plugin.
final AnnotatingModalGraphMouse<String,Number> graphMouse =
new AnnotatingModalGraphMouse<String,Number>(rc, annotatingPlugin);
// Create annotation controls to allow the selection of color, shape, fill,
// and z-order. None of these controls is of interest to us.
AnnotationControls<String,Number> annotationControls =
new AnnotationControls<String,Number>(annotatingPlugin);