use of org.vcell.wizard.Wizard in project vcell by virtualcell.
the class BatchRunDetailsPanel method actionPerformed.
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == addButton) {
// check file before loading into batch run, if the file has .vfrap extension
// check if it has the model that is required by the batch run, if no, run the reference simulation and get the parameters
final Wizard loadWizard = getAddFRAPDataWizard();
if (loadWizard != null) {
loadWizard.showModalDialog(new Dimension(550, 640));
// code return
if (loadWizard.getReturnCode() == Wizard.FINISH_RETURN_CODE) {
// get newly added frapstudy
FRAPStudy fStudy = getBatchRunWorkspace().getWorkingFrapStudy();
// check if the batch run has results already and the newly loaded data should have same model ready
int batchRunSelectedModel = getBatchRunWorkspace().getSelectedModel();
if (getBatchRunWorkspace().isBatchRunResultsAvailable() && fStudy.getModels()[batchRunSelectedModel] != null && fStudy.getFrapModel(batchRunSelectedModel).getModelParameters() != null) {
Parameter[] parameters = fStudy.getFrapModel(batchRunSelectedModel).getModelParameters();
double[][] fitData = null;
if (batchRunSelectedModel == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT || batchRunSelectedModel == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
FRAPOptData optData = fStudy.getFrapOptData();
// newly loaded frapstudy doesn't have estimation data ready, generate the data
if (optData == null) {
try {
optData = new FRAPOptData(fStudy, parameters.length, getLocalWorkspace(), fStudy.getStoredRefData());
fStudy.setFrapOptData(optData);
fitData = optData.getFitData(parameters);
} catch (Exception ex) {
ex.printStackTrace(System.out);
DialogUtils.showErrorDialog(BatchRunDetailsPanel.this, ex.getMessage());
}
}
} else if (batchRunSelectedModel == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
FRAPOptFunctions optFunc = fStudy.getFrapOptFunc();
if (optFunc == null) {
try {
optFunc = new FRAPOptFunctions(fStudy);
fStudy.setFrapOptFunc(optFunc);
fitData = optFunc.getFitData(parameters);
} catch (Exception ex2) {
ex2.printStackTrace();
DialogUtils.showErrorDialog(BatchRunDetailsPanel.this, ex2.getMessage());
}
}
}
fStudy.getModels()[batchRunSelectedModel].setData(fitData);
// add new data into the frapStudy list in batch run.
getBatchRunWorkspace().addFrapStudy(fStudy);
// refresh the results
getBatchRunWorkspace().refreshBatchRunResults();
} else // batch run has no results, simply add the frapStudy into
{
getBatchRunWorkspace().addFrapStudy(fStudy);
}
// set save flag true when a doc has been added successfully
getBatchRunWorkspace().setSaveNeeded(true);
// update tree
DefaultMutableTreeNode newNode = frapBatchRunViewTree.addBatchRunDocNode(new File(getBatchRunWorkspace().getWorkingFrapStudy().getXmlFilename()));
// get the new tree node after sorting
newNode = frapBatchRunViewTree.orderFRAPDocChildren(newNode);
frapBatchRunViewTree.setSelectionPath(new TreePath(newNode.getPath()));
} else {
// load data unsuccessfully, remove the displayed image
getBatchRunWorkspace().clearWorkingSingleWorkspace();
// clear tree selection
frapBatchRunViewTree.clearSelection();
// clear stored tree selection
batchRunWorkspace.clearStoredTreeSelection();
}
}
} else if (source == deleteButton) {
AsynchClientTask deleteFromWorkspaceTask = new AsynchClientTask("deleting file ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// remove tree node(doc node removable only)
DefaultMutableTreeNode parent = frapBatchRunViewTree.removeCurrentNode();
// handle differently for doc node and results node
if (// doc node
parent.equals(BatchRunTree.FRAP_BATCHRUN_DOC_NODE)) {
// remove the data & displayed image
getBatchRunWorkspace().removeFrapStudy(getBatchRunWorkspace().getWorkingFrapStudy());
} else if (// results node
parent.equals(BatchRunTree.FRAP_BATCHRUN_RESULT_NODE)) {
getBatchRunWorkspace().clearResultData();
}
getBatchRunWorkspace().clearWorkingSingleWorkspace();
}
};
AsynchClientTask deleteFromUITask = new AsynchClientTask("deleting file ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// clear tree selection
frapBatchRunViewTree.clearSelection();
if (batchRunWorkspace.getFrapStudies() == null || batchRunWorkspace.getFrapStudies().size() < 1) {
frapBatchRunViewTree.clearAll();
} else // if doc has been deleted successfully and frapStudyList still has doc, set save flag true.
{
batchRunWorkspace.setSaveNeeded(true);
}
batchRunWorkspace.clearStoredTreeSelection();
// clear parameter display
clearParameterDisplay();
}
};
ClientTaskDispatcher.dispatch(BatchRunDetailsPanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { deleteFromWorkspaceTask, deleteFromUITask }, false, false, false, null, true);
} else if (source == delAllButton) {
deleteAllBatchrunDocs();
}
}
use of org.vcell.wizard.Wizard in project vcell by virtualcell.
the class FRAPStudyPanel method getChooseModelTypeWizard.
public Wizard getChooseModelTypeWizard() {
if (modelTypeWizard == null) {
modelTypeWizard = new Wizard(JOptionPane.getFrameForComponent(this));
modelTypeWizard.getDialog().setTitle("Choose Models");
ChooseModel_ModelTypesDescriptor modelTypesDescriptor = new ChooseModel_ModelTypesDescriptor();
modelTypeWizard.registerWizardPanel(ChooseModel_ModelTypesDescriptor.IDENTIFIER, modelTypesDescriptor);
(modelTypesDescriptor).setFrapWorkspace(getFrapWorkspace());
}
// always start from the first page
modelTypeWizard.setCurrentPanel(ChooseModel_ModelTypesDescriptor.IDENTIFIER);
return modelTypeWizard;
}
use of org.vcell.wizard.Wizard in project vcell by virtualcell.
the class BatchRunDetailsPanel method getAddFRAPDataWizard.
public Wizard getAddFRAPDataWizard() {
// summarypanel) to frapdatapanel.
if (batchRunAddDataWizard == null) {
batchRunAddDataWizard = new Wizard(JOptionPane.getFrameForComponent(this));
batchRunAddDataWizard.getDialog().setTitle("Load FRAP Data");
WizardPanelDescriptor fTypeDescriptor = new FileTypeDescriptor();
// goes next to single file input by default
fTypeDescriptor.setNextPanelDescriptorID(SingleFileDescriptor.IDENTIFIER);
batchRunAddDataWizard.registerWizardPanel(FileTypeDescriptor.IDENTIFIER, fTypeDescriptor);
WizardPanelDescriptor singleFileDescriptor = new SingleFileDescriptor();
batchRunAddDataWizard.registerWizardPanel(SingleFileDescriptor.IDENTIFIER, singleFileDescriptor);
((SingleFileDescriptor) singleFileDescriptor).setBatchRunWorkspace(getBatchRunWorkspace());
((SingleFileDescriptor) singleFileDescriptor).setLocalWorkspace(getLocalWorkspace());
WizardPanelDescriptor multiFileDescriptor = new MultiFileDescriptor();
batchRunAddDataWizard.registerWizardPanel(MultiFileDescriptor.IDENTIFIER, multiFileDescriptor);
((MultiFileDescriptor) multiFileDescriptor).setBatchRunWorkspace(getBatchRunWorkspace());
FileSummaryDescriptor fSummaryDescriptor = new FileSummaryDescriptor();
// goes back to single file input by default
fSummaryDescriptor.setBackPanelDescriptorID(SingleFileDescriptor.IDENTIFIER);
batchRunAddDataWizard.registerWizardPanel(FileSummaryDescriptor.IDENTIFIER, fSummaryDescriptor);
fSummaryDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
final WizardPanelDescriptor fileTypeDescriptor = fTypeDescriptor;
final WizardPanelDescriptor fileSummaryDescriptor = fSummaryDescriptor;
// actionListener to single file input radio button
// this radio button affects the wizard series. especially on the next of file type and the back of summary
((LoadFRAPData_FileTypePanel) fTypeDescriptor.getPanelComponent()).getSingleFileButton().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JRadioButton) {
if (((JRadioButton) e.getSource()).isSelected()) {
fileTypeDescriptor.setNextPanelDescriptorID(SingleFileDescriptor.IDENTIFIER);
fileSummaryDescriptor.setBackPanelDescriptorID(SingleFileDescriptor.IDENTIFIER);
} else {
fileTypeDescriptor.setNextPanelDescriptorID(MultiFileDescriptor.IDENTIFIER);
fileSummaryDescriptor.setBackPanelDescriptorID(MultiFileDescriptor.IDENTIFIER);
}
}
}
});
// actionListener to multiple file input radio button
// this radio button affects the wizard series. especially on the next of file type and the back of summary
((LoadFRAPData_FileTypePanel) fTypeDescriptor.getPanelComponent()).getMultipleFileButton().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JRadioButton) {
if (((JRadioButton) e.getSource()).isSelected()) {
fileTypeDescriptor.setNextPanelDescriptorID(MultiFileDescriptor.IDENTIFIER);
fileSummaryDescriptor.setBackPanelDescriptorID(MultiFileDescriptor.IDENTIFIER);
} else {
fileTypeDescriptor.setNextPanelDescriptorID(SingleFileDescriptor.IDENTIFIER);
fileSummaryDescriptor.setBackPanelDescriptorID(SingleFileDescriptor.IDENTIFIER);
}
}
}
});
}
// use one panel for all the steps through out defining ROIs.
imgPanel = new BatchRunROIImgPanel();
// batch run work space, no data yet.
imgPanel.setBatchRunWorkspace(getBatchRunWorkspace());
CropDescriptor cropDescriptor = new CropDescriptor(imgPanel);
batchRunAddDataWizard.registerWizardPanel(CropDescriptor.IDENTIFIER, cropDescriptor);
cropDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
CellROIDescriptor cellROIDescriptor = new CellROIDescriptor(imgPanel);
batchRunAddDataWizard.registerWizardPanel(CellROIDescriptor.IDENTIFIER, cellROIDescriptor);
cellROIDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
BleachedROIDescriptor bleachedROIDescriptor = new BleachedROIDescriptor(imgPanel);
batchRunAddDataWizard.registerWizardPanel(BleachedROIDescriptor.IDENTIFIER, bleachedROIDescriptor);
bleachedROIDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
BackgroundROIDescriptor backgroundROIDescriptor = new BackgroundROIDescriptor(imgPanel);
batchRunAddDataWizard.registerWizardPanel(BackgroundROIDescriptor.IDENTIFIER, backgroundROIDescriptor);
backgroundROIDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
ROISummaryDescriptor roiSummaryDescriptor = new ROISummaryDescriptor(imgPanel);
batchRunAddDataWizard.registerWizardPanel(ROISummaryDescriptor.IDENTIFIER, roiSummaryDescriptor);
roiSummaryDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
WizardPanelDescriptor roiForErrorDescriptor = new RoiForErrorDescriptor();
batchRunAddDataWizard.registerWizardPanel(RoiForErrorDescriptor.IDENTIFIER, roiForErrorDescriptor);
((RoiForErrorDescriptor) roiForErrorDescriptor).setBatchRunWorkspace(batchRunWorkspace);
FileSaveDescriptor fileSaveDescriptor = new FileSaveDescriptor();
batchRunAddDataWizard.registerWizardPanel(FileSaveDescriptor.IDENTIFIER, fileSaveDescriptor);
fileSaveDescriptor.setBatchRunWorkspace(getBatchRunWorkspace());
fileSaveDescriptor.setLocalWorkspace(localWorkspace);
imgPanel.refreshUI();
// always start from the first page
batchRunAddDataWizard.setCurrentPanel(FileTypeDescriptor.IDENTIFIER);
return batchRunAddDataWizard;
}
Aggregations