Search in sources :

Example 26 with ExternalDataIdentifier

use of org.vcell.util.document.ExternalDataIdentifier in project vcell by virtualcell.

the class FRAPStudyPanel method showMovie.

private void showMovie() {
    AsynchClientTask createMovieTask = new AsynchClientTask("Buffering movie data...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
            if (fStudy == null) {
                return;
            }
            if (fStudy.getMovieURLString() != null && fStudy.getMovieFileString() != null) {
                hashTable.put("FrapStudy", fStudy);
                return;
            }
            // create export specs
            Simulation sim = null;
            if (fStudy.getBioModel() == null || fStudy.getBioModel().getSimulations() == null || fStudy.getBioModel().getSimulations().length < 1) {
                return;
            } else {
                sim = fStudy.getBioModel().getSimulations()[0];
            }
            FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(sim.getMathDescription());
            FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = new FieldDataIdentifierSpec[fieldFunctionArgs.length];
            for (int i = 0; i < fieldDataIdentifierSpecs.length; i++) {
                fieldDataIdentifierSpecs[i] = new FieldDataIdentifierSpec(fieldFunctionArgs[i], fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier());
            }
            ExternalDataIdentifier timeSeriesExtDataID = fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier();
            ExternalDataIdentifier maskExtDataID = fStudy.getRoiExternalDataInfo().getExternalDataIdentifier();
            // add sim
            int jobIndex = 0;
            SimulationJob simJob = new SimulationJob(sim, jobIndex, fieldDataIdentifierSpecs);
            VCDataIdentifier[] dataIDs = new VCDataIdentifier[] { timeSeriesExtDataID, maskExtDataID, simJob.getVCDataIdentifier() };
            VCDataIdentifier vcDataId = new MergedDataInfo(LocalWorkspace.getDefaultOwner(), dataIDs, FRAPStudy.VFRAP_DS_PREFIX);
            PDEDataManager dataManager = new PDEDataManager(null, getLocalWorkspace().getVCDataManager(), vcDataId);
            PDEDataContext pdeDataContext = new ClientPDEDataContext(dataManager);
            ExportFormat format = ExportFormat.QUICKTIME;
            String[] variableNames = new String[] { NORM_FLUOR_VAR, NORM_SIM_VAR };
            VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
            // int endTimeIndex = (int)Math.round(sim.getSolverTaskDescription().getTimeBounds().getEndingTime()/((UniformOutputTimeSpec)sim.getSolverTaskDescription().getOutputTimeSpec()).getOutputTimeStep());
            int endTimeIndex = getFRAPSimDataViewerPanel().getOriginalDataViewer().getPdeDataContext().getTimePoints().length - 1;
            TimeSpecs timeSpecs = new TimeSpecs(0, endTimeIndex, pdeDataContext.getTimePoints(), ExportConstants.TIME_RANGE);
            int geoMode = ExportConstants.GEOMETRY_SLICE;
            GeometrySpecs geometrySpecs = new GeometrySpecs(null, Coordinate.Z_AXIS, 0, geoMode);
            // 10s
            double duration = 10000;
            DisplayPreferences pref1 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
            DisplayPreferences pref2 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
            DisplayPreferences[] displayPref = new DisplayPreferences[] { pref1, pref2 };
            int imageScale = 1;
            int membraneScale = 1;
            int scaleMode = ImagePaneModel.MESH_MODE;
            // the default setting in MediaSettingsPanel.
            int volVarMemOutlineThickness = 1;
            MovieSpecs mSpec = new MovieSpecs(duration, true, displayPref, ExportFormat.QUICKTIME, ExportConstants.NO_MIRRORING, volVarMemOutlineThickness, imageScale, membraneScale, scaleMode, FormatSpecificSpecs.CODEC_JPEG, 1.0f, /*lossless*/
            false, FormatSpecificSpecs.PARTICLE_NONE);
            // mSpec.setViewZoom(1);
            ExportSpecs exSpecs = new ExportSpecs(vcDataId, format, variableSpecs, timeSpecs, geometrySpecs, mSpec, fStudy.getName(), null);
            // pass the request
            ExportEvent exportEvt = ((VirtualFrapWindowManager) getFlourDataViewer().getDataViewerManager()).startExportMovie(exSpecs, outputContext, this.getClientTaskStatusSupport());
            hashTable.put("ExportEvt", exportEvt);
            hashTable.put("FrapStudy", fStudy);
        }
    };
    AsynchClientTask showMovieTask = new AsynchClientTask("Showing movie ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            ExportEvent exportEvt = (ExportEvent) hashTable.get("ExportEvt");
            FRAPStudy fStudy = (FRAPStudy) hashTable.get("FrapStudy");
            // show movie if successfully exported
            if (exportEvt != null) {
                final String fileURLString = System.getProperty(PropertyLoader.exportBaseURLProperty) + exportEvt.getJobID() + ".mov";
                final String fileString = System.getProperty(PropertyLoader.exportBaseDirInternalProperty) + exportEvt.getJobID() + ".mov";
                fStudy.setMovieURLString(fileURLString);
                fStudy.setMovieFileString(fileString);
            }
            showMovieInDialog(fStudy.getMovieURLString(), fStudy.getMovieFileString());
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { createMovieTask, showMovieTask }, true, true, null, true);
}
Also used : ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) PDEDataContext(cbit.vcell.simdata.PDEDataContext) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ExportSpecs(cbit.vcell.export.server.ExportSpecs) ExportEvent(cbit.rmi.event.ExportEvent) GeometrySpecs(cbit.vcell.export.server.GeometrySpecs) MergedDataInfo(cbit.vcell.simdata.MergedDataInfo) DisplayPreferences(cbit.image.DisplayPreferences) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) TimeSpecs(cbit.vcell.export.server.TimeSpecs) SimulationJob(cbit.vcell.solver.SimulationJob) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) Hashtable(java.util.Hashtable) ExportFormat(cbit.vcell.export.server.ExportFormat) Range(org.vcell.util.Range) Point(java.awt.Point) VariableSpecs(cbit.vcell.export.server.VariableSpecs) MovieSpecs(cbit.vcell.export.server.MovieSpecs) Simulation(cbit.vcell.solver.Simulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier)

Example 27 with ExternalDataIdentifier

use of org.vcell.util.document.ExternalDataIdentifier in project vcell by virtualcell.

the class DataSymbolsPanel method addVFrapDerivedImages.

private void addVFrapDerivedImages() {
    // add special (computed) images from vFrap
    AsynchClientTask[] taskArray = new AsynchClientTask[5];
    // select the desired vfrap file
    taskArray[0] = ChooseVFrapFile();
    // load the images from the vfrap file, compute derived images, store them all in memory
    taskArray[1] = new AsynchClientTask("Import images", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            File vFrapFile = (File) hashTable.get("vFrapFile");
            Component requesterComponent = DataSymbolsPanel.this;
            DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
            DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
            if (documentManager == null) {
                throw new RuntimeException("Not connected to server.");
            }
            // ex  ccc8.vfrap
            String vFrapFileNameExtended = vFrapFile.getName();
            {
                // we want to make sure to reload these strings from the hash later on
                String initialFieldDataName = vFrapFileNameExtended.substring(0, vFrapFileNameExtended.indexOf(".vfrap"));
                // we'll save here the "special" vFrap images (prebleach_avg, ...)
                String mixedFieldDataName = initialFieldDataName + "Mx";
                hashTable.put("initialFieldDataName", initialFieldDataName);
                hashTable.put("mixedFieldDataName", mixedFieldDataName);
            }
            if (vFrapFileNameExtended.indexOf(".vfrap") <= -1) {
                throw new RuntimeException("File extension must be .vfrap");
            }
            // for derived images and ROIs
            checkNameAvailability(hashTable, true, documentManager, requesterComponent);
            // ----- read needed info from Virtual FRAP xml file
            System.out.println("Loading " + vFrapFileNameExtended + " ...");
            String xmlString = XmlUtil.getXMLString(vFrapFile.getAbsolutePath());
            MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
            Element vFrapRoot = XmlUtil.stringToXML(xmlString, null).getRootElement();
            // loading frap images and a ROIs subset for display purposes only (see next task)
            AnnotatedImageDataset annotatedImages = xmlReader.getAnnotatedImageDataset(vFrapRoot, null);
            hashTable.put("annotatedImages", annotatedImages);
            ROI[] rois = xmlReader.getPrimaryROIs(XmlUtil.stringToXML(xmlString, null).getRootElement(), null);
            LoadVFrapDisplayRoi(hashTable, annotatedImages, rois);
            // ------ locate the special images within the vFrap files and load them in memory
            if (!LoadVFrapSpecialImages(hashTable, vFrapRoot)) {
                throw new RuntimeException("Unable to recover derived images from vFrap.");
            }
        // int startingIndexRecovery = xmlReader.getStartindIndexForRecovery(XmlUtil.stringToXML(xmlString, null).getRootElement());
        // vFrapXmlHelper.LoadVFrapSpecialImages(annotatedImages, startingIndexRecovery);	// prebleach average and first postbleach
        // vFrapXmlHelper.LoadVFrapRoiCompositeImages(annotatedImages, rois);
        }
    };
    // show the images from the vfrap file in an OverlayEditorPanelJAI dialog
    taskArray[2] = new AsynchClientTask("Display images", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            String mixedFieldDataName = (String) hashTable.get("mixedFieldDataName");
            if (mixedFieldDataName.equals("")) {
                JOptionPane.showMessageDialog(DataSymbolsPanel.this, "Field Data name " + mixedFieldDataName + " already in use.");
                // prevents the rest of tasks below from running
                throw UserCancelException.CANCEL_GENERIC;
            }
            AnnotatedImageDataset annotatedImages = (AnnotatedImageDataset) hashTable.get("annotatedImages");
            BufferedImage[] displayROI = (BufferedImage[]) hashTable.get("displayROI");
            if (annotatedImages == null || displayROI == null) {
                return;
            }
            // display the images
            OverlayEditorPanelJAI overlayPanel = new OverlayEditorPanelJAI();
            overlayPanel.setAllowAddROI(false);
            ImageDataset imageDataset = annotatedImages.getImageDataset();
            overlayPanel.setImages(imageDataset, 1, 0, new OverlayEditorPanelJAI.AllPixelValuesRange(1, 200));
            overlayPanel.setAllROICompositeImage(displayROI, OverlayEditorPanelJAI.FRAP_DATA_INIT_PROPERTY);
            int choice = DialogUtils.showComponentOKCancelDialog(DataSymbolsPanel.this, overlayPanel, "vFrap Field Data");
            if (choice != JOptionPane.OK_OPTION) {
                throw UserCancelException.CANCEL_GENERIC;
            }
        }
    };
    // save the ROIs, prebleach average and the first postbleach frame from memory to the database as field data
    taskArray[3] = new AsynchClientTask("Saving roi masks, pre-bleach average and first post-bleach", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Component requesterComponent = DataSymbolsPanel.this;
            DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
            DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
            if (documentManager == null) {
                throw new RuntimeException("Not connected to server.");
            }
            ExternalDataIdentifier derivedEDI = SaveVFrapSpecialImagesAsFieldData(hashTable, documentManager);
            hashTable.put("derivedEDI", derivedEDI);
        }
    };
    // create the data symbols for the images saved above and display them in the tree/table
    taskArray[4] = new AsynchClientTask("Display Data Symbols", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            ExternalDataIdentifier derivedEDI = (ExternalDataIdentifier) hashTable.get("derivedEDI");
            BioModel bioModel = simulationContext.getBioModel();
            CreateSaveVFrapDataSymbols(hashTable, bioModel, derivedEDI);
        }
    };
    // save the ROIs, prebleach average and the first postbleach frame from memory to the database as field data
    // taskArray[4] = new AsynchClientTask("Saving roi masks, pre-bleach average and first post-bleach", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
    // public void run(Hashtable<String, Object> hashTable) throws Exception {
    // File vFrapFile = (File)hashTable.get("vFrapFile");
    // if(vFrapFile == null) {
    // return;
    // }
    // AnnotatedImageDataset annotatedImages = (AnnotatedImageDataset)hashTable.get("annotatedImages");
    // String initialFieldDataName = (String)hashTable.get("initialFieldDataName");
    // 
    // DocumentWindow documentWindow = (DocumentWindow)BeanUtils.findTypeParentOfComponent(DataSymbolsPanel.this, DocumentWindow.class);
    // DocumentManager dm = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
    // if(dm == null){
    // throw new RuntimeException("not connected to server");
    // }
    // 
    // // mesh
    // ImageDataset imageDataset = annotatedImages.getImageDataset();
    // Extent extent = imageDataset.getExtent();
    // ISize isize = imageDataset.getISize();
    // Origin origin = new Origin(0,0,0);
    // CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent,isize,
    // new RegionImage( new VCImageUncompressed(null, new byte[isize.getXYZ()], extent,
    // isize.getX(),isize.getY(),isize.getZ()),0,null,null,RegionImage.NO_SMOOTHING));
    // double[] firstPostBleach = (double[])hashTable.get("firstPostBleach");
    // double[] prebleachAvg = (double[])hashTable.get("prebleachAverage");
    // ROI[] rois = (ROI[])hashTable.get("rois");
    // 
    // int NumTimePoints = 1;
    // int NumChannels = 2+rois.length;  // prebleach, postbleach, roi1, roi2 ... roiN
    // String[] channelNames = new String[NumChannels];
    // VariableType[] channelTypes = new VariableType[NumChannels];
    // DataSymbolType[] channelVFrapImageType = new DataSymbolType[NumChannels];
    // double[][][] pixData = new double[NumTimePoints][NumChannels][];
    // pixData[0][0] = firstPostBleach;
    // channelNames[0] = "firstPostBleach";
    // channelTypes[0] = VariableType.VOLUME;
    // channelVFrapImageType[0] = DataSymbolType.VFRAP_FIRST_POSTBLEACH;
    // pixData[0][1] = prebleachAvg;
    // channelNames[1] = "prebleachAverage";
    // channelTypes[1] = VariableType.VOLUME;
    // channelVFrapImageType[1] = DataSymbolType.VFRAP_PREBLEACH_AVG;
    // int index = 0;
    // for (ROI roi : rois){
    // short[] ushortPixels = roi.getPixelsXYZ();
    // double[] doublePixels = new double[ushortPixels.length];
    // for (int i = 0; i < ushortPixels.length; i++) {
    // doublePixels[i] = ((int)ushortPixels[i])&0xffff;
    // }
    // pixData[0][index+2] = doublePixels;
    // channelNames[index+2] = "roi_"+index;
    // channelTypes[index+2] = VariableType.VOLUME;
    // channelVFrapImageType[index+2] = DataSymbolType.VFRAP_ROI;
    // index++;
    // }
    // double[] times = new double[] { 0.0 };
    // 
    // FieldDataFileOperationSpec vfrapMiscFieldDataOpSpec = new FieldDataFileOperationSpec();
    // vfrapMiscFieldDataOpSpec.opType = FieldDataFileOperationSpec.FDOS_ADD;
    // vfrapMiscFieldDataOpSpec.cartesianMesh = cartesianMesh;
    // vfrapMiscFieldDataOpSpec.doubleSpecData =  pixData;
    // vfrapMiscFieldDataOpSpec.specEDI = null;
    // vfrapMiscFieldDataOpSpec.varNames = channelNames;
    // vfrapMiscFieldDataOpSpec.owner = dm.getUser();
    // vfrapMiscFieldDataOpSpec.times = times;
    // vfrapMiscFieldDataOpSpec.variableTypes = channelTypes;
    // vfrapMiscFieldDataOpSpec.origin = origin;
    // vfrapMiscFieldDataOpSpec.extent = extent;
    // vfrapMiscFieldDataOpSpec.isize = isize;
    // //  localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
    // 
    // //			String formattedDate = (String)hashTable.get("formattedDate");
    // //			String fieldDataName = initialFieldDataName + "_vfrapMisc_" + formattedDate;
    // String mixedFieldDataName = (String)hashTable.get("mixedFieldDataName");
    // ExternalDataIdentifier vfrapMisc = dm.saveFieldData(vfrapMiscFieldDataOpSpec, mixedFieldDataName);
    // 
    // hashTable.put("channelNames", channelNames);
    // hashTable.put("channelVFrapImageType", channelVFrapImageType);
    // hashTable.put("vfrapMisc", vfrapMisc);
    // }
    // };
    // create the data symbols for the images saved above and display them in the tree/table
    // taskArray[5] = new AsynchClientTask("Display Data Symbols", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
    // public void run(Hashtable<String, Object> hashTable) throws Exception {
    // 
    // // --- create the data symbols associated with the time series
    // String initialFieldDataName = (String)hashTable.get("initialFieldDataName");
    // String mixedFieldDataName = (String)hashTable.get("mixedFieldDataName");
    // String formattedDate = (String)hashTable.get("formattedDate");
    // ImageDataset imageDataset = (ImageDataset)hashTable.get("imageDataset");
    // ExternalDataIdentifier timeSeriesEDI = (ExternalDataIdentifier)hashTable.get("timeSeriesEDI");
    // 
    // for (double time : imageDataset.getImageTimeStamps()){
    // //	   			String fluorName = TokenMangler.fixTokenStrict("fluor_"+time+"_");
    // //				while (simulationContext.getDataContext().getDataSymbol(fluorName)!=null){
    // //					fluorName = TokenMangler.getNextEnumeratedToken(fluorName);
    // //	   			}
    // DecimalFormat df = new  DecimalFormat("0.##");
    // //	   			String fluorName = "fluor_" + df.format(time) + "_" + formattedDate;
    // String fluorName = "fluor_" + df.format(time) + "_" + initialFieldDataName;
    // //				FieldFunctionArguments fluorFFArgs = new FieldFunctionArguments(timeSeriesEDI.getName(), fluorName, new Expression(time), VariableType.VOLUME);
    // DataSymbol fluorDataSymbol = new FieldDataSymbol( fluorName, DataSymbolType.VFRAP_TIMEPOINT,
    // simulationContext.getDataContext(), VCUnitDefinition.UNIT_TBD,
    // timeSeriesEDI, fluorName, VariableType.VOLUME.getTypeName(), time);
    // simulationContext.getDataContext().addDataSymbol(fluorDataSymbol);
    // }
    // // --- create the vFrap-specific symbols (ROIs, first postbleach, prebleach average)
    // String[] channelNames = (String[])hashTable.get("channelNames");
    // DataSymbolType[] channelVFrapImageType = (DataSymbolType[])hashTable.get("channelVFrapImageType");
    // ExternalDataIdentifier vfrapMisc = (ExternalDataIdentifier)hashTable.get("vfrapMisc");
    // 
    // for (int i=0; i<channelNames.length; i++) {
    // String dataSymbolID = channelNames[i] + "_" + mixedFieldDataName;
    // //				while (simulationContext.getDataContext().getDataSymbol(dataSymbolID)!=null){
    // //					dataSymbolID = TokenMangler.getNextEnumeratedToken(dataSymbolID);
    // //				}
    // //				FieldFunctionArguments prebleachFFArgs = new FieldFunctionArguments(vfrapMisc.getName(), channelNames[i], new Expression(0.0), VariableType.VOLUME);
    // //				DataSymbol dataSymbol = new FieldDataSymbol(channelNames[i], channelVFrapImageType[i],
    // //				DataSymbol dataSymbol = new FieldDataSymbol(dataSymbolID + "_" + formattedDate, channelVFrapImageType[i],
    // DataSymbol dataSymbol = new FieldDataSymbol(dataSymbolID, channelVFrapImageType[i],
    // simulationContext.getDataContext(), VCUnitDefinition.UNIT_TBD,
    // vfrapMisc, channelNames[i], VariableType.VOLUME.getTypeName(), 0D);
    // simulationContext.getDataContext().addDataSymbol(dataSymbol);
    // }
    // }
    // };
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    ClientTaskDispatcher.dispatch(this, hash, taskArray, false, true, null);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) AnnotatedImageDataset(cbit.vcell.VirtualMicroscopy.importer.AnnotatedImageDataset) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Hashtable(java.util.Hashtable) Element(org.jdom.Element) DocumentManager(cbit.vcell.clientdb.DocumentManager) UserCancelException(org.vcell.util.UserCancelException) BufferedImage(java.awt.image.BufferedImage) DocumentWindow(cbit.vcell.client.desktop.DocumentWindow) MicroscopyXmlReader(cbit.vcell.VirtualMicroscopy.importer.MicroscopyXmlReader) BioModel(cbit.vcell.biomodel.BioModel) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) Component(java.awt.Component) File(java.io.File) OverlayEditorPanelJAI(cbit.vcell.geometry.gui.OverlayEditorPanelJAI) AnnotatedImageDataset(cbit.vcell.VirtualMicroscopy.importer.AnnotatedImageDataset)

Example 28 with ExternalDataIdentifier

use of org.vcell.util.document.ExternalDataIdentifier in project vcell by virtualcell.

the class PDEDataViewer method setPdeDataContext.

public void setPdeDataContext(ClientPDEDataContext pdeDataContext) {
    if (pdeDataContext != null && pdeDataContext.getVCDataIdentifier() instanceof ExternalDataIdentifier) {
        // getJTabbedPane1().removeTabAt(getJTabbedPane1().indexOfTab(POST_PROCESS_IMAGE_TABNAME));
        // getJTabbedPane1().removeTabAt(getJTabbedPane1().indexOfTab(POST_PROCESS_STATS_TABNAME));
        getJTabbedPane1().setEnabledAt(getJTabbedPane1().indexOfTab(POST_PROCESS_IMAGE_TABNAME), false);
        getJTabbedPane1().setEnabledAt(getJTabbedPane1().indexOfTab(POST_PROCESS_STATS_TABNAME), false);
    }
    getPDEDataContextPanel1().getdisplayAdapterServicePanel1().enableAutoAllTimes(true && !(pdeDataContext instanceof PostProcessDataPDEDataContext));
    PDEDataContext oldValue = fieldPdeDataContext;
    String setVarName = null;
    Integer setTimePoint = null;
    if (oldValue != null) {
        setVarName = oldValue.getVariableName();
        setTimePoint = getPDEPlotControlPanel1().getTimeSliderValue();
        try {
            if (pdeDataContext != null) {
                pdeDataContext.setVariableNameAndTime(setVarName, pdeDataContext.getTimePoints()[setTimePoint]);
            }
        } catch (Exception e) {
            e.printStackTrace();
            setVarName = null;
            setTimePoint = null;
        }
        oldValue.removePropertyChangeListener(ivjEventHandler);
    }
    fieldPdeDataContext = pdeDataContext;
    if (getPdeDataContext() != null && (setVarName == null || setTimePoint == null)) {
        setVarName = getPdeDataContext().getVariableNames()[0];
        setTimePoint = 0;
        try {
            pdeDataContext.setVariableNameAndTime(setVarName, pdeDataContext.getTimePoints()[setTimePoint]);
        } catch (Exception e2) {
            e2.printStackTrace();
            DialogUtils.showErrorDialog(this, "Couldn't set time and variable on pdeDataContext");
            return;
        }
    }
    if (getPdeDataContext() != null) {
        getPdeDataContext().removePropertyChangeListener(ivjEventHandler);
        getPdeDataContext().addPropertyChangeListener(ivjEventHandler);
        try {
            getPDEPlotControlPanel1().removePropertyChangeListener(ivjEventHandler);
            try {
                getPDEPlotControlPanel1().setup(((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext().getOutputFunctions(), getPdeDataContext().getDataIdentifiers(), getPdeDataContext().getTimePoints(), setVarName, setTimePoint);
            } catch (Exception e) {
                e.printStackTrace();
                DialogUtils.showErrorDialog(this, "Couldn't setup PDEPlotControlPanel, " + e.getMessage());
                return;
            }
        } finally {
            getPDEPlotControlPanel1().addPropertyChangeListener(ivjEventHandler);
        }
    }
    bSkipSurfaceCalc = true;
    firePropertyChange(PDEDataContext.PROP_PDE_DATA_CONTEXT, null, pdeDataContext);
    bSkipSurfaceCalc = false;
    if (ivjJTabbedPane1.getTitleAt(ivjJTabbedPane1.getSelectedIndex()).equals(POST_PROCESS_STATS_TABNAME)) {
        dataProcessingResultsPanel.update(getPdeDataContext());
    }
    postProcessPdeDataViewerPanel.setParentPDEDataContext((ClientPDEDataContext) getPdeDataContext());
    if (ivjJTabbedPane1.getTitleAt(ivjJTabbedPane1.getSelectedIndex()).equals(POST_PROCESS_IMAGE_TABNAME)) {
        postProcessPdeDataViewerPanel.update();
    }
}
Also used : ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) PDEDataContext(cbit.vcell.simdata.PDEDataContext) PostProcessDataPDEDataContext(cbit.vcell.client.data.PDEDataViewerPostProcess.PostProcessDataPDEDataContext) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) PostProcessDataPDEDataContext(cbit.vcell.client.data.PDEDataViewerPostProcess.PostProcessDataPDEDataContext) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException)

Example 29 with ExternalDataIdentifier

use of org.vcell.util.document.ExternalDataIdentifier in project vcell by virtualcell.

the class PDEDataViewer method calcAutoAllTimes.

private void calcAutoAllTimes() throws Exception {
    HashSet<String> stateVarNames = null;
    Variable theVariable = null;
    boolean bStateVar = true;
    boolean isFieldData = getPdeDataContext().getVCDataIdentifier() instanceof ExternalDataIdentifier || getPdeDataContext().getVCDataIdentifier() instanceof MergedDataInfo;
    if (isFieldData) {
        // fielddata
        DataIdentifier[] dataids = getPdeDataContext().getDataIdentifiers();
        stateVarNames = new HashSet<>();
        for (int i = 0; i < dataids.length; i++) {
            if (!dataids[i].isFunction()) {
                stateVarNames.add(dataids[i].getName());
            }
        // System.out.println("name:'"+dataids[i].getName()+"' type:"+dataids[i].getVariableType()+" func:"+dataids[i].isFunction());
        }
        bStateVar = !getPdeDataContext().getDataIdentifier().isFunction();
        if (bStateVar) {
            theVariable = new VolVariable(getPdeDataContext().getDataIdentifier().getName(), getPdeDataContext().getDataIdentifier().getDomain());
        } else {
            AnnotatedFunction[] funcs = getPdeDataContext().getFunctions();
            for (int i = 0; i < funcs.length; i++) {
                if (funcs[i].getName().equals(getPdeDataContext().getDataIdentifier().getName())) {
                    theVariable = funcs[i];
                    break;
                }
            }
        }
    } else {
        stateVarNames = getSimulation().getMathDescription().getStateVariableNames();
        theVariable = getSimulation().getMathDescription().getVariable(getPdeDataContext().getVariableName());
        if (theVariable == null) {
            theVariable = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext().getOutputFunction(getPdeDataContext().getVariableName());
        }
        if (theVariable == null) {
            DataProcessingOutputInfo dataProcessingOutputInfo = DataProcessingResultsPanel.getDataProcessingOutputInfo(getPdeDataContext());
            if (dataProcessingOutputInfo != null && Arrays.asList(dataProcessingOutputInfo.getVariableNames()).contains(getPdeDataContext().getVariableName())) {
                // PostProcess Variable
                return;
            }
        }
        bStateVar = stateVarNames.contains(getPdeDataContext().getVariableName());
    }
    if (theVariable == null) {
        throw new Exception("Unexpected Alltimes... selected variable '" + getPdeDataContext().getVariableName() + "' is not stateVariable or OutputFunction");
    }
    if (getPDEDataContextPanel1().getdisplayAdapterService1().getAllTimes()) {
        // min-max over all timepoints (allTimes)
        if (theVariable.isConstant()) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
            double constVal = theVariable.getExpression().evaluateConstant();
            getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(constVal, constVal));
        } else if (bStateVar) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
            ArrayList<VarStatistics> varStatsArr = calcVarStat(getPdeDataContext(), new String[] { theVariable.getName() });
            if (errorAutoAllTimes(varStatsArr != null, (varStatsArr == null ? null : varStatsArr.size() > 0), isFieldData)) {
                // no postprocessinfo
                return;
            }
            FunctionStatistics functionStatistics = new FunctionStatistics(varStatsArr.get(0).minValuesOverTime, varStatsArr.get(0).maxValuesOverTime);
            getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(functionStatistics.getMinOverTime(), functionStatistics.getMaxOverTime()));
        } else if (theVariable instanceof Function) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__APPROX_TEXT);
            Function flattened = MathDescription.getFlattenedFunctions(SimulationSymbolTable.createMathSymbolTableFactory(), getSimulation().getMathDescription(), new String[] { theVariable.getName() })[0];
            if (flattened == null) {
                flattened = (Function) theVariable;
            }
            ArrayList<VarStatistics> varStatsArr = calcVarStat(getPdeDataContext(), stateVarNames.toArray(new String[0]));
            if (errorAutoAllTimes(varStatsArr != null, (varStatsArr == null ? null : varStatsArr.size() > 0), isFieldData)) {
                // check for no postprocessinfo
                return;
            }
            if (varStatsArr.size() == stateVarNames.size()) {
                if (getSimulation().getMeshSpecification().getGeometry().getGeometrySurfaceDescription().getRegionImage() == null) {
                    getSimulation().getMeshSpecification().getGeometry().getGeometrySurfaceDescription().updateAll();
                }
                FunctionStatistics functionStatistics = FunctionRangeGenerator.getFunctionStatistics(flattened.getExpression(), varStatsArr.toArray(new VarStatistics[0]), getPdeDataContext().getTimePoints(), getPdeDataContext().getCartesianMesh(), calcInDomainBitSet(), getPdeDataContext().getDataIdentifier().getVariableType());
                getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(functionStatistics.getMinOverTime(), functionStatistics.getMaxOverTime()));
            } else {
                throw new Exception("Unexpectede AllTimes... calculated state var stats size != mathdescr state var size");
            }
        } else {
            throw new Exception("Unexpected AllTimes... not constant, stateVar or function");
        }
    } else {
        // min-max at each timepoint (currTime)
        if (!(theVariable instanceof Function)) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
        } else {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__APPROX_TEXT);
        }
        getPDEDataContextPanel1().setFunctionStatisticsRange(null);
    }
}
Also used : VolVariable(cbit.vcell.math.VolVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) Variable(cbit.vcell.math.Variable) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) LocalVCSimulationDataIdentifier(cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VolVariable(cbit.vcell.math.VolVariable) ArrayList(java.util.ArrayList) Range(org.vcell.util.Range) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) MergedDataInfo(cbit.vcell.simdata.MergedDataInfo) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Function(cbit.vcell.math.Function) VarStatistics(cbit.vcell.util.FunctionRangeGenerator.VarStatistics) DataProcessingOutputInfo(cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) FunctionStatistics(cbit.vcell.util.FunctionRangeGenerator.FunctionStatistics)

Example 30 with ExternalDataIdentifier

use of org.vcell.util.document.ExternalDataIdentifier in project vcell by virtualcell.

the class Xmlproducer method getXML.

private Element getXML(FieldDataSymbol fds, ModelUnitSystem modelUnitSystem) {
    Element fieldDataSymbolElement = new Element(XMLTags.FieldDataSymbolTag);
    fieldDataSymbolElement.setAttribute(XMLTags.DataSymbolNameTag, fds.getName());
    fieldDataSymbolElement.setAttribute(XMLTags.DataSymbolTypeTag, fds.getDataSymbolType().getDatabaseName());
    // DataContext is runtime only
    fieldDataSymbolElement.setAttribute(XMLTags.VCUnitDefinitionAttrTag, fds.getUnitDefinition().getSymbol());
    Element dataSetIDElement = new Element(XMLTags.ExternalDataIdentifierTag);
    ExternalDataIdentifier edi = fds.getExternalDataIdentifier();
    dataSetIDElement.setAttribute(XMLTags.NameAttrTag, edi.getName());
    dataSetIDElement.setAttribute(XMLTags.KeyValueAttrTag, edi.getKey().toString());
    dataSetIDElement.setAttribute(XMLTags.OwnerNameAttrTag, edi.getOwner().getName());
    dataSetIDElement.setAttribute(XMLTags.OwnerKeyAttrTag, edi.getOwner().getID().toString());
    fieldDataSymbolElement.addContent(dataSetIDElement);
    fieldDataSymbolElement.setAttribute(XMLTags.FieldItemNameTag, fds.getFieldDataVarName());
    fieldDataSymbolElement.setAttribute(XMLTags.FieldItemTypeTag, fds.getFieldDataVarType());
    fieldDataSymbolElement.setAttribute(XMLTags.FieldItemTimeTag, Double.toString(fds.getFieldDataVarTime()));
    return fieldDataSymbolElement;
}
Also used : Element(org.jdom.Element) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier)

Aggregations

ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)46 DataAccessException (org.vcell.util.DataAccessException)15 KeyValue (org.vcell.util.document.KeyValue)15 FieldFunctionArguments (cbit.vcell.field.FieldFunctionArguments)12 File (java.io.File)12 UserCancelException (org.vcell.util.UserCancelException)12 User (org.vcell.util.document.User)12 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)9 Hashtable (java.util.Hashtable)9 ISize (org.vcell.util.ISize)9 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 Expression (cbit.vcell.parser.Expression)8 Origin (org.vcell.util.Origin)8 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)7 Element (org.jdom.Element)7 Extent (org.vcell.util.Extent)7 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)7 ImageException (cbit.image.ImageException)6 FieldDataDBOperationResults (cbit.vcell.field.FieldDataDBOperationResults)6 RegionImage (cbit.vcell.geometry.RegionImage)6