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");
}
}
}
}
}
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();
}
}
}
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);
}
}
Aggregations