use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.
the class PDEDataViewer method showKymograph.
private void showKymograph() {
String title = createContextTitle(PDEDataViewer.this.isPostProcess(), "Kymograph: ", getPdeDataContext(), getSimulationModelInfo(), getSimulation());
final String INDICES_KEY = "INDICES_KEY";
final String CROSSING_KEY = "CROSSING_KEY";
final String ACCUM_KEY = "ACCUM_KEY";
AsynchClientTask multiTimePlotHelperTask = new AsynchClientTask("multiTimePlotHelperTask...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// Collect all sample curves created by user
SpatialSelection[] spatialSelectionArr = getPDEDataContextPanel1().fetchSpatialSelections(false, true);
final Vector<SpatialSelection> lineSSOnly = 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 cbit.vcell.geometry.SinglePoint)) {
} else {
lineSSOnly.add(spatialSelectionArr[i]);
}
}
}
//
if (lineSSOnly.size() == 0) {
throw new Exception("No line samples match DataType=" + getPdeDataContext().getDataIdentifier().getVariableType());
}
VariableType varType = getPdeDataContext().getDataIdentifier().getVariableType();
int[] indices = null;
int[] crossingMembraneIndices = null;
double[] accumDistances = null;
for (int i = 0; i < lineSSOnly.size(); i++) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) lineSSOnly.get(i);
SpatialSelection.SSHelper ssh = ssv.getIndexSamples(0.0, 1.0);
indices = ssh.getSampledIndexes();
crossingMembraneIndices = ssh.getMembraneIndexesInOut();
accumDistances = ssh.getWorldCoordinateLengths();
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) lineSSOnly.get(i);
SpatialSelection.SSHelper ssh = ssm.getIndexSamples();
indices = ssh.getSampledIndexes();
accumDistances = ssh.getWorldCoordinateLengths();
}
}
if (indices != null) {
hashTable.put(INDICES_KEY, indices);
}
if (crossingMembraneIndices != null) {
hashTable.put(CROSSING_KEY, crossingMembraneIndices);
}
if (accumDistances != null) {
hashTable.put(ACCUM_KEY, accumDistances);
}
MultiTimePlotHelper multiTimePlotHelper = createMultiTimePlotHelper((ClientPDEDataContext) getPdeDataContext(), getDataViewerManager().getUser(), getSimulationModelInfo().getDataSymbolMetadataResolver());
hashTable.put(MULTITPHELPER_TASK_KEY, multiTimePlotHelper);
}
};
AsynchClientTask kymographTask = new AsynchClientTask("Kymograph showing...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
KymographPanel kymographPanel = new KymographPanel(PDEDataViewer.this, title, (MultiTimePlotHelper) hashTable.get(MULTITPHELPER_TASK_KEY));
SymbolTable symbolTable;
if (getSimulation() != null && getSimulation().getMathDescription() != null) {
symbolTable = getSimulation().getMathDescription();
} else {
symbolTable = new SimpleSymbolTable(new String[] { getPdeDataContext().getDataIdentifier().getName() });
}
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
ChildWindow childWindow = childWindowManager.addChildWindow(kymographPanel, kymographPanel, title);
childWindow.setSize(new Dimension(700, 500));
childWindow.show();
kymographPanel.initDataManager(getPdeDataContext().getDataIdentifier(), getPdeDataContext().getTimePoints()[0], 1, getPdeDataContext().getTimePoints()[getPdeDataContext().getTimePoints().length - 1], (int[]) hashTable.get(INDICES_KEY), (int[]) hashTable.get(CROSSING_KEY), (double[]) hashTable.get(ACCUM_KEY), true, getPdeDataContext().getTimePoint(), symbolTable);
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { multiTimePlotHelperTask, kymographTask }, null, false, false, true, null, false);
}
use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.
the class PDEDataViewer method showSpatialPlot.
/**
* Comment
*/
private void showSpatialPlot() {
// check selections
final SpatialSelection[] sl = getPDEDataContextPanel1().fetchSpatialSelections(false, true);
if (sl == null) {
PopupGenerator.showErrorDialog(this, "Nothing selected!");
return;
}
for (int i = 0; i < sl.length; i++) {
if (sl[i].isPoint()) {
PopupGenerator.showErrorDialog(this, "One or more selections are single points - no spatial plot will be produced for those selections");
break;
}
}
final String varName = getPdeDataContext().getVariableName();
final double timePoint = getPdeDataContext().getTimePoint();
final SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[1];
if (getSimulation() != null && getSimulation().getMathDescription() != null) {
symbolTableEntries[0] = getSimulation().getMathDescription().getEntry(varName);
}
if (symbolTableEntries[0] == null) {
// TODO domain
Domain domain = null;
symbolTableEntries[0] = new VolVariable(varName, domain);
}
AsynchClientTask task1 = new AsynchClientTask("Retrieving spatial series for variable '" + varName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// get plots, ignoring points
PlotData[] plotDatas = new PlotData[sl.length];
for (int i = 0; i < sl.length; i++) {
PlotData plotData = null;
if (getPdeDataContext() instanceof PDEDataViewerPostProcess.PostProcessDataPDEDataContext) {
SpatialSelectionVolume ssVolume = (SpatialSelectionVolume) sl[i];
SpatialSelection.SSHelper ssvHelper = ssVolume.getIndexSamples(0.0, 1.0);
ssvHelper.initializeValues_VOLUME(getPdeDataContext().getDataValues());
double[] values = ssvHelper.getSampledValues();
plotData = new PlotData(ssvHelper.getWorldCoordinateLengths(), values);
} else {
plotData = getPdeDataContext().getLineScan(varName, timePoint, sl[i]);
}
plotDatas[i] = plotData;
}
hashTable.put("plotDatas", plotDatas);
}
};
AsynchClientTask task2 = new AsynchClientTask("Showing spatial plot for variable" + varName, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
for (PlotData plotData : plotDatas) {
if (plotData != null) {
PlotPane plotPane = new PlotPane();
Plot2D plot2D = new Plot2D(symbolTableEntries, getSimulationModelInfo().getDataSymbolMetadataResolver(), new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
plotPane.setPlot2D(plot2D);
String title = createContextTitle(PDEDataViewer.this.isPostProcess(), "Spatial Plot:'" + varName + "' ", getPdeDataContext(), getSimulationModelInfo(), getSimulation());
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
ChildWindow childWindow = childWindowManager.addChildWindow(plotPane, plotPane, title);
childWindow.setIsCenteredOnParent();
childWindow.pack();
childWindow.show();
// System.out.println("Spatial plot requesting focus. Result is: "+childWindow.requestFocusInWindow());
}
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.
the class PDEDataViewerPostProcess method activatePanel.
public void activatePanel(boolean bActivate) {
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(postProcessPDEDataViewer);
ChildWindow[] childwindows = childWindowManager.getAllChildWindows();
for (int i = 0; i < childwindows.length; i++) {
if (childwindows[i].getTitle().startsWith(PDEDataViewer.POST_PROCESS_PREFIX)) {
// System.out.println("showing "+childwindows[i].getTitle()+" "+childwindows[i].getContentPane().getClass().getName());
if (bActivate) {
childwindows[i].show();
} else {
childwindows[i].hide();
}
}
}
if (bActivate) {
update();
}
}
use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.
the class ReturnBNGOutput method validateConstraints.
private void validateConstraints(BNGOutputSpec outputSpec) {
ValidateConstraintsPanel panel = new ValidateConstraintsPanel(owner);
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(owner);
ChildWindow childWindow = childWindowManager.addChildWindow(panel, panel, "Apply the new constraints?");
// 320, 160 without the warning line
Dimension dim = new Dimension(376, 163);
childWindow.pack();
panel.setChildWindow(childWindow);
childWindow.setPreferredSize(dim);
childWindow.showModal();
if (panel.getButtonPushed() == ValidateConstraintsPanel.ActionButtons.Apply) {
System.out.println("pressed APPLY from task");
TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.TaskEndAdjustSimulationContextFlagsOnly, "");
owner.setNewCallbackMessage(tcm);
String string = "Updating the network constraints with the test values.";
System.out.println(string);
owner.updateOutputSpecToSimulationContext(outputSpec);
sc.getNetworkConstraints().updateConstraintsFromTest();
tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, string);
sc.firePropertyChange("appendToConsole", "", tcm);
return;
} else {
System.out.println("pressed CANCEL from task");
owner.updateOutputSpecToSimulationContext(null);
TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.Clean, "");
sc.appendToConsole(tcm);
String string = "The Network constraints were not updated with the test values.";
tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, string);
sc.firePropertyChange("appendToConsole", "", tcm);
// owner.refreshInterface();
return;
}
}
Aggregations