Search in sources :

Example 6 with WorkflowObject

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

the class WorkflowJGraphProxy method validateConnection.

private String validateConnection(mxICell source, mxICell target) {
    try {
        if (!(source instanceof WorkflowObjectCell) || !(target instanceof WorkflowObjectCell)) {
            return "source or target is null";
        }
        WorkflowObject workflowSourceObject = ((WorkflowObjectCell) source).workflowObject;
        WorkflowObject workflowTargetObject = ((WorkflowObjectCell) target).workflowObject;
        if (workflowSourceObject instanceof DataOutput && workflowTargetObject instanceof DataInput) {
            DataInput input = (DataInput) workflowTargetObject;
            Type inputClass = input.getType();
            if (context.getWorkflow().getConnectorSource(input) != null) {
                return "don't add this connection, a connection already exists";
            } else {
                DataOutput output = (DataOutput) workflowSourceObject;
                Type outputClass = output.getType();
                if (outputClass.getClass().isAssignableFrom(inputClass.getClass())) {
                    return null;
                } else {
                    return "can't connect " + workflowSourceObject.getPath() + " of type " + outputClass + "\n to " + workflowTargetObject.getPath() + " of type " + inputClass;
                }
            }
        } else {
            return "unknown source or desintation type";
        }
    } catch (Exception e) {
        e.printStackTrace();
        return "error validating edge: exception: " + e.getMessage();
    } finally {
        context.getWorkflow().refreshStatus();
    }
}
Also used : DataInput(org.vcell.workflow.DataInput) DataOutput(org.vcell.workflow.DataOutput) Type(java.lang.reflect.Type) WorkflowObject(org.vcell.workflow.WorkflowObject)

Example 7 with WorkflowObject

use of org.vcell.workflow.WorkflowObject 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 WorkflowObject

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

the class WorkflowObjectsTableModel method setValueAt.

public void setValueAt(Object value, int row, int col) {
    if (value == null) {
        return;
    }
    try {
        String inputValue = (String) value;
        inputValue = inputValue.trim();
        WorkflowObject workflowObject = getValueAt(row);
        switch(col) {
            case COLUMN_VALUE:
                {
                    if (inputValue.length() == 0) {
                        return;
                    }
                    if (workflowObject instanceof WorkflowParameter) {
                        WorkflowParameter dataHolder = (WorkflowParameter) workflowObject;
                        Class dataClass = dataHolder.getType();
                        Repository repository = taskContext.getRepository();
                        Workflow workflow = taskContext.getWorkflow();
                        if (dataClass.equals(Double.class)) {
                            repository.setData(dataHolder, Double.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(Float.class)) {
                            repository.setData(dataHolder, Float.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(Integer.class)) {
                            repository.setData(dataHolder, Integer.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(Boolean.class)) {
                            repository.setData(dataHolder, Boolean.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(String.class)) {
                            repository.setData(dataHolder, inputValue);
                            workflow.refreshStatus();
                        } else {
                            System.out.println("type " + dataClass.getSimpleName() + " not supported");
                        }
                    }
                    break;
                }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Repository(org.vcell.workflow.Repository) Workflow(org.vcell.workflow.Workflow) WorkflowParameter(org.vcell.workflow.WorkflowParameter) WorkflowObject(org.vcell.workflow.WorkflowObject)

Example 9 with WorkflowObject

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

the class WorkflowObjectsPanel method showButtonPressed.

private void showButtonPressed() {
    int[] rows = parametersFunctionsTable.getSelectedRows();
    if (rows == null || rows.length == 0) {
        return;
    }
    for (int r : rows) {
        if (r < parametersFunctionsTableModel.getRowCount()) {
            WorkflowObject workflowObject = parametersFunctionsTableModel.getValueAt(r);
            displayData(taskContext, workflowObject);
        }
    }
}
Also used : WorkflowObject(org.vcell.workflow.WorkflowObject)

Example 10 with WorkflowObject

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

the class WorkflowObjectsPanel method tableSelectionChanged.

protected void tableSelectionChanged() {
    int[] rows = parametersFunctionsTable.getSelectedRows();
    if (rows == null || rows.length == 0) {
        showButton.setEnabled(false);
        deleteButton.setEnabled(false);
        return;
    }
    boolean bAllTasks = true;
    boolean bAllDisplable = true;
    for (int r : rows) {
        if (r < parametersFunctionsTableModel.getRowCount()) {
            WorkflowObject workflowObject = parametersFunctionsTableModel.getValueAt(r);
            if (!(workflowObject instanceof Task)) {
                bAllTasks = false;
            }
            if (!hasDisplayData(taskContext, workflowObject)) {
                bAllDisplable = false;
            }
        }
    }
    deleteButton.setEnabled(bAllTasks);
    showButton.setEnabled(bAllDisplable);
}
Also used : Task(org.vcell.workflow.Task) WorkflowObject(org.vcell.workflow.WorkflowObject)

Aggregations

WorkflowObject (org.vcell.workflow.WorkflowObject)11 DataInput (org.vcell.workflow.DataInput)7 DataOutput (org.vcell.workflow.DataOutput)6 Task (org.vcell.workflow.Task)6 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 Workflow (org.vcell.workflow.Workflow)2 WorkflowParameter (org.vcell.workflow.WorkflowParameter)2 ImageException (cbit.image.ImageException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1