use of cbit.vcell.simdata.SpatialSelectionMembrane in project vcell by virtualcell.
the class PDEDataContextPanel method fetchSpatialSelections0.
/**
* Insert the method's description here.
* Creation date: (6/28/2003 4:57:18 PM)
* @return cbit.vcell.simdata.gui.SpatialSelection[]
*/
private SpatialSelection[] fetchSpatialSelections0(Curve curveOfInterest, boolean bFetchOnlyVisible, VariableType vt) {
//
java.util.Vector<SpatialSelection> spatialSelection = new java.util.Vector<SpatialSelection>();
//
if (getPdeDataContext() != null && getPdeDataContext().getCartesianMesh() != null && getImagePlaneManagerPanel() != null && getImagePlaneManagerPanel().getCurveRenderer() != null) {
//
CartesianMesh cm = getPdeDataContext().getCartesianMesh();
Curve[] curves = getImagePlaneManagerPanel().getCurveRenderer().getAllCurves();
//
if (curves != null && curves.length > 0) {
for (int i = 0; i < curves.length; i += 1) {
boolean bIsVisible = getImagePlaneManagerPanel().getCurveRenderer().getRenderPropertyVisible(curves[i]);
if ((bFetchOnlyVisible && !bIsVisible) || (curveOfInterest != null && curves[i] != curveOfInterest)) {
continue;
}
//
if ((vt.equals(VariableType.POSTPROCESSING) || vt.equals(VariableType.VOLUME) || vt.equals(VariableType.VOLUME_REGION)) && curves[i] instanceof ControlPointCurve && !(curves[i] instanceof CurveSelectionCurve) && (curves[i].getDescription() == null || curves[i].getDescription().startsWith(CurveValueProvider.DESCRIPTION_VOLUME)) && (membranesAndIndexes == null || !membranesAndIndexes.containsKey(curves[i]))) {
// Volume
//
Curve samplerCurve = null;
// if(isSpatial2D){
samplerCurve = projectCurveOntoSlice(curves[i].getSampledCurve());
// }
if (samplerCurve != null) {
samplerCurve.setDescription(curves[i].getDescription());
spatialSelection.add(new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), vt, cm));
}
} else if ((vt.equals(VariableType.MEMBRANE) || vt.equals(VariableType.MEMBRANE_REGION)) && membranesAndIndexes != null) {
//
if (curves[i] instanceof CurveSelectionCurve) {
CurveSelectionCurve csCurve = (CurveSelectionCurve) curves[i];
if (csCurve.getSourceCurveSelectionInfo().getCurve() instanceof ControlPointCurve) {
int[] csisegsel = csCurve.getSourceCurveSelectionInfo().getSegmentsInSelectionOrder();
if (csisegsel != null) {
ControlPointCurve cscpcCurve = (ControlPointCurve) (csCurve.getSourceCurveSelectionInfo().getCurve());
Curve[] membraneCurves = (Curve[]) (membranesAndIndexes.keySet().toArray(new Curve[membranesAndIndexes.size()]));
// See if CurveSelectionCurve matches controlpoints in space of a membrane we have
for (int j = 0; j < membraneCurves.length; j += 1) {
if (membraneCurves[j] instanceof ControlPointCurve) {
// They should all be
ControlPointCurve cpc = (ControlPointCurve) membraneCurves[j];
boolean bSame = true;
for (int k = 0; k < csisegsel.length; k += 1) {
if (csisegsel[k] >= cpc.getControlPointCount() || csisegsel[k] >= cscpcCurve.getControlPointCount() || !Coordinate.get2DProjection(cpc.getControlPoint(csisegsel[k]), getNormalAxis()).equals(Coordinate.get2DProjection(cscpcCurve.getControlPoint(csisegsel[k]), getNormalAxis()))) {
//
bSame = false;
break;
}
}
if (bSame) {
int[] mi = (int[]) membranesAndIndexes.get(membraneCurves[j]);
spatialSelection.add(new SpatialSelectionMembrane(new CurveSelectionInfo(membraneCurves[j], csisegsel[0], csisegsel[csisegsel.length - 1], csCurve.getSourceCurveSelectionInfo().getDirectionNegative()), vt, cm, mi, csCurve));
}
}
}
}
}
} else if (curves[i] instanceof SinglePoint && (curves[i].getDescription() == null || curves[i].getDescription().startsWith(CurveValueProvider.DESCRIPTION_MEMBRANE))) {
CurveSelectionInfo[] csiArr = getImagePlaneManagerPanel().getCurveRenderer().getCloseCurveSelectionInfos(curves[i].getBeginningCoordinate());
if (csiArr != null && csiArr.length > 0) {
for (int j = 0; j < csiArr.length; j += 1) {
if (membranesAndIndexes.containsKey(csiArr[j].getCurve())) {
CurveSelectionInfo closestCSI = getImagePlaneManagerPanel().getCurveRenderer().getClosestSegmentSelectionInfo(curves[i].getBeginningCoordinate(), csiArr[j].getCurve());
int[] mi = (int[]) membranesAndIndexes.get(csiArr[j].getCurve());
spatialSelection.add(new SpatialSelectionMembrane(closestCSI, vt, cm, mi, (SinglePoint) curves[i]));
break;
}
}
}
}
}
}
}
}
//
if (spatialSelection.size() > 0) {
SpatialSelection[] ss = new SpatialSelection[spatialSelection.size()];
spatialSelection.copyInto(ss);
return ss;
}
return null;
}
use of cbit.vcell.simdata.SpatialSelectionMembrane in project vcell by virtualcell.
the class ASCIIExporter method getallSampleIndexes.
private int[] getallSampleIndexes(GeometrySpecs geometrySpecs, CartesianMesh mesh) throws DataAccessException {
ArrayList<Integer> sampleIndexes = new ArrayList<>();
SpatialSelection[] spatialSelections = geometrySpecs.getSelections();
for (int i = 0; i < spatialSelections.length; i++) {
spatialSelections[i].setMesh(mesh);
}
// Add points
if (geometrySpecs.getPointIndexes().length > 0) {
for (int i = 0; i < geometrySpecs.getPointIndexes().length; i++) {
sampleIndexes.add(geometrySpecs.getPointIndexes()[i]);
}
}
// Add curves
if (geometrySpecs.getCurves().length != 0) {
for (int i = 0; i < geometrySpecs.getCurves().length; i++) {
SpatialSelection curve = geometrySpecs.getCurves()[i];
curve.setMesh(mesh);
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
for (int j = 0; j < ssh.getSampledIndexes().length; j++) {
sampleIndexes.add(ssh.getSampledIndexes()[j]);
}
// numSamplePoints+= ssh.getSampledIndexes().length;
// pointIndexes = ssh.getSampledIndexes();
// distances = ssh.getWorldCoordinateLengths();
// crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
sampleIndexes.add(ssh.getSampledIndexes()[0]);
// numSamplePoints++;
// pointIndexes = new int[] {ssh.getSampledIndexes()[0]};
// distances = new double[] {0};
} else {
for (int j = 0; j < ssh.getSampledIndexes().length; j++) {
sampleIndexes.add(ssh.getSampledIndexes()[j]);
}
// numSamplePoints+= ssh.getSampledIndexes().length;
// pointIndexes = ssh.getSampledIndexes();
// distances = ssh.getWorldCoordinateLengths();
}
}
}
}
if (sampleIndexes.size() > 0) {
int[] allSampleIndexes = new int[sampleIndexes.size()];
for (int i = 0; i < allSampleIndexes.length; i++) {
allSampleIndexes[i] = sampleIndexes.get(i);
}
return allSampleIndexes;
}
return null;
}
use of cbit.vcell.simdata.SpatialSelectionMembrane in project vcell by virtualcell.
the class ASCIIExporter method getCurveTimeSeries.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @throws IOException
*/
private FileDataContainerID getCurveTimeSeries(int hdf5GroupVarID, PointsCurvesSlices pointsCurvesSlices, OutputContext outputContext, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, String variableName, SpatialSelection curve, double[] allTimes, int beginIndex, int endIndex, boolean switchRowsColumns, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
int[] pointIndexes = null;
double[] distances = null;
int[] crossingMembraneIndexes = null;
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
pointIndexes = new int[] { ssh.getSampledIndexes()[0] };
distances = new double[] { 0 };
} else {
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
}
}
pointsCurvesSlices.data.put(PCS.TIMES, new ArrayList<Double>());
pointsCurvesSlices.data.put(PCS.TIMEBOUNDS, new int[] { beginIndex, endIndex });
final TreeMap<PCS, Object> treePCS = new TreeMap<PCS, Object>();
((TreeMap<String, TreeMap<PCS, Object>>) pointsCurvesSlices.data.get(PCS.CURVES)).put(getSpatialSelectionDescription(curve), treePCS);
treePCS.put(PCS.CURVEINDEXES, pointIndexes);
treePCS.put(PCS.CURVEDISTANCES, distances);
if (crossingMembraneIndexes != null) {
treePCS.put(PCS.CURVECROSSMEMBRINDEX, crossingMembraneIndexes);
}
treePCS.put(PCS.CURVEVALS, new ArrayList<Double>());
org.vcell.util.document.TimeSeriesJobSpec timeSeriesJobSpec = new org.vcell.util.document.TimeSeriesJobSpec(new String[] { variableName }, new int[][] { pointIndexes }, new int[][] { crossingMembraneIndexes }, allTimes[beginIndex], 1, allTimes[endIndex], VCDataJobID.createVCDataJobID(user, false));
org.vcell.util.document.TSJobResultsNoStats timeSeriesJobResults = (org.vcell.util.document.TSJobResultsNoStats) dataServerImpl.getTimeSeriesValues(outputContext, user, vcdID, timeSeriesJobSpec);
// variableValues[0] is time array
// variableValues[1] is values for 1st spatial point.
// variableValues[2] is values for 2nd spatial point.
// variableValues[n] (n>=1) is values for nth spatial point.
// the length of variableValues should always be 1 + pointIndexes.length
// the length of variableValues[n] is allTimes.length
final double[][] variableValues = timeSeriesJobResults.getTimesAndValuesForVariable(variableName);
//
// put data in csv format
//
FileDataContainerID fileDataContainerID = fileDataContainerManager.getNewFileDataContainerID();
fileDataContainerManager.append(fileDataContainerID, "\"variable ('" + variableName + "') times (" + allTimes[beginIndex] + " " + allTimes[endIndex] + ") " + getSpatialSelectionDescription(curve) + "\"\n");
if (switchRowsColumns) {
fileDataContainerManager.append(fileDataContainerID, ",Distances\n");
fileDataContainerManager.append(fileDataContainerID, "Times,");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
((ArrayList<Double>) pointsCurvesSlices.data.get(PCS.TIMES)).add(allTimes[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[j]);
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
((ArrayList<Double>) treePCS.get(PCS.CURVEVALS)).add(variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
} else {
fileDataContainerManager.append(fileDataContainerID, ",Times\n");
fileDataContainerManager.append(fileDataContainerID, "Distances,");
for (int i = 0; i < distances.length; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
((ArrayList<Double>) pointsCurvesSlices.data.get(PCS.TIMES)).add(allTimes[i]);
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
((ArrayList<Double>) treePCS.get(PCS.CURVEVALS)).add(variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
if (curve instanceof SpatialSelectionMembrane) {
fileDataContainerManager.append(fileDataContainerID, "\n");
fileDataContainerManager.append(fileDataContainerID, "\"Centroid(XYZ):Times:Values[Times,Centroid]\",X,Y,Z,distance");
for (int i = 0; i < variableValues[0].length; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[0][i]);
((ArrayList<Double>) pointsCurvesSlices.data.get(PCS.TIMES)).add(variableValues[0][i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
double distance = 0;
for (int i = 0; i < pointIndexes.length; i++) {
if (pointIndexes.length > 1 && (i == (pointIndexes.length - 1)) && pointIndexes[i] == pointIndexes[i - 1]) {
continue;
}
Coordinate coord = curve.getMesh().getCoordinateFromMembraneIndex(pointIndexes[i]);
// double value = variableValues[i+1][0];
fileDataContainerManager.append(fileDataContainerID, "," + coord.getX() + "," + coord.getY() + "," + coord.getZ());
if (i > 0) {
Coordinate prevCoord = curve.getMesh().getCoordinateFromMembraneIndex(pointIndexes[i - 1]);
distance += coord.distanceTo(prevCoord);
}
fileDataContainerManager.append(fileDataContainerID, "," + distance);
for (int t = 0; t < variableValues[t].length; t++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[i + 1][t]);
((ArrayList<Double>) treePCS.get(PCS.CURVEVALS)).add(variableValues[i + 1][t]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
if (hdf5GroupVarID != -1) {
try {
int hdf5GroupCurveID = H5.H5Gcreate(hdf5GroupVarID, getSpatialSelectionDescription(curve), HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVEINDEXES.name(), new long[] {((int[])treePCS.get(PCS.CURVEINDEXES)).length}, (int[])treePCS.get(PCS.CURVEINDEXES),false);
Hdf5Utils.insertInts(hdf5GroupCurveID, PCS.CURVEINDEXES.name(), new long[] { ((int[]) treePCS.get(PCS.CURVEINDEXES)).length }, (int[]) treePCS.get(PCS.CURVEINDEXES));
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVEDISTANCES.name(), new long[] {((double[])treePCS.get(PCS.CURVEDISTANCES)).length}, (double[])treePCS.get(PCS.CURVEDISTANCES),false);
Hdf5Utils.insertDoubles(hdf5GroupCurveID, PCS.CURVEDISTANCES.name(), new long[] { ((double[]) treePCS.get(PCS.CURVEDISTANCES)).length }, (double[]) treePCS.get(PCS.CURVEDISTANCES));
if (treePCS.get(PCS.CURVECROSSMEMBRINDEX) != null) {
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name(), new long[] {((int[])treePCS.get(PCS.CURVECROSSMEMBRINDEX)).length}, (int[])treePCS.get(PCS.CURVECROSSMEMBRINDEX),false);
Hdf5Utils.insertInts(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name(), new long[] { ((int[]) treePCS.get(PCS.CURVECROSSMEMBRINDEX)).length }, (int[]) treePCS.get(PCS.CURVECROSSMEMBRINDEX));
ArrayList<Integer> crossPoints = new ArrayList<Integer>();
for (int i = 0; i < crossingMembraneIndexes.length; i++) {
if (crossingMembraneIndexes[i] != -1) {
crossPoints.add(i);
}
}
String attrText = PCS.CURVEVALS.name() + " columns " + crossPoints.get(0) + " and " + crossPoints.get(1) + " are added points of interpolation near membrane";
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name()+" Info", null, attrText,true);
Hdf5Utils.insertAttribute(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name() + " Info", attrText);
}
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVEVALS.name(), new long[] {endIndex-beginIndex+1,((int[])treePCS.get(PCS.CURVEINDEXES)).length}, (ArrayList<Double>)treePCS.get(PCS.CURVEVALS),false);
Hdf5Utils.insertDoubles(hdf5GroupCurveID, PCS.CURVEVALS.name(), new long[] { endIndex - beginIndex + 1, ((int[]) treePCS.get(PCS.CURVEINDEXES)).length }, (ArrayList<Double>) treePCS.get(PCS.CURVEVALS));
H5.H5Gclose(hdf5GroupCurveID);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage(), e);
}
}
return fileDataContainerID;
}
use of cbit.vcell.simdata.SpatialSelectionMembrane 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.simdata.SpatialSelectionMembrane 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