Search in sources :

Example 51 with StereoMolecule

use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.

the class ChangeAtomPropertiesAction method onMouseUp.

@Override
public boolean onMouseUp(IMouseEvent evt) {
    model.pushUndo();
    int theAtom = model.getSelectedAtom();
    StereoMolecule mol = model.getMolecule();
    if (mol != null && theAtom != -1) {
        GeomFactory builder = model.getGeomFactory();
        IAtomPropertiesDialog dlg = builder.createAtomPropertiesDialog(mol, theAtom);
        if (dlg.doModalAt(evt.getX(), evt.getY()) == DialogResult.IDOK) {
            return true;
        }
    }
    return false;
}
Also used : GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) IAtomPropertiesDialog(com.actelion.research.share.gui.editor.dialogs.IAtomPropertiesDialog) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 52 with StereoMolecule

use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.

the class SelectionAction method duplicateSelectedOl.

private void duplicateSelectedOl() {
    StereoMolecule mMol = model.getMolecule();
    int atomCount = 0;
    for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
        if (mMol.isSelectedAtom(atom)) {
            atomCount++;
        }
    }
    int originalAtoms = mMol.getAllAtoms();
    int originalBonds = mMol.getAllBonds();
    // double[] mX, mY;
    // mX = Arrays.copyOf(mX, mX.length + atomCount);
    // mY = Arrays.copyOf(mY, mY.length + atomCount);
    int[] atomMap = new int[mMol.getAllAtoms()];
    int esrGroupCountAND = mMol.renumberESRGroups(Molecule.cESRTypeAnd);
    int esrGroupCountOR = mMol.renumberESRGroups(Molecule.cESRTypeOr);
    for (int atom = 0; atom < originalAtoms; atom++) {
        if (mMol.isSelectedAtom(atom)) {
            int newAtom = mMol.getAllAtoms();
            // mX[newAtom] = mX[atom];
            // mY[newAtom] = mY[atom];
            atomMap[atom] = newAtom;
            mMol.copyAtom(mMol, atom, esrGroupCountAND, esrGroupCountOR);
        }
    }
    for (int bond = 0; bond < originalBonds; bond++) {
        if (mMol.isSelectedBond(bond)) {
            mMol.copyBond(mMol, bond, esrGroupCountAND, esrGroupCountOR, atomMap, false);
        }
    }
    for (int atom = 0; atom < originalAtoms; atom++) {
        mMol.setAtomSelection(atom, false);
    }
    for (int atom = originalAtoms; atom < mMol.getAllAtoms(); atom++) {
        mMol.setAtomMapNo(atom, 0, false);
    }
// if (mDrawingObjectList != null) {
// for (int i = mDrawingObjectList.size() - 1; i >= 0; i--) {
// AbstractDrawingObject object = (AbstractDrawingObject) mDrawingObjectList.get(i);
// if (object.isSelected() && !(object instanceof ReactionArrow)) {
// mDrawingObjectList.add(object.clone());
// }
// }
// }
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 53 with StereoMolecule

use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.

the class SelectionAction method getCursor.

@Override
public int getCursor() {
    int ha = model.getSelectedAtom();
    int hb = model.getSelectedBond();
    StereoMolecule mol = model.getMolecule();
    if (shift && rectangular)
        return ICursor.TOOL_SELECTRECTPLUSCURSOR;
    if (shift)
        return ICursor.TOOL_LASSOPLUSCURSOR;
    if (rectangular)
        return ICursor.TOOL_SELECTRECTCURSOR;
    if (ha != -1 && mol.isSelectedAtom(ha))
        return shift ? ICursor.TOOL_HANDPLUSCURSOR : ICursor.TOOL_HANDCURSOR;
    if (hb != -1 && mol.isSelectedBond(hb))
        return shift ? ICursor.TOOL_HANDPLUSCURSOR : ICursor.TOOL_HANDCURSOR;
    if (ha != -1 || hb != -1)
        return ICursor.TOOL_POINTERCURSOR;
    return ICursor.TOOL_LASSOCURSOR;
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 54 with StereoMolecule

use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.

the class SelectionAction method duplicateSelected.

private void duplicateSelected() {
    StereoMolecule mol = model.getMolecule();
    int originalAtoms = mol.getAllAtoms();
    int originalBonds = mol.getAllBonds();
    int[] atomMap = new int[mol.getAllAtoms()];
    int esrGroupCountAND = mol.renumberESRGroups(Molecule.cESRTypeAnd);
    int esrGroupCountOR = mol.renumberESRGroups(Molecule.cESRTypeOr);
    for (int atom = 0; atom < originalAtoms; atom++) {
        if (mol.isSelectedAtom(atom)) {
            int newAtom = mol.getAllAtoms();
            atomMap[atom] = newAtom;
            mol.copyAtom(mol, atom, esrGroupCountAND, esrGroupCountOR);
        }
    }
    for (int bond = 0; bond < originalBonds; bond++) {
        if (mol.isSelectedBond(bond)) {
            mol.copyBond(mol, bond, esrGroupCountAND, esrGroupCountOR, atomMap, false);
        }
    }
    for (int atom = 0; atom < originalAtoms; atom++) {
        mol.setAtomSelection(atom, false);
    }
    for (int atom = originalAtoms; atom < mol.getAllAtoms(); atom++) {
        mol.setAtomMapNo(atom, 0, false);
    }
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 55 with StereoMolecule

use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.

the class SelectionAction method selectRectanglarRegion.

private void selectRectanglarRegion(StereoMolecule mol) {
    java.awt.geom.Rectangle2D rc = makeRect(origin, last);
    boolean selected = false;
    if (mol != null) {
        selectAtomsInRectangle(mol, rc);
        selected = true;
    } else {
        StereoMolecule m = model.getMolecule();
        deselectAtoms(m);
        java.awt.geom.Rectangle2D bounds = factory.getBoundingRect(m);
        if (bounds != null && bounds.intersects(rc.getX(), rc.getY(), rc.getWidth(), rc.getHeight())) {
            selectRectanglarRegion(m);
        // break;
        }
    }
    if (!selected) {
        selectDrawingObjectsInRectangle(rc);
    }
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Aggregations

StereoMolecule (com.actelion.research.chem.StereoMolecule)62 Point2D (java.awt.geom.Point2D)11 Canonizer (com.actelion.research.chem.Canonizer)8 IDCodeParser (com.actelion.research.chem.IDCodeParser)8 GeomFactory (com.actelion.research.share.gui.editor.geom.GeomFactory)7 SSSearcher (com.actelion.research.chem.SSSearcher)4 Rectangle2D (java.awt.geom.Rectangle2D)3 IDrawingObject (com.actelion.research.share.gui.editor.chem.IDrawingObject)2 IOException (java.io.IOException)2 Depictor2D (com.actelion.research.chem.Depictor2D)1 DrawingObjectList (com.actelion.research.chem.DrawingObjectList)1 CoordinateInventor (com.actelion.research.chem.coords.CoordinateInventor)1 IAtomPropertiesDialog (com.actelion.research.share.gui.editor.dialogs.IAtomPropertiesDialog)1 IAtomQueryFeaturesDialog (com.actelion.research.share.gui.editor.dialogs.IAtomQueryFeaturesDialog)1 IBondQueryFeaturesDialog (com.actelion.research.share.gui.editor.dialogs.IBondQueryFeaturesDialog)1 LittleEndianDataOutputStream (com.actelion.research.util.LittleEndianDataOutputStream)1 IntVec (com.actelion.research.util.datamodel.IntVec)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1