Search in sources :

Example 16 with CyAnnotator

use of org.cytoscape.ding.impl.cyannotator.CyAnnotator in project cytoscape-impl by cytoscape.

the class GroupAnnotationsTask method run.

@Override
public void run(TaskMonitor tm) throws Exception {
    if (view instanceof DGraphView) {
        DGraphView dView = (DGraphView) view;
        CyAnnotator cyAnnotator = dView.getCyAnnotator();
        GroupAnnotationImpl group = new GroupAnnotationImpl(dView, null);
        // Need to add this first so we can update
        group.addComponent(null);
        // things appropriately
        cyAnnotator.addAnnotation(group);
        // Now, add all of the children
        for (DingAnnotation child : new ArrayList<DingAnnotation>(cyAnnotator.getSelectedAnnotations())) {
            group.addMember(child);
            child.setSelected(false);
        }
        // Finally, set ourselves to be the selected component
        group.setSelected(true);
        group.update();
    }
}
Also used : GroupAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.GroupAnnotationImpl) ArrayList(java.util.ArrayList) CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 17 with CyAnnotator

use of org.cytoscape.ding.impl.cyannotator.CyAnnotator in project cytoscape-impl by cytoscape.

the class ChangeAnnotationCanvasTaskFactory method isReady.

@Override
public boolean isReady(CyNetworkView networkView, Point2D javaPt, Point2D xformPt) {
    CyAnnotator cyAnnotator = ((DGraphView) networkView).getCyAnnotator();
    DingAnnotation annotation = cyAnnotator.getAnnotationAt(javaPt);
    if (annotation == null)
        return false;
    if (!annotation.getCanvasName().equals(canvas))
        return true;
    return false;
}
Also used : CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 18 with CyAnnotator

use of org.cytoscape.ding.impl.cyannotator.CyAnnotator in project cytoscape-impl by cytoscape.

the class EditAnnotationTaskFactory method isReady.

@Override
public boolean isReady(CyNetworkView networkView, Point2D javaPt, Point2D xformPt) {
    CyAnnotator cyAnnotator = ((DGraphView) networkView).getCyAnnotator();
    DingAnnotation annotation = cyAnnotator.getAnnotationAt(javaPt);
    if (annotation != null)
        return true;
    return false;
}
Also used : CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 19 with CyAnnotator

use of org.cytoscape.ding.impl.cyannotator.CyAnnotator in project cytoscape-impl by cytoscape.

the class LayerAnnotationTaskFactory method createTaskIterator.

@Override
public TaskIterator createTaskIterator(CyNetworkView networkView, Point2D javaPt, Point2D xformPt) {
    CyAnnotator cyAnnotator = ((DGraphView) networkView).getCyAnnotator();
    DingAnnotation annotation = cyAnnotator.getAnnotationAt(javaPt);
    return new TaskIterator(new LayerAnnotationTask(networkView, annotation, newZorder));
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 20 with CyAnnotator

use of org.cytoscape.ding.impl.cyannotator.CyAnnotator in project cytoscape-impl by cytoscape.

the class LayerAnnotationTaskFactory method isReady.

@Override
public boolean isReady(CyNetworkView networkView, Point2D javaPt, Point2D xformPt) {
    CyAnnotator cyAnnotator = ((DGraphView) networkView).getCyAnnotator();
    DingAnnotation annotation = cyAnnotator.getAnnotationAt(javaPt);
    if (annotation == null)
        return false;
    JComponent canvas = annotation.getCanvas();
    int zorder = canvas.getComponentZOrder(annotation.getComponent());
    if ((offset < 0 && zorder > 0) || (offset > 0 && zorder < canvas.getComponentCount() - 1)) {
        this.newZorder = zorder + offset;
        if (this.newZorder < 0)
            this.newZorder = 0;
        else if (this.newZorder > canvas.getComponentCount() - 1)
            this.newZorder = canvas.getComponentCount() - 1;
        return true;
    }
    return false;
}
Also used : JComponent(javax.swing.JComponent) CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Aggregations

DGraphView (org.cytoscape.ding.impl.DGraphView)20 CyAnnotator (org.cytoscape.ding.impl.cyannotator.CyAnnotator)20 DingAnnotation (org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation)20 TaskIterator (org.cytoscape.work.TaskIterator)8 GroupAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.GroupAnnotationImpl)3 JComponent (javax.swing.JComponent)2 Annotation (org.cytoscape.view.presentation.annotations.Annotation)2 ArrayList (java.util.ArrayList)1 ArrowAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ArrowAnnotationImpl)1 ImageAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ImageAnnotationImpl)1 ShapeAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ShapeAnnotationImpl)1 GroupAnnotation (org.cytoscape.view.presentation.annotations.GroupAnnotation)1