use of org.vcell.workflow.DataObject 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));
}
use of org.vcell.workflow.DataObject 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.DataObject 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;
}
Aggregations