Search in sources :

Example 6 with DataIdentifier

use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.

the class PDEPlotControlPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getJTextField1().addActionListener(ivjEventHandler);
    getJTextField1().addFocusListener(ivjEventHandler);
    getDefaultListModelCivilized1().addListDataListener(ivjEventHandler);
    getViewFunctionButton().addActionListener(ivjEventHandler);
    getPlotVariableJList().setModel(getDefaultListModelCivilized1());
    getJSliderTime().getModel().addChangeListener(ivjEventHandler);
    getPlotVariableJList().addListSelectionListener(ivjEventHandler);
    getPlotVariableJList().setCellRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (dataInfoProvider == null) {
                if (value instanceof DataIdentifier) {
                    DataIdentifier var = (DataIdentifier) value;
                    if (var.getVariableType() == VariableType.POSTPROCESSING) {
                        setToolTipText(getText());
                        setText(var.getName());
                    }
                }
                return this;
            }
            // System.out.println("rendering object "+value+" of type "+value.getClass());
            DataIdentifier var = (DataIdentifier) value;
            c.setText(var.getName());
            c.setToolTipText("dataInfoProvier not found");
            DataSymbolMetadataResolver dataSymbolMetadataResolver = dataInfoProvider.getSimulationModelInfo().getDataSymbolMetadataResolver();
            if (dataSymbolMetadataResolver != null && dataSymbolMetadataResolver.getDataSymbolMetadata(var.getName()) != null) {
                DataSymbolMetadata dsm = dataSymbolMetadataResolver.getDataSymbolMetadata(var.getName());
                String tooltipString = "dataInfoProvider found, but identifier " + var.getName() + " not found";
                if (dsm == null) {
                    tooltipString = "did not find info on variable " + var.getDisplayName();
                } else {
                    c.setText(var.getName() + " [" + dsm.unit + "]");
                    tooltipString = dsm.tooltipString;
                }
                c.setToolTipText(tooltipString);
            }
            return this;
        }
    });
}
Also used : DataIdentifier(cbit.vcell.simdata.DataIdentifier) DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) JLabel(javax.swing.JLabel) Component(java.awt.Component) JList(javax.swing.JList) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata)

Example 7 with DataIdentifier

use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.

the class PDEPlotControlPanel method getFilterVarNamesTasks.

private AsynchClientTask[] getFilterVarNamesTasks() {
    final Object oldselection = getPlotVariableJList().getSelectedValue();
    final ArrayList<DataIdentifier> displayDataIdentifiers = new ArrayList<DataIdentifier>();
    AsynchClientTask task2 = new AsynchClientTask("filter variables", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            if (PDEPlotControlPanel.this.getName().equals("PostProcessPDEPCP")) {
                System.out.println("PostProcessPDEPCP");
            }
            getViewFunctionButton().setVisible(bHasOldUserDefinedFunctions);
            if (myDataIdentifiers != null && myDataIdentifiers.length > 0) {
                DataIdentifier[] dataIdentifierArr = new DataIdentifier[myDataIdentifiers.length];
                System.arraycopy(myDataIdentifiers, 0, dataIdentifierArr, 0, myDataIdentifiers.length);
                Arrays.sort(dataIdentifierArr, new Comparator<DataIdentifier>() {

                    public int compare(DataIdentifier o1, DataIdentifier o2) {
                        int bEqualIgnoreCase = o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
                        if (bEqualIgnoreCase == 0) {
                            return o1.getDisplayName().compareTo(o2.getDisplayName());
                        }
                        return bEqualIgnoreCase;
                    }
                });
                if (dataIdentifierFilter == null) {
                    displayDataIdentifiers.addAll(Arrays.asList(dataIdentifierArr));
                } else {
                    ArrayList<DataIdentifier> acceptedDataIdentifiers = dataIdentifierFilter.accept((String) filterComboBox.getSelectedItem(), Arrays.asList(myAnnotFunctions), dataIdentifierArr);
                    if (acceptedDataIdentifiers != null) {
                        displayDataIdentifiers.addAll(acceptedDataIdentifiers);
                    }
                }
            }
        }
    };
    AsynchClientTask task3 = new AsynchClientTask("Update filtered variables", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            if (PDEPlotControlPanel.this.getName().equals("PostProcessPDEPCP")) {
                System.out.println("PostProcessPDEPCP");
            }
            getDefaultListModelCivilized1().removeListDataListener(ivjEventHandler);
            getDefaultListModelCivilized1().setContents(displayDataIdentifiers.size() == 0 ? null : displayDataIdentifiers.toArray(new DataIdentifier[0]));
            getPlotVariableJList().clearSelection();
            getDefaultListModelCivilized1().addListDataListener(ivjEventHandler);
            if (getPlotVariableJList().getModel().getSize() > 0) {
                if (oldselection == null) {
                    getPlotVariableJList().setSelectedIndex(0);
                } else {
                    boolean bFound = false;
                    for (int i = 0; i < getPlotVariableJList().getModel().getSize(); i++) {
                        if (oldselection.equals(getPlotVariableJList().getModel().getElementAt(i))) {
                            getPlotVariableJList().setSelectedIndex(i);
                            bFound = true;
                            break;
                        }
                    }
                    if (!bFound) {
                        getPlotVariableJList().setSelectedIndex(0);
                    }
                }
            }
        }
    };
    return new AsynchClientTask[] { task2, task3 };
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DataIdentifier(cbit.vcell.simdata.DataIdentifier) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList)

Example 8 with DataIdentifier

use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.

the class SingleFileDescriptor method preNextProcess.

// load the data before the panel disappears
public ArrayList<AsynchClientTask> preNextProcess() {
    // create AsynchClientTask arraylist
    ArrayList<AsynchClientTask> taskArrayList = new ArrayList<AsynchClientTask>();
    if (singleFilePanel.getFileName().length() > 0) {
        final String fileStr = singleFilePanel.getFileName();
        final String LOADING_MESSAGE = "Loading " + fileStr + "...";
        AsynchClientTask updateUIBeforeLoadTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                VirtualFrapBatchRunFrame.updateStatus(LOADING_MESSAGE);
            }
        };
        AsynchClientTask loadTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                FRAPStudy newFRAPStudy = null;
                File inFile = new File(fileStr);
                if (// .log (vcell log file)
                inFile.getName().endsWith(SimDataConstants.LOGFILE_EXTENSION)) {
                    DataIdentifier[] dataIdentifiers = FrapDataUtils.getDataIdentiferListFromVCellSimulationData(inFile, 0);
                    String[][] rowData = new String[dataIdentifiers.length][1];
                    for (int i = 0; i < dataIdentifiers.length; i++) {
                        if (dataIdentifiers[i].getVariableType().equals(VariableType.VOLUME)) {
                            rowData[i][0] = dataIdentifiers[i].getName();
                        }
                    }
                    int[] selectedIndexArr = DialogUtils.showComponentOKCancelTableList(SingleFileDescriptor.this.getPanelComponent(), "Select Volume Variable", new String[] { "Volume Variable Name" }, rowData, ListSelectionModel.SINGLE_SELECTION);
                    if (selectedIndexArr != null && selectedIndexArr.length > 0) {
                        // newFRAPStudy = getFrapWorkspace().loadFRAPDataFromVcellLogFile(inFile, dataIdentifiers[selectedIndexArr[0]].getName(), this.getClientTaskStatusSupport());
                        isFileLoaded = true;
                    } else {
                        throw UserCancelException.CANCEL_GENERIC;
                    }
                } else if (// .vfrap
                inFile.getName().endsWith(VirtualFrapLoader.VFRAP_EXTENSION)) {
                    String xmlString = XmlUtil.getXMLString(inFile.getAbsolutePath());
                    MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
                    newFRAPStudy = xmlReader.getFrapStudy(XmlUtil.stringToXML(xmlString, null).getRootElement(), this.getClientTaskStatusSupport());
                    newFRAPStudy.setXmlFilename(inFile.getAbsolutePath());
                    if (!FRAPWorkspace.areExternalDataOK(localWorkspace, newFRAPStudy.getFrapDataExternalDataInfo(), newFRAPStudy.getRoiExternalDataInfo())) {
                        newFRAPStudy.setFrapDataExternalDataInfo(null);
                        newFRAPStudy.setRoiExternalDataInfo(null);
                    }
                } else // .lsm or other image formatss
                {
                    newFRAPStudy = FRAPWorkspace.loadFRAPDataFromImageFile(inFile, this.getClientTaskStatusSupport());
                    isFileLoaded = true;
                }
                // otherwise, popup a dialog saying the result will be invalid.
                if (!batchRunWorkspace.isBatchRunResultsAvailable()) {
                    hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
                } else if ((batchRunWorkspace.isBatchRunResultsAvailable() && inFile.getName().endsWith(VirtualFrapLoader.VFRAP_EXTENSION)) && ((newFRAPStudy.getFrapModel(batchRunWorkspace.getSelectedModel()) != null) && (newFRAPStudy.getFrapModel(batchRunWorkspace.getSelectedModel()).getModelParameters() != null))) {
                    // put newfrapstudy into hashtable to be used for next task
                    hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
                } else {
                    String continueStr = "Remove results and continue";
                    String cancelStr = "Cancel loading data";
                    String msg = "Loading a new data file,\n or a vfrap file with no model data,\n or a vfrap file with different selected model type, \n will INVALID the existing resuls.";
                    String choice = DialogUtils.showWarningDialog(singleFilePanel, msg, new String[] { continueStr, cancelStr }, continueStr);
                    if (choice == continueStr) {
                        hashTable.put(CLEAR_RESULT_KEY, new Boolean(true));
                        hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
                    } else // cancel
                    {
                        throw UserCancelException.CANCEL_GENERIC;
                    }
                }
            }
        };
        AsynchClientTask afterLoadingSwingTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                // check to see if results need to be cleared
                Boolean needClear = (Boolean) hashTable.get(CLEAR_RESULT_KEY);
                if (needClear != null && needClear.booleanValue()) {
                    double[][] oldAnalysisData = batchRunWorkspace.getAnalysisMSESummaryData();
                    double[][] newAnalysisData = null;
                    batchRunWorkspace.firePropertyChange(FRAPBatchRunWorkspace.PROPERTY_CHANGE_BATCHRUN_CLEAR_RESULTS, oldAnalysisData, newAnalysisData);
                }
                FRAPStudy newFRAPStudy = (FRAPStudy) hashTable.get(FRAPStudyPanel.NEW_FRAPSTUDY_KEY);
                // setFrapStudy fires property change, so we have to put it in Swing thread.
                getBatchRunWorkspace().getWorkingSingleWorkspace().setFrapStudy(newFRAPStudy, true);
                VirtualFrapBatchRunFrame.updateProgress(0);
                if (isFileLoaded) {
                    VirtualFrapBatchRunFrame.updateStatus("Loaded " + fileStr);
                } else {
                    VirtualFrapBatchRunFrame.updateStatus("Failed loading " + fileStr + ".");
                }
            }
        };
        taskArrayList.add(updateUIBeforeLoadTask);
        taskArrayList.add(loadTask);
        taskArrayList.add(afterLoadingSwingTask);
    } else {
        DialogUtils.showErrorDialog(singleFilePanel, "Load File name is empty. Please input a file name to continue.");
        throw new RuntimeException("Load File name is empty. Please input a file name to continue.");
    }
    return taskArrayList;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DataIdentifier(cbit.vcell.simdata.DataIdentifier) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) MicroscopyXmlReader(cbit.vcell.microscopy.MicroscopyXmlReader) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Example 9 with DataIdentifier

use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.

the class LoadFRAPData_SingleFileDescriptor method preNextProcess.

// load the data before the panel disappears
public ArrayList<AsynchClientTask> preNextProcess() {
    // create AsynchClientTask arraylist
    ArrayList<AsynchClientTask> taskArrayList = new ArrayList<AsynchClientTask>();
    if (singleFilePanel.getFileName().length() > 0) {
        final String fileStr = singleFilePanel.getFileName();
        final String LOADING_MESSAGE = "Loading " + fileStr + "...";
        AsynchClientTask updateUIBeforeLoadTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                VirtualFrapMainFrame.updateStatus(LOADING_MESSAGE);
            }
        };
        AsynchClientTask loadTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                FRAPStudy newFRAPStudy = null;
                File inFile = new File(fileStr);
                if (inFile != null) {
                    if (// .log (vcell log file)
                    inFile.getName().endsWith(SimDataConstants.LOGFILE_EXTENSION)) {
                        DataIdentifier[] dataIdentifiers = FrapDataUtils.getDataIdentiferListFromVCellSimulationData(inFile, 0);
                        ArrayList<String> selectedIdentifiers = new ArrayList<String>();
                        for (int i = 0; i < dataIdentifiers.length; i++) {
                            if (dataIdentifiers[i].getVariableType().equals(VariableType.VOLUME)) {
                                selectedIdentifiers.add(dataIdentifiers[i].getName());
                            }
                        }
                        String[][] rowData = new String[selectedIdentifiers.size()][1];
                        for (int i = 0; i < selectedIdentifiers.size(); i++) {
                            rowData[i][0] = selectedIdentifiers.get(i);
                        }
                        int[] selectedIndexArr = DialogUtils.showComponentOKCancelTableList(LoadFRAPData_SingleFileDescriptor.this.getPanelComponent(), "Select Volume Variable", new String[] { "Volume Variable Name" }, rowData, ListSelectionModel.SINGLE_SELECTION);
                        if (selectedIndexArr != null && selectedIndexArr.length > 0) {
                            scalePanel = getScalePanelForLoadingLogFile();
                            int choice = DialogUtils.showComponentOKCancelDialog(LoadFRAPData_SingleFileDescriptor.this.getPanelComponent(), scalePanel, "Input image maximum intensity (max: 65535)");
                            if (choice == JOptionPane.OK_OPTION) {
                                Double maxIntensity = null;
                                if (scalePanel.getInputScaleString() != null) {
                                    maxIntensity = new Double(scalePanel.getInputScaleString());
                                }
                                newFRAPStudy = FRAPWorkspace.loadFRAPDataFromVcellLogFile(inFile, selectedIdentifiers.get(selectedIndexArr[0]), null, maxIntensity, true, this.getClientTaskStatusSupport());
                                isFileLoaded = true;
                            } else {
                                throw UserCancelException.CANCEL_GENERIC;
                            }
                        } else {
                            throw UserCancelException.CANCEL_GENERIC;
                        }
                    } else if (inFile.getName().endsWith(SimDataConstants.DATA_PROCESSING_OUTPUT_EXTENSION_HDF5)) {
                        scalePanel = getScalePanelForLoadingLogFile();
                        int choice = DialogUtils.showComponentOKCancelDialog(LoadFRAPData_SingleFileDescriptor.this.getPanelComponent(), scalePanel, "Input data maximum value (max: 65535) which is used to avoid losing double precision when casting it to short.");
                        if (choice == JOptionPane.OK_OPTION) {
                            Double maxIntensity = null;
                            if (scalePanel.getInputScaleString() != null) {
                                maxIntensity = new Double(scalePanel.getInputScaleString());
                            }
                            newFRAPStudy = FRAPWorkspace.loadFRAPDataFromHDF5File(inFile, maxIntensity, this.getClientTaskStatusSupport());
                            isFileLoaded = true;
                        } else {
                            throw UserCancelException.CANCEL_GENERIC;
                        }
                    } else // .lsm or other image formatss
                    {
                        newFRAPStudy = FRAPWorkspace.loadFRAPDataFromImageFile(inFile, this.getClientTaskStatusSupport());
                        isFileLoaded = true;
                    }
                } else {
                    throw new RuntimeException("Input file is null.");
                }
                // for all loaded file
                hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
            }
        };
        AsynchClientTask afterLoadingSwingTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                FRAPStudy newFRAPStudy = (FRAPStudy) hashTable.get(FRAPStudyPanel.NEW_FRAPSTUDY_KEY);
                // setFrapStudy fires property change, so we have to put it in Swing thread.
                getFrapWorkspace().setFrapStudy(newFRAPStudy, true);
                VirtualFrapLoader.mf.setMainFrameTitle("");
                VirtualFrapMainFrame.updateProgress(0);
                if (isFileLoaded) {
                    VirtualFrapMainFrame.updateStatus("Loaded " + fileStr);
                } else {
                    VirtualFrapMainFrame.updateStatus("Failed loading " + fileStr + ".");
                }
            }
        };
        taskArrayList.add(updateUIBeforeLoadTask);
        taskArrayList.add(loadTask);
        taskArrayList.add(afterLoadingSwingTask);
    } else {
        DialogUtils.showErrorDialog(singleFilePanel, "Load File name is empty. Please input a file name to continue.");
        throw new RuntimeException("Load File name is empty. Please input a file name to continue.");
    }
    return taskArrayList;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DataIdentifier(cbit.vcell.simdata.DataIdentifier) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Example 10 with DataIdentifier

use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.

the class RasterExporter method exportPDEData.

private NrrdInfo[] exportPDEData(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, VariableSpecs variableSpecs, TimeSpecs timeSpecs2, GeometrySpecs geometrySpecs, RasterSpecs rasterSpecs, FileDataContainerManager fileDataContainerManager) throws RemoteException, DataAccessException, IOException {
    CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
    DataProcessingOutputInfo dataProcessingOutputInfo = null;
    // check if any of export variables are PostProcess and if so try to get PostProcessOutputInfo
    exportServiceImpl.fireExportProgress(jobID, vcdID, "Check PostProcess", 0.0);
    DataIdentifier[] dataIdentifiers = dataServerImpl.getDataIdentifiers(outputContext, user, vcdID);
    for (int i = 0; i < dataIdentifiers.length; i++) {
        for (int j = 0; j < variableSpecs.getVariableNames().length; j++) {
            if (variableSpecs.getVariableNames()[j].equals(dataIdentifiers[i].getName()) && VariableType.POSTPROCESSING.equals(dataIdentifiers[i].getVariableType())) {
                try {
                    // we need PostProcessOutputInfo
                    exportServiceImpl.fireExportProgress(jobID, vcdID, "Read PostProcess", 0.0);
                    dataProcessingOutputInfo = (DataProcessingOutputInfo) dataServerImpl.doDataOperation(user, new DataOperation.DataProcessingOutputInfoOP(vcdID, false, outputContext));
                    break;
                } catch (Exception e) {
                    throw new DataAccessException("Export variable '" + variableSpecs.getVariableNames()[j] + "' is PostProcessing type.  Error reading PostProcessing data: " + e.getClass().getName() + " " + e.getMessage());
                }
            }
        }
    }
    long lastUpdateTime = 0;
    switch(rasterSpecs.getFormat()) {
        case NRRD_SINGLE:
            {
                switch(geometrySpecs.getModeID()) {
                    case GEOMETRY_FULL:
                        {
                            NrrdInfo nrrdInfo = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglfull", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
                                }
                            }
                            nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
                            return new NrrdInfo[] { nrrdInfo };
                        }
                    case GEOMETRY_SLICE:
                        {
                            NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglslice", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
                                }
                            }
                            sliceNrrdInfo = NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
                            return new NrrdInfo[] { sliceNrrdInfo };
                        }
                    default:
                        {
                            throw new DataAccessException("NRRD export from slice not yet supported");
                        }
                }
            }
        case NRRD_BY_TIME:
            {
                switch(geometrySpecs.getModeID()) {
                    case GEOMETRY_FULL:
                        {
                            NRRDHelper nrrdHelper = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timefull", jobID, vcdID, progressIndex, progressEnd);
                                progressIndex++;
                                NrrdInfo nrrdInfo = nrrdHelper.createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
                                nrrdinfoV.add(nrrdInfo);
                                for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
                                }
                                NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    case GEOMETRY_SLICE:
                        {
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timeslice", jobID, vcdID, progressIndex, progressEnd);
                                progressIndex++;
                                NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
                                nrrdinfoV.add(sliceNrrdInfo);
                                for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
                                }
                                NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    default:
                        {
                            throw new DataAccessException("NRRD export from slice not yet supported");
                        }
                }
            }
        case NRRD_BY_VARIABLE:
            {
                switch(geometrySpecs.getModeID()) {
                    case GEOMETRY_FULL:
                        {
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                NRRDHelper nrrdhelHelper = new NRRDHelper(variableSpecs.getVariableNames()[i], mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
                                NrrdInfo nrrdInfo = nrrdhelHelper.createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
                                nrrdinfoV.add(nrrdInfo);
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
                                }
                                nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    case GEOMETRY_SLICE:
                        {
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
                                nrrdinfoV.add(sliceNrrdInfo);
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
                                }
                                NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    default:
                        {
                            throw new DataAccessException("NRRD export from slice not yet supported");
                        }
                }
            }
        default:
            {
                throw new DataAccessException("Multiple NRRD file export not yet supported");
            }
    }
}
Also used : DataOperation(cbit.vcell.simdata.DataOperation) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) NrrdInfo(cbit.vcell.export.nrrd.NrrdInfo) Point(java.awt.Point) RemoteException(java.rmi.RemoteException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MathException(cbit.vcell.math.MathException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) DataProcessingOutputInfo(cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

DataIdentifier (cbit.vcell.simdata.DataIdentifier)35 ArrayList (java.util.ArrayList)13 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)13 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)11 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)11 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)11 Hashtable (java.util.Hashtable)11 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)10 VariableType (cbit.vcell.math.VariableType)9 CartesianMesh (cbit.vcell.solvers.CartesianMesh)9 OutputContext (cbit.vcell.simdata.OutputContext)8 Point (java.awt.Point)8 DataAccessException (org.vcell.util.DataAccessException)8 TimeSeriesJobSpec (org.vcell.util.document.TimeSeriesJobSpec)8 SimDataBlock (cbit.vcell.simdata.SimDataBlock)6 File (java.io.File)6 ExportSpecs (cbit.vcell.export.server.ExportSpecs)5 DataOperation (cbit.vcell.simdata.DataOperation)5 ActionEvent (java.awt.event.ActionEvent)5 ActionListener (java.awt.event.ActionListener)5