Search in sources :

Example 11 with StereoMolecule

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

the class BondBaseAction method onChangeBond.

public void onChangeBond(int bond) {
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        mol.changeBond(bond, Molecule.cBondTypeIncreaseOrder);
        mol.ensureHelperArrays(Molecule.cHelperNeighbours);
    }
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 12 with StereoMolecule

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

the class BondHighlightAction method showBondQFDialog.

private boolean showBondQFDialog(int bond) {
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        GeomFactory factory = model.getGeomFactory();
        IBondQueryFeaturesDialog dlg = factory.createBondFeaturesDialog(/*new BondQueryFeaturesDialog(*/
        mol, bond);
        return dlg.doModalAt(lastHightlightPoint.getX(), lastHightlightPoint.getY()) == DialogResult.IDOK;
    }
    return false;
}
Also used : IBondQueryFeaturesDialog(com.actelion.research.share.gui.editor.dialogs.IBondQueryFeaturesDialog) GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 13 with StereoMolecule

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

the class BondHighlightAction method paint.

public boolean paint(IDrawContext _ctx) {
    StereoMolecule mol = model.getMolecule();
    boolean ok = false;
    if (mol != null) {
        int theAtom = model.getSelectedAtom();
        int theBond = model.getSelectedBond();
        if (theBond != -1) {
            drawBondHighlight(_ctx, mol, theBond);
            ok = true;
        } else if (theAtom != -1) {
            return super.paint(_ctx);
        }
    }
    return ok;
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 14 with StereoMolecule

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

the class BondHighlightAction method handleCharacter.

private boolean handleCharacter(String code) {
    StereoMolecule mol = model.getMolecule();
    int theBond = model.getSelectedBond();
    if (mol != null && theBond != -1) {
        if (code != null && code.length() > 0) {
            char c = code.charAt(0);
            switch(c) {
                case 'q':
                    return mol.isFragment() ? showBondQFDialog(theBond) : false;
                case '4':
                case '5':
                case '6':
                case '7':
                    return mol.addRingToBond(theBond, c - '0', false);
                case 'b':
                    return mol.addRingToBond(theBond, 6, true);
                case '1':
                    return mol.changeBond(theBond, Molecule.cBondTypeSingle);
                case '2':
                    return mol.changeBond(theBond, Molecule.cBondTypeDouble);
                case '3':
                    return mol.changeBond(theBond, Molecule.cBondTypeTriple);
                case 'u':
                    return mol.changeBond(theBond, Molecule.cBondTypeUp);
                case 'd':
                    return mol.changeBond(theBond, Molecule.cBondTypeDown);
                case 'c':
                    return mol.changeBond(theBond, Molecule.cBondTypeCross);
                case 'm':
                    return mol.changeBond(theBond, Molecule.cBondTypeMetalLigand);
            }
        }
    }
    return false;
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 15 with StereoMolecule

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

the class ChangeChargeAction method onMouseUp.

@Override
public boolean onMouseUp(IMouseEvent evt) {
    model.pushUndo();
    int theAtom = model.getSelectedAtom();
    if (theAtom != -1) {
        StereoMolecule mol = model.getMolecule();
        int charge = mol.getAtomCharge(theAtom);
        if (plus)
            charge++;
        else
            charge--;
        mol.setAtomCharge(theAtom, charge);
        return true;
    }
    return false;
}
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