Search in sources :

Example 1 with TimeSpecs

use of cbit.vcell.export.server.TimeSpecs in project vcell by virtualcell.

the class PDEDataViewer method sendTimeSeriesImageJ.

// private Hashtable<String, JLabel> sendTimeSeriesLabels = new Hashtable<>();
// @Override
// public void exportMessage(ExportEvent event) {
// super.exportMessage(event);
// if(sendTimeSeriesLabels.size() > 0){
// JLabel messgLabel = sendTimeSeriesLabels.values().iterator().next();
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// messgLabel.setText(event.getMessageData().toString());
// }
// });
// }
// }
private void sendTimeSeriesImageJ() {
    final JPanel mainJPanel = new JPanel();
    BoxLayout mainBL = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
    mainJPanel.setLayout(mainBL);
    final boolean[] response = new boolean[] { false };
    MiniTimePanel timeJPanel = new MiniTimePanel();
    final JLabel messgLabel = new JLabel("time points to export:" + (timeJPanel.jcb_time_end.getSelectedIndex() - timeJPanel.jcb_time_begin.getSelectedIndex() + 1));
    JRadioButton slicebtn = new JRadioButton("Slice " + getPDEDataContextPanel1().getSlice() + " only");
    slicebtn.setSelected(true);
    JPanel messageAndSlicePanel = null;
    if (getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3) {
        messageAndSlicePanel = new JPanel();
        ((FlowLayout) messageAndSlicePanel.getLayout()).setAlignment(FlowLayout.LEFT);
        ButtonGroup buttonGroup = new ButtonGroup();
        JRadioButton allslicebtn = new JRadioButton("All slices");
        buttonGroup.add(slicebtn);
        buttonGroup.add(allslicebtn);
        messageAndSlicePanel.add(messgLabel);
        messageAndSlicePanel.add(slicebtn);
        messageAndSlicePanel.add(allslicebtn);
    }
    ActionListener okAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (((Double) timeJPanel.jcb_time_begin.getSelectedItem()).compareTo((Double) timeJPanel.jcb_time_end.getSelectedItem()) > 0) {
                PopupGenerator.showErrorDialog(PDEDataViewer.this, "Selected 'Begin Time' must be less than or equal to 'End Time'");
                return;
            }
            response[0] = true;
            BeanUtils.disposeParentWindow(mainJPanel);
        }
    };
    ActionListener cancelAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            BeanUtils.disposeParentWindow(mainJPanel);
        }
    };
    final OkCancelSubPanel okCancelJPanel = new OkCancelSubPanel(okAction, cancelAction);
    ActionListener rangeListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int range = timeJPanel.jcb_time_end.getSelectedIndex() - timeJPanel.jcb_time_begin.getSelectedIndex() + 1;
            okCancelJPanel.okButton.setEnabled(range > 0);
            messgLabel.setText((range < 0 ? "Error: begin time must be < end time" : "time points to export:" + (range)));
        }
    };
    timeJPanel.jcb_time_end.addActionListener(rangeListener);
    timeJPanel.jcb_time_begin.addActionListener(rangeListener);
    okCancelJPanel.okButton.setEnabled(true);
    mainJPanel.add(timeJPanel);
    mainJPanel.add((messageAndSlicePanel == null ? messgLabel : messageAndSlicePanel));
    mainJPanel.add(okCancelJPanel);
    Frame dialogOwner = JOptionPane.getFrameForComponent(this);
    JOptionPane inputDialog = new JOptionPane(mainJPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[0]);
    final JDialog d = inputDialog.createDialog(dialogOwner, "'" + getSimulationModelInfo().getContextName() + "':'" + getSimulationModelInfo().getSimulationName() + "':'" + getPdeDataContext().getVariableName() + "'");
    d.setResizable(true);
    d.setModal(true);
    d.pack();
    d.setVisible(true);
    // }
    if (!response[0]) {
        return;
    }
    ExportSpecs exportSpecs = new ExportSpecs(getPdeDataContext().getVCDataIdentifier(), ExportFormat.IMAGEJ, new VariableSpecs(new String[] { getPdeDataContext().getDataIdentifier().getName() }, ExportConstants.VARIABLE_MULTI), new TimeSpecs(timeJPanel.jcb_time_begin.getSelectedIndex(), timeJPanel.jcb_time_end.getSelectedIndex(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE), new GeometrySpecs(null, getPDEDataContextPanel1().getNormalAxis(), getPDEDataContextPanel1().getSlice(), (slicebtn.isSelected() ? ExportConstants.GEOMETRY_SLICE : ExportConstants.GEOMETRY_FULL)), new RasterSpecs(ExportConstants.NRRD_BY_VARIABLE, false), getSimulationModelInfo().getSimulationName(), getSimulationModelInfo().getContextName());
    getDataViewerManager().startExport(this, ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext(), exportSpecs);
}
Also used : JPanel(javax.swing.JPanel) Frame(java.awt.Frame) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) RasterSpecs(cbit.vcell.export.server.RasterSpecs) ActionEvent(java.awt.event.ActionEvent) ExportSpecs(cbit.vcell.export.server.ExportSpecs) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) GeometrySpecs(cbit.vcell.export.server.GeometrySpecs) JOptionPane(javax.swing.JOptionPane) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) VariableSpecs(cbit.vcell.export.server.VariableSpecs) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) TimeSpecs(cbit.vcell.export.server.TimeSpecs) JDialog(javax.swing.JDialog)

Example 2 with TimeSpecs

use of cbit.vcell.export.server.TimeSpecs in project vcell by virtualcell.

the class PDEExportDataPanel method getExportSpecs.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.export.server.ExportSpecs
 */
private ExportSpecs getExportSpecs() {
    @SuppressWarnings("deprecation") Object[] variableSelections = getJListVariables().getSelectedValues();
    String[] variableNames = new String[variableSelections.length];
    for (int i = 0; i < variableSelections.length; i++) {
        variableNames[i] = (String) variableSelections[i];
    }
    VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
    TimeSpecs timeSpecs = new TimeSpecs(getJSlider1().getValue(), getJSlider2().getValue(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE);
    int geoMode = ExportConstants.GEOMETRY_SELECTIONS;
    if (getJRadioButtonSlice().isSelected()) {
        geoMode = ExportConstants.GEOMETRY_SLICE;
    } else if (getJRadioButtonFull().isSelected()) {
        geoMode = ExportConstants.GEOMETRY_FULL;
    }
    Object[] selectionsArr = getROISelections().getSelectedValuesList().toArray();
    SpatialSelection[] selections = new SpatialSelection[selectionsArr.length];
    for (int i = 0; i < selections.length; i++) {
        selections[i] = (SpatialSelection) selectionsArr[i];
    }
    GeometrySpecs geometrySpecs = new GeometrySpecs(selections, getNormalAxis(), getSlice(), geoMode);
    return new ExportSpecs(getPdeDataContext().getVCDataIdentifier(), getExportSettings1().getSelectedFormat(), variableSpecs, timeSpecs, geometrySpecs, getExportSettings1().getFormatSpecificSpecs(), dataInfoProvider.getSimulationModelInfo().getSimulationName(), dataInfoProvider.getSimulationModelInfo().getContextName());
}
Also used : VariableSpecs(cbit.vcell.export.server.VariableSpecs) SpatialSelection(cbit.vcell.simdata.SpatialSelection) ExportSpecs(cbit.vcell.export.server.ExportSpecs) GeometrySpecs(cbit.vcell.export.server.GeometrySpecs) TimeSpecs(cbit.vcell.export.server.TimeSpecs)

Example 3 with TimeSpecs

use of cbit.vcell.export.server.TimeSpecs in project vcell by virtualcell.

the class ClientRequestManager method downloadExportedData.

/**
 * Comment
 */
public static void downloadExportedData(final Component requester, final UserPreferences userPrefs, final ExportEvent evt) {
    AsynchClientTask task1 = new AsynchClientTask("Retrieving data from '" + evt.getLocation() + "'", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            final Exception[] excArr = new Exception[] { null };
            final boolean[] bFlagArr = new boolean[] { false };
            final ByteArrayOutputStream[] baosArr = new ByteArrayOutputStream[1];
            final HttpGet[] httpGetArr = new HttpGet[1];
            final ImageJConnection[] imagejConnetArr = new ImageJConnection[1];
            // Start download of exported file in separate thread that is interruptible (apache HTTPClient)
            Thread interruptible = new Thread(new Runnable() {

                @Override
                public void run() {
                    if (getClientTaskStatusSupport() != null) {
                        getClientTaskStatusSupport().setMessage("downloading data...");
                    }
                    CloseableHttpClient httpclient = HttpClients.createDefault();
                    httpGetArr[0] = new HttpGet(evt.getLocation());
                    CloseableHttpResponse response = null;
                    try {
                        response = httpclient.execute(httpGetArr[0]);
                        HttpEntity entity = response.getEntity();
                        if (entity != null) {
                            long size = entity.getContentLength();
                            InputStream instream = entity.getContent();
                            try {
                                // Thread.sleep(60000);
                                if (size > 0) {
                                    baosArr[0] = new ByteArrayOutputStream((int) size);
                                } else {
                                    baosArr[0] = new ByteArrayOutputStream();
                                }
                                IOUtils.copy(instream, baosArr[0]);
                            } finally {
                                instream.close();
                            }
                        }
                    } catch (Exception e) {
                        excArr[0] = e;
                    } finally {
                        if (imagejConnetArr[0] != null) {
                            imagejConnetArr[0].closeConnection();
                        }
                        if (response != null) {
                            try {
                                response.close();
                            } catch (Exception e) {
                            }
                        }
                        if (httpclient != null) {
                            try {
                                httpclient.close();
                            } catch (Exception e) {
                            }
                        }
                        bFlagArr[0] = true;
                    }
                }
            });
            interruptible.start();
            // Wait for download to 1-finish, 2-fail or 3-be cancelled by user
            while (!bFlagArr[0]) {
                if (getClientTaskStatusSupport() != null && getClientTaskStatusSupport().isInterrupted()) {
                    // user cancelled
                    if (httpGetArr[0] != null) {
                        httpGetArr[0].abort();
                    }
                    if (imagejConnetArr[0] != null) {
                        imagejConnetArr[0].closeConnection();
                    }
                    throw UserCancelException.CANCEL_GENERIC;
                }
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // caused by pressing 'cancel' button on progresspopup
                    if (httpGetArr[0] != null) {
                        httpGetArr[0].abort();
                    }
                    if (imagejConnetArr[0] != null) {
                        imagejConnetArr[0].closeConnection();
                    }
                    if (getClientTaskStatusSupport() != null && getClientTaskStatusSupport().isInterrupted()) {
                        throw UserCancelException.CANCEL_GENERIC;
                    }
                }
            }
            if (excArr[0] != null) {
                // download failed
                throw excArr[0];
            }
            // 
            if (evt.getFormat() == null || !evt.getFormat().equals("IMAGEJ")) {
                // save for file save operations
                hashTable.put(BYTES_KEY, baosArr[0].toByteArray());
            } else {
                // NRRD format send to ImageJ
                if (getClientTaskStatusSupport() != null) {
                    getClientTaskStatusSupport().setMessage("unpacking data...");
                }
                ByteArrayInputStream bais = new ByteArrayInputStream(baosArr[0].toByteArray());
                ZipInputStream zis = null;
                BufferedInputStream bis = null;
                try {
                    zis = new ZipInputStream(bais);
                    ZipEntry entry = zis.getNextEntry();
                    // System.out.println("zipfile entry name="+entry.getName()+"zipfile entry size="+entry.getSize());
                    // File tempf = new File("C:\\temp\\tempf.nrrd");
                    // FileOutputStream fos = new FileOutputStream(tempf);
                    // byte[] mybuf = new byte[1000];
                    // int numread = 0;
                    // while((numread = zis.read(mybuf)) != -1){
                    // fos.write(mybuf, 0, numread);
                    // }
                    // fos.close();
                    TimeSpecs timeSpecs = evt.getTimeSpecs();
                    double[] timePoints = new double[timeSpecs.getEndTimeIndex() - timeSpecs.getBeginTimeIndex() + 1];
                    for (int tp = timeSpecs.getBeginTimeIndex(); tp <= timeSpecs.getEndTimeIndex(); tp++) {
                        timePoints[tp - timeSpecs.getBeginTimeIndex()] = timeSpecs.getAllTimes()[tp];
                    }
                    // doesn't open connection until later
                    imagejConnetArr[0] = new ImageJConnection(ImageJHelper.ExternalCommunicator.IMAGEJ);
                    bis = new BufferedInputStream(zis);
                    ImageJHelper.vcellSendNRRD(requester, bis, getClientTaskStatusSupport(), imagejConnetArr[0], "VCell exported data '" + entry.getName() + "'", timePoints, evt.getVariableSpecs().getVariableNames());
                } finally {
                    if (zis != null) {
                        try {
                            zis.closeEntry();
                            zis.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (bis != null) {
                        try {
                            bis.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                // finished, exit all further tasks
                throw UserCancelException.CANCEL_GENERIC;
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("selecting file to save", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // user pref could be null if trying local export
            String defaultPath = getPreferredPath(userPrefs);
            final VCFileChooser fileChooser = new VCFileChooser(defaultPath);
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setMultiSelectionEnabled(false);
            String name = evt.getDataIdString();
            String suffix = null;
            if (evt.getLocation().toLowerCase().endsWith(".mov")) {
                fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_MOV);
                fileChooser.setFileFilter(FileFilters.FILE_FILTER_MOV);
                suffix = "_exported.mov";
            } else if (evt.getLocation().toLowerCase().endsWith(".gif")) {
                fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_GIF);
                fileChooser.setFileFilter(FileFilters.FILE_FILTER_GIF);
                suffix = "_exported.gif";
            } else if (evt.getLocation().toLowerCase().endsWith(".jpeg")) {
                fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_JPEG);
                fileChooser.setFileFilter(FileFilters.FILE_FILTER_JPEG);
                suffix = "_exported.jpeg";
            } else {
                fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_ZIP);
                fileChooser.setFileFilter(FileFilters.FILE_FILTER_ZIP);
                suffix = "_exported.zip";
            }
            File file = new File(name + suffix);
            if (file.exists()) {
                int count = 0;
                do {
                    file = new File(name + "_" + count + suffix);
                    count++;
                } while (file.exists());
            }
            fileChooser.setSelectedFile(file);
            fileChooser.setDialogTitle("Save exported dataset...");
            int approve = fileChooser.showSaveDialog(requester);
            if (approve == JFileChooser.APPROVE_OPTION) {
                hashTable.put("selectedFile", fileChooser.getSelectedFile());
            } else {
                fileChooser.setSelectedFile(null);
            }
        }
    };
    AsynchClientTask task3 = new AsynchClientTask("saving to file", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            File selectedFile = (File) hashTable.get("selectedFile");
            if (selectedFile == null) {
                return;
            }
            setPreferredPath(userPrefs, selectedFile);
            // System.out.println("New preferred file path: " + newPath + ", Old preferred file path: " + defaultPath);
            if (selectedFile.exists()) {
                String question = null;
                if (userPrefs != null) {
                    question = PopupGenerator.showWarningDialog(requester, userPrefs, UserMessage.warn_OverwriteFile, selectedFile.getAbsolutePath());
                } else {
                    question = DialogUtils.showWarningDialog(requester, "Overwrite File?", "Overwrite file '" + selectedFile.getAbsolutePath() + "'?", new String[] { UserMessage.OPTION_OVERWRITE_FILE, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OVERWRITE_FILE);
                }
                if (question != null && question.equals(UserMessage.OPTION_CANCEL)) {
                    return;
                }
            }
            byte[] bytes = (byte[]) hashTable.get(BYTES_KEY);
            FileOutputStream fo = new FileOutputStream(selectedFile);
            fo.write(bytes);
            fo.close();
        }
    };
    ClientTaskDispatcher.dispatch(requester, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2, task3 }, false, true, null);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) ZipEntry(java.util.zip.ZipEntry) BufferedInputStream(java.io.BufferedInputStream) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) VCFileChooser(org.vcell.util.gui.VCFileChooser) TimeSpecs(cbit.vcell.export.server.TimeSpecs) ImageJConnection(org.vcell.imagej.ImageJHelper.ImageJConnection) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Hashtable(java.util.Hashtable) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ProgrammingException(org.vcell.util.ProgrammingException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileOutputStream(java.io.FileOutputStream) CSGObject(cbit.vcell.geometry.CSGObject) ChooseFile(cbit.vcell.client.task.ChooseFile) File(java.io.File)

Example 4 with TimeSpecs

use of cbit.vcell.export.server.TimeSpecs 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 5 with TimeSpecs

use of cbit.vcell.export.server.TimeSpecs in project vcell by virtualcell.

the class ExportEvent method fromJsonRep.

public static ExportEvent fromJsonRep(Object eventSource, ExportEventRepresentation rep) {
    User user = new User(rep.username, new KeyValue(rep.userkey));
    TimeSpecs timeSpecs = null;
    if (rep.exportTimeSpecs != null) {
        timeSpecs = TimeSpecs.fromJsonRep(rep.exportTimeSpecs);
    }
    VariableSpecs variableSpecs = null;
    if (rep.exportVariableSpecs != null) {
        variableSpecs = VariableSpecs.fromJsonRep(rep.exportVariableSpecs);
    }
    ExportEvent event = new ExportEvent(eventSource, rep.jobid, user, rep.dataIdString, new KeyValue(rep.dataKey), rep.eventType, rep.format, rep.location, rep.progress, timeSpecs, variableSpecs);
    return event;
}
Also used : VariableSpecs(cbit.vcell.export.server.VariableSpecs) ExportVariableSpecs(org.vcell.api.common.events.ExportVariableSpecs) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) ExportTimeSpecs(org.vcell.api.common.events.ExportTimeSpecs) TimeSpecs(cbit.vcell.export.server.TimeSpecs)

Aggregations

TimeSpecs (cbit.vcell.export.server.TimeSpecs)6 ExportSpecs (cbit.vcell.export.server.ExportSpecs)4 VariableSpecs (cbit.vcell.export.server.VariableSpecs)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 GeometrySpecs (cbit.vcell.export.server.GeometrySpecs)3 Hashtable (java.util.Hashtable)3 DisplayPreferences (cbit.image.DisplayPreferences)2 ExportEvent (cbit.rmi.event.ExportEvent)2 ExportFormat (cbit.vcell.export.server.ExportFormat)2 MovieSpecs (cbit.vcell.export.server.MovieSpecs)2 RasterSpecs (cbit.vcell.export.server.RasterSpecs)2 ClientPDEDataContext (cbit.vcell.simdata.ClientPDEDataContext)2 Frame (java.awt.Frame)2 Point (java.awt.Point)2 File (java.io.File)2 IOException (java.io.IOException)2 User (org.vcell.util.document.User)2 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)2 ImageException (cbit.image.ImageException)1 ChooseFile (cbit.vcell.client.task.ChooseFile)1