Search in sources :

Example 11 with DGraphView

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

the class CustomGraphicsManagerImpl method handleEvent.

@Override
public void handleEvent(SessionLoadedEvent e) {
    // Add new images
    final CySession sess = e.getLoadedSession();
    if (sess != null) {
        final Map<String, List<File>> filesMap = sess.getAppFileListMap();
        if (filesMap != null) {
            final List<File> files = filesMap.get(APP_NAME);
            if (files != null && files.size() != 0) {
                // get parent directory
                final File parent = files.get(0).getParentFile();
                final RestoreImageTaskFactory taskFactory = new RestoreImageTaskFactory(new HashSet<>(), parent, this, serviceRegistrar);
                final TaskIterator loadImagesIterator = taskFactory.createTaskIterator();
                for (CyNetworkView networkView : sess.getNetworkViews()) {
                    loadImagesIterator.append(((DGraphView) networkView).getCyAnnotator().getReloadImagesTask());
                }
                loadImagesIterator.append(new ReloadMissingImagesTask(sess.getNetworkViews()));
                serviceRegistrar.getService(DialogTaskManager.class).execute(loadImagesIterator);
            }
        }
    }
}
Also used : CySession(org.cytoscape.session.CySession) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) DGraphView(org.cytoscape.ding.impl.DGraphView) TaskIterator(org.cytoscape.work.TaskIterator) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 12 with DGraphView

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

the class AddArrowTask method run.

@Override
public void run(TaskMonitor tm) throws Exception {
    if (view instanceof DGraphView && annotationFactory instanceof AbstractDingAnnotationFactory) {
        SwingUtilities.invokeLater(() -> {
            final JDialog dialog = ((AbstractDingAnnotationFactory<?>) annotationFactory).createAnnotationDialog((DGraphView) view, location);
            dialog.setLocation((int) location.getX(), (int) location.getY());
            dialog.setVisible(true);
        });
    }
}
Also used : AbstractDingAnnotationFactory(org.cytoscape.ding.impl.cyannotator.create.AbstractDingAnnotationFactory) JDialog(javax.swing.JDialog) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 13 with DGraphView

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

the class EditAnnotationTask method run.

@Override
public void run(TaskMonitor tm) throws Exception {
    if (view instanceof DGraphView) {
        SwingUtilities.invokeLater(() -> {
            final JDialog dialog = annotation.getModifyDialog();
            if (dialog != null) {
                dialog.setLocation((int) location.getX(), (int) location.getY());
                dialog.setVisible(true);
            }
        });
    }
}
Also used : JDialog(javax.swing.JDialog) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 14 with DGraphView

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

the class AddArrowTaskFactory method isReady.

@Override
public boolean isReady(CyNetworkView networkView, Point2D javaPt, Point2D xformPt) {
    // We need to be over an annotation
    CyAnnotator cyAnnotator = ((DGraphView) networkView).getCyAnnotator();
    DingAnnotation annotation = cyAnnotator.getAnnotationAt(javaPt);
    if (annotation == null || annotation instanceof ArrowAnnotationImpl)
        return false;
    return true;
}
Also used : ArrowAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.ArrowAnnotationImpl) CyAnnotator(org.cytoscape.ding.impl.cyannotator.CyAnnotator) DingAnnotation(org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 15 with DGraphView

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

the class ChangeAnnotationCanvasTaskFactory 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 ChangeAnnotationCanvasTask(networkView, annotation, canvas));
}
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)

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