Search in sources :

Example 21 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class ClientRequestManager method createFDOSFromVCImage.

private static FieldDataFileOperationSpec createFDOSFromVCImage(VCImage dbImage) throws ImageException {
    int[] temp = new int[256];
    short[] templateShorts = new short[dbImage.getNumXYZ()];
    for (int i = 0; i < dbImage.getPixels().length; i++) {
        templateShorts[i] = (short) (0x00FF & dbImage.getPixels()[i]);
        temp[templateShorts[i]]++;
    }
    for (int j = 0; j < dbImage.getPixelClasses().length; j++) {
        short tempshort = (short) (0x00FF & dbImage.getPixelClasses()[j].getPixel());
    }
    FieldDataFileOperationSpec fdfos = null;
    fdfos = new FieldDataFileOperationSpec();
    fdfos.origin = new Origin(0, 0, 0);
    fdfos.extent = dbImage.getExtent();
    fdfos.isize = new ISize(dbImage.getNumX(), dbImage.getNumY(), dbImage.getNumZ());
    fdfos.shortSpecData = new short[][][] { { templateShorts } };
    return fdfos;
}
Also used : BngUnitOrigin(org.vcell.model.bngl.BngUnitSystem.BngUnitOrigin) Origin(org.vcell.util.Origin) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) ISize(org.vcell.util.ISize)

Example 22 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class ClientRequestManager method createFDOSWithChannels.

public static FieldDataFileOperationSpec createFDOSWithChannels(ImageDataset[] imagedataSets, Integer saveOnlyThisTimePointIndex) {
    final FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
    // [time][var][data]
    int numXY = imagedataSets[0].getISize().getX() * imagedataSets[0].getISize().getY();
    int numXYZ = imagedataSets[0].getSizeZ() * numXY;
    fdos.variableTypes = new VariableType[imagedataSets.length];
    fdos.varNames = new String[imagedataSets.length];
    short[][][] shortData = new short[(saveOnlyThisTimePointIndex != null ? 1 : imagedataSets[0].getSizeT())][imagedataSets.length][numXYZ];
    for (int c = 0; c < imagedataSets.length; c += 1) {
        fdos.variableTypes[c] = VariableType.VOLUME;
        fdos.varNames[c] = "Channel" + c;
        for (int t = 0; t < imagedataSets[c].getSizeT(); t += 1) {
            if (saveOnlyThisTimePointIndex != null && saveOnlyThisTimePointIndex.intValue() != t) {
                continue;
            }
            int zOffset = 0;
            for (int z = 0; z < imagedataSets[c].getSizeZ(); z += 1) {
                UShortImage ushortImage = imagedataSets[c].getImage(z, 0, t);
                System.arraycopy(ushortImage.getPixels(), 0, shortData[(saveOnlyThisTimePointIndex != null ? 0 : t)][c], zOffset, numXY);
                // shortData[t][c] = ushortImage.getPixels();
                zOffset += numXY;
            }
        }
    }
    fdos.shortSpecData = shortData;
    fdos.times = imagedataSets[0].getImageTimeStamps();
    if (fdos.times == null) {
        fdos.times = new double[imagedataSets[0].getSizeT()];
        for (int i = 0; i < fdos.times.length; i += 1) {
            fdos.times[i] = i;
        }
    }
    fdos.origin = (imagedataSets[0].getAllImages()[0].getOrigin() != null ? imagedataSets[0].getAllImages()[0].getOrigin() : new Origin(0, 0, 0));
    fdos.extent = (imagedataSets[0].getExtent() != null) ? (imagedataSets[0].getExtent()) : (new Extent(1, 1, 1));
    fdos.isize = imagedataSets[0].getISize();
    return fdos;
}
Also used : BngUnitOrigin(org.vcell.model.bngl.BngUnitSystem.BngUnitOrigin) Origin(org.vcell.util.Origin) Extent(org.vcell.util.Extent) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

Example 23 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class FieldDataGUIPanel method addNewExternalData.

public static AsynchClientTask[] addNewExternalData(final Component requester, final FieldDataGUIPanel fieldDataGUIPanel, final boolean isFromSimulation) {
    final RequestManager clientRequestManager = fieldDataGUIPanel.fieldDataWindowManager.getLocalRequestManager();
    AsynchClientTask task1 = new AsynchClientTask("creating field data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // Check if this is ImageJ op, if so, this task unnecessary
            if (hashTable.get(USER_DEFINED_FDOS) != null && hashTable.get(FIELD_NAME) != null) {
                return;
            }
            // Allow user to review/change info about fielddata
            FieldDataFileOperationSpec fdos = (FieldDataFileOperationSpec) hashTable.get("fdos");
            String initialExtDataName = (String) hashTable.get("initFDName");
            fdos.specEDI = null;
            FieldDataInfoPanel fdip = new FieldDataInfoPanel();
            fdip.setSimulationMode(isFromSimulation);
            fdip.initISize(fdos.isize);
            fdip.initIOrigin(fdos.origin);
            fdip.initIExtent(fdos.extent);
            fdip.initTimes(fdos.times);
            fdip.initNames(TokenMangler.fixTokenStrict(initialExtDataName), fdos.varNames);
            fdip.setAnnotation(fdos.annotation);
            FieldDataFileOperationSpec userDefinedFDOS = new FieldDataFileOperationSpec();
            while (true) {
                int choice = PopupGenerator.showComponentOKCancelDialog(requester, fdip, "Create new field data");
                if (choice == JOptionPane.OK_OPTION) {
                    // Check values
                    try {
                        userDefinedFDOS.extent = fdip.getExtent();
                    } catch (Exception e) {
                        PopupGenerator.showErrorDialog(requester, "Problem with Extent values. Please re-enter.\n" + e.getMessage() + "\nTry Again.", e);
                        continue;
                    }
                    try {
                        userDefinedFDOS.origin = fdip.getOrigin();
                    } catch (Exception e) {
                        PopupGenerator.showErrorDialog(requester, "Problem with Origin values. Please re-enter.\n" + e.getMessage() + "\nTry Again.", e);
                        continue;
                    }
                    try {
                        userDefinedFDOS.varNames = fdip.getVariableNames();
                    } catch (Exception e) {
                        PopupGenerator.showErrorDialog(requester, "Problem with Variable names. Please re-enter.\n" + e.getMessage() + "\nTry Again.", e);
                        continue;
                    }
                    userDefinedFDOS.annotation = fdip.getAnnotation();
                    userDefinedFDOS.times = fdip.getTimes();
                    try {
                        fieldDataGUIPanel.checkFieldDataName(fdip.getFieldName());
                    } catch (Exception e) {
                        PopupGenerator.showErrorDialog(requester, "Error saving Field Data Name to Database. Try again.\n" + e.getMessage(), e);
                        continue;
                    }
                    hashTable.put(USER_DEFINED_FDOS, userDefinedFDOS);
                    hashTable.put(FIELD_NAME, fdip.getFieldName());
                    break;
                } else {
                    throw UserCancelException.CANCEL_GENERIC;
                }
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("saving field data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // Add to Server Disk
            // save Database
            FieldDataFileOperationSpec tempFDOS = (FieldDataFileOperationSpec) hashTable.get(USER_DEFINED_FDOS);
            String fieldName = (String) hashTable.get(FIELD_NAME);
            FieldDataFileOperationSpec fdos = (FieldDataFileOperationSpec) hashTable.get("fdos");
            DocumentManager documentManager = clientRequestManager.getDocumentManager();
            FieldDataDBOperationSpec newExtDataIDSpec = FieldDataDBOperationSpec.createSaveNewExtDataIDSpec(documentManager.getUser(), fieldName, tempFDOS.annotation);
            tempFDOS.specEDI = documentManager.fieldDataDBOperation(newExtDataIDSpec).extDataID;
            fdos.specEDI = tempFDOS.specEDI;
            fdos.annotation = tempFDOS.annotation;
            try {
                if (!isFromSimulation) {
                    fdos.extent = tempFDOS.extent;
                    fdos.origin = tempFDOS.origin;
                    fdos.varNames = tempFDOS.varNames;
                    fdos.times = tempFDOS.times;
                    // 
                    // Subvolumes and Regions NOT implemented now
                    // 
                    fdos.cartesianMesh = CartesianMesh.createSimpleCartesianMesh(fdos.origin, fdos.extent, fdos.isize, new RegionImage(new // empty regions
                    VCImageUncompressed(// empty regions
                    null, // empty regions
                    new byte[fdos.isize.getXYZ()], fdos.extent, fdos.isize.getX(), fdos.isize.getY(), fdos.isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
                }
                // Add to Server Disk
                documentManager.fieldDataFileOperation(fdos);
            } catch (Exception e) {
                try {
                    // try to cleanup new ExtDataID
                    documentManager.fieldDataDBOperation(FieldDataDBOperationSpec.createDeleteExtDataIDSpec(fdos.specEDI));
                } catch (Exception e2) {
                // ignore
                }
                fdos.specEDI = null;
                throw e;
            }
        }
    };
    AsynchClientTask task3 = new AsynchClientTask("refreshing field data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FieldDataFileOperationSpec fdos = (FieldDataFileOperationSpec) hashTable.get("fdos");
            DefaultMutableTreeNode root = ((DefaultMutableTreeNode) fieldDataGUIPanel.getJTree1().getModel().getRoot());
            if (root.getChildCount() == 0) {
                fieldDataGUIPanel.updateJTree(clientRequestManager);
            } else {
                int alphabeticalIndex = -1;
                for (int i = 0; i < root.getChildCount(); i += 1) {
                    if ((((FieldDataMainList) ((DefaultMutableTreeNode) root.getChildAt(i)).getUserObject())).externalDataIdentifier.getName().compareToIgnoreCase(fdos.specEDI.getName()) > 0) {
                        alphabeticalIndex = i;
                        break;
                    }
                }
                if (alphabeticalIndex == -1) {
                    alphabeticalIndex = root.getChildCount();
                }
                DefaultMutableTreeNode mainNode = new DefaultMutableTreeNode(new FieldDataMainList(fdos.specEDI, fdos.annotation));
                mainNode.add(new DefaultMutableTreeNode(new FieldDataVarMainList()));
                ((DefaultTreeModel) fieldDataGUIPanel.getJTree1().getModel()).insertNodeInto(mainNode, root, alphabeticalIndex);
            }
        }
    };
    return new AsynchClientTask[] { task1, task2, task3 };
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Hashtable(java.util.Hashtable) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) DocumentManager(cbit.vcell.clientdb.DocumentManager) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException) RequestManager(cbit.vcell.client.RequestManager) ClientRequestManager(cbit.vcell.client.ClientRequestManager) RegionImage(cbit.vcell.geometry.RegionImage) FieldDataDBOperationSpec(cbit.vcell.field.FieldDataDBOperationSpec)

Example 24 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class FRAPStudy method getPSFFieldData.

public static FieldDataIdentifierSpec getPSFFieldData(LocalWorkspace localWorkspace) {
    // create ROI image
    short[] psfFieldData = null;
    psfFieldData = new short[9];
    psfFieldData[4] = (short) 1;
    // create field data
    int NumTimePoints = 1;
    // 8 rois integrated into 1 image
    int NumChannels = 1;
    short[][][] pixData = new short[NumTimePoints][NumChannels][1];
    pixData[0][0] = psfFieldData;
    // get extental data id
    ExternalDataIdentifier newPsfExtDataID = FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.PSF_DATA_NAME).getExternalDataIdentifier();
    CartesianMesh cartesianMesh;
    try {
        Origin origin = new Origin(0, 0, 0);
        Extent ext = new Extent(1, 1, 1);
        ISize isize = new ISize(3, 3, 1);
        cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, ext, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], ext, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
        FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
        fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
        fdos.cartesianMesh = cartesianMesh;
        fdos.shortSpecData = pixData;
        fdos.specEDI = newPsfExtDataID;
        fdos.varNames = new String[] { "psfVar" };
        fdos.owner = LocalWorkspace.getDefaultOwner();
        fdos.times = new double[] { 0.0 };
        fdos.variableTypes = new VariableType[] { VariableType.VOLUME };
        fdos.origin = origin;
        fdos.extent = ext;
        fdos.isize = isize;
        localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
        FieldFunctionArguments psfFieldFunc = new FieldFunctionArguments(PSF_DATA_NAME, "psfVar", new Expression(0.0), VariableType.VOLUME);
        FieldDataIdentifierSpec fdis = new FieldDataIdentifierSpec(psfFieldFunc, newPsfExtDataID);
        return fdis;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }
}
Also used : Origin(org.vcell.util.Origin) Extent(org.vcell.util.Extent) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) ISize(org.vcell.util.ISize) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) VCImageUncompressed(cbit.image.VCImageUncompressed) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Expression(cbit.vcell.parser.Expression) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) RegionImage(cbit.vcell.geometry.RegionImage)

Example 25 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class ROIMultiPaintManager method loadFD.

private void loadFD(Hashtable<String, Object> hashTable) throws Exception {
    final Exception[] excHolder = new Exception[] { null };
    final JDialog jDialog = new JDialog(JOptionPane.getFrameForComponent(this.overlayEditorPanelJAI));
    jDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    jDialog.setTitle("Import Type");
    jDialog.setModal(true);
    final JPanel okCancelJPanel = new JPanel(new FlowLayout());
    JButton okJButton = new JButton("from File...");
    okJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                fdDelta = new double[] { 0, 0, 0 };
                fdDeltaLast = new double[] { 0, 0, 0 };
                currScale = 1.0;
                currScaleLast = 1.0;
                VCDocument.DocumentCreationInfo documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FILE);
                final AsynchClientTask selectImageFile = ClientRequestManager.getSelectImageFileTask(overlayEditorPanelJAI, null);
                final AsynchClientTask parseImageTask = ClientRequestManager.getParseImageTask(overlayEditorPanelJAI, documentCreationInfo, null);
                final AsynchClientTask importFileImage = ClientRequestManager.getImportFileImageTask(documentCreationInfo);
                // final AsynchClientTask resizeImageTask = ClientRequestManager.getResizeImageTask(documentCreationInfo);
                hashTable.put(ClientRequestManager.GUI_PARENT, ROIMultiPaintManager.this.overlayEditorPanelJAI);
                selectImageFile.run(hashTable);
                parseImageTask.run(hashTable);
                hashTable.put(ClientRequestManager.NEW_IMAGE_SIZE_INFO, hashTable.get(ClientRequestManager.ORIG_IMAGE_SIZE_INFO));
                importFileImage.run(hashTable);
                // resizeImageTask.run(hashTable);
                saveFDUnderlay(hashTable);
            } catch (Exception e1) {
                excHolder[0] = e1;
            // e1.printStackTrace();
            // DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e1.getMessage());
            } finally {
                jDialog.dispose();
            }
        }
    });
    JButton fdJButton = new JButton("from FieldData...");
    fdJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                ArrayList<Object[]> allRows = new ArrayList<Object[]>();
                ArrayList<ISize> iSizes = new ArrayList<ISize>();
                ArrayList<CartesianMesh> meshes = new ArrayList<CartesianMesh>();
                // DocumentManager documentManager = documentManager.getSessionManager()..getRequestManager().getDocumentManager();
                FieldDataDBOperationSpec fdos = FieldDataDBOperationSpec.createGetExtDataIDsSpec(documentManager.getUser());
                FieldDataDBOperationResults fieldDataDBOperationResults = documentManager.fieldDataDBOperation(fdos);
                ExternalDataIdentifier[] externalDataIdentifierArr = fieldDataDBOperationResults.extDataIDArr;
                Arrays.sort(externalDataIdentifierArr, new Comparator<ExternalDataIdentifier>() {

                    @Override
                    public int compare(ExternalDataIdentifier o1, ExternalDataIdentifier o2) {
                        // TODO Auto-generated method stub
                        return o1.getName().compareToIgnoreCase(o2.getName());
                    }
                });
                ArrayList<ExternalDataIdentifier> okEDI = new ArrayList<ExternalDataIdentifier>();
                for (int i = 0; externalDataIdentifierArr != null && i < externalDataIdentifierArr.length; i++) {
                    try {
                        FieldDataFileOperationSpec fieldDataFileOperationSpec = FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(externalDataIdentifierArr[i].getSimulationKey(), externalDataIdentifierArr[i].getOwner(), externalDataIdentifierArr[i].getJobIndex());
                        FieldDataFileOperationResults fieldDataFileOperationResults = documentManager.fieldDataFileOperation(fieldDataFileOperationSpec);
                        // System.out.println(externalDataIdentifierArr[i].getName()+" "+fieldDataFileOperationResults.iSize);
                        ISize iSize = fieldDataFileOperationResults.iSize;
                        iSizes.add(iSize);
                        // isizes.add(iSize);
                        okEDI.add(externalDataIdentifierArr[i]);
                        allRows.add(new Object[] { iSize.getX(), iSize.getY(), iSize.getZ(), "FieldData='" + externalDataIdentifierArr[i].getName() + "'" });
                        VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[iSize.getXYZ()], fieldDataFileOperationResults.extent, iSize.getX(), iSize.getY(), iSize.getZ());
                        int dimension = 1 + (iSize.getY() > 1 ? 1 : 0) + (iSize.getZ() > 1 ? 1 : 0);
                        CartesianMesh simpleMesh = CartesianMesh.createSimpleCartesianMesh(fieldDataFileOperationResults.origin, fieldDataFileOperationResults.extent, iSize, new RegionImage(vcImageUnc, dimension, fieldDataFileOperationResults.extent, fieldDataFileOperationResults.origin, RegionImage.NO_SMOOTHING));
                        meshes.add(simpleMesh);
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
                if (allRows.size() > 0) {
                    Object[][] rowData = allRows.toArray(new Object[0][]);
                    int[] selections = DialogUtils.showComponentOKCancelTableList(ROIMultiPaintManager.this.overlayEditorPanelJAI, "Select Simulation for Geom Size", new String[] { "X", "Y", "Z", "Name" }, rowData, ListSelectionModel.SINGLE_SELECTION);
                    if (selections != null && selections.length == 1) {
                        FieldDataFileOperationResults fdfor = documentManager.fieldDataFileOperation(FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(okEDI.get(selections[0]).getSimulationKey(), okEDI.get(selections[0]).getOwner(), okEDI.get(selections[0]).getJobIndex()));
                        SimDataBlock simDataBlock = VCellClientTest.getVCellClient().getClientServerManager().getDataSetController().getSimDataBlock(null, okEDI.get(selections[0]), fdfor.dataIdentifierArr[0].getName(), 0.0);
                        FieldDataFileOperationSpec fieldDataFileOperationSpec = new FieldDataFileOperationSpec();
                        fieldDataFileOperationSpec.isize = meshes.get(selections[0]).getISize();
                        fieldDataFileOperationSpec.shortSpecData = new short[][][] { { new short[fieldDataFileOperationSpec.isize.getXYZ()] } };
                        for (int i = 0; i < simDataBlock.getData().length; i++) {
                            fieldDataFileOperationSpec.shortSpecData[0][0][i] = (short) simDataBlock.getData()[i];
                        // if(simDataBlock.getData()[i] != 0) {
                        // System.out.println(simDataBlock.getData()[i]);
                        // }
                        }
                        hashTable.put(ClientRequestManager.FDFOS, fieldDataFileOperationSpec);
                        hashTable.put(ClientRequestManager.IMPORT_SOURCE_NAME, "FieldData=" + okEDI.get(selections[0]).getName());
                        saveFDUnderlay(hashTable);
                    // ROIMultiPaintManager.this.fdShort = (FieldDataFileOperationSpec)hashTable.get(ClientRequestManager.FDFOS);
                    // ROIMultiPaintManager.this.importSourceName = (String)hashTable.get(ClientRequestManager.IMPORT_SOURCE_NAME);
                    // (outMax-outMin)(inVal - inMin)
                    // ------------------------------ + outMin
                    // inMax - inMin
                    // externalDataIdentifierArr[selections[0]].
                    // //						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);
                    // hashTable.put(ClientRequestManager.NEW_IMAGE_SIZE_INFO, imagesizeInfo);
                    // 
                    // VCImage 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));
                    // 
                    // hashTable.put("newMesh", meshes.get(selections[0]));
                    // hashTable.put("sourceMesh", sourceMesh);
                    }
                }
            } catch (Exception e1) {
                excHolder[0] = e1;
            // e1.printStackTrace();
            // DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e1.getMessage());
            } finally {
                jDialog.dispose();
            }
        }
    });
    JButton clipbboardJButton = new JButton("from Clipboard");
    clipbboardJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            try {
                Object transferData = contents.getTransferData(DataFlavor.stringFlavor);
                if (transferData instanceof String) {
                    StringTokenizer st = new StringTokenizer(((String) transferData).toString(), ",");
                    String varName = st.nextToken();
                    String vcDataIdentifer = st.nextToken();
                    double timePoint = Double.parseDouble(st.nextToken());
                    ISize isize = new ISize(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
                    Range inRange = new Range(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
                    String simDataFile = st.nextToken();
                    DataInputStream dis = new DataInputStream(new FileInputStream(simDataFile));
                    FieldDataFileOperationSpec fieldDataFileOperationSpec = new FieldDataFileOperationSpec();
                    fieldDataFileOperationSpec.isize = isize;
                    fieldDataFileOperationSpec.shortSpecData = new short[][][] { { new short[fieldDataFileOperationSpec.isize.getXYZ()] } };
                    double outMax = 65535;
                    double outMin = 0;
                    double scale = (outMax - outMin) / (inRange.getMax() - inRange.getMin());
                    for (int i = 0; i < isize.getXYZ(); i++) {
                        double val = dis.readDouble();
                        fieldDataFileOperationSpec.shortSpecData[0][0][i] = (short) (scale * (val - inRange.getMin()) + outMin);
                    }
                    hashTable.put(ClientRequestManager.FDFOS, fieldDataFileOperationSpec);
                    hashTable.put(ClientRequestManager.IMPORT_SOURCE_NAME, "SimData=" + vcDataIdentifer + " varName=" + varName + " time=" + timePoint);
                    saveFDUnderlay(hashTable);
                    ROIMultiPaintManager.this.overlayEditorPanelJAI.setFDScale(new double[] { scale, inRange.getMin(), outMin });
                }
            } catch (Exception e1) {
                excHolder[0] = e1;
            // e1.printStackTrace();
            // DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e1.getMessage());
            } finally {
                jDialog.dispose();
            }
        }
    });
    final boolean[] bCanelHolder = new boolean[] { false };
    JButton cancelJButton = new JButton("Cancel");
    cancelJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            jDialog.dispose();
            bCanelHolder[0] = true;
        }
    });
    okCancelJPanel.add(okJButton);
    okCancelJPanel.add(fdJButton);
    okCancelJPanel.add(clipbboardJButton);
    okCancelJPanel.add(cancelJButton);
    jDialog.getContentPane().add(okCancelJPanel, BorderLayout.SOUTH);
    jDialog.pack();
    // jDialog.setSize(300,250);
    DialogUtils.showModalJDialogOnTop(jDialog, overlayEditorPanelJAI);
    if (bCanelHolder[0]) {
        throw UserCancelException.CANCEL_GENERIC;
    }
    if (excHolder[0] != null) {
        throw excHolder[0];
    }
}
Also used : JPanel(javax.swing.JPanel) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ISize(org.vcell.util.ISize) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) SimDataBlock(cbit.vcell.simdata.SimDataBlock) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FieldDataDBOperationResults(cbit.vcell.field.FieldDataDBOperationResults) FieldDataDBOperationSpec(cbit.vcell.field.FieldDataDBOperationSpec) FieldDataFileOperationResults(cbit.vcell.field.io.FieldDataFileOperationResults) VCDocument(org.vcell.util.document.VCDocument) Transferable(java.awt.datatransfer.Transferable) VCImageUncompressed(cbit.image.VCImageUncompressed) Range(org.vcell.util.Range) DataInputStream(java.io.DataInputStream) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException) FileInputStream(java.io.FileInputStream) CartesianMesh(cbit.vcell.solvers.CartesianMesh) StringTokenizer(java.util.StringTokenizer) ActionListener(java.awt.event.ActionListener) RegionImage(cbit.vcell.geometry.RegionImage) JDialog(javax.swing.JDialog)

Aggregations

FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)29 ISize (org.vcell.util.ISize)19 Origin (org.vcell.util.Origin)18 CartesianMesh (cbit.vcell.solvers.CartesianMesh)16 Extent (org.vcell.util.Extent)16 RegionImage (cbit.vcell.geometry.RegionImage)14 UserCancelException (org.vcell.util.UserCancelException)13 VCImageUncompressed (cbit.image.VCImageUncompressed)12 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)10 VCImage (cbit.image.VCImage)9 ImageException (cbit.image.ImageException)8 Hashtable (java.util.Hashtable)8 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)7 VariableType (cbit.vcell.math.VariableType)6 DataFormatException (java.util.zip.DataFormatException)6 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)5 File (java.io.File)5 ClientRequestManager (cbit.vcell.client.ClientRequestManager)4 RequestManager (cbit.vcell.client.RequestManager)4 SimDataBlock (cbit.vcell.simdata.SimDataBlock)4