use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class PDEDataViewer method roiAction.
private void roiAction() {
BeanUtils.setCursorThroughout(this, Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
final String[] ROI_COLUMN_NAMES = new String[] { "ROI source", "ROI source name", "ROI Description" };
final Vector<Object> auxInfoV = new Vector<Object>();
final DataIdentifier dataIdentifier = getPdeDataContext().getDataIdentifier();
VariableType variableType = dataIdentifier.getVariableType();
final boolean isVolume = variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION);
DefaultTableModel tableModel = new DefaultTableModel() {
public boolean isCellEditable(int row, int column) {
return false;
}
};
for (int i = 0; i < ROI_COLUMN_NAMES.length; i++) {
tableModel.addColumn(ROI_COLUMN_NAMES[i]);
}
// Add Snapshot ROI
if ((isVolume ? volumeSnapshotROI : membraneSnapshotROI) != null) {
tableModel.addRow(new Object[] { (isVolume ? "Volume" : "Membrane") + " Variables and Functions", "Snapshot", (isVolume ? volumeSnapshotROIDescription : membraneSnapshotROIDescription) + ", (values = 1.0)" });
auxInfoV.add((isVolume ? volumeSnapshotROI : membraneSnapshotROI));
}
// Add user ROIs
SpatialSelection[] userROIArr = getPDEDataContextPanel1().fetchSpatialSelections(true, false);
for (int i = 0; userROIArr != null && i < userROIArr.length; i += 1) {
String descr = null;
boolean bPoint = false;
if (isVolume) {
if (userROIArr[i] instanceof SpatialSelectionVolume) {
Curve curve = ((SpatialSelectionVolume) userROIArr[i]).getCurveSelectionInfo().getCurve();
descr = curve.getDescription();
if (curve instanceof SinglePoint) {
bPoint = true;
}
}
} else {
if (userROIArr[i] instanceof SpatialSelectionMembrane) {
SampledCurve selectionSource = ((SpatialSelectionMembrane) userROIArr[i]).getSelectionSource();
descr = selectionSource.getDescription();
if (selectionSource instanceof SinglePoint) {
bPoint = true;
}
}
}
// Add Area User ROI
BitSet fillBitSet = null;
if (userROIArr[i] instanceof SpatialSelectionVolume) {
fillBitSet = getFillROI((SpatialSelectionVolume) userROIArr[i]);
if (fillBitSet != null) {
tableModel.addRow(new Object[] { "User Defined", descr, "Area Enclosed Volume ROI" });
auxInfoV.add(fillBitSet);
}
}
// Add Point and Line User ROI
if (fillBitSet == null) {
tableModel.addRow(new Object[] { "User Defined", descr, (bPoint ? "Point" : "Line") + (isVolume ? " Volume" : " Membrane") + " ROI " });
auxInfoV.add(userROIArr[i]);
}
}
// Add sorted Geometry ROI
final CartesianMesh cartesianMesh = getPdeDataContext().getCartesianMesh();
HashMap<Integer, ?> regionMapSubvolumesHashMap = (isVolume ? cartesianMesh.getVolumeRegionMapSubvolume() : cartesianMesh.getMembraneRegionMapSubvolumesInOut());
Set<?> regionMapSubvolumesEntrySet = regionMapSubvolumesHashMap.entrySet();
Iterator<?> regionMapSubvolumesEntryIter = regionMapSubvolumesEntrySet.iterator();
TreeSet<Object[]> sortedGeomROITreeSet = new TreeSet<Object[]>(new Comparator<Object[]>() {
public int compare(Object[] o1, Object[] o2) {
int result = ((String) ((Object[]) o1[0])[1]).compareToIgnoreCase((String) ((Object[]) o2[0])[1]);
if (result == 0) {
result = (((Entry<Integer, ?>) o1[1]).getKey()).compareTo(((Entry<Integer, ?>) o2[1]).getKey());
}
return result;
}
});
while (regionMapSubvolumesEntryIter.hasNext()) {
Entry<Integer, ?> regionMapSubvolumesEntry = (Entry<Integer, ?>) regionMapSubvolumesEntryIter.next();
sortedGeomROITreeSet.add(new Object[] { new Object[] { "Geometry", (isVolume ? getSimulationModelInfo().getVolumeNamePhysiology(((Integer) regionMapSubvolumesEntry.getValue())) : getSimulationModelInfo().getMembraneName(((int[]) regionMapSubvolumesEntry.getValue())[0], ((int[]) regionMapSubvolumesEntry.getValue())[1], false)), (isVolume ? "(svID=" + regionMapSubvolumesEntry.getValue() + " " : "(") + "vrID=" + regionMapSubvolumesEntry.getKey() + ") Predefined " + (isVolume ? "volume" : "membrane") + " region" }, regionMapSubvolumesEntry });
}
Iterator<Object[]> sortedGeomROIIter = sortedGeomROITreeSet.iterator();
while (sortedGeomROIIter.hasNext()) {
Object[] sortedGeomROIObjArr = (Object[]) sortedGeomROIIter.next();
tableModel.addRow((Object[]) sortedGeomROIObjArr[0]);
auxInfoV.add(sortedGeomROIObjArr[1]);
}
final ScrollTable roiTable = new ScrollTable();
roiTable.setModel(tableModel);
roiTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
roiTable.setPreferredScrollableViewportSize(new Dimension(500, 200));
final JPanel mainJPanel = new JPanel();
BoxLayout mainBL = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
mainJPanel.setLayout(mainBL);
MiniTimePanel timeJPanel = new MiniTimePanel();
ActionListener okAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (((Double) timeJPanel.jcb_time_begin.getSelectedItem()).compareTo((Double) timeJPanel.jcb_time_end.getSelectedItem()) > 0) {
PopupGenerator.showErrorDialog(PDEDataViewer.this, "Selected 'Begin Time' must be less than or equal to 'End Time'");
return;
}
int[] selectedRows = roiTable.getSelectedRows();
if (selectedRows != null) {
try {
BitSet dataBitSet = new BitSet(getPdeDataContext().getDataValues().length);
for (int i = 0; i < selectedRows.length; i++) {
Object auxInfo = auxInfoV.elementAt(selectedRows[i]);
if (auxInfo instanceof BitSet) {
dataBitSet.or((BitSet) auxInfo);
} else if (auxInfo instanceof SpatialSelectionMembrane) {
int[] roiIndexes = ((SpatialSelectionMembrane) auxInfo).getIndexSamples().getSampledIndexes();
for (int j = 0; j < roiIndexes.length; j += 1) {
dataBitSet.set(roiIndexes[j], true);
}
} else if (auxInfo instanceof SpatialSelectionVolume) {
int[] roiIndexes = ((SpatialSelectionVolume) auxInfo).getIndexSamples(0, 1).getSampledIndexes();
for (int j = 0; j < roiIndexes.length; j += 1) {
dataBitSet.set(roiIndexes[j], true);
}
} else if (auxInfo instanceof Entry) {
Entry<Integer, Integer> entry = (Entry<Integer, Integer>) auxInfo;
if (isVolume) {
int volumeRegionID = entry.getKey();
dataBitSet.or(cartesianMesh.getVolumeROIFromVolumeRegionID(volumeRegionID));
} else {
int membraneRegionID = entry.getKey();
dataBitSet.or(cartesianMesh.getMembraneROIFromMembraneRegionID(membraneRegionID));
}
} else if (auxInfo instanceof BitSet) {
dataBitSet.or((BitSet) auxInfo);
} else {
throw new Exception("ROI table, Unknown data type: " + auxInfo.getClass().getName());
}
}
TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(new String[] { dataIdentifier.getName() }, new BitSet[] { dataBitSet }, ((Double) timeJPanel.jcb_time_begin.getSelectedItem()).doubleValue(), 1, ((Double) timeJPanel.jcb_time_end.getSelectedItem()).doubleValue(), true, false, VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieve data for '" + dataIdentifier + "'", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask task2 = new AsynchClientTask("Showing stat for '" + dataIdentifier + "'", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsSpaceStats tsJobResultsSpaceStats = (TSJobResultsSpaceStats) hashTable.get(StringKey_timeSeriesJobResults);
plotSpaceStats(tsJobResultsSpaceStats);
}
};
ClientTaskDispatcher.dispatch(PDEDataViewer.this, hash, new AsynchClientTask[] { task1, task2 }, true, true, null);
} catch (Exception e1) {
e1.printStackTrace();
PopupGenerator.showErrorDialog(PDEDataViewer.this, "ROI Error.\n" + e1.getMessage(), e1);
}
}
BeanUtils.disposeParentWindow(mainJPanel);
}
};
ActionListener cancelAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
BeanUtils.disposeParentWindow(mainJPanel);
}
};
OkCancelSubPanel okCancelJPanel = new OkCancelSubPanel(okAction, cancelAction);
roiTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (roiTable.getSelectedRows() != null && roiTable.getSelectedRows().length > 0) {
okCancelJPanel.okButton.setEnabled(true);
} else {
okCancelJPanel.okButton.setEnabled(false);
}
}
});
mainJPanel.add(timeJPanel);
mainJPanel.add(roiTable.getEnclosingScrollPane());
mainJPanel.add(okCancelJPanel);
// showComponentInFrame(mainJPanel,
// "Calculate "+(isVolume?"volume":"membrane")+" statistics for '"+getPdeDataContext().getVariableName()+"'."+
// " Choose times and 1 or more ROI(s).");
Frame dialogOwner = JOptionPane.getFrameForComponent(this);
JOptionPane inputDialog = new JOptionPane(mainJPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[0]);
final JDialog d = inputDialog.createDialog(dialogOwner, "Calculate " + (isVolume ? "volume" : "membrane") + " statistics for '" + getPdeDataContext().getVariableName() + "'." + " Choose times and 1 or more ROI(s).");
d.setResizable(true);
try {
DialogUtils.showModalJDialogOnTop(d, PDEDataViewer.this);
} finally {
d.dispose();
}
} finally {
BeanUtils.setCursorThroughout(this, Cursor.getDefaultCursor());
}
}
use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class PDEDataViewerPostProcess method createPostProcessPDEDataContext.
public static PostProcessDataPDEDataContext createPostProcessPDEDataContext(final ClientPDEDataContext parentPDEDataContext) throws Exception {
final DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputInfoOP(parentPDEDataContext.getVCDataIdentifier(), false, parentPDEDataContext.getDataManager().getOutputContext()));
if (dataProcessingOutputInfo == null) {
return null;
}
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return new DataSetController() {
// DataIdentifier[] dataIdentifiers;
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new DataAccessException("Not implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getTimeSeriesValues(timeSeriesJobSpec);
DataOperation.DataProcessingOutputTimeSeriesOP dataProcessingOutputTimeSeriesOP = new DataOperation.DataProcessingOutputTimeSeriesOP(vcdataID, timeSeriesJobSpec, outputContext, getDataSetTimes(vcdataID));
DataOperationResults.DataProcessingOutputTimeSeriesValues dataopDataProcessingOutputTimeSeriesValues = (DataOperationResults.DataProcessingOutputTimeSeriesValues) parentPDEDataContext.doDataOperation(dataProcessingOutputTimeSeriesOP);
return dataopDataProcessingOutputTimeSeriesValues.getTimeSeriesJobResults();
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getSimDataBlock(varName, time);
DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputValues = (DataOperationResults.DataProcessingOutputDataValues) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(vcdataID, varName, TimePointHelper.createSingleTimeTimePointHelper(time), DataIndexHelper.createAllDataIndexesDataIndexHelper(), outputContext, null));
PDEDataInfo pdeDataInfo = new PDEDataInfo(vcdataID.getOwner(), vcdataID.getID(), varName, time, Long.MIN_VALUE);
SimDataBlock simDataBlock = new SimDataBlock(pdeDataInfo, dataProcessingOutputValues.getDataValues()[0], VariableType.POSTPROCESSING);
return simDataBlock;
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// throw new DataAccessException("PostProcessData mesh not available at this level");
return null;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new DataAccessException("Remote getLineScan method should not be called for PostProcess");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return outputContext.getOutputFunctions();
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return dataProcessingOutputInfo.getVariableTimePoints();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataIdentifiers();
ArrayList<DataIdentifier> postProcessDataIDs = new ArrayList<DataIdentifier>();
if (outputContext != null && outputContext.getOutputFunctions() != null) {
for (int i = 0; i < outputContext.getOutputFunctions().length; i++) {
if (outputContext.getOutputFunctions()[i].isPostProcessFunction()) {
postProcessDataIDs.add(new DataIdentifier(outputContext.getOutputFunctions()[i].getName(), VariableType.POSTPROCESSING, null, false, outputContext.getOutputFunctions()[i].getDisplayName()));
}
}
}
// get 'state' variables
for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(PostProcessDataType.image)) {
DataIdentifier dataIdentifier = new DataIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null, false, dataProcessingOutputInfo.getVariableNames()[i]);
postProcessDataIDs.add(dataIdentifier);
}
}
if (postProcessDataIDs.size() > 0) {
return postProcessDataIDs.toArray(new DataIdentifier[0]);
}
return null;
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return parentPDEDataContext.doDataOperation(dataOperation);
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
// TODO Auto-generated method stub
return null;
}
@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) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
}
};
VCDataManager postProcessVCDataManager = new VCDataManager(dataSetControllerProvider);
PDEDataManager postProcessPDEDataManager = new PDEDataManager(((ClientPDEDataContext) parentPDEDataContext).getDataManager().getOutputContext(), postProcessVCDataManager, parentPDEDataContext.getVCDataIdentifier());
PostProcessDataPDEDataContext postProcessDataPDEDataContext = new PostProcessDataPDEDataContext(postProcessPDEDataManager);
return postProcessDataPDEDataContext;
}
use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class PDEExportDataPanel method getExportSpecs.
/**
* This method was created in VisualAge.
* @return cbit.vcell.export.server.ExportSpecs
*/
private ExportSpecs getExportSpecs() {
@SuppressWarnings("deprecation") Object[] variableSelections = getJListVariables().getSelectedValues();
String[] variableNames = new String[variableSelections.length];
for (int i = 0; i < variableSelections.length; i++) {
variableNames[i] = (String) variableSelections[i];
}
VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
TimeSpecs timeSpecs = new TimeSpecs(getJSlider1().getValue(), getJSlider2().getValue(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE);
int geoMode = ExportConstants.GEOMETRY_SELECTIONS;
if (getJRadioButtonSlice().isSelected()) {
geoMode = ExportConstants.GEOMETRY_SLICE;
} else if (getJRadioButtonFull().isSelected()) {
geoMode = ExportConstants.GEOMETRY_FULL;
}
Object[] selectionsArr = getROISelections().getSelectedValuesList().toArray();
SpatialSelection[] selections = new SpatialSelection[selectionsArr.length];
for (int i = 0; i < selections.length; i++) {
selections[i] = (SpatialSelection) selectionsArr[i];
}
GeometrySpecs geometrySpecs = new GeometrySpecs(selections, getNormalAxis(), getSlice(), geoMode);
return new ExportSpecs(getPdeDataContext().getVCDataIdentifier(), getExportSettings1().getSelectedFormat(), variableSpecs, timeSpecs, geometrySpecs, getExportSettings1().getFormatSpecificSpecs(), dataInfoProvider.getSimulationModelInfo().getSimulationName(), dataInfoProvider.getSimulationModelInfo().getContextName());
}
use of cbit.vcell.simdata.SpatialSelection 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.SpatialSelection in project vcell by virtualcell.
the class ASCIIExporter method getPointsTimeSeries.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @throws IOException
*/
private FileDataContainerID getPointsTimeSeries(OutputContext outputContext, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, String variableName, GeometrySpecs geometrySpecs, double[] allTimes, int beginIndex, int endIndex, boolean switchRowsColumns, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
org.vcell.util.document.TimeSeriesJobSpec timeSeriesJobSpec = new org.vcell.util.document.TimeSeriesJobSpec(new String[] { variableName }, new int[][] { geometrySpecs.getPointIndexes() }, null, 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
//
SpatialSelection[] pointSpatialSelections = geometrySpecs.getPointSpatialSelections();
FileDataContainerID fileDataContainerID = fileDataContainerManager.getNewFileDataContainerID();
// FileDataContainer container = fileDataContainerManager.getFileDataContainer(fileDataContainerID);
// buffer.append(
// "\"Time Series for variable '" + variableName + "'\" over the range " + allTimes[beginIndex] + " to " + allTimes[endIndex] + "\n");
fileDataContainerManager.append(fileDataContainerID, "\"variable ('" + variableName + "') times (" + allTimes[beginIndex] + " " + allTimes[endIndex] + ") " + /*+getSpatialSelectionDescription(curve)*/
"\"\n");
if (switchRowsColumns) {
fileDataContainerManager.append(fileDataContainerID, ",Coordinates\n");
fileDataContainerManager.append(fileDataContainerID, "Time,");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int k = 0; k < pointSpatialSelections.length; k++) {
fileDataContainerManager.append(fileDataContainerID, "," + getSpatialSelectionDescription(pointSpatialSelections[k]));
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[k + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
} else {
fileDataContainerManager.append(fileDataContainerID, ",Time\n");
fileDataContainerManager.append(fileDataContainerID, "Coordinates,");
for (int k = 0; k < pointSpatialSelections.length; k++) {
fileDataContainerManager.append(fileDataContainerID, "," + getSpatialSelectionDescription(pointSpatialSelections[k]));
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
for (int k = 0; k < pointSpatialSelections.length; k++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[k + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
return fileDataContainerID;
}
Aggregations