use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class FieldDataGUIPanel method getJButtonFindRefModel.
/**
* This method initializes jButtonFindRefModel
*
* @return javax.swing.JButton
*/
private JButton getJButtonFindRefModel() {
if (jButtonFindRefModel == null) {
jButtonFindRefModel = new JButton();
jButtonFindRefModel.setText("Model Refs...");
jButtonFindRefModel.setEnabled(false);
jButtonFindRefModel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TreePath selPath = getJTree1().getSelectionPath();
DefaultMutableTreeNode mainNode = (DefaultMutableTreeNode) selPath.getLastPathComponent();
if (mainNode.getUserObject() instanceof FieldDataMainList) {
final ExternalDataIdentifier extDataID = ((FieldDataMainList) mainNode.getUserObject()).externalDataIdentifier;
AsynchClientTask task1 = new AsynchClientTask("find model references", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
fieldDataWindowManager.findReferencingModels(extDataID, true);
}
};
ClientTaskDispatcher.dispatch(FieldDataGUIPanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
}
}
});
}
return jButtonFindRefModel;
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class FieldDataGUIPanel method fdFromFile.
private AsynchClientTask[] fdFromFile() {
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
AsynchClientTask[] addTasks = addNewExternalData(this, this, false);
AsynchClientTask[] taskArray = new AsynchClientTask[2 + addTasks.length];
// add to the end
System.arraycopy(addTasks, 0, taskArray, 2, addTasks.length);
taskArray[0] = new AsynchClientTask("select a file", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FieldDataFileOperationSpec argfdos = (FieldDataFileOperationSpec) hashTable.get("argfdos");
if (argfdos == null && hashTable.get(IMAGE_FILE_KEY) == null) {
File imageFile = DatabaseWindowManager.showFileChooserDialog(fieldDataWindowManager, FileFilters.FILE_FILTER_FIELDIMAGES, clientRequestManager.getUserPreferences(), JFileChooser.FILES_AND_DIRECTORIES);
hashTable.put(IMAGE_FILE_KEY, imageFile);
}
}
};
taskArray[1] = new AsynchClientTask("Import image", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FieldDataFileOperationSpec fdos = null;
String initFDName = null;
FieldDataFileOperationSpec argfdos = (FieldDataFileOperationSpec) hashTable.get("argfdos");
String arginitFDName = (String) hashTable.get("arginitFDName");
if (argfdos == null) {
File imageFile = (File) hashTable.get(IMAGE_FILE_KEY);
if (imageFile == null) {
return;
}
initFDName = imageFile.getName();
if (initFDName.indexOf(".vfrap") > -1) {
/* //read the image dataset from Virtual FRAP xml file
System.out.println("Loading " + initFDName + " ...");
AnnotatedImageDataset annotatedImages = null;
String xmlString;
try {
xmlString = XmlUtil.getXMLString(imageFile.getAbsolutePath());
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
annotatedImages = xmlReader.getAnnotatedImageDataset(XmlUtil.stringToXML(xmlString, null).getRootElement(), this.getClientTaskStatusSupport());
OverlayEditorPanelJAI overlayPanel = new OverlayEditorPanelJAI();
overlayPanel.setImages(annotatedImages.getImageDataset(), 1, 0, new OverlayEditorPanelJAI.AllPixelValuesRange(1, 200) );
DialogUtils.showComponentCloseDialog(FieldDataGUIPanel.this, overlayPanel, "this is it");
} catch (Exception e) {
e.printStackTrace(System.out);
} */
} else // not a .vfrap file
{
try {
fdos = ClientRequestManager.createFDOSFromImageFile(imageFile, false, null);
} catch (DataFormatException ex) {
throw new Exception("Cannot read image " + imageFile.getAbsolutePath() + "\n" + ex.getMessage());
}
}
} else {
fdos = argfdos;
initFDName = arginitFDName;
}
fdos.owner = clientRequestManager.getDocumentManager().getUser();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
hashTable.put("fdos", fdos);
hashTable.put("initFDName", initFDName);
// addNewExternalData(clientRequestManager, fdos, initFDName, false);
}
};
return taskArray;
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class FieldDataGUIPanel method refreshMainNode.
private void refreshMainNode(final DefaultMutableTreeNode mainNode) {
final boolean isMainExpanded = getJTree1().isExpanded(new TreePath(mainNode.getPath()));
final boolean isVarExpanded = getJTree1().isExpanded(new TreePath(((DefaultMutableTreeNode) mainNode.getLastChild()).getPath()));
// Remove all children from Main node in a Tree safe way
DefaultMutableTreeNode root = (DefaultMutableTreeNode) getJTree1().getModel().getRoot();
int mainNodeIndex = ((DefaultTreeModel) getJTree1().getModel()).getIndexOfChild(root, mainNode);
((DefaultTreeModel) getJTree1().getModel()).removeNodeFromParent(mainNode);
mainNode.removeAllChildren();
final DefaultMutableTreeNode varNode = new DefaultMutableTreeNode(new FieldDataVarMainList());
mainNode.add(varNode);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(mainNode, root, mainNodeIndex);
//
// Create thread-safe tasks to get Field Data Info and update JTree
//
final String FDOR_INFO = "FDOR_INFO";
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
AsynchClientTask FieldDataInfoTask = new AsynchClientTask("Gather Field Data info", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
final FieldDataFileOperationResults fieldDataFileOperationResults = clientRequestManager.getDocumentManager().fieldDataFileOperation(FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(fieldDataMainList.externalDataIdentifier.getKey(), clientRequestManager.getDocumentManager().getUser(), FieldDataFileOperationSpec.JOBINDEX_DEFAULT));
hash.put(FDOR_INFO, fieldDataFileOperationResults);
}
};
AsynchClientTask FieldDataInfoTreeUpdate = new AsynchClientTask("Update Field Data GUI", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
try {
FieldDataFileOperationResults fieldDataFileOperationResults = (FieldDataFileOperationResults) hash.get(FDOR_INFO);
Arrays.sort(fieldDataFileOperationResults.dataIdentifierArr, new Comparator<DataIdentifier>() {
public int compare(DataIdentifier o1, DataIdentifier o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
final DefaultMutableTreeNode isizeNode = new DefaultMutableTreeNode(new FieldDataISizeList(fieldDataFileOperationResults.iSize));
final DefaultMutableTreeNode originNode = new DefaultMutableTreeNode(new FieldDataOriginList(fieldDataFileOperationResults.origin));
final DefaultMutableTreeNode extentNode = new DefaultMutableTreeNode(new FieldDataExtentList(fieldDataFileOperationResults.extent));
final DefaultMutableTreeNode timeNode = new DefaultMutableTreeNode(new FieldDataTimeList(fieldDataFileOperationResults.times));
final DefaultMutableTreeNode idNode = new DefaultMutableTreeNode(new FieldDataIDList(fieldDataMainList.externalDataIdentifier.getKey()));
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(isizeNode, mainNode, 0);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(originNode, mainNode, 1);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(extentNode, mainNode, 2);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(timeNode, mainNode, 3);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(idNode, mainNode, 4);
for (int i = 0; i < fieldDataFileOperationResults.dataIdentifierArr.length; i += 1) {
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(new DefaultMutableTreeNode(new FieldDataVarList(fieldDataFileOperationResults.dataIdentifierArr[i])), varNode, varNode.getChildCount());
}
if (isMainExpanded) {
getJTree1().expandPath(new TreePath(mainNode.getPath()));
}
if (isVarExpanded) {
getJTree1().expandPath(new TreePath(varNode.getPath()));
}
} catch (Throwable e) {
hash.put(ClientTaskDispatcher.TASK_ABORTED_BY_ERROR, e);
}
}
};
//
// Execute Field Data Info - JTree tasks
//
AsynchClientTask[] tasks = new AsynchClientTask[] { FieldDataInfoTask, FieldDataInfoTreeUpdate };
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, tasks, false);
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class GeometrySubVolumeTableModel method setValueAt.
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (rowIndex < 0 || rowIndex >= getRowCount()) {
throw new RuntimeException("GeometrySubVolumeTableModel.setValueAt(), row = " + rowIndex + " out of range [" + 0 + "," + (getRowCount() - 1) + "]");
}
if (columnIndex < 0 || columnIndex >= getColumnCount()) {
throw new RuntimeException("GeometrySubVolumeTableModel.setValueAt(), column = " + columnIndex + " out of range [" + 0 + "," + (getColumnCount() - 1) + "]");
}
final SubVolume subVolume = getValueAt(rowIndex);
try {
switch(columnIndex) {
case COLUMN_NAME:
{
final String newName = (String) aValue;
final String oldName = subVolume.getName();
subVolume.setName(newName);
AsynchClientTask task1 = new AsynchClientTask("changing the name", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
GeometrySpec gs = getGeometry().getGeometrySpec();
if (gs != null) {
gs.geometryNameChanged(oldName, newName);
} else {
if (lg.isEnabledFor(Level.WARN)) {
lg.warn(getGeometry().getDescription() + " has no GeometrySpec?");
}
}
}
};
ClientTaskDispatcher.dispatch(ownerTable, new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
break;
}
case COLUMN_VALUE:
{
if (subVolume instanceof AnalyticSubVolume) {
final AnalyticSubVolume analyticSubVolume = (AnalyticSubVolume) subVolume;
if (aValue instanceof ScopedExpression) {
throw new RuntimeException("unexpected value type ScopedExpression");
} else if (aValue instanceof String) {
final String newExpressionString = (String) aValue;
analyticSubVolume.setExpression(new Expression(newExpressionString));
AsynchClientTask task1 = new AsynchClientTask("changing the expression", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
ClientTaskDispatcher.dispatch(ownerTable, new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
}
}
break;
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(ownerTable, e.getMessage(), e);
}
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class ROIAssistPanel method resolveCurrentROI.
private void resolveCurrentROI() {
final String CELL_ROI = "CELL_ROI";
AsynchClientTask keepRegionsTask = new AsynchClientTask("Pick Region", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// TODO Auto-generated method stub
RegionInfo[] keepRegionInfos = pickKeepRegionInfoFromCurrentROI();
if (keepRegionInfos == null) {
throw UserCancelException.CANCEL_GENERIC;
}
// dataToThreshold.getCurrentlyDisplayedROI().getPixelsXYZ();
short[] keepPixels = new short[dataToThreshold.getCurrentlyDisplayedROI().getISize().getXYZ()];
for (int i = 0; i < keepPixels.length; i++) {
for (int j = 0; j < keepRegionInfos.length; j++) {
if (keepRegionInfos[j].isIndexInRegion(i)) {
keepPixels[i] = 1;
}
}
}
UShortImage ushortImage = new UShortImage(keepPixels, originalROI.getRoiImages()[0].getOrigin(), originalROI.getRoiImages()[0].getExtent(), originalROI.getISize().getX(), originalROI.getISize().getY(), originalROI.getISize().getZ());
ROI newCellROI = new ROI(ushortImage, originalROI.getROIName());
hashTable.put(CELL_ROI, newCellROI);
}
};
AsynchClientTask updateDisplayTask = new AsynchClientTask("Updating display", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
dataToThreshold.addReplaceRoi((ROI) hashTable.get(CELL_ROI));
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { keepRegionsTask, updateDisplayTask }, false, false, null, true);
}
Aggregations