use of org.vcell.util.document.Version in project vcell by virtualcell.
the class GeometryTreePanel method actionsOnClick.
/**
* Comment
*/
protected void actionsOnClick(MouseEvent mouseEvent) {
if (mouseEvent.isPopupTrigger()) {
if (!getPopupMenuDisabled()) {
TreePath treePath = ((JTree) mouseEvent.getSource()).getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
((JTree) mouseEvent.getSource()).setSelectionPath(treePath);
if (getSelectedVersionInfo() instanceof GeometryInfo) {
Version version = getSelectedVersionInfo().getVersion();
boolean isOwner = version.getOwner().compareEqual(getDocumentManager().getUser());
getJMenuItemPermission().setEnabled(isOwner);
getJMenuItemDelete().setEnabled(isOwner);
getJMenuItemGeomRefs().setEnabled(isOwner);
getGeometryPopupMenu().show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
} else if (treePath != null) {
BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
Object object = bioModelNode.getUserObject();
if (object instanceof User) {
User selectedUser = (User) object;
boolean isOwner = selectedUser.compareEqual(getDocumentManager().getUser());
if (isOwner) {
JPopupMenu jPopupMenu = new JPopupMenu();
jPopupMenu.add(getJMenuItemCreateNewGeometry());
jPopupMenu.show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
}
}
}
} else {
ifNeedsDoubleClickEvent(mouseEvent, GeometryInfo.class);
}
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class ApplicationsPropertiesPanel method updateInterface.
/**
* Comment
*/
private void updateInterface() {
if (bioModel == null) {
return;
}
applicationsPanel.removeAll();
int gridy = 0;
SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
if (simulationContexts != null) {
for (int i = 0; i < simulationContexts.length; i++) {
SimulationContext simContext = simulationContexts[i];
JLabel label = new JLabel(simContext.getName());
label.setFont(label.getFont().deriveFont(Font.BOLD));
label.setIcon(simulationContextIcon);
GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy++;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.FIRST_LINE_START;
if (i > 0) {
gbc.insets = new Insets(4, 0, 0, 0);
}
applicationsPanel.add(label, gbc);
Geometry geometry = simContext.getGeometry();
String geometryText = "Compartmental geometry";
if (geometry != null) {
Version geometryVersion = geometry.getVersion();
int dimension = geometry.getDimension();
if (dimension > 0) {
String description = geometry.getDimension() + "D " + (geometry.getGeometrySpec().hasImage() ? "image" : "analytic") + " geometry";
geometryText = description;
if (geometryVersion != null) {
geometryText += " - " + geometryVersion.getName();
}
}
}
JLabel geometryLabel = new JLabel(geometryText);
geometryLabel.setIcon(geometryIcon);
JLabel detStochLabel = new JLabel(simContext.getMathType().getDescription());
detStochLabel.setIcon(appTypeIcon);
gbc.insets = new Insets(2, 20, 2, 2);
gbc.gridy = gridy++;
applicationsPanel.add(detStochLabel, gbc);
gbc.gridy = gridy++;
if (i == simulationContexts.length - 1) {
gbc.weighty = 1.0;
}
applicationsPanel.add(geometryLabel, gbc);
}
}
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class MathModelPropertiesPanel method updateInterface.
/**
* Comment
*/
private void updateInterface() {
if (mathModel == null || mathModelWindowManager == null) {
return;
}
nameLabel.setText(mathModel.getName());
Version version = mathModel.getVersion();
try {
if (version != null) {
ownerLabel.setText(version.getOwner().getName());
lastModifiedLabel.setText(version.getDate().toString());
MathModelInfo mathModelInfo = mathModelWindowManager.getRequestManager().getDocumentManager().getMathModelInfo(version.getVersionKey());
permissionLabel.setText(mathModelInfo.getVersion().getGroupAccess().getDescription());
changePermissionButton.setEnabled(true);
}
Geometry geometry = mathModel.getGeometry();
String geometryText = "Compartmental geometry";
if (geometry != null) {
Version geometryVersion = geometry.getVersion();
int dimension = geometry.getDimension();
if (dimension > 0) {
String description = geometry.getDimension() + "D " + (geometry.getGeometrySpec().hasImage() ? "image" : "analytic") + " geometry";
geometryText = description;
if (geometryVersion != null) {
geometryText += " - " + geometryVersion.getName() + " (" + geometryVersion.getDate() + ")";
}
}
}
geometryLabel.setText(geometryText);
detStochLabel.setText(mathModel.getMathDescription().getMathType().getDescription());
} catch (DataAccessException e) {
e.printStackTrace();
}
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class DataSymbolsPanel method addVFrapOriginalImages.
private void addVFrapOriginalImages() {
// add dataset (normal images) from vFrap
AsynchClientTask[] taskArray = new AsynchClientTask[5];
// select the desired vfrap file
taskArray[0] = ChooseVFrapFile();
taskArray[1] = new AsynchClientTask("Import objects", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
File vFrapFile = (File) hashTable.get("vFrapFile");
Component requesterComponent = DataSymbolsPanel.this;
DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
if (documentManager == null) {
throw new RuntimeException("Not connected to server.");
}
// ex ccc8.vfrap
String vFrapFileNameExtended = vFrapFile.getName();
{
// we want to make sure to reload these strings from the hash later on
String initialFieldDataName = vFrapFileNameExtended.substring(0, vFrapFileNameExtended.indexOf(".vfrap"));
// we'll save here the "special" vFrap images (prebleach_avg, ...)
String mixedFieldDataName = initialFieldDataName + "Mx";
hashTable.put("initialFieldDataName", initialFieldDataName);
hashTable.put("mixedFieldDataName", mixedFieldDataName);
}
if (vFrapFileNameExtended.indexOf(".vfrap") <= -1) {
throw new RuntimeException("File extension must be .vfrap");
}
// normal images
checkNameAvailability(hashTable, false, documentManager, requesterComponent);
// ----- read needed info from Virtual FRAP xml file
System.out.println("Loading " + vFrapFileNameExtended + " ...");
String xmlString = XmlUtil.getXMLString(vFrapFile.getAbsolutePath());
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
Element vFrapRoot = XmlUtil.stringToXML(xmlString, null).getRootElement();
// loading frap images
AnnotatedImageDataset annotatedImages = xmlReader.getAnnotatedImageDataset(vFrapRoot, null);
hashTable.put("annotatedImages", annotatedImages);
// loading ROIs for display purposes only (see next task)
ROI[] rois = xmlReader.getPrimaryROIs(XmlUtil.stringToXML(xmlString, null).getRootElement(), null);
LoadVFrapDisplayRoi(hashTable, annotatedImages, rois);
// Calendar cal = Calendar.getInstance();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_hhmmss");
// DocumentWindow documentWindow = (DocumentWindow)BeanUtils.findTypeParentOfComponent(DataSymbolsPanel.this, DocumentWindow.class);
// DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
// VFrapXmlHelper vFrapXmlHelper = new VFrapXmlHelper();
// if(vFrapXmlHelper.isAlreadyImported(vFrapFileName, documentManager)) {
// throw new RuntimeException("FieldData name already in use.");
// }
// // bioModel.setName(vFrapFileName + "-" + sdf.format(cal.getTime()));
// bioModel.setName(vFrapFileName);
// BioModel feedbackModel = documentManager.save(bioModel, null);
// BioModelChildSummary childSummary = BioModelChildSummary.fromDatabaseSerialization(xmlString);
// BioModelInfo biomodelInfo = new BioModelInfo(feedbackModel.getVersion(), feedbackModel.getVersion().getVersionKey(), childSummary );
// documentWindow.getTopLevelWindowManager().getRequestManager().openDocument(biomodelInfo, documentWindow.getTopLevelWindowManager(), true);
}
};
// show the images from the vfrap file in an OverlayEditorPanelJAI dialog
taskArray[2] = new AsynchClientTask("Display images", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
if (initialFieldDataName.equals("")) {
JOptionPane.showMessageDialog(DataSymbolsPanel.this, "Field Data name " + initialFieldDataName + " already in use.");
// prevents the rest of tasks below from running
throw UserCancelException.CANCEL_GENERIC;
}
AnnotatedImageDataset annotatedImages = (AnnotatedImageDataset) hashTable.get("annotatedImages");
BufferedImage[] displayROI = (BufferedImage[]) hashTable.get("displayROI");
if (annotatedImages == null || displayROI == null) {
return;
}
// display the images
OverlayEditorPanelJAI overlayPanel = new OverlayEditorPanelJAI();
overlayPanel.setAllowAddROI(false);
ImageDataset imageDataset = annotatedImages.getImageDataset();
overlayPanel.setImages(imageDataset, 1, 0, new OverlayEditorPanelJAI.AllPixelValuesRange(1, 200));
overlayPanel.setAllROICompositeImage(displayROI, OverlayEditorPanelJAI.FRAP_DATA_INIT_PROPERTY);
int choice = DialogUtils.showComponentOKCancelDialog(DataSymbolsPanel.this, overlayPanel, "vFrap Field Data");
if (choice != JOptionPane.OK_OPTION) {
throw UserCancelException.CANCEL_GENERIC;
}
}
};
// save the timepoints from memory to the database as field data
taskArray[3] = new AsynchClientTask("Saving time series data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
AnnotatedImageDataset annotatedImages = (AnnotatedImageDataset) hashTable.get("annotatedImages");
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(DataSymbolsPanel.this, DocumentWindow.class);
DocumentManager dm = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
if (dm == null) {
throw new RuntimeException("Not connected to server.");
}
User owner = null;
Version version = simulationContext.getVersion();
if (version == null) {
// new document, so the owner is the user
owner = dm.getUser();
} else {
owner = simulationContext.getVersion().getOwner();
}
// mesh
ImageDataset imageDataset = annotatedImages.getImageDataset();
Extent extent = imageDataset.getExtent();
ISize isize = imageDataset.getISize();
Origin origin = new Origin(0, 0, 0);
CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
// save field data
int NumTimePoints = imageDataset.getImageTimeStamps().length;
int NumChannels = 1;
double[][][] pixData = new double[NumTimePoints][NumChannels][];
for (int i = 0; i < NumTimePoints; i++) {
// images according to zIndex at specific time points(tIndex)
short[] originalData = imageDataset.getPixelsZ(0, i);
double[] doubleData = new double[originalData.length];
for (int j = 0; j < originalData.length; j++) {
doubleData[j] = 0x0000ffff & originalData[j];
}
pixData[i][NumChannels - 1] = doubleData;
}
FieldDataFileOperationSpec timeSeriesFieldDataOpSpec = new FieldDataFileOperationSpec();
timeSeriesFieldDataOpSpec.opType = FieldDataFileOperationSpec.FDOS_ADD;
timeSeriesFieldDataOpSpec.cartesianMesh = cartesianMesh;
timeSeriesFieldDataOpSpec.doubleSpecData = pixData;
timeSeriesFieldDataOpSpec.specEDI = null;
timeSeriesFieldDataOpSpec.varNames = new String[] { SimulationContext.FLUOR_DATA_NAME };
timeSeriesFieldDataOpSpec.owner = owner;
timeSeriesFieldDataOpSpec.times = imageDataset.getImageTimeStamps();
timeSeriesFieldDataOpSpec.variableTypes = new VariableType[] { VariableType.VOLUME };
timeSeriesFieldDataOpSpec.origin = origin;
timeSeriesFieldDataOpSpec.extent = extent;
timeSeriesFieldDataOpSpec.isize = isize;
// realignment for the case when first timepoint is not zero
if (timeSeriesFieldDataOpSpec.times[0] != 0) {
double shift = timeSeriesFieldDataOpSpec.times[0];
for (int i = 0; i < NumTimePoints; i++) {
timeSeriesFieldDataOpSpec.times[i] -= shift;
}
}
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyMMMdd_hhmmss");
String formattedDate = sdf.format(cal.getTime());
hashTable.put("formattedDate", formattedDate);
// ExternalDataIdentifier timeSeriesEDI = dm.saveFieldData(timeSeriesFieldDataOpSpec,
// initialFieldDataName + "_" + formattedDate);
ExternalDataIdentifier timeSeriesEDI = dm.saveFieldData(timeSeriesFieldDataOpSpec, initialFieldDataName);
hashTable.put("imageDataset", imageDataset);
hashTable.put("timeSeriesEDI", timeSeriesEDI);
}
};
// create the data symbols for the images saved above and display them in the tree/table
taskArray[4] = new AsynchClientTask("Display Data Symbols", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// --- create the data symbols associated with the time series
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
ImageDataset imageDataset = (ImageDataset) hashTable.get("imageDataset");
ExternalDataIdentifier timeSeriesEDI = (ExternalDataIdentifier) hashTable.get("timeSeriesEDI");
for (double time : imageDataset.getImageTimeStamps()) {
// String fluorName = TokenMangler.fixTokenStrict("fluor_"+time+"_");
// while (simulationContext.getDataContext().getDataSymbol(fluorName)!=null){
// fluorName = TokenMangler.getNextEnumeratedToken(fluorName);
// }
// max time interval we can display is about 11 days
DecimalFormat df = new DecimalFormat("###000.00");
// String fluorName = "fluor_" + df.format(time) + "_" + formattedDate;
String fluorName = "fluor_" + df.format(time).substring(0, df.format(time).indexOf(".")) + "s" + df.format(time).substring(1 + df.format(time).indexOf(".")) + "_" + initialFieldDataName;
// FieldFunctionArguments fluorFFArgs = new FieldFunctionArguments(timeSeriesEDI.getName(), fluorName, new Expression(time), VariableType.VOLUME);
DataSymbol fluorDataSymbol = new FieldDataSymbol(fluorName, DataSymbolType.VFRAP_TIMEPOINT, simulationContext.getDataContext(), simulationContext.getModel().getUnitSystem().getInstance_TBD(), timeSeriesEDI, SimulationContext.FLUOR_DATA_NAME, VariableType.VOLUME.getTypeName(), time);
simulationContext.getDataContext().addDataSymbol(fluorDataSymbol);
}
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, taskArray, false, true, null);
// String name = null;
// try {
// getNewDataSymbolPanel().setSymbolName("");
// getNewDataSymbolPanel().setSymbolExpression("vcField(dataset1,var1,0.0,Volume)");
// int newSettings = org.vcell.util.gui.DialogUtils.showComponentOKCancelDialog(this, getNewDataSymbolPanel(), "New DataSymbol");
// if (newSettings == JOptionPane.OK_OPTION) {
// name = getNewDataSymbolPanel().getSymbolName();
// String expression = getNewDataSymbolPanel().getSymbolExpression();
// Expression exp = new Expression(expression);
// FunctionInvocation[] functionInvocations = exp.getFunctionInvocations(null);
// // DataSymbol ds = new FieldDataSymbol(DataSymbolType.GENERIC_SYMBOL, name, "",
// // simulationContext.getDataContext(), VCUnitDefinition.UNIT_TBD,
// // new FieldFunctionArguments(functionInvocations[0]));
// DataSymbol ds = new FieldDataSymbol(name, DataSymbolType.GENERIC_SYMBOL,
// simulationContext.getDataContext(), VCUnitDefinition.UNIT_TBD);
// simulationContext.getDataContext().addDataSymbol(ds);
// }
// } catch (java.lang.Throwable ivjExc) {
// DialogUtils.showErrorDialog(this, "Data symbol " + name + " already exists");
// }
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class GeometryTable method getGeometry.
/**
* This method was created in VisualAge.
* @return Model
* @param rset ResultSet
* @param log SessionLog
*/
public Geometry getGeometry(ResultSet rset, Connection con) throws SQLException, DataAccessException, PropertyVetoException {
int dim = rset.getInt(dimension.toString());
double ox = rset.getBigDecimal(originX.toString()).doubleValue();
double oy = rset.getBigDecimal(originY.toString()).doubleValue();
double oz = rset.getBigDecimal(originZ.toString()).doubleValue();
double ex = rset.getBigDecimal(ExtentTable.table.extentX.toString()).doubleValue();
double ey = rset.getBigDecimal(ExtentTable.table.extentY.toString()).doubleValue();
double ez = rset.getBigDecimal(ExtentTable.table.extentZ.toString()).doubleValue();
java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
Geometry geometry = new Geometry(version, dim);
geometry.getGeometrySpec().setOrigin(new org.vcell.util.Origin(ox, oy, oz));
geometry.getGeometrySpec().setExtent(new org.vcell.util.Extent(ex, ey, ez));
return geometry;
}
Aggregations