Search in sources :

Example 6 with DataOutput

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

the class WorkflowGraphModel method refreshAll.

/**
 * Insert the method's description here.
 * Creation date: (7/8/2003 9:11:57 AM)
 */
@Override
public void refreshAll() {
    clearAllShapes();
    if (getWorkflow() == null) {
        fireGraphChanged(new GraphEvent(this));
        return;
    }
    ContainerShape containerShape = new SimpleContainerShape(new Object(), this, "workflow-container");
    addShape(containerShape);
    // 
    for (Task task : getWorkflow().getTasks()) {
        TaskShape taskShape = new TaskShape(task, this);
        containerShape.addChildShape(taskShape);
        addShape(taskShape);
        // 
        for (DataOutput<? extends Object> output : task.getOutputs()) {
            if (!output.getName().equals("displayed")) {
                DataHolderShape dataHolderShape = new DataHolderShape(output, this);
                containerShape.addChildShape(dataHolderShape);
                addShape(dataHolderShape);
                WorkflowEdgeShape workflowEdgeShape = new WorkflowEdgeShape(task.getName() + ":" + output.getName(), taskShape, dataHolderShape, this, true, false);
                containerShape.addChildShape(workflowEdgeShape);
                addShape(workflowEdgeShape);
            }
        }
    // //
    // // add a DataInputShape for each input and connect to TaskShape with an edge
    // //
    // for (DataInput<? extends Object> input : task.getInputs()){
    // DataInputShape dataInputShape = new DataInputShape(input,this);
    // containerShape.addChildShape(dataInputShape);
    // addShape(dataInputShape);
    // 
    // WorkflowEdgeShape workflowEdgeShape = new WorkflowEdgeShape("input:"+task.getName()+":"+input.name,dataInputShape, taskShape, this, true, false);
    // containerShape.addChildShape(workflowEdgeShape);
    // addShape(workflowEdgeShape);
    // }
    }
    // 
    for (Task task : getWorkflow().getTasks()) {
        for (DataInput<? extends Object> input : task.getInputs()) {
            DataObject<? extends Object> source = getWorkflow().getConnectorSource(input);
            if (source instanceof DataOutput) {
                DataHolderShape dataHolderShape = (DataHolderShape) getShapeFromModelObject(source);
                TaskShape taskShape = (TaskShape) getShapeFromModelObject(task);
                WorkflowEdgeShape workflowEdgeShape = new WorkflowEdgeShape("connection:" + input.getName(), dataHolderShape, taskShape, this, true, false);
                containerShape.addChildShape(workflowEdgeShape);
                addShape(workflowEdgeShape);
            }
        }
    }
    fireGraphChanged(new GraphEvent(this));
}
Also used : DataOutput(org.vcell.workflow.DataOutput) Task(org.vcell.workflow.Task) GraphEvent(cbit.gui.graph.GraphEvent) SimpleContainerShape(cbit.gui.graph.SimpleContainerShape) ContainerShape(cbit.gui.graph.ContainerShape) DataObject(org.vcell.workflow.DataObject) SimpleContainerShape(cbit.gui.graph.SimpleContainerShape)

Example 7 with DataOutput

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

Example 8 with DataOutput

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

the class WorkflowJGraphProxy method createGraphJGraphX.

public WorkflowGraph createGraphJGraphX() {
    graph = new WorkflowGraph();
    graph.getModel().beginUpdate();
    graph.setCellsEditable(false);
    graph.setCellsCloneable(false);
    graph.setCellsMovable(true);
    graph.setCellsResizable(false);
    graph.setDropEnabled(false);
    Object parent = graph.getDefaultParent();
    try {
        // 
        // make subgraph for each task ... alot space from [-1:1] in x and center in y
        // 
        int scale = 100;
        int taskPosX = 20;
        int taskPosXDelta = 240;
        int taskPosY = scale / 2;
        HashMap<Task, WorkflowObjectCell> taskMap = new HashMap<Task, WorkflowObjectCell>();
        for (Task task : context.getWorkflow().getTasks()) {
            WorkflowObjectCell taskNode = createGenericCell(task);
            taskNode.getGeometry().setX(task.getDiagramStyle().getX(taskPosX));
            taskNode.getGeometry().setY(task.getDiagramStyle().getY(taskPosY));
            taskMap.put(task, taskNode);
            graph.addCell(taskNode);
            taskPosX += taskPosXDelta;
        }
        // 
        for (Task task : context.getWorkflow().getTasks()) {
            for (DataInput<? extends Object> input : task.getInputs()) {
                DataObject<? extends Object> dataSource = context.getWorkflow().getConnectorSource(input);
                if (dataSource != null) {
                    WorkflowObjectCell inputTaskNode = taskMap.get(input.getParent());
                    if (inputTaskNode != null) {
                        WorkflowObjectCell inputNode = null;
                        for (int i = 0; i < inputTaskNode.getChildCount(); i++) {
                            if (inputTaskNode.getChildAt(i).getValue().equals(input.getName())) {
                                inputNode = (WorkflowObjectCell) inputTaskNode.getChildAt(i);
                            }
                        }
                        if (dataSource instanceof DataOutput) {
                            DataOutput dataHolder = (DataOutput) dataSource;
                            Object dataHolderParent = dataHolder.getParent();
                            if (dataHolderParent instanceof Task) {
                                WorkflowObjectCell outputTask = taskMap.get((Task) dataHolderParent);
                                WorkflowObjectCell holderNode = null;
                                for (int i = 0; i < outputTask.getChildCount(); i++) {
                                    if (outputTask.getChildAt(i).getValue().equals(dataHolder.getName())) {
                                        holderNode = (WorkflowObjectCell) outputTask.getChildAt(i);
                                    }
                                }
                                if (holderNode != null) {
                                    // an output of another task
                                    graph.insertEdge(parent, null, null, holderNode, inputNode);
                                }
                            }
                        }
                    }
                }
            }
        }
    } finally {
        graph.getModel().endUpdate();
    }
    graph.addListener(null, graphEventListener);
    // graph.getModel().addListener(mxEvent.CHANGE, getEventListener());
    return graph;
}
Also used : DataOutput(org.vcell.workflow.DataOutput) Task(org.vcell.workflow.Task) HashMap(java.util.HashMap) com.mxgraph.util.mxEventObject(com.mxgraph.util.mxEventObject) WorkflowObject(org.vcell.workflow.WorkflowObject) DataObject(org.vcell.workflow.DataObject) com.mxgraph.util.mxPoint(com.mxgraph.util.mxPoint)

Example 9 with DataOutput

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

Aggregations

DataOutput (org.vcell.workflow.DataOutput)9 DataInput (org.vcell.workflow.DataInput)7 WorkflowObject (org.vcell.workflow.WorkflowObject)7 Task (org.vcell.workflow.Task)6 DataObject (org.vcell.workflow.DataObject)4 com.mxgraph.util.mxEventObject (com.mxgraph.util.mxEventObject)3 Image (cbit.vcell.VirtualMicroscopy.Image)2 ROI (cbit.vcell.VirtualMicroscopy.ROI)2 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)2 com.mxgraph.model.mxCell (com.mxgraph.model.mxCell)2 com.mxgraph.model.mxICell (com.mxgraph.model.mxICell)2 WindowAdapter (java.awt.event.WindowAdapter)2 WindowListener (java.awt.event.WindowListener)2 ProfileData (org.vcell.optimization.ProfileData)2 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)2 WorkflowDataSource (org.vcell.workflow.WorkflowDataSource)2 ContainerShape (cbit.gui.graph.ContainerShape)1 GraphEvent (cbit.gui.graph.GraphEvent)1 SimpleContainerShape (cbit.gui.graph.SimpleContainerShape)1 ImageException (cbit.image.ImageException)1