2012-11-27 37 views
1

我似乎无法找到任何注释我的JUNG图形的文档。我拼凑在一起的最多的是:我如何使用JUNG的注释系统注释我的图表?

AnnotationRenderer renderer = new AnnotationRenderer(); 
AnnotationPaintable annotate = new AnnotationPaintable(viewer.getRenderContext(), renderer); 

Shape square = new Rectangle(0, 0, 50, 50); 
Annotation<Shape> a = new Annotation<Shape>(square, Annotation.Layer.UPPER, null, true, 
       new Point2D.Double(0, 0)); 
annotate.add(a); 

我该如何考虑并开始在AnnotationPaintable对象内绘制实际的注解?

回答

1

答案是将其添加到您的可视化浏览器:

viewer.addPostRenderPaintable(...) 
+1

真实的,但有时你也可能需要做'viewer.addPreRenderPaintable(...)''因为将PostRendererPaintable'使注释出现在在顶点之前的前景(不管是否有'Annotation.Layer.UPPER'参数),它可能不是每个人都想要的东西。 –

+0

@Rafał好点! – sdasdadas