Search in sources :

Example 6 with DataInput

use of org.vcell.workflow.DataInput in project vcell by virtualcell.

the class WorkflowJGraphProxy method removeCells.

private void removeCells(mxEventObject event) {
    // remove an existing connection
    Object[] cells = (Object[]) event.getProperty("cells");
    // remove edges first
    for (Object cellObject : cells) {
        if (cellObject instanceof mxCell) {
            mxCell cell = (mxCell) cellObject;
            if (cell.isEdge()) {
                mxICell source = cell.getSource();
                mxICell target = cell.getTarget();
                if ((source instanceof WorkflowObjectCell) && (source instanceof WorkflowObjectCell)) {
                    WorkflowObject workflowSourceObject = ((WorkflowObjectCell) source).workflowObject;
                    WorkflowObject workflowTargetObject = ((WorkflowObjectCell) target).workflowObject;
                    if (workflowSourceObject instanceof DataOutput && workflowTargetObject instanceof DataInput) {
                        DataOutput output = (DataOutput) workflowSourceObject;
                        DataInput input = (DataInput) workflowTargetObject;
                        if (context.getWorkflow().getConnectorSource(input) == output) {
                            context.getWorkflow().removeConnector(output, input);
                            System.out.println("removed edge from " + workflowSourceObject.getPath() + " to " + workflowTargetObject.getPath());
                        } else {
                            System.out.println("can't remove edge, edge from " + output.getPath() + " to " + input.getPath() + " not found in workflow");
                        }
                    } else {
                        System.out.println("can't remove edge, edge from " + source.getId() + " to " + target.getId() + " not found in workflow");
                    }
                }
            }
        }
    }
    // remove tasks next
    for (Object cellObject : cells) {
        if (cellObject instanceof mxCell) {
            mxCell cell = (mxCell) cellObject;
            if (!cell.isEdge() && cell instanceof WorkflowObjectCell) {
                WorkflowObject workflowObject = ((WorkflowObjectCell) cell).workflowObject;
                if (workflowObject instanceof Task) {
                    context.getWorkflow().removeTask((Task) workflowObject);
                    System.out.println("removed task " + workflowObject.getPath());
                } else {
                    System.out.println("can't remove non-edge cell " + cell.getId() + " not a task in this workflow");
                }
            }
        }
    }
}
Also used : DataInput(org.vcell.workflow.DataInput) com.mxgraph.model.mxICell(com.mxgraph.model.mxICell) DataOutput(org.vcell.workflow.DataOutput) Task(org.vcell.workflow.Task) com.mxgraph.model.mxCell(com.mxgraph.model.mxCell) com.mxgraph.util.mxEventObject(com.mxgraph.util.mxEventObject) WorkflowObject(org.vcell.workflow.WorkflowObject) DataObject(org.vcell.workflow.DataObject) WorkflowObject(org.vcell.workflow.WorkflowObject)

Example 7 with DataInput

use of org.vcell.workflow.DataInput in project vcell by virtualcell.

the class WorkflowObjectsTableModel method getValue.

private String getValue(WorkflowObject workflowObject) {
    if (workflowObject instanceof Task) {
        return "";
    } else {
        Object data = null;
        Class dataType = null;
        if (workflowObject instanceof WorkflowDataSource) {
            WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
            WorkflowDataSource dataSource = taskContext.getWorkflow().getDataSource((DataObject) dataHolder);
            data = taskContext.getRepository().getData(dataSource);
            dataType = dataHolder.getType();
        } else if (workflowObject instanceof DataInput) {
            DataInput dataInput = (DataInput) workflowObject;
            data = taskContext.getData(dataInput);
            dataType = dataInput.getType();
        }
        if (data instanceof RowColumnResultSet) {
            RowColumnResultSet rc = (RowColumnResultSet) data;
            int N = rc.getColumnDescriptionsCount();
            StringBuffer buffer = new StringBuffer(rc.getRowCount() + " rows of " + N + " {");
            int MAX = 3;
            for (int i = 0; i < N; i++) {
                buffer.append("\"" + rc.getColumnDescriptions(i).getDisplayName() + "\"");
                if (i >= MAX - 1) {
                    buffer.append(", ...");
                    break;
                }
                if (i < N - 1) {
                    buffer.append(", ");
                }
            }
            buffer.append("}");
            return buffer.toString();
        } else if (data instanceof String) {
            return "\"" + (String) data + "\"";
        } else if (data instanceof ROI) {
            return "ROI \"" + ((ROI) data).getROIName() + "\"";
        } else if (data instanceof ROI[]) {
            ROI[] rois = (ROI[]) data;
            int N = rois.length;
            int MAX = 3;
            StringBuffer buffer = new StringBuffer("ROI[" + N + "] { ");
            for (int i = 0; i < N; i++) {
                buffer.append("\"" + rois[i].getROIName() + "\"");
                if (i >= MAX - 1) {
                    buffer.append(", ...");
                    break;
                }
                if (i < N - 1) {
                    buffer.append(", ");
                }
            }
            buffer.append("}");
            return buffer.toString();
        } else if (data instanceof Image) {
            Image image = (Image) data;
            return image.getClass().getSimpleName() + " " + image.getISize().toString();
        } else if (data instanceof ImageTimeSeries) {
            ImageTimeSeries ts = (ImageTimeSeries) data;
            int N = ts.getSizeT();
            double[] times = ts.getImageTimeStamps();
            return ts.getType().getSimpleName() + "[" + N + "] " + ts.getISize() + " times=[" + times[0] + "," + times[N - 1] + "]";
        } else if (data != null) {
            return data.toString();
        } else {
            return "null " + dataType.getSimpleName();
        }
    }
}
Also used : Task(org.vcell.workflow.Task) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI) WorkflowDataSource(org.vcell.workflow.WorkflowDataSource) DataInput(org.vcell.workflow.DataInput) DataObject(org.vcell.workflow.DataObject) WorkflowObject(org.vcell.workflow.WorkflowObject) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 8 with DataInput

use of org.vcell.workflow.DataInput in project vcell by virtualcell.

the class WorkflowModelPanel method main.

/**
 * main entrypoint - starts the part when it is run as an application
 * @param args java.lang.String[]
 */
public static void main(java.lang.String[] args) {
    try {
        JFrame frame = new javax.swing.JFrame();
        WorkflowModelPanel aWorkflowModelPanel;
        aWorkflowModelPanel = new WorkflowModelPanel();
        frame.setContentPane(aWorkflowModelPanel);
        frame.setSize(aWorkflowModelPanel.getSize());
        frame.addWindowListener(new java.awt.event.WindowAdapter() {

            @Override
            public void windowClosing(java.awt.event.WindowEvent e) {
                System.exit(0);
            }
        });
        LocalWorkspace localWorkspace = new LocalWorkspace(new File("C:\\temp"));
        Workflow workflow = new Workflow("temp");
        class Task1 extends Task {

            final DataInput<Double> in = new DataInput<Double>(Double.class, "in", this);

            final DataOutput<Double> out = new DataOutput<Double>(Double.class, "out", this);

            public Task1() {
                super("t1");
                addInput(in);
                addOutput(out);
            }

            @Override
            protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
                System.out.println("executing task " + getName());
            }
        }
        ;
        class Task2 extends Task {

            final DataInput<Double> in = new DataInput<Double>(Double.class, "in", this);

            final DataOutput<Double> out = new DataOutput<Double>(Double.class, "out", this);

            public Task2() {
                super("t2");
                addInput(in);
                addOutput(out);
            }

            @Override
            protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
                System.out.println("executing task " + getName());
            }
        }
        ;
        Task1 task1 = new Task1();
        workflow.addTask(task1);
        Task2 task2 = new Task2();
        workflow.addTask(task2);
        workflow.connect2(task1.out, task2.in);
        aWorkflowModelPanel.setWorkflow(workflow);
        frame.setVisible(true);
        java.awt.Insets insets = frame.getInsets();
        frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
        frame.setVisible(true);
    } catch (Throwable exception) {
        System.err.println("Exception occurred in main() of javax.swing.JPanel");
        exception.printStackTrace(System.out);
    }
}
Also used : DataOutput(org.vcell.workflow.DataOutput) LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) Task(org.vcell.workflow.Task) TaskContext(org.vcell.workflow.TaskContext) Workflow(org.vcell.workflow.Workflow) DataInput(org.vcell.workflow.DataInput) JFrame(javax.swing.JFrame) ClientTaskStatusSupport(org.vcell.util.ClientTaskStatusSupport) File(java.io.File)

Aggregations

DataInput (org.vcell.workflow.DataInput)8 DataOutput (org.vcell.workflow.DataOutput)7 WorkflowObject (org.vcell.workflow.WorkflowObject)7 Task (org.vcell.workflow.Task)5 Image (cbit.vcell.VirtualMicroscopy.Image)3 ROI (cbit.vcell.VirtualMicroscopy.ROI)3 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)3 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)3 DataObject (org.vcell.workflow.DataObject)3 WorkflowDataSource (org.vcell.workflow.WorkflowDataSource)3 com.mxgraph.model.mxCell (com.mxgraph.model.mxCell)2 com.mxgraph.model.mxICell (com.mxgraph.model.mxICell)2 com.mxgraph.util.mxEventObject (com.mxgraph.util.mxEventObject)2 WindowAdapter (java.awt.event.WindowAdapter)2 WindowListener (java.awt.event.WindowListener)2 ProfileData (org.vcell.optimization.ProfileData)2 ImageException (cbit.image.ImageException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 File (java.io.File)1 IOException (java.io.IOException)1