use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class FRAPDataPanel method initialize.
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.ipadx = 0;
gridBagConstraints1.ipady = 0;
gridBagConstraints1.fill = GridBagConstraints.BOTH;
gridBagConstraints1.weighty = 1.0D;
gridBagConstraints1.weightx = 1.0D;
gridBagConstraints1.gridy = 0;
this.setSize(653, 492);
this.setLayout(new GridBagLayout());
this.add(getOverlayEditorPanelJAI(), gridBagConstraints1);
getOverlayEditorPanelJAI().addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(VFrap_OverlayEditorPanelJAI.FRAP_DATA_TIMEPLOTROI_PROPERTY)) {
try {
plotROI();
} catch (Exception e) {
DialogUtils.showErrorDialog(FRAPDataPanel.this, "Error Time Plot ROI:\n" + e.getMessage());
}
} else if (evt.getPropertyName().equals(VFrap_OverlayEditorPanelJAI.FRAP_DATA_CURRENTROI_PROPERTY)) {
try {
String roiName = (String) evt.getNewValue();
if (roiName != null) {
getFrapWorkspace().getWorkingFrapStudy().getFrapData().setCurrentlyDisplayedROI(getFrapWorkspace().getWorkingFrapStudy().getFrapData().getRoi(roiName), false);
}
} catch (Exception e) {
DialogUtils.showErrorDialog(FRAPDataPanel.this, "Error Setting Current ROI:\n" + e.getMessage());
}
} else if (evt.getPropertyName().equals(VFrap_OverlayEditorPanelJAI.FRAP_DATA_UNDOROI_PROPERTY)) {
try {
ROI undoableROI = (ROI) evt.getNewValue();
getFrapWorkspace().getWorkingFrapStudy().getFrapData().addReplaceRoi(undoableROI);
} catch (Exception e) {
PopupGenerator.showErrorDialog(FRAPDataPanel.this, "Error Setting Current ROI:\n" + e.getMessage());
}
}
}
});
VFrap_OverlayEditorPanelJAI.CustomROIImport importVFRAPROI = new VFrap_OverlayEditorPanelJAI.CustomROIImport() {
public boolean importROI(File inputFile) throws Exception {
try {
if (!VirtualFrapLoader.filter_vfrap.accept(inputFile)) {
return false;
}
String xmlString = XmlUtil.getXMLString(inputFile.getAbsolutePath());
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
FRAPStudy importedFrapStudy = xmlReader.getFrapStudy(XmlUtil.stringToXML(xmlString, null).getRootElement(), null);
VirtualFrapMainFrame.updateProgress(0);
ROI roi = getFrapWorkspace().getWorkingFrapStudy().getFrapData().getCurrentlyDisplayedROI();
ROI[] importedROIs = importedFrapStudy.getFrapData().getRois();
if (importedFrapStudy.getFrapData() != null && importedROIs != null) {
if (!importedROIs[0].getISize().compareEqual(roi.getISize())) {
throw new Exception("Imported ROI mask size (" + importedROIs[0].getISize().getX() + "," + importedROIs[0].getISize().getY() + "," + importedROIs[0].getISize().getZ() + ")" + " does not match current Frap DataSet size (" + roi.getISize().getX() + "," + roi.getISize().getY() + "," + roi.getISize().getZ() + ")");
}
for (int i = 0; i < importedROIs.length; i++) {
getFrapWorkspace().getWorkingFrapStudy().getFrapData().addReplaceRoi(importedROIs[i]);
}
// undoableEditSupport.postEdit(FRAPStudyPanel.CLEAR_UNDOABLE_EDIT);
}
return true;
} catch (Exception e1) {
throw new Exception("VFRAP ROI Import - " + e1.getMessage());
}
}
};
getOverlayEditorPanelJAI().setCustomROIImport(importVFRAPROI);
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class BatchRunDisplayPanel method getFRAPDataPanel.
public FRAPDataPanel getFRAPDataPanel() {
if (frapDataPanel == null) {
// the frap data panel in the main frame is not editable
frapDataPanel = new FRAPDataPanel(false);
// set display mode
frapDataPanel.adjustComponents(VFrap_OverlayEditorPanelJAI.DISPLAY_WITH_ROIS);
Hashtable<String, Cursor> cursorsForROIsHash = new Hashtable<String, Cursor>();
cursorsForROIsHash.put(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name(), FRAPStudyPanel.ROI_CURSORS[FRAPStudyPanel.CURSOR_CELLROI]);
cursorsForROIsHash.put(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name(), FRAPStudyPanel.ROI_CURSORS[FRAPStudyPanel.CURSOR_BLEACHROI]);
cursorsForROIsHash.put(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name(), FRAPStudyPanel.ROI_CURSORS[FRAPStudyPanel.CURSOR_BACKGROUNDROI]);
frapDataPanel.getOverlayEditorPanelJAI().setCursorsForROIs(cursorsForROIsHash);
VFrap_OverlayEditorPanelJAI.CustomROIImport importVFRAPROI = new VFrap_OverlayEditorPanelJAI.CustomROIImport() {
public boolean importROI(File inputFile) throws Exception {
try {
if (!VirtualFrapLoader.filter_vfrap.accept(inputFile)) {
return false;
}
String xmlString = XmlUtil.getXMLString(inputFile.getAbsolutePath());
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
FRAPStudy importedFrapStudy = xmlReader.getFrapStudy(XmlUtil.stringToXML(xmlString, null).getRootElement(), null);
VirtualFrapMainFrame.updateProgress(0);
ROI roi = getBatchRunWorkspace().getWorkingSingleWorkspace().getWorkingFrapStudy().getFrapData().getCurrentlyDisplayedROI();
ROI[] importedROIs = importedFrapStudy.getFrapData().getRois();
if (importedFrapStudy.getFrapData() != null && importedROIs != null) {
if (!importedROIs[0].getISize().compareEqual(roi.getISize())) {
throw new Exception("Imported ROI mask size (" + importedROIs[0].getISize().getX() + "," + importedROIs[0].getISize().getY() + "," + importedROIs[0].getISize().getZ() + ")" + " does not match current Frap DataSet size (" + roi.getISize().getX() + "," + roi.getISize().getY() + "," + roi.getISize().getZ() + ")");
}
for (int i = 0; i < importedROIs.length; i++) {
getBatchRunWorkspace().getWorkingSingleWorkspace().getWorkingFrapStudy().getFrapData().addReplaceRoi(importedROIs[i]);
}
// undoableEditSupport.postEdit(FRAPStudyPanel.CLEAR_UNDOABLE_EDIT);
}
return true;
} catch (Exception e1) {
throw new Exception("VFRAP ROI Import - " + e1.getMessage());
}
}
};
frapDataPanel.getOverlayEditorPanelJAI().setCustomROIImport(importVFRAPROI);
}
return frapDataPanel;
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class DefineROI_RoiForErrorPanel method refreshCheckboxes.
public void refreshCheckboxes() {
FRAPData frapData = frapWorkspace.getWorkingFrapStudy().getFrapData();
ROI[] rois = frapData.getRois();
// disable all the checkboxes first
setAllCheckboxesEnabled(false);
setAllCheckboxesSelected(false);
// disable ROIs with 0 pixel in it
// or disselect checkboxes according to stored selected ROIS
boolean[] storedSelectedROIs = frapWorkspace.getWorkingFrapStudy().getSelectedROIsForErrorCalculation();
for (int i = 0; i < rois.length; i++) {
if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).getNonzeroPixelsCount() > 0) {
roi_bleachedCheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleachedCheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring1CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring1CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING2.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING2.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring2CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring2CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING3.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING3.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring3CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring3CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING4.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING4.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring4CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring4CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING5.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING5.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring5CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring5CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING6.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING6.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring6CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring6CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING7.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING7.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring7CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring7CheckBox.setSelected(true);
}
} else if (rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING8.name()) && frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING8.name()).getNonzeroPixelsCount() > 0) {
roi_bleached_ring8CheckBox.setEnabled(true);
if (storedSelectedROIs == null || storedSelectedROIs.length < 1 || storedSelectedROIs[i]) {
roi_bleached_ring8CheckBox.setSelected(true);
}
}
}
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class DefineROI_RoiForErrorPanel method refreshROIImageForDisplay.
public void refreshROIImageForDisplay() {
FRAPData frapData = frapWorkspace.getWorkingFrapStudy().getFrapData();
ROI[] allROIs = getAllROIs();
Color[] allColors = getAllROIColors();
ArrayList<ROI> plottedROIs = new ArrayList<ROI>();
ArrayList<Color> plottedColors = new ArrayList<Color>();
if (roi_bleachedCheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED]);
plottedColors.add(allColors[IDX_ROI_BLEACHED]);
}
if (roi_bleached_ring1CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING1]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING1]);
}
if (roi_bleached_ring2CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING2]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING2]);
}
if (roi_bleached_ring3CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING3]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING3]);
}
if (roi_bleached_ring4CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING4]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING4]);
}
if (roi_bleached_ring5CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING5]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING5]);
}
if (roi_bleached_ring6CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING6]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING6]);
}
if (roi_bleached_ring7CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING7]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING7]);
}
if (roi_bleached_ring8CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING8]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING8]);
}
// show ROI image
ROI[] plottedROIArray = new ROI[plottedROIs.size()];
plottedROIArray = plottedROIs.toArray(plottedROIArray);
Color[] plottedColorArray = new Color[plottedColors.size()];
plottedColorArray = plottedColors.toArray(plottedColorArray);
roiImagePanel.refreshROIImage(plottedROIArray, plottedColorArray, frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()), Color.white);
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class VFrap_OverlayEditorPanelJAI method fireUndoableEditROI.
@SuppressWarnings("serial")
private void fireUndoableEditROI(final String editType) {
if (undoableROI == null) {
return;
}
final ROI originalROI = undoableROI;
undoableROI = null;
if (editType != null && undoableEditSupport != null) {
undoableEditSupport.postEdit(new AbstractUndoableEdit() {
public boolean canUndo() {
return true;
}
public String getUndoPresentationName() {
return editType + " " + originalROI.getROIName();
}
public void undo() throws CannotUndoException {
super.undo();
firePropertyChange(FRAP_DATA_UNDOROI_PROPERTY, null, originalROI);
}
});
} else {
if (undoableEditSupport != null) {
undoableEditSupport.postEdit(VFrap_OverlayEditorPanelJAI.CLEAR_UNDOABLE_EDIT);
}
}
}
Aggregations