Search in sources :

Example 1 with DGraphView

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

the class BoundedTextAnnotationFactory method createAnnotation.

@Override
public BoundedTextAnnotation createAnnotation(Class<? extends BoundedTextAnnotation> type, CyNetworkView view, Map<String, String> argMap) {
    if (!(view instanceof DGraphView))
        return null;
    DGraphView dView = (DGraphView) view;
    if (type.equals(BoundedTextAnnotation.class)) {
        final BoundedTextAnnotationImpl a = new BoundedTextAnnotationImpl(dView, argMap, getActiveWindow());
        a.update();
        return (BoundedTextAnnotation) a;
    } else {
        return null;
    }
}
Also used : BoundedTextAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.BoundedTextAnnotationImpl) BoundedTextAnnotation(org.cytoscape.view.presentation.annotations.BoundedTextAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 2 with DGraphView

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

the class ImageAnnotationFactory method createAnnotation.

@Override
public ImageAnnotation createAnnotation(Class<? extends ImageAnnotation> clazz, CyNetworkView view, Map<String, String> argMap) {
    if (!(view instanceof DGraphView))
        return null;
    DGraphView dView = (DGraphView) view;
    if (ImageAnnotation.class.equals(clazz)) {
        final CustomGraphicsManager customGraphicsManager = serviceRegistrar.getService(CustomGraphicsManager.class);
        final ImageAnnotationImpl a = new ImageAnnotationImpl(dView, argMap, customGraphicsManager, getActiveWindow());
        a.update();
        return (ImageAnnotation) a;
    } else {
        return null;
    }
}
Also used : ImageAnnotation(org.cytoscape.view.presentation.annotations.ImageAnnotation) ImageAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.ImageAnnotationImpl) CustomGraphicsManager(org.cytoscape.ding.customgraphics.CustomGraphicsManager) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 3 with DGraphView

use of org.cytoscape.ding.impl.DGraphView 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)

Example 4 with DGraphView

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

the class ShapeAnnotationFactory method createAnnotation.

@Override
public ShapeAnnotation createAnnotation(Class<? extends ShapeAnnotation> type, CyNetworkView view, Map<String, String> argMap) {
    if (!(view instanceof DGraphView))
        return null;
    DGraphView dView = (DGraphView) view;
    if (type.equals(ShapeAnnotation.class)) {
        final ShapeAnnotationImpl a = new ShapeAnnotationImpl(dView, argMap, getActiveWindow());
        a.update();
        return (ShapeAnnotation) a;
    }
    return null;
}
Also used : ShapeAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.ShapeAnnotationImpl) ShapeAnnotation(org.cytoscape.view.presentation.annotations.ShapeAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 5 with DGraphView

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

the class LayerAnnotationTask method run.

@Override
public void run(TaskMonitor tm) throws Exception {
    JComponent canvas = annotation.getCanvas();
    if (annotation instanceof GroupAnnotation) {
        int z = zorder;
        for (Annotation ann : ((GroupAnnotation) annotation).getMembers()) {
            DingAnnotation dAnn = (DingAnnotation) ann;
            z += 1;
            dAnn.getCanvas().setComponentZOrder(dAnn.getComponent(), z);
        }
    }
    canvas.setComponentZOrder(annotation.getComponent(), zorder);
    canvas.repaint();
    if (view instanceof DGraphView) {
        DGraphView dView = (DGraphView) view;
        CyAnnotator cyAnnotator = dView.getCyAnnotator();
        // Force an update of all of the argMaps
        for (Annotation ann : cyAnnotator.getAnnotations()) cyAnnotator.addAnnotation(ann);
    }
    // We need to do this to update the Bird's Eye View
    annotation.contentChanged();
}
Also used : GroupAnnotation(org.cytoscape.view.presentation.annotations.GroupAnnotation) JComponent(javax.swing.JComponent) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) GroupAnnotation(org.cytoscape.view.presentation.annotations.GroupAnnotation) Annotation(org.cytoscape.view.presentation.annotations.Annotation) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Aggregations

DGraphView (org.cytoscape.ding.impl.DGraphView)35 DingAnnotation (org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation)22 CyAnnotator (org.cytoscape.ding.impl.cyannotator.CyAnnotator)20 TaskIterator (org.cytoscape.work.TaskIterator)9 GroupAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.GroupAnnotationImpl)4 CyNetworkView (org.cytoscape.view.model.CyNetworkView)4 JDialog (javax.swing.JDialog)3 GroupAnnotation (org.cytoscape.view.presentation.annotations.GroupAnnotation)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JComponent (javax.swing.JComponent)2 ImageAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ImageAnnotationImpl)2 ShapeAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ShapeAnnotationImpl)2 AbstractDingAnnotationFactory (org.cytoscape.ding.impl.cyannotator.create.AbstractDingAnnotationFactory)2 Annotation (org.cytoscape.view.presentation.annotations.Annotation)2 Dimension (java.awt.Dimension)1 File (java.io.File)1 Collectors.toList (java.util.stream.Collectors.toList)1 JFrame (javax.swing.JFrame)1 JPanel (javax.swing.JPanel)1