Search in sources :

Example 6 with Wizard

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();
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) FRAPOptFunctions(cbit.vcell.microscopy.FRAPOptFunctions) Hashtable(java.util.Hashtable) Dimension(java.awt.Dimension) TreePath(javax.swing.tree.TreePath) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) Parameter(cbit.vcell.opt.Parameter) FRAPOptData(cbit.vcell.microscopy.FRAPOptData) Wizard(org.vcell.wizard.Wizard) File(java.io.File)

Example 7 with Wizard

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;
}
Also used : ChooseModel_ModelTypesDescriptor(cbit.vcell.microscopy.gui.choosemodelwizard.ChooseModel_ModelTypesDescriptor) Wizard(org.vcell.wizard.Wizard)

Example 8 with Wizard

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;
}
Also used : BatchRunROIImgPanel(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.BatchRunROIImgPanel) CellROIDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.CellROIDescriptor) BleachedROIDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.BleachedROIDescriptor) JRadioButton(javax.swing.JRadioButton) FileSaveDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.FileSaveDescriptor) ROISummaryDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.ROISummaryDescriptor) ActionEvent(java.awt.event.ActionEvent) WizardPanelDescriptor(org.vcell.wizard.WizardPanelDescriptor) FileTypeDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.FileTypeDescriptor) CropDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.CropDescriptor) SingleFileDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.SingleFileDescriptor) ActionListener(java.awt.event.ActionListener) FileSummaryDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.FileSummaryDescriptor) BackgroundROIDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.BackgroundROIDescriptor) MultiFileDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.MultiFileDescriptor) RoiForErrorDescriptor(cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.RoiForErrorDescriptor) Wizard(org.vcell.wizard.Wizard)

Aggregations

Wizard (org.vcell.wizard.Wizard)8 WizardPanelDescriptor (org.vcell.wizard.WizardPanelDescriptor)4 FRAPStudy (cbit.vcell.microscopy.FRAPStudy)3 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 FRAPOptData (cbit.vcell.microscopy.FRAPOptData)2 FRAPOptFunctions (cbit.vcell.microscopy.FRAPOptFunctions)2 Parameter (cbit.vcell.opt.Parameter)2 Dimension (java.awt.Dimension)2 Point (java.awt.Point)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 Hashtable (java.util.Hashtable)2 FRAPModel (cbit.vcell.microscopy.FRAPModel)1 BackgroundROIDescriptor (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.BackgroundROIDescriptor)1 BatchRunROIImgPanel (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.BatchRunROIImgPanel)1 BleachedROIDescriptor (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.BleachedROIDescriptor)1 CellROIDescriptor (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.CellROIDescriptor)1 CropDescriptor (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.CropDescriptor)1 FileSaveDescriptor (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.FileSaveDescriptor)1 FileSummaryDescriptor (cbit.vcell.microscopy.batchrun.gui.addFRAPdocWizard.FileSummaryDescriptor)1