Search in sources :

Example 16 with StereoMolecule

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

the class SelectionAction method moveAtomsAndBonds.

private boolean moveAtomsAndBonds(double dx, double dy, boolean force) {
    boolean ok = false;
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        if (mol != null && atom != -1 || force) {
            translateAtoms(mol, dx, dy, true);
            ok = true;
        } else if (mol != null && bond != -1 || force) {
            translateBonds(mol, dx, dy, true);
            ok = true;
        }
    }
    return ok;
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 17 with StereoMolecule

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

the class SelectionAction method deselectAllAtoms.

private void deselectAllAtoms() {
    StereoMolecule mol = model.getMolecule();
    deselectAtoms(mol);
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 18 with StereoMolecule

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

the class SelectionAction method onDoubleClick.

@Override
public boolean onDoubleClick(IMouseEvent evt) {
    // StereoMolecule mol = model.getSelectedMolecule();
    java.awt.geom.Point2D pt = new Point2D.Double(evt.getX(), evt.getY());
    StereoMolecule mol = model.getMoleculeAt(pt, true);
    if (mol != null) {
        int atom = mol.findAtom((float) pt.getX(), (float) pt.getY());
        int bond = mol.findBond((float) pt.getX(), (float) pt.getY());
        boolean mShiftIsDown = evt.isShiftDown();
        int mMode = model.getMode();
        if (mol.isFragment()) {
            if (atom != -1) {
                return showAtomQFDialog(atom);
            } else if (bond != -1) {
                return showBondQFDialog(bond);
            }
        // else if (mCurrentHiliteObject != null) {
        // if (!mShiftIsDown) {
        // for (int i = 0; i < mol.getAllAtoms(); i++)
        // mol.setAtomSelection(i, false);
        // for (int i = 0; i < mDrawingObjectList.size(); i++)
        // ((AbstractDrawingObject) mDrawingObjectList.get(i)).setSelected(false);
        // }
        // 
        // mCurrentHiliteObject.setSelected(true);
        // update(UPDATE_REDRAW);
        // }
        } else {
            int rootAtom = -1;
            if (atom != -1) {
                rootAtom = atom;
            } else if (bond != -1) {
                rootAtom = mol.getBondAtom(0, bond);
            }
            if (rootAtom != -1) /*|| mCurrentHiliteObject != null*/
            {
                if (!mShiftIsDown) {
                    deselectAllAtoms();
                    if (model.isReaction()) {
                        model.selectFragmentByAtom(rootAtom);
                    } else {
                        for (int i = 0; i < mol.getAllAtoms(); i++) {
                            mol.setAtomSelection(i, true);
                        }
                    }
                // if (mDrawingObjectList != null)
                // for (AbstractDrawingObject drawingObject : mDrawingObjectList)
                // drawingObject.setSelected(false);
                }
                // }
                return true;
            }
        }
    } else {
        IDrawingObject drawingObject = model.getSelectedDrawingObject();
        if (drawingObject != null) {
            // System.out.printf("Doubleclick on seleted object\n");
            if (evt.isShiftDown()) {
                deselectAllAtoms();
                deselectAllDrawingObjects();
            // model.setSelectedDrawingObject(null);
            }
            drawingObject.setSelected(true);
            model.setSelectedDrawingObject(drawingObject);
        }
    }
    return false;
}
Also used : Point2D(java.awt.geom.Point2D) IDrawingObject(com.actelion.research.share.gui.editor.chem.IDrawingObject) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 19 with StereoMolecule

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

the class SelectionAction method selectFromPolygonRegion.

private void selectFromPolygonRegion() {
    StereoMolecule mol = model.getMolecule();
    for (int i = 0; i < mol.getAllAtoms(); i++) {
        boolean isSelected = polygon.contains(mol.getAtomX(i), mol.getAtomY(i));
        mol.setAtomSelection(i, isSelected);
    // model.setSelectedMolecule(mol);
    }
    List<IDrawingObject> drawables = model.getDrawingObjects();
    for (IDrawingObject d : drawables) {
        Rectangle2D r = d.getBoundingRect();
        if (polygon.contains(r.getCenterX(), r.getCenterY()))
            d.setSelected(true);
    }
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) IDrawingObject(com.actelion.research.share.gui.editor.chem.IDrawingObject) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 20 with StereoMolecule

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

the class UpBondAction method onChangeBond.

public void onChangeBond(int bond) {
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        mol.changeBond(bond, Molecule.cBondTypeUp);
        mol.ensureHelperArrays(Molecule.cHelperNeighbours);
    }
}
Also used : 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