use of cbit.vcell.simdata.ClientPDEDataContext in project vcell by virtualcell.
the class VCellClientDataServiceImpl method displayPostProcessingDataInVCell.
@Override
public void displayPostProcessingDataInVCell(SimulationDataSetRef simulationDataSetRef) throws NumberFormatException, DataAccessException {
User vcUser = vcellClient.getRequestManager().getDocumentManager().getUser();
VCSimulationIdentifier vcSimId = new VCSimulationIdentifier(new KeyValue(simulationDataSetRef.getSimId()), vcUser);
ClientDocumentManager clientDocumentManager = (ClientDocumentManager) vcellClient.getClientServerManager().getDocumentManager();
SimulationOwner simulationOwner = null;
if (simulationDataSetRef.isMathModel) {
simulationOwner = clientDocumentManager.getMathModel(new KeyValue(simulationDataSetRef.getModelId()));
} else {
BioModel bioModel = clientDocumentManager.getBioModel(new KeyValue(simulationDataSetRef.getModelId()));
simulationOwner = bioModel.getSimulationContext(simulationDataSetRef.getSimulationContextName());
}
ArrayList<AnnotatedFunction> outputFunctionsList = simulationOwner.getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
VCSimulationDataIdentifier vcSimDataId = new VCSimulationDataIdentifier(vcSimId, simulationDataSetRef.getJobIndex());
PDEDataManager pdeDataManager = (PDEDataManager) vcellClient.getRequestManager().getDataManager(outputContext, vcSimDataId, true);
final ClientPDEDataContext newClientPDEDataContext = pdeDataManager.getPDEDataContext();
// this was the code before the windows refactoring; appears to just always get the first window???
// Enumeration<TopLevelWindowManager> windowManagers = vcellClient.getMdiManager().getWindowManagers();
// final Window window = FindWindow.getWindow(windowManagers.nextElement().getComponent());
Optional<TopLevelWindowManager> first = vcellClient.getMdiManager().getWindowManagers().stream().findFirst();
VCAssert.assertTrue(first.isPresent(), "window manager not present?");
final Window window = getWindow(first.get().getComponent());
AsynchClientTask task = new AsynchClientTask("Display Post Processing Statistics", AsynchClientTask.TASKTYPE_SWING_NONBLOCKING, false, false) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
DataProcessingResultsPanel dataProcessingResultsPanel = new DataProcessingResultsPanel();
dataProcessingResultsPanel.update(newClientPDEDataContext);
DialogUtils.showComponentOKCancelDialog(window, dataProcessingResultsPanel, "Post Processing Statistics");
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
Vector<AsynchClientTask> tasksV = new Vector<AsynchClientTask>();
tasksV.add(task);
AsynchClientTask[] tasks = new AsynchClientTask[tasksV.size()];
tasksV.copyInto(tasks);
ClientTaskDispatcher.dispatch(window, hash, tasks, true);
}
use of cbit.vcell.simdata.ClientPDEDataContext in project vcell by virtualcell.
the class DisplayTimeSeries method displayImageTimeSeries.
public static void displayImageTimeSeries(final ImageTimeSeries<Image> imageTimeSeries, String title, WindowListener windowListener) throws ImageException, IOException {
ISize size = imageTimeSeries.getISize();
int dimension = (size.getZ() > 0) ? (3) : (2);
Extent extent = imageTimeSeries.getExtent();
Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
// don't care ... no surfaces
double filterCutoffFrequency = 0.5;
VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
final DataSetController dataSetController = new DataSetController() {
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
double timePoint = time;
double[] timePoints = getDataSetTimes(vcdataID);
int index = -1;
for (int i = 0; i < timePoints.length; i++) {
if (timePoint == timePoints[i]) {
index = i;
break;
}
}
double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
VariableType varType = VariableType.VOLUME;
return new SimDataBlock(pdeDataInfo, data, varType);
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return mesh;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return new AnnotatedFunction[0];
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return imageTimeSeries.getImageTimeStamps();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return new DataIdentifier[] { dataIdentifier };
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return dataSetController;
}
};
VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {
public User getOwner() {
return new User("nouser", null);
}
public KeyValue getDataKey() {
return null;
}
public String getID() {
return "mydata";
}
};
PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
PDEDataViewer pdeDataViewer = new PDEDataViewer();
JFrame jframe = new JFrame();
jframe.setTitle(title);
jframe.getContentPane().add(pdeDataViewer);
jframe.setSize(1000, 600);
jframe.setVisible(true);
if (windowListener != null) {
jframe.addWindowListener(windowListener);
}
pdeDataViewer.setPdeDataContext(myPdeDataContext);
}
Aggregations