0

Does JUNG give the ability to pick, move, resize, or delete Annotation objects from the graph?

Edit:

After considering the AnnotationDemo (cited by @sdasdadas), the following code of interest was identified (in lines 126-134):

// 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);

and (in lines 174-180):

// 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);

Based on the comments shown above, my initial question remains the same.


sdasdadas
  • 23,917
  • 20
  • 63
  • 148
rkmylo
  • 29
  • 3

1 Answers1

1

Yes, take a look at the AnnotationsDemo.

sdasdadas
  • 23,917
  • 20
  • 63
  • 148
  • @rkmylo I apologize, my answer was too brief - but I'm afraid I can't expand too much more. While drawing annotations is possible, picking, resizing, etc. may need a custom mouse listener and logic. EG. Keep a list of your annotations and their coordinates, on mouse click check if the mouse falls within the domain of any of those annotations. If so, select it... You can do similar things with `mouseDragged()`. – sdasdadas Feb 13 '13 at 17:38