Search in sources :

Example 21 with UserCancelException

use of org.vcell.util.UserCancelException in project vcell by virtualcell.

the class ReactionCartoonTool method detailsDeleteSpecies.

private static DeleteSpeciesInfo detailsDeleteSpecies(Component requester, SpeciesContext[] speciesContextArr, ReactionStep[] toBeDeletedReactStepArr, ReactionCartoon rxCartoon) throws Exception, UserCancelException {
    if (speciesContextArr == null || speciesContextArr.length == 0) {
        return null;
    }
    // Warn user that there may be some BioModel components that reference speciesContext to be removed
    // Get ReactionParticipant list
    Collection<Shape> rxPartColl = rxCartoon.getShapes();
    HashMap<SpeciesContext, HashSet<ReactionParticipant>> rxPartHashMap = new HashMap<SpeciesContext, HashSet<ReactionParticipant>>();
    for (Shape objShape : rxPartColl) {
        if (objShape instanceof ReactionParticipantShape) {
            ReactionParticipant objReactionParticipant = ((ReactionParticipantShape) objShape).getReactionParticipant();
            if (Arrays.asList(speciesContextArr).contains(objReactionParticipant.getSpeciesContext())) {
                if (!rxPartHashMap.containsKey(objReactionParticipant.getSpeciesContext())) {
                    rxPartHashMap.put(objReactionParticipant.getSpeciesContext(), new HashSet<ReactionParticipant>());
                }
                if (!rxPartHashMap.get(objReactionParticipant.getSpeciesContext()).contains(objReactionParticipant)) {
                    rxPartHashMap.get(objReactionParticipant.getSpeciesContext()).add(objReactionParticipant);
                }
            }
        }
    }
    int reactionParticipantCount = 0;
    for (HashSet<ReactionParticipant> objReactPart : rxPartHashMap.values()) {
        reactionParticipantCount += objReactPart.size();
    }
    // find bioModel and get SymbolTable references to SpeciesContext
    BioModelEditor bioModelEditor = (BioModelEditor) BeanUtils.findTypeParentOfComponent(requester, BioModelEditor.class);
    if (bioModelEditor == null) {
        throw new Exception("Error deleting Speciescontext, Can't find BiomodelEditor");
    }
    BioModel bioModel = bioModelEditor.getBioModelWindowManager().getVCDocument();
    HashMap<SpeciesContext, HashSet<SymbolTableEntry>> referencingSymbolsHashMap = new HashMap<SpeciesContext, HashSet<SymbolTableEntry>>();
    for (int i = 0; i < speciesContextArr.length; i++) {
        List<SymbolTableEntry> referencingSymbolsList = bioModel.findReferences(speciesContextArr[i]);
        if (referencingSymbolsList != null && referencingSymbolsList.size() > 0) {
            if (!referencingSymbolsHashMap.containsKey(speciesContextArr[i])) {
                referencingSymbolsHashMap.put(speciesContextArr[i], new HashSet<SymbolTableEntry>());
            }
            referencingSymbolsHashMap.get(speciesContextArr[i]).addAll(referencingSymbolsList);
        }
    }
    int referencingSymbolsCount = 0;
    for (HashSet<SymbolTableEntry> objSimTableEntry : referencingSymbolsHashMap.values()) {
        referencingSymbolsCount += objSimTableEntry.size();
    }
    // Warn user about delete
    HashMap<SpeciesContext, Boolean> bUnresolvableHashMap = new HashMap<SpeciesContext, Boolean>();
    for (int i = 0; i < speciesContextArr.length; i++) {
        bUnresolvableHashMap.put(speciesContextArr[i], Boolean.FALSE);
    }
    String[][] rowData = null;
    if (rxPartHashMap.size() == 0 && referencingSymbolsHashMap.size() == 0) {
        rowData = new String[speciesContextArr.length][4];
        for (int i = 0; i < speciesContextArr.length; i++) {
            rowData[i][0] = speciesContextArr[i].getName();
            rowData[i][1] = "";
            rowData[i][2] = "";
            rowData[i][3] = "";
        }
        Arrays.sort(rowData, new Comparator<String[]>() {

            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[0].compareToIgnoreCase(o2[0]);
            }
        });
    } else {
        // find SpeciesContext that had no reference warnings
        Vector<SpeciesContext> speciesContextNoReferences = new Vector<SpeciesContext>();
        for (int i = 0; i < speciesContextArr.length; i++) {
            if (!rxPartHashMap.containsKey(speciesContextArr[i]) && !referencingSymbolsHashMap.containsKey(speciesContextArr[i])) {
                speciesContextNoReferences.add(speciesContextArr[i]);
            }
        }
        rowData = new String[reactionParticipantCount + referencingSymbolsCount + speciesContextNoReferences.size()][4];
        int count = 0;
        for (SpeciesContext objSpeciesContext : speciesContextNoReferences) {
            rowData[count][0] = objSpeciesContext.getName();
            rowData[count][1] = "";
            rowData[count][2] = "";
            rowData[count][3] = "";
            count++;
        }
        for (SpeciesContext objSpeciesContext : rxPartHashMap.keySet()) {
            Iterator<ReactionParticipant> iterRxPart = rxPartHashMap.get(objSpeciesContext).iterator();
            while (iterRxPart.hasNext()) {
                rowData[count][0] = objSpeciesContext.getName();
                rowData[count][1] = "";
                rowData[count][2] = "Reaction Diagram stoichiometry '" + iterRxPart.next().getReactionStep().getName() + "'";
                rowData[count][3] = "";
                count++;
            }
        }
        for (SpeciesContext objSpeciesContext : referencingSymbolsHashMap.keySet()) {
            Iterator<SymbolTableEntry> iterSymbolTableEntry = referencingSymbolsHashMap.get(objSpeciesContext).iterator();
            while (iterSymbolTableEntry.hasNext()) {
                rowData[count][0] = objSpeciesContext.getName();
                rowData[count][1] = "";
                SymbolTableEntry objSymbolTableEntry = iterSymbolTableEntry.next();
                boolean bKineticsParameter = objSymbolTableEntry instanceof KineticsParameter;
                if (bKineticsParameter) {
                    KineticsParameter kp = (KineticsParameter) objSymbolTableEntry;
                    boolean isOK = kp.isRegenerated();
                    for (int i = 0; toBeDeletedReactStepArr != null && i < toBeDeletedReactStepArr.length; i++) {
                        if (toBeDeletedReactStepArr[i] == kp.getKinetics().getReactionStep()) {
                            // OK to delete this Speciescontext if were deleting the reaction that contained the reference
                            isOK = true;
                        }
                    }
                    rowData[count][1] = (isOK ? "" : RXSPECIES_ERROR);
                    bUnresolvableHashMap.put(objSpeciesContext, bUnresolvableHashMap.get(objSpeciesContext) || !isOK);
                }
                boolean bReaction = objSymbolTableEntry.getNameScope() instanceof ReactionNameScope;
                rowData[count][2] = (bReaction ? "Reaction" : objSymbolTableEntry.getNameScope().getClass().getName()) + "( " + objSymbolTableEntry.getNameScope().getName() + " )";
                rowData[count][3] = (bKineticsParameter ? "Parameter" : objSymbolTableEntry.getClass().getName()) + "( " + objSymbolTableEntry.getName() + " )";
                count++;
            }
        }
        // for (SymbolTableEntry referencingSTE : referencingSymbols) {
        // System.out.println("REFERENCE   "+referencingSTE.getClass().getName()+"("+referencingSTE.getName()+") nameScope "+referencingSTE.getNameScope().getClass().getName()+"("+referencingSTE.getNameScope().getName()+")");
        // }
        Arrays.sort(rowData, new Comparator<String[]>() {

            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[0].compareToIgnoreCase(o2[0]);
            }
        });
    }
    if (rowData == null || rowData.length == 0) {
        return null;
    }
    return new DeleteSpeciesInfo(rxPartHashMap, bUnresolvableHashMap, rowData);
}
Also used : SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RubberBandRectShape(cbit.gui.graph.RubberBandRectShape) ProductShape(cbit.vcell.graph.ProductShape) ContainerShape(cbit.gui.graph.ContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactantShape(cbit.vcell.graph.ReactantShape) ElipseShape(cbit.gui.graph.ElipseShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) SpeciesContext(cbit.vcell.model.SpeciesContext) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) Vector(java.util.Vector) ReactionNameScope(cbit.vcell.model.ReactionStep.ReactionNameScope) HashSet(java.util.HashSet) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) BioModel(cbit.vcell.biomodel.BioModel) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 22 with UserCancelException

use of org.vcell.util.UserCancelException in project vcell by virtualcell.

the class ROIMultiPaintManager method showGUI.

public Geometry showGUI(final String okButtonText, final String sourceDataName, final Component parentComponent, String initalAnnotation, final VCPixelClass[] vcPixelClasses, UserPreferences userPreferences) {
    originalAnnotation = initalAnnotation;
    final Geometry[] finalGeometryHolder = new Geometry[1];
    if (overlayEditorPanelJAI == null) {
        overlayEditorPanelJAI = new OverlayEditorPanelJAI();
        overlayEditorPanelJAI.setCalcCoords(new CalcCoords());
        overlayEditorPanelJAI.setUserPreferences(userPreferences);
        overlayEditorPanelJAI.setMinimumSize(new Dimension(700, 600));
        overlayEditorPanelJAI.setPreferredSize(new Dimension(700, 600));
        overlayEditorPanelJAI.addPropertyChangeListener(ROIMultiPaintManager.this);
    }
    // delete all names
    overlayEditorPanelJAI.deleteROIName(null);
    // when user selects image "from DB" or "from current geometry"
    applyPixelClasses(vcPixelClasses, parentComponent);
    if (getImageDataset().length > 1) {
        String[] channelNames = new String[getImageDataset().length];
        for (int i = 0; i < channelNames.length; i++) {
            channelNames[i] = "channel " + i;
        }
        overlayEditorPanelJAI.setChannelNames(channelNames);
    } else {
        overlayEditorPanelJAI.setChannelNames(null);
    }
    updateUnderlayHistogramDisplay();
    overlayEditorPanelJAI.setContrastToMinMax();
    overlayEditorPanelJAI.setAllROICompositeImage(roiComposite, OverlayEditorPanelJAI.FRAP_DATA_INIT_PROPERTY);
    final JDialog jDialog = new JDialog(JOptionPane.getFrameForComponent(parentComponent));
    jDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    jDialog.setTitle("Geometry Editor (" + sourceDataName + ")");
    jDialog.setModal(true);
    final JButton cancelJButton = new JButton("Cancel");
    cancelJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final String QUIT_ANSWER = "Quit Geometry Editor";
            String result = DialogUtils.showWarningDialog(jDialog, "Confirm cancel", "Quit geometry editor and lose all changes?", new String[] { QUIT_ANSWER, "back" }, QUIT_ANSWER);
            if (result != null && result.equals(QUIT_ANSWER)) {
                jDialog.dispose();
            }
        }
    });
    jDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent e) {
            super.windowOpened(e);
            if (bHasOriginalData) {
                calculateHistogram();
            }
            updateUndoAfter(false);
            if (vcPixelClasses == null) {
                askInitialize(false);
            }
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // TODO Auto-generated method stub
            super.windowClosing(e);
            cancelJButton.doClick();
        }
    });
    final JPanel okCancelJPanel = new JPanel(new FlowLayout());
    JButton okJButton = new JButton(okButtonText);
    okJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                VCImage finalImage = checkAll();
                finalImage.setDescription((editedGeometryAttributes != null ? editedGeometryAttributes.annotation : originalAnnotation));
                finalGeometryHolder[0] = new Geometry((String) null, finalImage);
                finalGeometryHolder[0].getGeometrySpec().setOrigin((editedGeometryAttributes != null ? editedGeometryAttributes.origin : originalOrigin));
                finalGeometryHolder[0].getGeometrySpec().setExtent((editedGeometryAttributes != null ? editedGeometryAttributes.extent : originalExtent));
                finalGeometryHolder[0].setDescription((editedGeometryAttributes != null ? editedGeometryAttributes.annotation : originalAnnotation));
                jDialog.dispose();
            } catch (UserCancelException uce) {
            } catch (Exception exc) {
                DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Error validating compartments.\n" + exc.getMessage(), exc);
            }
        }
    });
    JButton attributesJButton = new JButton("Attributes...");
    attributesJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                editedGeometryAttributes = showEditGeometryAttributes(jDialog, editedGeometryAttributes);
            } catch (UserCancelException uce) {
            // ignore
            }
        }
    });
    // JButton surfaceButton = new JButton("View Surfaces...");
    // surfaceButton.addActionListener(new ActionListener() {
    // public void actionPerformed(ActionEvent e) {
    // showDataValueSurfaceViewer(geomAttr);
    // }
    // });
    JButton exportJButton = new JButton("Export...");
    exportJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            export();
        }
    });
    JButton importJButton = new JButton("Import stl...");
    importJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFileChooser importJFC = new JFileChooser(ClientRequestManager.getPreferredPath(UserPreferences.getLastUserPreferences()));
            importJFC.setDialogTitle("Choose .stl file(s) to import");
            importJFC.setMultiSelectionEnabled(true);
            int result = importJFC.showOpenDialog(overlayEditorPanelJAI);
            if (result == JFileChooser.APPROVE_OPTION) {
                File[] selectedFiles = importJFC.getSelectedFiles();
                if (selectedFiles != null && selectedFiles.length > 0) {
                    ClientRequestManager.setPreferredPath(UserPreferences.getLastUserPreferences(), selectedFiles[0]);
                    Vect3d sampleSize = new Vect3d(getImageDataset()[0].getISize().getX(), getImageDataset()[0].getISize().getY(), getImageDataset()[0].getISize().getZ());
                    ArrayList<AsynchClientTask> stlImportTasks = getImportSTLtasks(selectedFiles, sampleSize, new Vect3d(0, 0, 0));
                    ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<>(), stlImportTasks.toArray(new AsynchClientTask[0]));
                } else {
                    DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Select at least 1 .stl file for import.");
                }
            }
        }
    });
    okCancelJPanel.add(okJButton);
    okCancelJPanel.add(attributesJButton);
    okCancelJPanel.add(exportJButton);
    okCancelJPanel.add(importJButton);
    // okCancelJPanel.add(surfaceButton);
    okCancelJPanel.add(cancelJButton);
    jDialog.getContentPane().add(overlayEditorPanelJAI, BorderLayout.CENTER);
    jDialog.getContentPane().add(okCancelJPanel, BorderLayout.SOUTH);
    jDialog.setSize(700, 600);
    DialogUtils.showModalJDialogOnTop(jDialog, parentComponent);
    if (finalGeometryHolder[0] == null) {
        throw UserCancelException.CANCEL_GENERIC;
    }
    return finalGeometryHolder[0];
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) Hashtable(java.util.Hashtable) JButton(javax.swing.JButton) UserCancelException(org.vcell.util.UserCancelException) ArrayList(java.util.ArrayList) WindowAdapter(java.awt.event.WindowAdapter) VCImage(cbit.image.VCImage) Dimension(java.awt.Dimension) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException) Vect3d(cbit.vcell.render.Vect3d) Geometry(cbit.vcell.geometry.Geometry) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) WindowEvent(java.awt.event.WindowEvent) JDialog(javax.swing.JDialog)

Example 23 with UserCancelException

use of org.vcell.util.UserCancelException in project vcell by virtualcell.

the class ROIMultiPaintManager method showEditGeometryAttributes.

private GeometryAttributes showEditGeometryAttributes(Component parentComponent, GeometryAttributes currentGeometryAttributes) throws UserCancelException {
    final GeometryAttributes[] finalGeometryAttributesHolder = new GeometryAttributes[1];
    final boolean[] cancelHolder = new boolean[] { false };
    final CopyOfImageAttributePanel copyOfImageAttributePanel = new CopyOfImageAttributePanel();
    if (currentGeometryAttributes == null) {
        copyOfImageAttributePanel.init(originalOrigin, createResizeExtent(originalExtent, originalISize, getImageDataSetChannel().getISize()), getImageDataSetChannel().getISize(), originalAnnotation);
    } else {
        copyOfImageAttributePanel.init(currentGeometryAttributes.origin, currentGeometryAttributes.extent, getImageDataSetChannel().getISize(), currentGeometryAttributes.annotation);
    }
    final JDialog jDialog = new JDialog(JOptionPane.getFrameForComponent(parentComponent));
    jDialog.setTitle("Edit Geometry Attributes");
    jDialog.setModal(true);
    JPanel okCancelJPanel = new JPanel(new FlowLayout());
    JButton okJButton = new JButton("OK");
    okJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                finalGeometryAttributesHolder[0] = new GeometryAttributes();
                finalGeometryAttributesHolder[0].annotation = copyOfImageAttributePanel.getEditedAnnotation();
                finalGeometryAttributesHolder[0].origin = copyOfImageAttributePanel.getEditedOrigin();
                finalGeometryAttributesHolder[0].extent = copyOfImageAttributePanel.getEditedExtent();
                jDialog.dispose();
            } catch (UserCancelException uce) {
            } catch (Exception exc) {
                DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Error validating Geometry attributes.\n" + exc.getMessage(), exc);
            }
        }
    });
    JButton cancelJButton = new JButton("Cancel");
    cancelJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            cancelHolder[0] = true;
            jDialog.dispose();
        }
    });
    okCancelJPanel.add(okJButton);
    okCancelJPanel.add(cancelJButton);
    jDialog.getContentPane().add(copyOfImageAttributePanel, BorderLayout.CENTER);
    jDialog.getContentPane().add(okCancelJPanel, BorderLayout.SOUTH);
    jDialog.setSize(500, 300);
    DialogUtils.showModalJDialogOnTop(jDialog, overlayEditorPanelJAI);
    if (cancelHolder[0]) {
        throw UserCancelException.CANCEL_GENERIC;
    }
    return finalGeometryAttributesHolder[0];
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) UserCancelException(org.vcell.util.UserCancelException) JDialog(javax.swing.JDialog) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

Example 24 with UserCancelException

use of org.vcell.util.UserCancelException in project vcell by virtualcell.

the class ROIMultiPaintManager method sampleAnalyticIntoImage.

private void sampleAnalyticIntoImage(OverlayEditorPanelJAI.ImgSubVolHelper imgSubVolHelper) {
    try {
        Extent extent = (editedGeometryAttributes == null ? originalExtent : editedGeometryAttributes.extent);
        Origin orig = (editedGeometryAttributes == null ? originalOrigin : editedGeometryAttributes.origin);
        int numX = roiComposite[0].getWidth();
        int numY = roiComposite[0].getHeight();
        int numZ = roiComposite.length;
        int dim = (roiComposite.length > 1 ? 1 : 0) + (roiComposite[0].getHeight() > 1 ? 1 : 0) + 1;
        double cX = calcCoord(imgSubVolHelper.getMousePoint().x, numX, orig.getX(), extent.getX());
        double cY = calcCoord(imgSubVolHelper.getMousePoint().y, numY, orig.getY(), extent.getY());
        double cZ = calcCoord(imgSubVolHelper.getZCenter(), numZ, orig.getZ(), extent.getZ());
        Coordinate center = new Coordinate(cX, cY, cZ);
        AnalyticSubVolume tempSV = GeometrySubVolumePanel.createAnalyticSubVolume(overlayEditorPanelJAI, dim, center, "tempSV");
        tempSV.rebind();
        for (int k = 0; k < numZ; k++) {
            double coordZ = calcCoord(k, numZ, orig.getZ(), extent.getZ());
            for (int j = 0; j < numY; j++) {
                double coordY = calcCoord(j, numY, orig.getY(), extent.getY());
                for (int i = 0; i < numX; i++) {
                    double coordX = calcCoord(i, numX, orig.getX(), extent.getX());
                    if (tempSV.isInside(coordX, coordY, coordZ, null)) {
                        ((DataBufferByte) roiComposite[k].getRaster().getDataBuffer()).getData()[j * numX + i] = (byte) (imgSubVolHelper.getCurrentSubVolHandle().getContrastColorIndex());
                    }
                }
            }
        }
    } catch (UserCancelException uce) {
    // ignore
    } catch (Exception e) {
        DialogUtils.showErrorDialog(overlayEditorPanelJAI, e.getClass().getName() + " " + e.getMessage());
    }
}
Also used : Origin(org.vcell.util.Origin) Extent(org.vcell.util.Extent) Coordinate(org.vcell.util.Coordinate) UserCancelException(org.vcell.util.UserCancelException) DataBufferByte(java.awt.image.DataBufferByte) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

Example 25 with UserCancelException

use of org.vcell.util.UserCancelException in project vcell by virtualcell.

the class ROIMultiPaintManager method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_CROP_PROPERTY)) {
        try {
            overlayEditorPanelJAI.cropDrawAndConfirm((Rectangle) evt.getNewValue());
            Rectangle rect2D = (Rectangle) evt.getNewValue();
            ROIMultiPaintManager.Crop3D crop3D = new ROIMultiPaintManager.Crop3D();
            crop3D.setBounds(rect2D.x, rect2D.y, 0, rect2D.width, rect2D.height, roiComposite.length);
            cropROIData(crop3D);
        } catch (UserCancelException e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_CURRENTROI_PROPERTY)) {
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_DELETEROI_PROPERTY)) {
        try {
            deleteROI((ComboboxROIName) evt.getOldValue());
            updateUndoAfter(false);
        } catch (Exception e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_ADDNEWROI_PROPERTY)) {
        try {
            addNewROI((ComboboxROIName[]) evt.getOldValue(), (String) evt.getNewValue());
            updateUndoAfter(false);
        } catch (UserCancelException e) {
            updateUndoAfter(null);
        } catch (Exception e) {
            e.printStackTrace();
            DialogUtils.showErrorDialog(overlayEditorPanelJAI, e.getMessage());
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_CLEARROI_PROPERTY)) {
        try {
            FLAG_CLEAR_ROI flag = askClearROI();
            updateUndo(UNDO_INIT.ALLZ);
            clearROI(flag, ((ComboboxROIName) evt.getOldValue()).getContrastColorIndex(), OverlayEditorPanelJAI.FRAP_DATA_CLEARROI_PROPERTY);
            updateUndoAfter(true);
        } catch (UserCancelException e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_BLEND_PROPERTY)) {
        overlayEditorPanelJAI.setBlendPercent((Integer) evt.getNewValue());
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_RESOLVEDHIGHLIGHT_PROPERTY)) {
        highliteImageWithResolvedSelections((RegionInfo[]) evt.getNewValue());
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_RESOLVEDMERGE_PROPERTY)) {
        try {
            mergeResolvedSelections((RegionInfo[]) evt.getNewValue());
        } catch (Exception e) {
            e.printStackTrace();
            DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Merge failed\n" + e.getMessage());
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_AUTOCROP_PROPERTY)) {
        try {
            autoCropQuestion();
        } catch (UserCancelException e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_HISTOGRAM_PROPERTY)) {
        overlayEditorPanelJAI.setHighliteInfo(null, OverlayEditorPanelJAI.FRAP_DATA_HISTOGRAM_PROPERTY);
        calculateHistogram();
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_HISTOUPDATEHIGHLIGHT_PROPERTY)) {
        highlightHistogramPixels((DefaultListSelectionModel) evt.getNewValue());
        wantBlendSetToEnhance();
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_UPDATEROI_WITHHIGHLIGHT_PROPERTY)) {
        try {
            updateROIWithHighlight();
            wantBlendSetToEnhance();
        } catch (Exception e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_UNDERLAY_SMOOTH_PROPERTY)) {
        if (!overlayEditorPanelJAI.isHistogramSelectionEmpty()) {
            overlayEditorPanelJAI.setHighliteInfo(null, OverlayEditorPanelJAI.FRAP_DATA_UNDERLAY_SMOOTH_PROPERTY);
        }
        enhanceImageAmount = (Integer) evt.getNewValue();
        smoothUnderlay();
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_DISCARDHIGHLIGHT_PROPERTY)) {
        overlayEditorPanelJAI.setHighliteInfo(null, OverlayEditorPanelJAI.FRAP_DATA_DISCARDHIGHLIGHT_PROPERTY);
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_ADDANALYTIC_PROPERTY)) {
        updateUndo(UNDO_INIT.ALLZ);
        sampleAnalyticIntoImage((OverlayEditorPanelJAI.ImgSubVolHelper) evt.getNewValue());
        updateUndoAfter(true);
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_FILL_PROPERTY)) {
        updateUndo(UNDO_INIT.ONEZ);
        fillFromPoint((Point) evt.getNewValue());
        updateUndoAfter(true);
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_CHANNEL_PROPERTY)) {
        imageDatasetChannel = (Integer) evt.getNewValue();
        if (!overlayEditorPanelJAI.isHistogramSelectionEmpty()) {
            overlayEditorPanelJAI.setHighliteInfo(null, OverlayEditorPanelJAI.FRAP_DATA_CHANNEL_PROPERTY);
        }
        updateUnderlayHistogramDisplay();
    } else // }
    if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_PAD_PROPERTY)) {
        try {
            padROIDataAsk();
        } catch (Exception e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_DUPLICATE_PROPERTY)) {
        try {
            duplicateROIDataAsk();
        } catch (Exception e) {
            updateUndoAfter(null);
        }
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_PAINTERASE_PROPERTY)) {
        wantBlendSetToEnhance();
        updateUndo(UNDO_INIT.ONEZ);
        updateUndoAfterPrivate(true, false);
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_UNDOROI_PROPERTY)) {
        recoverUndo();
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_PAINTERASE_FINISH_PROPERTY)) {
        refreshObjects();
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_FINDROI_PROPERTY)) {
        findROI((RegionInfo) evt.getNewValue());
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_SELECTIMGROI_PROPERTY)) {
        pickImgROI((SelectImgInfo) evt.getNewValue());
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_CONVERTDOMAIN_PROPERTY)) {
        convertDomain((Integer) evt.getNewValue(), (RegionInfo[]) evt.getOldValue());
    } else if (evt.getPropertyName().equals(OverlayEditorPanelJAI.FRAP_DATA_SEPARATE_PROPERTY)) {
        updateUndo(UNDO_INIT.ALLZ);
        separateDomains();
        updateUndoAfter(true);
    }
}
Also used : Rectangle(java.awt.Rectangle) UserCancelException(org.vcell.util.UserCancelException) RegionInfo(cbit.vcell.geometry.RegionImage.RegionInfo) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

Aggregations

UserCancelException (org.vcell.util.UserCancelException)44 Hashtable (java.util.Hashtable)15 UtilCancelException (org.vcell.util.UtilCancelException)15 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)14 PropertyVetoException (java.beans.PropertyVetoException)11 DataAccessException (org.vcell.util.DataAccessException)10 Vector (java.util.Vector)9 ActionEvent (java.awt.event.ActionEvent)8 DataFormatException (java.util.zip.DataFormatException)8 BioModel (cbit.vcell.biomodel.BioModel)7 ActionListener (java.awt.event.ActionListener)7 IOException (java.io.IOException)7 Point (java.awt.Point)6 ArrayList (java.util.ArrayList)6 ImageException (cbit.image.ImageException)5 CSGObject (cbit.vcell.geometry.CSGObject)5 GeometryException (cbit.vcell.geometry.GeometryException)5 Structure (cbit.vcell.model.Structure)5 JButton (javax.swing.JButton)5 ProgrammingException (org.vcell.util.ProgrammingException)5