Search in sources :

Example 51 with CartesianMesh

use of cbit.vcell.solvers.CartesianMesh in project vcell by virtualcell.

the class DataSetControllerImpl method writeFieldFunctionData.

/**
 * Insert the method's description here.
 * Creation date: (9/21/2006 1:28:12 PM)
 * @throws FileNotFoundException
 * @throws DataAccessException
 */
public void writeFieldFunctionData(OutputContext outputContext, FieldDataIdentifierSpec[] argFieldDataIDSpecs, boolean[] bResampleFlags, CartesianMesh newMesh, SimResampleInfoProvider simResampleInfoProvider, int simResampleMembraneDataLength, int handleExistingResampleMode) throws FileNotFoundException, DataAccessException, IOException {
    if (handleExistingResampleMode != FVSolverStandalone.HESM_KEEP_AND_CONTINUE && handleExistingResampleMode != FVSolverStandalone.HESM_OVERWRITE_AND_CONTINUE && handleExistingResampleMode != FVSolverStandalone.HESM_THROW_EXCEPTION) {
        throw new IllegalArgumentException("Unknown mode " + handleExistingResampleMode);
    }
    if (argFieldDataIDSpecs == null || argFieldDataIDSpecs.length == 0) {
        return;
    }
    HashMap<FieldDataIdentifierSpec, File> uniqueFieldDataIDSpecAndFileH = new HashMap<FieldDataIdentifierSpec, File>();
    HashMap<FieldDataIdentifierSpec, Boolean> bFieldDataResample = new HashMap<FieldDataIdentifierSpec, Boolean>();
    for (int i = 0; i < argFieldDataIDSpecs.length; i++) {
        if (!uniqueFieldDataIDSpecAndFileH.containsKey(argFieldDataIDSpecs[i])) {
            File newResampledFieldDataFile = null;
            try {
                newResampledFieldDataFile = ((SimulationData) getVCData(simResampleInfoProvider)).getFieldDataFile(simResampleInfoProvider, argFieldDataIDSpecs[i].getFieldFuncArgs());
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                // use the original way
                newResampledFieldDataFile = new File(getPrimaryUserDir(simResampleInfoProvider.getOwner(), true), SimulationData.createCanonicalResampleFileName(simResampleInfoProvider, argFieldDataIDSpecs[i].getFieldFuncArgs()));
            }
            if (handleExistingResampleMode == FVSolverStandalone.HESM_THROW_EXCEPTION && newResampledFieldDataFile.exists()) {
                throw new RuntimeException("Resample Error: mode not allow overwrite or ignore of " + "existing file\n" + newResampledFieldDataFile.getAbsolutePath());
            }
            uniqueFieldDataIDSpecAndFileH.put(argFieldDataIDSpecs[i], newResampledFieldDataFile);
            bFieldDataResample.put(argFieldDataIDSpecs[i], bResampleFlags[i]);
        }
    }
    try {
        Set<Entry<FieldDataIdentifierSpec, File>> resampleSet = uniqueFieldDataIDSpecAndFileH.entrySet();
        Iterator<Entry<FieldDataIdentifierSpec, File>> resampleSetIter = resampleSet.iterator();
        while (resampleSetIter.hasNext()) {
            Entry<FieldDataIdentifierSpec, File> resampleEntry = resampleSetIter.next();
            if (handleExistingResampleMode == FVSolverStandalone.HESM_KEEP_AND_CONTINUE && resampleEntry.getValue().exists()) {
                continue;
            }
            FieldDataIdentifierSpec fieldDataIdSpec = resampleEntry.getKey();
            boolean bResample = bFieldDataResample.get(fieldDataIdSpec);
            CartesianMesh origMesh = getMesh(fieldDataIdSpec.getExternalDataIdentifier());
            SimDataBlock simDataBlock = getSimDataBlock(outputContext, fieldDataIdSpec.getExternalDataIdentifier(), fieldDataIdSpec.getFieldFuncArgs().getVariableName(), fieldDataIdSpec.getFieldFuncArgs().getTime().evaluateConstant());
            VariableType varType = fieldDataIdSpec.getFieldFuncArgs().getVariableType();
            VariableType dataVarType = simDataBlock.getVariableType();
            if (!varType.equals(VariableType.UNKNOWN) && !varType.equals(dataVarType)) {
                throw new IllegalArgumentException("field function variable type (" + varType.getTypeName() + ") doesn't match real variable type (" + dataVarType.getTypeName() + ")");
            }
            double[] origData = simDataBlock.getData();
            double[] newData = null;
            CartesianMesh resampleMesh = newMesh;
            if (!bResample) {
                if (resampleMesh.getGeometryDimension() != origMesh.getGeometryDimension()) {
                    throw new DataAccessException("Field data " + fieldDataIdSpec.getFieldFuncArgs().getFieldName() + " (" + origMesh.getGeometryDimension() + "D) should have same dimension as simulation mesh (" + resampleMesh.getGeometryDimension() + "D) because it is not resampled to simulation mesh (e.g. Point Spread Function)");
                }
                newData = origData;
                resampleMesh = origMesh;
            } else {
                if (CartesianMesh.isSpatialDomainSame(origMesh, resampleMesh)) {
                    newData = origData;
                    if (simDataBlock.getVariableType().equals(VariableType.MEMBRANE)) {
                        if (origData.length != simResampleMembraneDataLength) {
                            throw new Exception("FieldData variable \"" + fieldDataIdSpec.getFieldFuncArgs().getVariableName() + "\" (" + simDataBlock.getVariableType().getTypeName() + ") " + "resampling failed: Membrane Data lengths must be equal");
                        }
                    } else if (!simDataBlock.getVariableType().equals(VariableType.VOLUME)) {
                        throw new Exception("FieldData variable \"" + fieldDataIdSpec.getFieldFuncArgs().getVariableName() + "\" (" + simDataBlock.getVariableType().getTypeName() + ") " + "resampling failed: Only Volume and Membrane variable types are supported");
                    }
                } else {
                    if (!simDataBlock.getVariableType().compareEqual(VariableType.VOLUME)) {
                        throw new Exception("FieldData variable \"" + fieldDataIdSpec.getFieldFuncArgs().getVariableName() + "\" (" + simDataBlock.getVariableType().getTypeName() + ") " + "resampling failed: Only VOLUME FieldData variable type allowed when\n" + "FieldData spatial domain does not match Simulation spatial domain.\n" + "Check dimension, xsize, ysize, zsize, origin and extent are equal.");
                    }
                    if (origMesh.getSizeY() == 1 && origMesh.getSizeZ() == 1) {
                        newData = MathTestingUtilities.resample1DSpatialSimple(origData, origMesh, resampleMesh);
                    } else if (origMesh.getSizeZ() == 1) {
                        newData = MathTestingUtilities.resample2DSpatialSimple(origData, origMesh, resampleMesh);
                    } else {
                        newData = MathTestingUtilities.resample3DSpatialSimple(origData, origMesh, resampleMesh);
                    }
                }
            }
            DataSet.writeNew(resampleEntry.getValue(), new String[] { fieldDataIdSpec.getFieldFuncArgs().getVariableName() }, new VariableType[] { simDataBlock.getVariableType() }, new ISize(resampleMesh.getSizeX(), resampleMesh.getSizeY(), resampleMesh.getSizeZ()), new double[][] { newData });
        }
    } catch (Exception ex) {
        ex.printStackTrace(System.out);
        throw new DataAccessException(ex.getMessage());
    }
}
Also used : VariableType(cbit.vcell.math.VariableType) HashMap(java.util.HashMap) ISize(org.vcell.util.ISize) FileNotFoundException(java.io.FileNotFoundException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) CacheException(org.vcell.util.CacheException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) FileNotFoundException(java.io.FileNotFoundException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ZipArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry) ZipEntry(java.util.zip.ZipEntry) Entry(java.util.Map.Entry) CartesianMesh(cbit.vcell.solvers.CartesianMesh) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException)

Example 52 with CartesianMesh

use of cbit.vcell.solvers.CartesianMesh in project vcell by virtualcell.

the class DataSetControllerImpl method findFunctionIndexes.

/**
 * Insert the method's description here.
 * Creation date: (10/13/00 9:13:52 AM)
 * @return cbit.vcell.simdata.SimDataBlock
 * @param user cbit.vcell.server.User
 * @param simResults cbit.vcell.simdata.SimResults
 * @param function cbit.vcell.math.Function
 * @param time double
 */
private FunctionIndexes[] findFunctionIndexes(VCDataIdentifier vcdID, AnnotatedFunction function, int[] dataIndexes, OutputContext outputContext) throws ExpressionException, DataAccessException, IOException, MathException {
    if (function.getFunctionType().equals(VariableType.POSTPROCESSING)) {
        FunctionIndexes[] fiArr = new FunctionIndexes[dataIndexes.length];
        Vector<DataSetIdentifier> dependencyList = identifyDataDependencies(function);
        SimulationData simData = (SimulationData) getVCData(vcdID);
        String[] varNames = new String[dependencyList.size()];
        String[] simFileVarNames = new String[dependencyList.size()];
        for (int i = 0; i < varNames.length; i++) {
            varNames[i] = dependencyList.get(i).getName();
            simFileVarNames[i] = dependencyList.get(i).getName();
        }
        CartesianMesh mesh = simData.getPostProcessingMesh(function.getName(), outputContext);
        int[][] varIndexes = new int[dataIndexes.length][varNames.length];
        for (int i = 0; i < dataIndexes.length; i += 1) {
            for (int j = 0; j < varNames.length; j++) {
                varIndexes[i][j] = dataIndexes[i];
            }
        }
        // VolumeIndexNearFar[][] outside_near_far_indexes = null;//new VolumeIndexNearFar[dataIndexes.length][/*varNames.length*/];
        for (int i = 0; i < dataIndexes.length; i += 1) {
            fiArr[i] = new FunctionIndexes(function, mesh.getCoordinateFromVolumeIndex(dataIndexes[i]), varNames, simFileVarNames, varIndexes[i], null, null);
        }
        return fiArr;
    }
    VariableType variableType = function.getFunctionType();
    Vector<DataSetIdentifier> dependencyList = identifyDataDependencies(function);
    int varIndex = TXYZ_OFFSET + dependencyList.size();
    // 
    // get Indexes and simFileNames
    // 
    Coordinate initCoord = new Coordinate(0, 0, 0);
    Coordinate[] coords = new Coordinate[dataIndexes.length];
    for (int i = 0; i < coords.length; i += 1) {
        coords[i] = initCoord;
    }
    String[] varNames = new String[varIndex - TXYZ_OFFSET];
    String[] simFileVarNames = new String[varNames.length];
    int[][] varIndexes = new int[dataIndexes.length][varNames.length];
    // New data needed for INSIDE-OUTSIDE interpolation
    VolumeIndexNearFar[][] inside_near_far_indexes = new VolumeIndexNearFar[dataIndexes.length][varNames.length];
    VolumeIndexNearFar[][] outside_near_far_indexes = new VolumeIndexNearFar[dataIndexes.length][varNames.length];
    CartesianMesh mesh = getMesh(vcdID);
    // 
    for (int i = 0; i < dataIndexes.length; i += 1) {
        coords[i] = mesh.getCoordinateFromVolumeIndex(dataIndexes[i]);
        if (variableType.equals(VariableType.VOLUME)) {
            // coord = mesh.getCoordinateFromVolumeIndex(dataIndex);
            coords[i] = mesh.getCoordinateFromVolumeIndex(dataIndexes[i]);
            for (int j = 0; j < varIndex - TXYZ_OFFSET; j++) {
                DataSetIdentifier dsi = (DataSetIdentifier) dependencyList.elementAt(j);
                if (dsi.getVariableType().equals(VariableType.VOLUME)) {
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = dataIndexes[i];
                } else if (dsi.getVariableType().equals(VariableType.VOLUME_REGION)) {
                    int volumeIndex = mesh.getVolumeRegionIndex(dataIndexes[i]);
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = volumeIndex;
                }
            }
        } else if (variableType.equals(VariableType.VOLUME_REGION)) {
            for (int j = 0; j < varIndex - TXYZ_OFFSET; j++) {
                DataSetIdentifier dsi = (DataSetIdentifier) dependencyList.elementAt(j);
                if (dsi.getVariableType().equals(VariableType.VOLUME_REGION)) {
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = dataIndexes[i];
                }
            }
        } else if (variableType.equals(VariableType.MEMBRANE)) {
            // coord = mesh.getCoordinateFromMembraneIndex(dataIndex);
            coords[i] = mesh.getCoordinateFromMembraneIndex(dataIndexes[i]);
            for (int j = 0; j < varIndex - TXYZ_OFFSET; j++) {
                DataSetIdentifier dsi = (DataSetIdentifier) dependencyList.elementAt(j);
                if (dsi.getVariableType().equals(VariableType.VOLUME)) {
                    if (mesh.isChomboMesh()) {
                        // don't do any varname modifications here,
                        // because chombo needs this info to decide
                        // which data set to read, extrapolate values or solution.
                        // if varname doesn't have _INSIDE or _OUTSIDE
                        // add _INSIDE to varname to indicate it needs to read extrapolated values
                        String varName = dsi.getName();
                        if (!varName.endsWith(InsideVariable.INSIDE_VARIABLE_SUFFIX) && !varName.endsWith(OutsideVariable.OUTSIDE_VARIABLE_SUFFIX)) {
                            varName += InsideVariable.INSIDE_VARIABLE_SUFFIX;
                            // add this new varname to the list if it's not already there
                            getVCData(vcdID).getEntry(varName);
                        }
                        simFileVarNames[j] = varName;
                        varIndexes[i][j] = dataIndexes[i];
                    } else {
                        if (dsi.getName().endsWith(InsideVariable.INSIDE_VARIABLE_SUFFIX)) {
                            int volInsideIndex = mesh.getMembraneElements()[dataIndexes[i]].getInsideVolumeIndex();
                            varNames[j] = dsi.getName();
                            simFileVarNames[j] = dsi.getName().substring(0, dsi.getName().lastIndexOf("_"));
                            varIndexes[i][j] = volInsideIndex;
                            inside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dataIndexes[i], true, false);
                        } else if (dsi.getName().endsWith(OutsideVariable.OUTSIDE_VARIABLE_SUFFIX)) {
                            int volOutsideIndex = mesh.getMembraneElements()[dataIndexes[i]].getOutsideVolumeIndex();
                            varNames[j] = dsi.getName();
                            simFileVarNames[j] = dsi.getName().substring(0, dsi.getName().lastIndexOf("_"));
                            varIndexes[i][j] = volOutsideIndex;
                            outside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dataIndexes[i], false, false);
                        } else {
                            varNames[j] = dsi.getName();
                            simFileVarNames[j] = dsi.getName();
                            if (isDomainInside(mesh, dsi.getDomain(), dataIndexes[i])) {
                                inside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dsi.getDomain(), dataIndexes[i], false);
                                varIndexes[i][j] = inside_near_far_indexes[i][j].volIndexNear;
                            } else {
                                outside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dsi.getDomain(), dataIndexes[i], false);
                                varIndexes[i][j] = outside_near_far_indexes[i][j].volIndexNear;
                            }
                        }
                    }
                } else if (dsi.getVariableType().equals(VariableType.VOLUME_REGION)) {
                    if (dsi.getName().endsWith(InsideVariable.INSIDE_VARIABLE_SUFFIX)) {
                        int insideVolumeIndex = mesh.getMembraneElements()[dataIndexes[i]].getInsideVolumeIndex();
                        int volRegionIndex = mesh.getVolumeRegionIndex(insideVolumeIndex);
                        varNames[j] = dsi.getName();
                        simFileVarNames[j] = dsi.getName().substring(0, dsi.getName().lastIndexOf("_"));
                        varIndexes[i][j] = volRegionIndex;
                        inside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dataIndexes[i], true, true);
                    } else if (dsi.getName().endsWith(OutsideVariable.OUTSIDE_VARIABLE_SUFFIX)) {
                        int outsideVolumeIndex = mesh.getMembraneElements()[dataIndexes[i]].getOutsideVolumeIndex();
                        int volRegionIndex = mesh.getVolumeRegionIndex(outsideVolumeIndex);
                        varNames[j] = dsi.getName();
                        simFileVarNames[j] = dsi.getName().substring(0, dsi.getName().lastIndexOf("_"));
                        varIndexes[i][j] = volRegionIndex;
                        outside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dataIndexes[i], false, true);
                    } else {
                        throw new DataAccessException("Must use '" + dsi.getName() + InsideVariable.INSIDE_VARIABLE_SUFFIX + "' or '" + dsi.getName() + OutsideVariable.OUTSIDE_VARIABLE_SUFFIX + "' when referencing VOLUME_REGION var '" + dsi.getName() + "' in membrane func '" + function.getName() + "'");
                    }
                } else if (dsi.getVariableType().equals(VariableType.MEMBRANE)) {
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = dataIndexes[i];
                } else if (dsi.getVariableType().equals(VariableType.MEMBRANE_REGION)) {
                    int memRegionIndex = mesh.getMembraneRegionIndex(dataIndexes[i]);
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = memRegionIndex;
                }
            }
        } else if (variableType.equals(VariableType.MEMBRANE_REGION)) {
            for (int j = 0; j < varIndex - TXYZ_OFFSET; j++) {
                DataSetIdentifier dsi = (DataSetIdentifier) dependencyList.elementAt(j);
                if (dsi.getVariableType().equals(VariableType.VOLUME_REGION) && dsi.getName().endsWith(InsideVariable.INSIDE_VARIABLE_SUFFIX)) {
                    // 
                    // find "inside" volume element index for first membrane element in MembraneRegion 'i'.
                    // 
                    int insideVolumeIndex = -1;
                    for (int k = 0; k < mesh.getMembraneElements().length; k++) {
                        if (mesh.getMembraneRegionIndex(k) == dataIndexes[i]) {
                            insideVolumeIndex = mesh.getMembraneElements()[k].getInsideVolumeIndex();
                            break;
                        }
                    }
                    int volRegionIndex = mesh.getVolumeRegionIndex(insideVolumeIndex);
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName().substring(0, dsi.getName().lastIndexOf("_"));
                    varIndexes[i][j] = volRegionIndex;
                    inside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dataIndexes[i], true, true);
                    ;
                } else if (dsi.getVariableType().equals(VariableType.VOLUME_REGION) && dsi.getName().endsWith(OutsideVariable.OUTSIDE_VARIABLE_SUFFIX)) {
                    // 
                    // find "outside" volume element index for first membrane element in MembraneRegion 'i'.
                    // 
                    int outsideVolumeIndex = -1;
                    for (int k = 0; k < mesh.getMembraneElements().length; k++) {
                        if (mesh.getMembraneRegionIndex(k) == dataIndexes[i]) {
                            outsideVolumeIndex = mesh.getMembraneElements()[k].getOutsideVolumeIndex();
                            break;
                        }
                    }
                    int volRegionIndex = mesh.getVolumeRegionIndex(outsideVolumeIndex);
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName().substring(0, dsi.getName().lastIndexOf("_"));
                    varIndexes[i][j] = volRegionIndex;
                    outside_near_far_indexes[i][j] = interpolateFindNearFarIndex(mesh, dataIndexes[i], false, true);
                } else if (dsi.getVariableType().equals(VariableType.MEMBRANE)) {
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = dataIndexes[i];
                } else if (dsi.getVariableType().equals(VariableType.MEMBRANE_REGION)) {
                    int memRegionIndex = mesh.getMembraneRegionIndex(dataIndexes[i]);
                    varNames[j] = dsi.getName();
                    simFileVarNames[j] = dsi.getName();
                    varIndexes[i][j] = memRegionIndex;
                }
            }
        }
    }
    FunctionIndexes[] fiArr = new FunctionIndexes[dataIndexes.length];
    for (int i = 0; i < dataIndexes.length; i += 1) {
        fiArr[i] = new FunctionIndexes(function, coords[i], varNames, simFileVarNames, varIndexes[i], inside_near_far_indexes[i], outside_near_far_indexes[i]);
    }
    return fiArr;
// 
}
Also used : VariableType(cbit.vcell.math.VariableType) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Coordinate(org.vcell.util.Coordinate) DataAccessException(org.vcell.util.DataAccessException)

Example 53 with CartesianMesh

use of cbit.vcell.solvers.CartesianMesh in project vcell by virtualcell.

the class ClientRequestManager method createNewGeometryTasks.

public AsynchClientTask[] createNewGeometryTasks(final TopLevelWindowManager requester, final VCDocument.DocumentCreationInfo documentCreationInfo, final AsynchClientTask[] afterTasks, final String okButtonText) {
    if (!isImportGeometryType(documentCreationInfo)) {
        throw new IllegalArgumentException("Analytic geometry not implemented.");
    }
    AsynchClientTask selectImageFileTask = getSelectImageFileTask(requester.getComponent(), getUserPreferences());
    final String INITIAL_ANNOTATION = "INITIAL_ANNOTATION";
    final String NEW_IMAGE_SIZE_INFO = "NEW_IMAGE_SIZE_INFO";
    final String FD_TIMEPOINTS = "FD_TIMEPOINTS";
    AsynchClientTask parseImageTask = getParseImageTask(requester.getComponent(), documentCreationInfo, getMdiManager());
    AsynchClientTask getFieldDataImageParams = new AsynchClientTask("Getting DB Image parameters...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VCDocument.GeomFromFieldDataCreationInfo docInfo = (VCDocument.GeomFromFieldDataCreationInfo) documentCreationInfo;
            PDEDataContext pdeDataContext = getMdiManager().getFieldDataWindowManager().getPDEDataContext(docInfo.getExternalDataID(), null);
            CartesianMesh mesh = pdeDataContext.getCartesianMesh();
            ISize meshISize = new ISize(mesh.getSizeX(), mesh.getSizeY(), mesh.getSizeZ());
            double[] timePoints = pdeDataContext.getTimePoints();
            hashTable.put(FD_MESH, mesh);
            hashTable.put(FD_MESHISIZE, meshISize);
            hashTable.put(FD_TIMEPOINTS, timePoints);
        }
    };
    AsynchClientTask queryImageResizeTask = new AsynchClientTask("Query File Image Resize...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            String importSourceName = (String) hashTable.get(IMPORT_SOURCE_NAME);
            if ((ImageSizeInfo) hashTable.get(ORIG_IMAGE_SIZE_INFO) != null) {
                // from file
                ImageSizeInfo newImagesiSizeInfo = queryImageResize(requester.getComponent(), (ImageSizeInfo) hashTable.get(ORIG_IMAGE_SIZE_INFO), true);
                hashTable.put(NEW_IMAGE_SIZE_INFO, newImagesiSizeInfo);
            } else if (documentCreationInfo.getOption() == VCDocument.GEOM_OPTION_FIELDDATA) {
                // from fielddata
                VCDocument.GeomFromFieldDataCreationInfo docInfo = (VCDocument.GeomFromFieldDataCreationInfo) documentCreationInfo;
                double[] fieldDataTimes = (double[]) hashTable.get(FD_TIMEPOINTS);
                hashTable.remove(FD_TIMEPOINTS);
                ISize fieldDataISize = (ISize) hashTable.get(FD_MESHISIZE);
                ImageSizeInfo origImageSizeInfo = new ImageSizeInfo(importSourceName, fieldDataISize, 1, fieldDataTimes, null);
                ImageSizeInfo newImagesiSizeInfo = queryImageResize(requester.getComponent(), origImageSizeInfo, true);
                hashTable.put(NEW_IMAGE_SIZE_INFO, newImagesiSizeInfo);
                hashTable.put(IMPORT_SOURCE_NAME, "FieldData: " + docInfo.getExternalDataID().getName() + " varName=" + docInfo.getVarName() + " timeIndex=" + newImagesiSizeInfo.getTimePoints()[newImagesiSizeInfo.getSelectedTimeIndex()]);
            }
        }
    };
    AsynchClientTask importFileImageTask = getImportFileImageTask(documentCreationInfo);
    AsynchClientTask resizeImageTask = getResizeImageTask(documentCreationInfo);
    AsynchClientTask finishTask = new AsynchClientTask("Finishing...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(final Hashtable<String, Object> hashTable) throws Exception {
            getClientTaskStatusSupport().setMessage("Initializing...");
            final ROIMultiPaintManager roiMultiPaintManager = new ROIMultiPaintManager();
            roiMultiPaintManager.setDocumentManager(ClientRequestManager.this.getDocumentManager());
            roiMultiPaintManager.initROIAndUnderlay((FieldDataFileOperationSpec) hashTable.get(FDFOS));
            final Geometry[] geomHolder = new Geometry[1];
            final VCPixelClass[] postProcessPixelClasses = (VCPixelClass[]) hashTable.get(VCPIXELCLASSES);
            AsynchClientTask task1 = new AsynchClientTask("edit geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    geomHolder[0] = roiMultiPaintManager.showGUI(okButtonText, (String) hashTable.get(IMPORT_SOURCE_NAME), (Component) hashTable.get(GUI_PARENT), (String) hashTable.get(INITIAL_ANNOTATION), postProcessPixelClasses, getUserPreferences(), (hashTable.get(BioModelWindowManager.FIELD_DATA_FLAG) == null ? false : ((Boolean) hashTable.get(BioModelWindowManager.FIELD_DATA_FLAG)).booleanValue()));
                }
            };
            AsynchClientTask task2 = new AsynchClientTask("update geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    // Create default name for image
                    String dateTimeString = BeanUtils.generateDateTimeString();
                    geomHolder[0].getGeometrySpec().getImage().setName("img_" + dateTimeString);
                    geomHolder[0].setName("geom_" + dateTimeString);
                    // cause update in this thread so later swing threads won't be delayed
                    geomHolder[0].precomputeAll(new GeometryThumbnailImageFactoryAWT());
                    hashTable.put("doc", geomHolder[0]);
                }
            };
            AsynchClientTask[] finalTasks = afterTasks;
            if (finalTasks == null) {
                finalTasks = new AsynchClientTask[] { getSaveImageAndGeometryTask() };
            }
            AsynchClientTask[] tasks = new AsynchClientTask[2 + finalTasks.length];
            tasks[0] = task1;
            tasks[1] = task2;
            System.arraycopy(finalTasks, 0, tasks, 2, finalTasks.length);
            ClientTaskDispatcher.dispatch((Component) hashTable.get(GUI_PARENT), hashTable, tasks, false, false, null, true);
        }
    };
    Vector<AsynchClientTask> tasksV = new Vector<AsynchClientTask>();
    if (documentCreationInfo.getOption() == VCDocument.GEOM_OPTION_FROM_SCRATCH) {
        tasksV.addAll(Arrays.asList(new AsynchClientTask[] { parseImageTask, finishTask }));
    } else if (documentCreationInfo.getOption() == VCDocument.GEOM_OPTION_FROM_WORKSPACE_ANALYTIC) {
        tasksV.addAll(Arrays.asList(new AsynchClientTask[] { parseImageTask, finishTask }));
    } else if (documentCreationInfo.getOption() == VCDocument.GEOM_OPTION_FROM_WORKSPACE_IMAGE) {
        tasksV.addAll(Arrays.asList(new AsynchClientTask[] { parseImageTask, resizeImageTask, finishTask }));
    } else if (documentCreationInfo.getOption() == VCDocument.GEOM_OPTION_FILE) {
        tasksV.addAll(Arrays.asList(new AsynchClientTask[] { selectImageFileTask, parseImageTask, queryImageResizeTask, importFileImageTask, /* resizes */
        finishTask }));
    } else // }
    if (documentCreationInfo.getOption() == VCDocument.GEOM_OPTION_FIELDDATA) {
        tasksV.addAll(Arrays.asList(new AsynchClientTask[] { getFieldDataImageParams, queryImageResizeTask, parseImageTask, resizeImageTask, finishTask }));
    }
    return tasksV.toArray(new AsynchClientTask[0]);
}
Also used : PDEDataContext(cbit.vcell.simdata.PDEDataContext) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCPixelClass(cbit.image.VCPixelClass) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) ISize(org.vcell.util.ISize) ROIMultiPaintManager(cbit.vcell.geometry.gui.ROIMultiPaintManager) ImageSizeInfo(cbit.image.ImageSizeInfo) Geometry(cbit.vcell.geometry.Geometry) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Component(java.awt.Component) Vector(java.util.Vector)

Example 54 with CartesianMesh

use of cbit.vcell.solvers.CartesianMesh in project vcell by virtualcell.

the class TopLevelWindowManager method addWorkspaceGeomSizeSelection.

private void addWorkspaceGeomSizeSelection(final Hashtable<String, Object> hash, Geometry sourceGeom) throws Exception {
    if (TopLevelWindowManager.this instanceof DocumentWindowManager) {
        Simulation[] simulations = null;
        SimulationContext[] simContexts = null;
        SimulationContext selectedSC = null;
        ArrayList<Object[]> allRows = new ArrayList<Object[]>();
        ArrayList<ISize> iSizes = new ArrayList<ISize>();
        if (this instanceof BioModelWindowManager) {
            BioModelWindowManager bmwm = ((BioModelWindowManager) this);
            // System.out.println(bmwm);
            if (bmwm.getDocumentEditor() instanceof cbit.vcell.client.desktop.biomodel.BioModelEditor) {
                cbit.vcell.client.desktop.biomodel.BioModelEditor bme = (cbit.vcell.client.desktop.biomodel.BioModelEditor) bmwm.getDocumentEditor();
                // System.out.println(bme);
                selectedSC = bme.getSelectedSimulationContext();
            // System.out.println(selectedSC);
            }
        }
        if (((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument() instanceof BioModel) {
            simContexts = ((BioModel) ((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument()).getSimulationContexts();
        } else if (((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument() instanceof MathModel) {
            simulations = ((MathModel) ((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument()).getSimulations();
        }
        String[] simColumnNames = null;
        if (simContexts != null) {
            simColumnNames = new String[] { "x", "y", "z", "appName", "simName" };
        } else {
            simColumnNames = new String[] { "x", "y", "z", "simName" };
        }
        ArrayList<Object[]> simRows = new ArrayList<Object[]>();
        ArrayList<CartesianMesh> meshes = new ArrayList<CartesianMesh>();
        for (int j = 0; j < (simContexts == null ? 1 : simContexts.length); j++) {
            Geometry geom = null;
            if (simContexts != null) {
                if (simContexts[j] != selectedSC) {
                    continue;
                }
                simulations = simContexts[j].getSimulations();
                geom = simContexts[j].getGeometry();
            } else {
                geom = ((MathModel) ((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument()).getGeometry();
            }
            // ISize defaultSamplesize = geom.getGeometrySpec().getDefaultSampledImageSize();
            if (simulations != null && simulations.length > 0) {
                for (int i = 0; i < simulations.length; i++) {
                    Object[] row = new Object[simColumnNames.length];
                    // }
                    if (simulations[i].getMeshSpecification() != null && simulations[i].getMeshSpecification() != null) {
                        row = new Object[simColumnNames.length];
                        ISize samplingSize = simulations[i].getMeshSpecification().getSamplingSize();
                        row[0] = samplingSize.getX();
                        row[1] = samplingSize.getY();
                        row[2] = samplingSize.getZ();
                        row[3] = (simContexts != null ? simContexts[j].getName() : simulations[i].getName());
                        if (simContexts != null) {
                            row[4] = simulations[i].getName();
                        }
                        simRows.add(row);
                        VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[samplingSize.getXYZ()], geom.getExtent(), samplingSize.getX(), samplingSize.getY(), samplingSize.getZ());
                        CartesianMesh simpleMesh = CartesianMesh.createSimpleCartesianMesh(geom.getOrigin(), geom.getExtent(), samplingSize, new RegionImage(vcImageUnc, geom.getDimension(), geom.getExtent(), geom.getOrigin(), RegionImage.NO_SMOOTHING));
                        meshes.add(simpleMesh);
                    }
                }
            }
        }
        for (int i = 0; i < simRows.size(); i++) {
            ISize iSize = meshes.get(i).getISize();
            iSizes.add(iSize);
            allRows.add(new Object[] { iSize.getX(), iSize.getY(), iSize.getZ(), "Simulation=" + (simColumnNames.length == 4 ? simRows.get(i)[3] : simRows.get(i)[3] + ":" + simRows.get(i)[4]) });
        }
        // if(allRows.size() > 0) {
        if (simRows.size() > 0) {
            Object[][] rowData = simRows.toArray(new Object[0][]);
            int[] selections = DialogUtils.showComponentOKCancelTableList(TopLevelWindowManager.this.getComponent(), "Select Simulation for Geom Size", simColumnNames, rowData, ListSelectionModel.SINGLE_SELECTION);
            if (selections != null && selections.length == 1) {
                // ImageSizeInfo imagesizeInfo = new ImageSizeInfo("internal",meshes.get(selections[0]).getISize(),1,new double[] {0},0);
                ImageSizeInfo imagesizeInfo = new ImageSizeInfo("internal", iSizes.get(selections[0]), 1, new double[] { 0 }, 0);
                hash.put(ClientRequestManager.NEW_IMAGE_SIZE_INFO, imagesizeInfo);
                VCImage image = null;
                if (sourceGeom.getGeometrySpec().getImage() == null) {
                    image = sourceGeom.getGeometrySpec().createSampledImage(iSizes.get(selections[0]));
                } else {
                    image = sourceGeom.getGeometrySpec().getImage();
                }
                // 
                ISize samplingSize = new ISize(image.getNumX(), image.getNumY(), image.getNumZ());
                VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[samplingSize.getXYZ()], sourceGeom.getExtent(), samplingSize.getX(), samplingSize.getY(), samplingSize.getZ());
                CartesianMesh sourceMesh = CartesianMesh.createSimpleCartesianMesh(sourceGeom.getOrigin(), sourceGeom.getExtent(), samplingSize, new RegionImage(vcImageUnc, sourceGeom.getDimension(), sourceGeom.getExtent(), sourceGeom.getOrigin(), RegionImage.NO_SMOOTHING));
                hash.put("newMesh", meshes.get(selections[0]));
                hash.put("sourceMesh", sourceMesh);
            }
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) ISize(org.vcell.util.ISize) ArrayList(java.util.ArrayList) VCImage(cbit.image.VCImage) VCImageUncompressed(cbit.image.VCImageUncompressed) SimulationContext(cbit.vcell.mapping.SimulationContext) ImageSizeInfo(cbit.image.ImageSizeInfo) Geometry(cbit.vcell.geometry.Geometry) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) RegionImage(cbit.vcell.geometry.RegionImage)

Example 55 with CartesianMesh

use of cbit.vcell.solvers.CartesianMesh in project vcell by virtualcell.

the class PDEExportDataPanel method startExport.

/**
 * Comment
 */
private void startExport() {
    if (getExportSettings1().getSelectedFormat() == ExportFormat.QUICKTIME && getJSlider1().getValue() == getJSlider2().getValue()) {
        DialogUtils.showWarningDialog(this, "User selected 'begin' and 'end' export times are the same.  'Movie' export format 'begin' and 'end' times must be different");
        return;
    }
    DisplayPreferences[] displayPreferences = null;
    @SuppressWarnings("deprecation") Object[] variableSelections = getJListVariables().getSelectedValues();
    boolean selectionHasVolumeVariables = false;
    boolean selectionHasMembraneVariables = false;
    switch(getExportSettings1().getSelectedFormat()) {
        case PLY:
        case QUICKTIME:
        case GIF:
        case FORMAT_JPEG:
        case ANIMATED_GIF:
            {
                displayPreferences = new DisplayPreferences[variableSelections.length];
                StringBuffer noScaleInfoNames = new StringBuffer();
                for (int i = 0; i < displayPreferences.length; i++) {
                    BitSet domainValid = null;
                    try {
                        if (dataInfoProvider != null) {
                            DataIdentifier varSelectionDataIdnetDataIdentifier = null;
                            for (int j = 0; j < dataInfoProvider.getPDEDataContext().getDataIdentifiers().length; j++) {
                                if (dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j].getName().equals(variableSelections[i])) {
                                    varSelectionDataIdnetDataIdentifier = dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j];
                                }
                            }
                            if (varSelectionDataIdnetDataIdentifier != null) {
                                selectionHasVolumeVariables = selectionHasVolumeVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.POSTPROCESSING) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME_REGION);
                                selectionHasMembraneVariables = selectionHasMembraneVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE_REGION);
                                CartesianMesh cartesianMesh = dataInfoProvider.getPDEDataContext().getCartesianMesh();
                                int dataLength = cartesianMesh.getDataLength(varSelectionDataIdnetDataIdentifier.getVariableType());
                                domainValid = new BitSet(dataLength);
                                domainValid.clear();
                                for (int j = 0; j < dataLength; j++) {
                                    if (dataInfoProvider.isDefined(varSelectionDataIdnetDataIdentifier, j)) {
                                        domainValid.set(j);
                                    }
                                }
                            } else {
                                throw new Exception("No DataIdentifer found for variable name '" + variableSelections[i] + "'");
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        DialogUtils.showErrorDialog(this, "Error during domain evaluation:\n" + e.getMessage());
                        return;
                    }
                    displayPreferences[i] = new DisplayPreferences(getDisplayAdapterService().getDisplayPreferences((String) variableSelections[i]), domainValid);
                    if (!getDisplayAdapterService().hasStateID((String) variableSelections[i])) {
                        noScaleInfoNames.append("--- " + (String) variableSelections[i] + "\n");
                    }
                }
                break;
            }
        case HDF5:
        case CSV:
            {
                // check for membrane variables... warn for 3D geometry...
                // one gets the whole nine yards by index, not generally useful... except for a few people like Boris :)
                boolean mbVars = false;
                DataIdentifier[] dataIDs = getPdeDataContext().getDataIdentifiers();
                for (int i = 0; i < variableSelections.length; i++) {
                    String varName = (String) variableSelections[i];
                    for (int j = 0; j < dataIDs.length; j++) {
                        if (dataIDs[j].getName().equals(varName) && dataIDs[j].getVariableType().equals(VariableType.MEMBRANE)) {
                            mbVars = true;
                            break;
                        }
                    }
                }
                if (mbVars && getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3 && getJRadioButtonSlice().isSelected()) {
                    String choice = PopupGenerator.showWarningDialog(this, getDataViewerManager().getUserPreferences(), UserMessage.warn_exportMembraneData3D, null);
                    if (choice.equals(UserMessage.OPTION_CANCEL)) {
                        // user canceled
                        return;
                    }
                }
                getExportSettings1().setSimulationSelector(createSimulationSelector());
                getExportSettings1().setIsCSVExport(true);
                break;
            }
        case NRRD:
        // case IMAGEJ:
        case UCD:
        case VTK_IMAGE:
        case VTK_UNSTRUCT:
            break;
        default:
            break;
    }
    ;
    if (getJRadioButtonROI().isSelected() && getROISelections().getSelectedIndex() == -1) {
        PopupGenerator.showErrorDialog(this, "To export selections, you must select at least one item from the ROI selection list");
    }
    getExportSettings1().setTimeSpecs(new TimeSpecs(getJSlider1().getValue(), getJSlider2().getValue(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE));
    getExportSettings1().setDisplayPreferences(displayPreferences, Arrays.asList(variableSelections).toArray(new String[0]), viewZoom);
    getExportSettings1().setSliceCount(FormatSpecificSpecs.getSliceCount(getJRadioButtonFull().isSelected(), getNormalAxis(), getPdeDataContext().getCartesianMesh()));
    getExportSettings1().setImageSizeCalculationInfo(getPdeDataContext().getCartesianMesh(), getNormalAxis());
    getExportSettings1().setIsSmoldyn(isSmoldyn);
    ExportFormat format = getSelectedFormat();
    if (format.equals(ExportFormat.PLY)) {
        getExportSettings1().setFormatSpecificSpecs(new PLYSpecs(true, displayPreferences));
    }
    if (format.requiresFollowOn()) {
        Frame theFrame = JOptionPane.getFrameForComponent(this);
        boolean okToExport = getExportSettings1().showFormatSpecificDialog(theFrame, selectionHasVolumeVariables, selectionHasMembraneVariables);
        if (!okToExport) {
            return;
        }
    }
    // if(format.equals(ExportFormat.IMAGEJ)){
    // //export nrrd for imagej direct, the we'll send to imagej from vcell client
    // getExportSettings1().setFormatSpecificSpecs(new RasterSpecs(ExportConstants.NRRD_SINGLE, false));
    // }
    // determine of sim result is from local (quick) run or on server.
    final OutputContext outputContext = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext();
    final ExportSpecs exportSpecs = getExportSpecs();
    boolean isLocalSimResult = false;
    VCDataIdentifier vcId = exportSpecs.getVCDataIdentifier();
    if (vcId instanceof LocalVCDataIdentifier) {
        isLocalSimResult = true;
    }
    // find out if smoldyn export choice is 'particle' - not available at this time
    boolean isParticle = false;
    if (getExportSettings1().getFormatSpecificSpecs() instanceof ImageSpecs) {
        isParticle = ((ImageSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
    } else if (getExportSettings1().getFormatSpecificSpecs() instanceof MovieSpecs) {
        isParticle = ((MovieSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
    }
    if (isLocalSimResult && isParticle) {
        DialogUtils.showErrorDialog(this, "Particle export for Smoldyn particles unavailable in local data at this time.");
        return;
    }
    // pass the export request down the line; non-blocking call
    if (!isLocalSimResult) {
        // for sims that ran on server, do as before.
        getDataViewerManager().startExport(this, outputContext, exportSpecs);
    } else {
        final String SOURCE_FILE_KEY = "SOURCE_FILE_KEY";
        final String DESTINATION_FILE_KEY = "DEESTINATION_FILE_KEY";
        AsynchClientTask localExportTast = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                try {
                    File primaryDir = ResourceUtil.getLocalRootDir();
                    User usr = User.tempUser;
                    File usrDir = new File(primaryDir.getAbsolutePath(), usr.getName());
                    System.setProperty(PropertyLoader.exportBaseDirInternalProperty, usrDir.getAbsolutePath() + File.separator);
                    System.setProperty(PropertyLoader.exportBaseURLProperty, usrDir.toURI().toURL().toString());
                    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
                    ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
                    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, localExportServiceImpl);
                    ExportEvent localExportEvent = dataServerImpl.makeRemoteFile(outputContext, usr, exportSpecs);
                    File sourceFile = new File(usrDir, new File((new URL(localExportEvent.getLocation()).getPath())).getName());
                    hashTable.put(SOURCE_FILE_KEY, sourceFile);
                } catch (Exception e) {
                    throw new Exception("Unable to export local sim results data : " + e.getMessage(), e);
                }
            }
        };
        AsynchClientTask localSaveTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
                JFileChooser jFileChooser = new JFileChooser();
                jFileChooser.setSelectedFile(new File(sourceFile.getName()));
                if (jFileChooser.showSaveDialog(PDEExportDataPanel.this) == JFileChooser.APPROVE_OPTION) {
                    File destinationFile = jFileChooser.getSelectedFile();
                    if (destinationFile.exists()) {
                        final String OVERWRITE = "Overwrite";
                        final String CANCEL = "Cancel";
                        String response = DialogUtils.showWarningDialog(PDEExportDataPanel.this, "OK to Overwrite " + destinationFile.getAbsolutePath() + "?", new String[] { OVERWRITE, CANCEL }, OVERWRITE);
                        if (response == null || !response.equals(OVERWRITE)) {
                            return;
                        }
                    }
                    hashTable.put(DESTINATION_FILE_KEY, destinationFile);
                }
            }
        };
        AsynchClientTask localDeleteTempTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, false, false) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
                File destinationFile = (File) hashTable.get(DESTINATION_FILE_KEY);
                if (sourceFile != null && sourceFile.exists()) {
                    try {
                        if (destinationFile != null) {
                            copyFile(sourceFile, destinationFile);
                        }
                    } finally {
                        sourceFile.delete();
                    }
                }
            }
        };
        ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { localExportTast, localSaveTask, localDeleteTempTask }, false, true, null);
    }
}
Also used : DataServerImpl(cbit.vcell.simdata.DataServerImpl) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) User(org.vcell.util.document.User) ExportSpecs(cbit.vcell.export.server.ExportSpecs) ExportEvent(cbit.rmi.event.ExportEvent) URL(java.net.URL) DisplayPreferences(cbit.image.DisplayPreferences) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) TimeSpecs(cbit.vcell.export.server.TimeSpecs) Hashtable(java.util.Hashtable) PLYSpecs(cbit.vcell.export.server.PLYSpecs) BitSet(java.util.BitSet) ExportFormat(cbit.vcell.export.server.ExportFormat) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) IOException(java.io.IOException) UserCancelException(org.vcell.util.UserCancelException) OutputContext(cbit.vcell.simdata.OutputContext) CartesianMesh(cbit.vcell.solvers.CartesianMesh) MovieSpecs(cbit.vcell.export.server.MovieSpecs) JFileChooser(javax.swing.JFileChooser) ImageSpecs(cbit.vcell.export.server.ImageSpecs) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) File(java.io.File)

Aggregations

CartesianMesh (cbit.vcell.solvers.CartesianMesh)55 ISize (org.vcell.util.ISize)27 Extent (org.vcell.util.Extent)19 VCImageUncompressed (cbit.image.VCImageUncompressed)18 RegionImage (cbit.vcell.geometry.RegionImage)18 Origin (org.vcell.util.Origin)18 VariableType (cbit.vcell.math.VariableType)17 DataAccessException (org.vcell.util.DataAccessException)17 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)16 File (java.io.File)14 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)14 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)13 IOException (java.io.IOException)12 VCImage (cbit.image.VCImage)10 SimDataBlock (cbit.vcell.simdata.SimDataBlock)10 DataIdentifier (cbit.vcell.simdata.DataIdentifier)9 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)9 UserCancelException (org.vcell.util.UserCancelException)9 ImageException (cbit.image.ImageException)7 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)7