use of org.vcell.util.Extent in project vcell by virtualcell.
the class ROIMultiPaintManager method resizeImpl.
private void resizeImpl(ResizeInfo resizeInfo, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
resizeImpl0(resizeInfo, (bHasOriginalData ? initImageDataSetChannels : null), roiComposite);
ISize newISize = resizeInfo.getNewSize();
ISize oldISize = resizeInfo.getOriginalSize();
Extent resizeExtent = createResizeExtent(originalExtent, oldISize, newISize);
if (bHasOriginalData) {
for (int c = 0; c < initImageDataSetChannels.length; c++) {
UShortImage[] zImageSet = new UShortImage[newISize.getZ()];
for (int z = 0; z < zImageSet.length; z++) {
zImageSet[z] = new UShortImage(resizeInfo.underlayC[c][z], originalOrigin, resizeExtent, newISize.getX(), newISize.getY(), 1);
}
initImageDataSetChannels[c] = new ImageDataset(zImageSet, new double[] { 0.0 }, newISize.getZ());
}
} else {
initImageDataSet(null, newISize);
}
roiComposite = resizeInfo.roiComposite;
updateAuxiliaryInfo(originalISize, clientTaskStatusSupport);
}
use of org.vcell.util.Extent in project vcell by virtualcell.
the class ROIMultiPaintManager method showGUI.
public Geometry showGUI(final String okButtonText, final String sourceDataName, final Component parentComponent, String initalAnnotation, final VCPixelClass[] vcPixelClasses, UserPreferences userPreferences, boolean bFieldData) {
originalAnnotation = initalAnnotation;
final Geometry[] finalGeometryHolder = new Geometry[1];
if (overlayEditorPanelJAI == null) {
overlayEditorPanelJAI = new OverlayEditorPanelJAI();
overlayEditorPanelJAI.setCalcCoords(new CalcCoords());
overlayEditorPanelJAI.setUserPreferences(userPreferences);
overlayEditorPanelJAI.setMinimumSize(new Dimension(700, 600));
overlayEditorPanelJAI.setPreferredSize(new Dimension(700, 600));
overlayEditorPanelJAI.addPropertyChangeListener(ROIMultiPaintManager.this);
}
// delete all names
overlayEditorPanelJAI.deleteROIName(null);
// when user selects image "from DB" or "from current geometry"
applyPixelClasses(vcPixelClasses, parentComponent);
if (getImageDataset().length > 1) {
String[] channelNames = new String[getImageDataset().length];
for (int i = 0; i < channelNames.length; i++) {
channelNames[i] = "channel " + i;
}
overlayEditorPanelJAI.setChannelNames(channelNames);
} else {
overlayEditorPanelJAI.setChannelNames(null);
}
updateUnderlayHistogramDisplay();
overlayEditorPanelJAI.setContrastToMinMax();
overlayEditorPanelJAI.setAllROICompositeImage(roiComposite, OverlayEditorPanelJAI.FRAP_DATA_INIT_PROPERTY);
final JDialog jDialog = new JDialog(JOptionPane.getFrameForComponent(parentComponent));
jDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
jDialog.setTitle("Geometry Editor (" + sourceDataName + ")");
jDialog.setModal(true);
final JButton cancelJButton = new JButton("Cancel");
cancelJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final String QUIT_ANSWER = "Quit Geometry Editor";
String result = DialogUtils.showWarningDialog(jDialog, "Confirm cancel", "Quit geometry editor and lose all changes?", new String[] { QUIT_ANSWER, "back" }, QUIT_ANSWER);
if (result != null && result.equals(QUIT_ANSWER)) {
jDialog.dispose();
}
}
});
jDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
super.windowOpened(e);
if (bHasOriginalData) {
calculateHistogram();
}
updateUndoAfter(false);
if (vcPixelClasses == null) {
askInitialize(false);
}
}
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
super.windowClosing(e);
cancelJButton.doClick();
}
});
final JPanel okCancelJPanel = new JPanel(new FlowLayout());
JButton okJButton = new JButton(okButtonText);
okJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
VCImage finalImage = checkAll();
finalImage.setDescription((editedGeometryAttributes != null ? editedGeometryAttributes.annotation : originalAnnotation));
finalGeometryHolder[0] = new Geometry((String) null, finalImage);
finalGeometryHolder[0].getGeometrySpec().setOrigin((editedGeometryAttributes != null ? editedGeometryAttributes.origin : originalOrigin));
finalGeometryHolder[0].getGeometrySpec().setExtent((editedGeometryAttributes != null ? editedGeometryAttributes.extent : originalExtent));
finalGeometryHolder[0].setDescription((editedGeometryAttributes != null ? editedGeometryAttributes.annotation : originalAnnotation));
jDialog.dispose();
} catch (UserCancelException uce) {
} catch (Exception exc) {
DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Error validating compartments.\n" + exc.getMessage(), exc);
}
}
});
JButton attributesJButton = new JButton("Attributes...");
attributesJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
editedGeometryAttributes = showEditGeometryAttributes(jDialog, editedGeometryAttributes);
} catch (UserCancelException uce) {
// ignore
}
}
});
// JButton surfaceButton = new JButton("View Surfaces...");
// surfaceButton.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// showDataValueSurfaceViewer(geomAttr);
// }
// });
JButton fieldDataJButton = null;
if (bFieldData) {
fieldDataJButton = new JButton("FieldData...");
fieldDataJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Component c = overlayEditorPanelJAI;
do {
System.out.println(c.getClass().getName());
if (c instanceof DocumentWindow) {
// BeanUtils.printComponentInfo((Container)c);
ArrayList<Component> comps = new ArrayList<Component>();
BeanUtils.findComponent((Container) c, InitialConditionsPanel.class, comps);
InitialConditionsPanel initialConditionsPanel = (InitialConditionsPanel) comps.get(0);
SpeciesContextSpec[] speciesContextSpecs = initialConditionsPanel.getInitConditionVars();
Object[][] objs = new Object[speciesContextSpecs.length][1];
for (int i = 0; i < speciesContextSpecs.length; i++) {
if (speciesContextSpecs[i].getSimulationContext() == initialConditionsPanel.getSimulationContext()) {
objs[i][0] = speciesContextSpecs[i].getSpeciesContext().getName();
}
}
int[] select = DialogUtils.showComponentOKCancelTableList(overlayEditorPanelJAI, "Select species to add InitialCondition Field Data, App:'" + initialConditionsPanel.getSimulationContext().getName() + "'", new String[] { "speciesContext" }, objs, ListSelectionModel.SINGLE_SELECTION);
if (select != null && select.length > 0) {
// try {
String scName = speciesContextSpecs[select[0]].getSpeciesContext().getName();
Origin orig = (editedGeometryAttributes != null ? editedGeometryAttributes.origin : originalOrigin);
Extent extent = (editedGeometryAttributes != null ? editedGeometryAttributes.extent : originalExtent);
String fieldDataName = null;
boolean bDone = false;
do {
try {
fieldDataName = DialogUtils.showInputDialog0(ROIMultiPaintManager.this.overlayEditorPanelJAI, "Enter FieldData name", (fieldDataName == null ? ROIMultiPaintManager.this.importSourceName : fieldDataName));
createFD(false, fieldDataName, ROIMultiPaintManager.this.importSourceName, extent, orig, new String[] { scName }, new double[] { 0.0 }, initImageDataSetChannels[0].getISize());
bDone = true;
} catch (UtilCancelException uce) {
return;
} catch (Exception e1) {
e1.printStackTrace();
if (e1.getMessage().toUpperCase().contains("ORA-00001")) {
DialogUtils.showWarningDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, fieldDataName + " already used, enter a different name");
continue;
}
throw e1;
}
} while (!bDone);
initialConditionsPanel.setGeneratedFieldData(scName, "vcField('" + fieldDataName + "','" + scName + "',0.0,'Volume')");
// if(true) {
// return;
// }
// ISize iSize = initImageDataSetChannels[0].getISize();
// Extent extent = initImageDataSetChannels[0].getExtent();
// Origin orig = (editedGeometryAttributes!=null?editedGeometryAttributes.origin:originalOrigin);
// Extent extent = (editedGeometryAttributes!=null?editedGeometryAttributes.extent:originalExtent);
// createFD(false, fieldDataName, ROIMultiPaintManager.this.importSourceName, extent, orig, new String[] {scName}, new double[] {0.0},initImageDataSetChannels[0].getISize());
// export();
// ORA-00001
// } catch (Exception e1) {
// if(e1 instanceof UserCancelException) {
// return;
// }
// e1.printStackTrace();
// DialogUtils.showErrorDialog(overlayEditorPanelJAI, e1.getMessage());
// }
}
}
} while ((c = c.getParent()) != null);
} catch (Exception e2) {
e2.printStackTrace();
if (e2 instanceof UserCancelException || e2 instanceof UtilCancelException) {
return;
}
DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e2.getMessage());
}
}
});
}
JButton exportJButton = new JButton("Export...");
exportJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
export();
}
});
JButton importJButton = new JButton("Import stl...");
importJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser importJFC = new JFileChooser(ClientRequestManager.getPreferredPath(UserPreferences.getLastUserPreferences()));
importJFC.setDialogTitle("Choose .stl file(s) to import");
importJFC.setMultiSelectionEnabled(true);
int result = importJFC.showOpenDialog(overlayEditorPanelJAI);
if (result == JFileChooser.APPROVE_OPTION) {
File[] selectedFiles = importJFC.getSelectedFiles();
if (selectedFiles != null && selectedFiles.length > 0) {
ClientRequestManager.setPreferredPath(UserPreferences.getLastUserPreferences(), selectedFiles[0]);
Vect3d sampleSize = new Vect3d(getImageDataset()[0].getISize().getX(), getImageDataset()[0].getISize().getY(), getImageDataset()[0].getISize().getZ());
ArrayList<AsynchClientTask> stlImportTasks = getImportSTLtasks(selectedFiles, sampleSize, new Vect3d(0, 0, 0));
ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<>(), stlImportTasks.toArray(new AsynchClientTask[0]));
} else {
DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Select at least 1 .stl file for import.");
}
}
}
});
okCancelJPanel.add(okJButton);
okCancelJPanel.add(attributesJButton);
okCancelJPanel.add(exportJButton);
okCancelJPanel.add(importJButton);
// okCancelJPanel.add(surfaceButton);
if (bFieldData) {
okCancelJPanel.add(fieldDataJButton);
}
this.overlayEditorPanelJAI.translateToolButton.setVisible(bFieldData);
this.overlayEditorPanelJAI.scaleToolButton.setVisible(bFieldData);
okCancelJPanel.add(cancelJButton);
jDialog.getContentPane().add(overlayEditorPanelJAI, BorderLayout.CENTER);
jDialog.getContentPane().add(okCancelJPanel, BorderLayout.SOUTH);
jDialog.setSize(700, 600);
DialogUtils.showModalJDialogOnTop(jDialog, parentComponent);
if (finalGeometryHolder[0] == null) {
throw UserCancelException.CANCEL_GENERIC;
}
return finalGeometryHolder[0];
}
use of org.vcell.util.Extent in project vcell by virtualcell.
the class GeometrySizeDialog method Ok.
/**
* Comment
*/
private void Ok() throws PropertyVetoException {
final double worldExtentX = Double.valueOf(getSizeXTextField().getText()).doubleValue();
final double worldExtentY = Double.valueOf(getSizeYTextField().getText()).doubleValue();
final double worldExtentZ = Double.valueOf(getSizeZTextField().getText()).doubleValue();
final double worldOriginX = Double.valueOf(getOriginXTextField().getText()).doubleValue();
final double worldOriginY = Double.valueOf(getOriginYTextField().getText()).doubleValue();
final double worldOriginZ = Double.valueOf(getOriginZTextField().getText()).doubleValue();
final GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
AsynchClientTask extentOriginTask = new AsynchClientTask("Changing domain", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
geometrySpec.setExtent(new Extent(worldExtentX, worldExtentY, worldExtentZ));
geometrySpec.setOrigin(new Origin(worldOriginX, worldOriginY, worldOriginZ));
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
ClientTaskDispatcher.dispatch(this.getParent(), new Hashtable<String, Object>(), new AsynchClientTask[] { extentOriginTask }, false);
}
use of org.vcell.util.Extent in project vcell by virtualcell.
the class ROIAssistPanel method calculateRegionInfos.
private RegionInfo[] calculateRegionInfos(short[] validatePixels) throws Exception {
byte[] roiBytes = new byte[validatePixels.length];
for (int i = 0; i < roiBytes.length; i++) {
roiBytes[i] = (byte) (validatePixels[i] == 0 ? 0 : 1);
}
VCImageUncompressed roiVCImage = new VCImageUncompressed(null, roiBytes, new Extent(1, 1, 1), originalROI.getISize().getX(), originalROI.getISize().getY(), originalROI.getISize().getZ());
RegionImage roiRegionImage = new RegionImage(roiVCImage, 0, null, null, RegionImage.NO_SMOOTHING);
return roiRegionImage.getRegionInfos();
}
use of org.vcell.util.Extent in project vcell by virtualcell.
the class VFrap_ROIAssistPanel method calculateRegionInfos.
private RegionInfo[] calculateRegionInfos(short[] validatePixels) throws Exception {
byte[] roiBytes = new byte[validatePixels.length];
for (int i = 0; i < roiBytes.length; i++) {
roiBytes[i] = (byte) (validatePixels[i] == 0 ? 0 : 1);
}
VCImageUncompressed roiVCImage = new VCImageUncompressed(null, roiBytes, new Extent(1, 1, 1), originalROI.getISize().getX(), originalROI.getISize().getY(), originalROI.getISize().getZ());
RegionImage roiRegionImage = new RegionImage(roiVCImage, 0, null, null, RegionImage.NO_SMOOTHING);
return roiRegionImage.getRegionInfos();
}
Aggregations