use of cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace in project vcell by virtualcell.
the class VirtualFrapBatchRunFrame method open.
public AsynchClientTask[] open(final File inFile) {
ArrayList<AsynchClientTask> totalTasks = new ArrayList<AsynchClientTask>();
// check if save is needed before loading batch run file
if (batchRunWorkspace.isSaveNeeded()) {
String choice = DialogUtils.showWarningDialog(VirtualFrapBatchRunFrame.this, "There are unsaved changes. Save current document before loading new document?", new String[] { FRAPStudyPanel.SAVE_CONTINUE_MSG, FRAPStudyPanel.NO_THANKS_MSG }, FRAPStudyPanel.SAVE_CONTINUE_MSG);
if (choice.equals(FRAPStudyPanel.SAVE_CONTINUE_MSG)) {
AsynchClientTask[] saveTasks = save();
for (int i = 0; i < saveTasks.length; i++) {
totalTasks.add(saveTasks[i]);
}
}
}
AsynchClientTask preOpenTask = new AsynchClientTask("Loading " + inFile.getAbsolutePath() + "...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
VirtualFrapBatchRunFrame.updateStatus("Loading " + inFile.getAbsolutePath() + "...");
}
};
totalTasks.add(preOpenTask);
// load frap batch run file
totalTasks.add(batchRunWorkspace.getLoadBatchRunFileTask(inFile));
// load each single vfrap file
totalTasks.add(batchRunWorkspace.getLoadSingleFilesTask(localWorkspace));
// after loading task
AsynchClientTask updateUIAfterLoadingTask = new AsynchClientTask("Updating User Interface ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPBatchRunWorkspace tempBatchRunWorkspace = (FRAPBatchRunWorkspace) hashTable.get(FRAPBatchRunWorkspace.BATCH_RUN_WORKSPACE_KEY);
// if loaded successfully, update the batchrunworkspace with the temporary one.
batchRunWorkspace.update(tempBatchRunWorkspace);
// update tree
getBatchRunDetailsPanel().updateViewTreeForNewBatchRunFile(batchRunWorkspace);
// update ui
VirtualFrapLoader.mf.setBatchRunFrameTitle(batchRunWorkspace.getBatchRunXmlFileName());
VirtualFrapBatchRunFrame.updateStatus("Loaded " + tempBatchRunWorkspace.getBatchRunXmlFileName());
}
};
totalTasks.add(updateUIAfterLoadingTask);
return totalTasks.toArray(new AsynchClientTask[totalTasks.size()]);
}
use of cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace in project vcell by virtualcell.
the class EstParams_OneDiffComponentPanel method loadBatchRunParameters.
public void loadBatchRunParameters(File inFile) {
String xmlString;
try {
xmlString = XmlUtil.getXMLString(inFile.getAbsolutePath());
BatchRunXmlReader batchRunXmlReader = new BatchRunXmlReader();
FRAPBatchRunWorkspace tempBatchRunWorkspace = batchRunXmlReader.getBatchRunWorkspace(XmlUtil.stringToXML(xmlString, null).getRootElement());
Parameter[] parameters = tempBatchRunWorkspace.getAverageParameters();
if (parameters != null && parameters.length > 0 && parameters.length == FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF) {
String paramMsg = "Replace the current parameters with the following parameter values: \n\n";
for (int i = 0; i < parameters.length; i++) {
paramMsg = paramMsg + parameters[i].getName() + ": " + parameters[i].getInitialGuess() + "\n";
}
String choice = DialogUtils.showWarningDialog(this, paramMsg, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (choice == UserMessage.OPTION_OK) {
getPureDiffusionPanel().setParameterValues(parameters[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess(), parameters[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess(), parameters[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess());
}
} else {
throw new Exception("Parameters are null or number of applied parameters don't match the number (3) of parameters for diffusion with one diffusing component.");
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(this, e.getMessage());
}
}
use of cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace in project vcell by virtualcell.
the class EstParams_TwoDiffComponentPanel method loadBatchRunParameters.
public void loadBatchRunParameters(File inFile) {
String xmlString;
try {
xmlString = XmlUtil.getXMLString(inFile.getAbsolutePath());
BatchRunXmlReader batchRunXmlReader = new BatchRunXmlReader();
FRAPBatchRunWorkspace tempBatchRunWorkspace = batchRunXmlReader.getBatchRunWorkspace(XmlUtil.stringToXML(xmlString, null).getRootElement());
Parameter[] parameters = tempBatchRunWorkspace.getAverageParameters();
if (parameters != null && parameters.length > 0 && parameters.length == FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF) {
String paramMsg = "Replace the current parameters with the following parameter values, \n";
for (int i = 0; i < parameters.length; i++) {
paramMsg = paramMsg + parameters[i].getName() + ": " + parameters[i].getInitialGuess() + "\n";
}
String choice = DialogUtils.showWarningDialog(this, paramMsg, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (choice == UserMessage.OPTION_OK) {
frapWorkspace.getWorkingFrapStudy();
getPureDiffusionPanel().setParameterValues(parameters[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess(), parameters[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess(), parameters[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess(), parameters[FRAPModel.INDEX_SECONDARY_DIFF_RATE].getInitialGuess(), parameters[FRAPModel.INDEX_SECONDARY_FRACTION].getInitialGuess());
}
} else {
throw new Exception("Parameters are null or number of applied parameters don't match the number (5) of parameters for diffusion with two diffusing components.");
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(this, e.getMessage());
}
}
use of cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace in project vcell by virtualcell.
the class BatchRunDetailsPanel method setBatchRunWorkspace.
public void setBatchRunWorkspace(FRAPBatchRunWorkspace batchRunWorkspace) {
FRAPBatchRunWorkspace oldBatchRunWorkspace = this.batchRunWorkspace;
if (oldBatchRunWorkspace != null) {
oldBatchRunWorkspace.removePropertyChangeListener(this);
}
batchRunWorkspace.addPropertyChangeListener(this);
this.batchRunWorkspace = batchRunWorkspace;
}
use of cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace in project vcell by virtualcell.
the class VirtualFrapLoader method loadVFRAP.
// the function is called when activate in VCell or as standalone.
public static void loadVFRAP(final String[] args, final boolean bStandalone, final DocumentWindowManager documentWindowManager) {
try {
File wd = null;
if (args == null || args.length == 0) {
wd = ResourceUtil.getUserHomeDir();
} else {
wd = new File(args[0]);
}
final File workingDirectory = wd;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
FRAPSingleWorkspace frapWorkspace = new FRAPSingleWorkspace();
FRAPBatchRunWorkspace batchRunWorkspace = new FRAPBatchRunWorkspace();
// Check swing availability
String vers = System.getProperty("java.version");
if (vers.compareTo("1.1.2") < 0) {
System.out.println("!!!WARNING: Swing must be run with a 1.1.2 or higher version JVM!!!");
}
/* Set Look and Feel */
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
// set up file choosers
openVFRAPFileChooser = new LWFileChooser();
openVFRAPFileChooser.setDialogTitle("Open Virtual FRAP document (.vfrap)");
openVFRAPFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
openVFRAPFileChooser.addChoosableFileFilter(filter_vfrap);
openVFRAPFileChooser.setAcceptAllFileFilterUsed(false);
openVFRAPBatchRunChooser = new LWFileChooser();
openVFRAPBatchRunChooser.setDialogTitle("Open Virtual FRAP batchrun document (.vfbatch)");
openVFRAPBatchRunChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
openVFRAPBatchRunChooser.addChoosableFileFilter(filter_vfbatch);
openVFRAPBatchRunChooser.setAcceptAllFileFilterUsed(false);
loadFRAPImageFileChooser = new LWFileChooser();
loadFRAPImageFileChooser.setDialogTitle("Load FRAP image file");
loadFRAPImageFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
loadFRAPImageFileChooser.addChoosableFileFilter(filter_tif);
loadFRAPImageFileChooser.addChoosableFileFilter(filter_lsm);
addDataFileChooser_batchRun = new LWFileChooser();
addDataFileChooser_batchRun.setDialogTitle("Add a Virtual FRAP docmument or FRAP image file to batchrun");
addDataFileChooser_batchRun.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
addDataFileChooser_batchRun.addChoosableFileFilter(filter_vfrap);
addDataFileChooser_batchRun.addChoosableFileFilter(filter_tif);
addDataFileChooser_batchRun.addChoosableFileFilter(filter_lsm);
saveFileChooser = new LWFileChooser();
saveFileChooser.setDialogTitle("Save Virtual FRAP document (.vfrap)");
saveFileChooser.addChoosableFileFilter(filter_vfrap);
saveFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
saveAsMatFileChooser = new LWFileChooser();
saveAsMatFileChooser.setDialogTitle("Save image data to matlab file (.mat)");
saveAsMatFileChooser.addChoosableFileFilter(filter_mat);
saveAsMatFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
saveFileChooser_batchRun = new LWFileChooser();
saveFileChooser_batchRun.setDialogTitle("Save Virtual FRAP batchrun document (.vfbatch)");
saveFileChooser_batchRun.addChoosableFileFilter(filter_vfbatch);
saveFileChooser_batchRun.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
saveFileChooser_batchRunSaveSingleFileAs = new LWFileChooser();
saveFileChooser_batchRunSaveSingleFileAs.addChoosableFileFilter(filter_vfrap);
saveFileChooser_batchRunSaveSingleFileAs.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
multiOpenFileChooser = new LWFileChooser();
multiOpenFileChooser.setDialogTitle("Open FRAP image series");
multiOpenFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
multiOpenFileChooser.addChoosableFileFilter(filter_tif);
multiOpenFileChooser.setMultiSelectionEnabled(true);
saveMovieFileChooser = new LWFileChooser();
saveMovieFileChooser.setDialogTitle("Save to quick time movie (.mov)");
saveMovieFileChooser.addChoosableFileFilter(filter_qt);
saveMovieFileChooser.setAcceptAllFileFilterUsed(false);
saveMovieFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
if (mf == null) {
mf = new VirtualFrapMainFrame(localWorkspace, frapWorkspace, batchRunWorkspace, bStandalone, documentWindowManager);
}
// System.out.println(mf.getLocation().x + "---"+mf.getLocation().y);
mf.setMainFrameTitle("");
mf.setVisible(true);
// initialize FRAPStudy
FRAPStudy fStudy = new FRAPStudy();
frapWorkspace.setFrapStudy(fStudy, true);
try {
Thread.sleep(30);
} catch (InterruptedException e) {
}
}
});
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Aggregations