use of cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel in project vcell by virtualcell.
the class PDEDataViewer method showTimePlot.
// private static final String PROPERTY_PDEDC = "pdedc";
/**
* Comment
*/
private void showTimePlot() {
VariableType varType = getPdeDataContext().getDataIdentifier().getVariableType();
// Collect all sample curves created by user
SpatialSelection[] spatialSelectionArr = getPDEDataContextPanel1().fetchSpatialSelections(true, true);
SpatialSelection[] spatialSelectionArr2 = null;
if (varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_VOLUME) || varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_POSTPROCESSING)) {
spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType, true, true);
} else {
spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType.equals(VariableType.MEMBRANE) ? VariableType.MEMBRANE_REGION : VariableType.MEMBRANE, true, true);
}
final Vector<SpatialSelection> singlePointSSOnly = new Vector<SpatialSelection>();
final Vector<SpatialSelection> singlePointSSOnly2 = new Vector<SpatialSelection>();
if (spatialSelectionArr != null && spatialSelectionArr.length > 0) {
for (int i = 0; i < spatialSelectionArr.length; i++) {
if (spatialSelectionArr[i].isPoint() || (spatialSelectionArr[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr[i]).getSelectionSource() instanceof SinglePoint)) {
singlePointSSOnly.add(spatialSelectionArr[i]);
}
if (spatialSelectionArr2[i].isPoint() || (spatialSelectionArr2[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr2[i]).getSelectionSource() instanceof SinglePoint)) {
singlePointSSOnly2.add(spatialSelectionArr2[i]);
}
}
}
final String varName = getPdeDataContext().getVariableName();
if (singlePointSSOnly.size() == 0) {
PopupGenerator.showErrorDialog(this, "No Time sampling points match DataType=" + varType);
return;
}
try {
int[] indices = null;
//
indices = new int[singlePointSSOnly.size()];
for (int i = 0; i < singlePointSSOnly.size(); i++) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) singlePointSSOnly.get(i);
indices[i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) singlePointSSOnly.get(i);
indices[i] = ssm.getIndex(0);
}
}
double[] timePoints = getPdeDataContext().getTimePoints();
final TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(new String[] { varName }, new int[][] { indices }, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
if (!tsjs.getVcDataJobID().isBackgroundTask()) {
throw new RuntimeException("Use getTimeSeries(...) if not a background job");
}
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, tsjs);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieving Data for '" + varName + "'...", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask multiTimePlotHelperTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = createMultiTimePlotHelper((ClientPDEDataContext) PDEDataViewer.this.getPdeDataContext(), PDEDataViewer.this.getDataViewerManager().getUser(), getSimulationModelInfo().getDataSymbolMetadataResolver());
hashTable.put(MULTITPHELPER_TASK_KEY, multiTimePlotHelper);
}
};
AsynchClientTask task2 = new AsynchClientTask("showing time plot for '" + varName + "'", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Exception timeSeriesJobFailed = (Exception) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobException);
if (timeSeriesJobFailed != null) {
throw timeSeriesJobFailed;
}
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(StringKey_timeSeriesJobResults);
// Make independent Plotviewer that is unaffected by changes (time,var,paramscan) in 'this' PDEDataviewer except to pass-thru OutputContext changes
PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = (PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) hashTable.get(MULTITPHELPER_TASK_KEY);
try {
PdeTimePlotMultipleVariablesPanel pdeTimePlotPanel = new PdeTimePlotMultipleVariablesPanel(multiTimePlotHelper, singlePointSSOnly, singlePointSSOnly2, tsJobResultsNoStats);
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
String prefix = "Time Plot (" + getPDEPlotControlPanel1().getPlotVariableJList().getSelectedValue().getVariableType().getTypeName() + ") ";
ChildWindow childWindow = childWindowManager.addChildWindow(pdeTimePlotPanel, pdeTimePlotPanel, createContextTitle(PDEDataViewer.this.isPostProcess(), prefix, getPdeDataContext(), getSimulationModelInfo(), getSimulation()));
childWindow.getParent().addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
multiTimePlotHelper.removeallPropertyChangeListeners();
}
@Override
public void windowClosed(WindowEvent e) {
super.windowClosed(e);
multiTimePlotHelper.removeallPropertyChangeListeners();
}
});
// childWindow.addChildWindowListener(new ChildWindowListener() {
// @Override
// public void closing(ChildWindow childWindow) {
// multiTimePlotHelper.removeallPropertyChangeListeners();
// }
// @Override
// public void closed(ChildWindow childWindow) {
// multiTimePlotHelper.removeallPropertyChangeListeners();
// }
// });
childWindow.setSize(900, 550);
childWindow.setIsCenteredOnParent();
childWindow.show();
} catch (Exception e) {
e.printStackTrace();
multiTimePlotHelper.removeallPropertyChangeListeners();
}
}
};
// ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1,multiTimePlotHelperTask, task2 }, true, true, null);
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, multiTimePlotHelperTask, task2 }, null, false, false, true, null, false);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Aggregations