use of cbit.vcell.field.FieldDataDBOperationSpec in project vcell by virtualcell.
the class ROIMultiPaintManager method loadFD.
private void loadFD(Hashtable<String, Object> hashTable) throws Exception {
final Exception[] excHolder = new Exception[] { null };
final JDialog jDialog = new JDialog(JOptionPane.getFrameForComponent(this.overlayEditorPanelJAI));
jDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
jDialog.setTitle("Import Type");
jDialog.setModal(true);
final JPanel okCancelJPanel = new JPanel(new FlowLayout());
JButton okJButton = new JButton("from File...");
okJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
fdDelta = new double[] { 0, 0, 0 };
fdDeltaLast = new double[] { 0, 0, 0 };
currScale = 1.0;
currScaleLast = 1.0;
VCDocument.DocumentCreationInfo documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FILE);
final AsynchClientTask selectImageFile = ClientRequestManager.getSelectImageFileTask(overlayEditorPanelJAI, null);
final AsynchClientTask parseImageTask = ClientRequestManager.getParseImageTask(overlayEditorPanelJAI, documentCreationInfo, null);
final AsynchClientTask importFileImage = ClientRequestManager.getImportFileImageTask(documentCreationInfo);
// final AsynchClientTask resizeImageTask = ClientRequestManager.getResizeImageTask(documentCreationInfo);
hashTable.put(ClientRequestManager.GUI_PARENT, ROIMultiPaintManager.this.overlayEditorPanelJAI);
selectImageFile.run(hashTable);
parseImageTask.run(hashTable);
hashTable.put(ClientRequestManager.NEW_IMAGE_SIZE_INFO, hashTable.get(ClientRequestManager.ORIG_IMAGE_SIZE_INFO));
importFileImage.run(hashTable);
// resizeImageTask.run(hashTable);
saveFDUnderlay(hashTable);
} catch (Exception e1) {
excHolder[0] = e1;
// e1.printStackTrace();
// DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e1.getMessage());
} finally {
jDialog.dispose();
}
}
});
JButton fdJButton = new JButton("from FieldData...");
fdJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
ArrayList<Object[]> allRows = new ArrayList<Object[]>();
ArrayList<ISize> iSizes = new ArrayList<ISize>();
ArrayList<CartesianMesh> meshes = new ArrayList<CartesianMesh>();
// DocumentManager documentManager = documentManager.getSessionManager()..getRequestManager().getDocumentManager();
FieldDataDBOperationSpec fdos = FieldDataDBOperationSpec.createGetExtDataIDsSpec(documentManager.getUser());
FieldDataDBOperationResults fieldDataDBOperationResults = documentManager.fieldDataDBOperation(fdos);
ExternalDataIdentifier[] externalDataIdentifierArr = fieldDataDBOperationResults.extDataIDArr;
Arrays.sort(externalDataIdentifierArr, new Comparator<ExternalDataIdentifier>() {
@Override
public int compare(ExternalDataIdentifier o1, ExternalDataIdentifier o2) {
// TODO Auto-generated method stub
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
ArrayList<ExternalDataIdentifier> okEDI = new ArrayList<ExternalDataIdentifier>();
for (int i = 0; externalDataIdentifierArr != null && i < externalDataIdentifierArr.length; i++) {
try {
FieldDataFileOperationSpec fieldDataFileOperationSpec = FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(externalDataIdentifierArr[i].getSimulationKey(), externalDataIdentifierArr[i].getOwner(), externalDataIdentifierArr[i].getJobIndex());
FieldDataFileOperationResults fieldDataFileOperationResults = documentManager.fieldDataFileOperation(fieldDataFileOperationSpec);
// System.out.println(externalDataIdentifierArr[i].getName()+" "+fieldDataFileOperationResults.iSize);
ISize iSize = fieldDataFileOperationResults.iSize;
iSizes.add(iSize);
// isizes.add(iSize);
okEDI.add(externalDataIdentifierArr[i]);
allRows.add(new Object[] { iSize.getX(), iSize.getY(), iSize.getZ(), "FieldData='" + externalDataIdentifierArr[i].getName() + "'" });
VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[iSize.getXYZ()], fieldDataFileOperationResults.extent, iSize.getX(), iSize.getY(), iSize.getZ());
int dimension = 1 + (iSize.getY() > 1 ? 1 : 0) + (iSize.getZ() > 1 ? 1 : 0);
CartesianMesh simpleMesh = CartesianMesh.createSimpleCartesianMesh(fieldDataFileOperationResults.origin, fieldDataFileOperationResults.extent, iSize, new RegionImage(vcImageUnc, dimension, fieldDataFileOperationResults.extent, fieldDataFileOperationResults.origin, RegionImage.NO_SMOOTHING));
meshes.add(simpleMesh);
} catch (Exception e2) {
e2.printStackTrace();
}
}
if (allRows.size() > 0) {
Object[][] rowData = allRows.toArray(new Object[0][]);
int[] selections = DialogUtils.showComponentOKCancelTableList(ROIMultiPaintManager.this.overlayEditorPanelJAI, "Select Simulation for Geom Size", new String[] { "X", "Y", "Z", "Name" }, rowData, ListSelectionModel.SINGLE_SELECTION);
if (selections != null && selections.length == 1) {
FieldDataFileOperationResults fdfor = documentManager.fieldDataFileOperation(FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(okEDI.get(selections[0]).getSimulationKey(), okEDI.get(selections[0]).getOwner(), okEDI.get(selections[0]).getJobIndex()));
SimDataBlock simDataBlock = VCellClientTest.getVCellClient().getClientServerManager().getDataSetController().getSimDataBlock(null, okEDI.get(selections[0]), fdfor.dataIdentifierArr[0].getName(), 0.0);
FieldDataFileOperationSpec fieldDataFileOperationSpec = new FieldDataFileOperationSpec();
fieldDataFileOperationSpec.isize = meshes.get(selections[0]).getISize();
fieldDataFileOperationSpec.shortSpecData = new short[][][] { { new short[fieldDataFileOperationSpec.isize.getXYZ()] } };
for (int i = 0; i < simDataBlock.getData().length; i++) {
fieldDataFileOperationSpec.shortSpecData[0][0][i] = (short) simDataBlock.getData()[i];
// if(simDataBlock.getData()[i] != 0) {
// System.out.println(simDataBlock.getData()[i]);
// }
}
hashTable.put(ClientRequestManager.FDFOS, fieldDataFileOperationSpec);
hashTable.put(ClientRequestManager.IMPORT_SOURCE_NAME, "FieldData=" + okEDI.get(selections[0]).getName());
saveFDUnderlay(hashTable);
// ROIMultiPaintManager.this.fdShort = (FieldDataFileOperationSpec)hashTable.get(ClientRequestManager.FDFOS);
// ROIMultiPaintManager.this.importSourceName = (String)hashTable.get(ClientRequestManager.IMPORT_SOURCE_NAME);
// (outMax-outMin)(inVal - inMin)
// ------------------------------ + outMin
// inMax - inMin
// externalDataIdentifierArr[selections[0]].
// // ImageSizeInfo imagesizeInfo = new ImageSizeInfo("internal",meshes.get(selections[0]).getISize(),1,new double[] {0},0);
// ImageSizeInfo imagesizeInfo = new ImageSizeInfo("internal",iSizes.get(selections[0]),1,new double[] {0},0);
// hashTable.put(ClientRequestManager.NEW_IMAGE_SIZE_INFO, imagesizeInfo);
//
// VCImage image = sourceGeom.getGeometrySpec().getImage();
// ISize samplingSize = new ISize(image.getNumX(),image.getNumY(),image.getNumZ());//
// VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[samplingSize.getXYZ()], sourceGeom.getExtent(), samplingSize.getX(), samplingSize.getY(), samplingSize.getZ());
// CartesianMesh sourceMesh = CartesianMesh.createSimpleCartesianMesh(
// sourceGeom.getOrigin(),
// sourceGeom.getExtent(),
// samplingSize,
// new RegionImage(vcImageUnc, sourceGeom.getDimension(), sourceGeom.getExtent(), sourceGeom.getOrigin(), RegionImage.NO_SMOOTHING));
//
// hashTable.put("newMesh", meshes.get(selections[0]));
// hashTable.put("sourceMesh", sourceMesh);
}
}
} catch (Exception e1) {
excHolder[0] = e1;
// e1.printStackTrace();
// DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e1.getMessage());
} finally {
jDialog.dispose();
}
}
});
JButton clipbboardJButton = new JButton("from Clipboard");
clipbboardJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
try {
Object transferData = contents.getTransferData(DataFlavor.stringFlavor);
if (transferData instanceof String) {
StringTokenizer st = new StringTokenizer(((String) transferData).toString(), ",");
String varName = st.nextToken();
String vcDataIdentifer = st.nextToken();
double timePoint = Double.parseDouble(st.nextToken());
ISize isize = new ISize(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
Range inRange = new Range(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
String simDataFile = st.nextToken();
DataInputStream dis = new DataInputStream(new FileInputStream(simDataFile));
FieldDataFileOperationSpec fieldDataFileOperationSpec = new FieldDataFileOperationSpec();
fieldDataFileOperationSpec.isize = isize;
fieldDataFileOperationSpec.shortSpecData = new short[][][] { { new short[fieldDataFileOperationSpec.isize.getXYZ()] } };
double outMax = 65535;
double outMin = 0;
double scale = (outMax - outMin) / (inRange.getMax() - inRange.getMin());
for (int i = 0; i < isize.getXYZ(); i++) {
double val = dis.readDouble();
fieldDataFileOperationSpec.shortSpecData[0][0][i] = (short) (scale * (val - inRange.getMin()) + outMin);
}
hashTable.put(ClientRequestManager.FDFOS, fieldDataFileOperationSpec);
hashTable.put(ClientRequestManager.IMPORT_SOURCE_NAME, "SimData=" + vcDataIdentifer + " varName=" + varName + " time=" + timePoint);
saveFDUnderlay(hashTable);
ROIMultiPaintManager.this.overlayEditorPanelJAI.setFDScale(new double[] { scale, inRange.getMin(), outMin });
}
} catch (Exception e1) {
excHolder[0] = e1;
// e1.printStackTrace();
// DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e1.getMessage());
} finally {
jDialog.dispose();
}
}
});
final boolean[] bCanelHolder = new boolean[] { false };
JButton cancelJButton = new JButton("Cancel");
cancelJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jDialog.dispose();
bCanelHolder[0] = true;
}
});
okCancelJPanel.add(okJButton);
okCancelJPanel.add(fdJButton);
okCancelJPanel.add(clipbboardJButton);
okCancelJPanel.add(cancelJButton);
jDialog.getContentPane().add(okCancelJPanel, BorderLayout.SOUTH);
jDialog.pack();
// jDialog.setSize(300,250);
DialogUtils.showModalJDialogOnTop(jDialog, overlayEditorPanelJAI);
if (bCanelHolder[0]) {
throw UserCancelException.CANCEL_GENERIC;
}
if (excHolder[0] != null) {
throw excHolder[0];
}
}
use of cbit.vcell.field.FieldDataDBOperationSpec in project vcell by virtualcell.
the class VFrapXmlHelper method isAlreadyImported.
// double[] firstPostBleach = null;
// double[] prebleachAvg = null;
// BufferedImage[] roiComposite = null;
//
// public double[] getFirstPostBleach() {
// if(firstPostBleach == null) {
// throw new RuntimeException("Missing vFrap FirstPostbleach Image");
// } else {
// return firstPostBleach;
// }
// }
// public double[] getPrebleachAvg() {
// if(prebleachAvg == null) {
// throw new RuntimeException("Missing vFrap PrebleachAverage Image");
// } else {
// return prebleachAvg;
// }
// }
// public BufferedImage[] getRoiComposite() {
// if(roiComposite == null) {
// throw new RuntimeException("Missing vFrap RoiComposite Image");
// } else {
// return roiComposite;
// }
// }
public static boolean isAlreadyImported(String candidateName, DocumentManager documentManager) throws DataAccessException {
FieldDataDBOperationSpec fdos = FieldDataDBOperationSpec.createGetExtDataIDsSpec(documentManager.getUser());
FieldDataDBOperationResults fieldDataDBOperationResults = documentManager.fieldDataDBOperation(fdos);
ExternalDataIdentifier[] externalDataIdentifierArr = fieldDataDBOperationResults.extDataIDArr;
for (ExternalDataIdentifier edi : externalDataIdentifierArr) {
if (candidateName.equals(edi.getName())) {
return true;
}
}
return false;
}
Aggregations