Search in sources :

Example 1 with ArbitraryGraphicsCanvas

use of org.cytoscape.ding.impl.ArbitraryGraphicsCanvas in project cytoscape-impl by cytoscape.

the class AnnotationManagerImpl method removeAnnotations.

@Override
public void removeAnnotations(Collection<? extends Annotation> annotations) {
    Map<DGraphView, List<DingAnnotation>> annotationsByView = groupByView(annotations);
    if (annotationsByView.isEmpty())
        return;
    invokeOnEDTAndWait(() -> {
        annotationsByView.forEach((view, viewAnnotations) -> {
            Map<ArbitraryGraphicsCanvas, List<DingAnnotation>> annotationsByCanvas = groupByCanvas(view, viewAnnotations);
            annotationsByCanvas.forEach((canvas, dingAnnotations) -> {
                // The following code is a batch version of Annotation.removeAnnotation()
                for (DingAnnotation a : dingAnnotations) {
                    GroupAnnotation parent = a.getGroupParent();
                    if (parent != null) {
                        parent.removeMember(a);
                    }
                }
                canvas.removeAnnotations(getArrows(dingAnnotations));
                canvas.removeAnnotations(dingAnnotations);
                canvas.repaint();
            });
        });
    });
}
Also used : GroupAnnotation(org.cytoscape.view.presentation.annotations.GroupAnnotation) ArbitraryGraphicsCanvas(org.cytoscape.ding.impl.ArbitraryGraphicsCanvas) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Aggregations

List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 ArbitraryGraphicsCanvas (org.cytoscape.ding.impl.ArbitraryGraphicsCanvas)1 DGraphView (org.cytoscape.ding.impl.DGraphView)1 DingAnnotation (org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation)1 GroupAnnotation (org.cytoscape.view.presentation.annotations.GroupAnnotation)1