Search in sources :

Example 6 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class AtomHighlightAction method onKeyPressed.

@Override
public boolean onKeyPressed(IKeyEvent evt) {
    GeomFactory factory = model.getGeomFactory();
    if (evt.getCode().equals(factory.getDeleteKey())) {
        int theAtom = model.getSelectedAtom();
        StereoMolecule mol = model.getMolecule();
        if (theAtom != -1) {
            mol.deleteAtom(theAtom);
            setHighlightAtom(mol, -1);
            return true;
        } else {
            boolean update = false;
            StereoMolecule m = model.getMolecule();
            if (m.deleteSelectedAtoms()) {
                update = true;
            }
            return update;
        }
    } else if (handleCharacter(evt)) {
        return true;
    }
    return false;
}
Also used : GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 7 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class AtomMapAction method onKeyPressed.

// @Override
// public boolean onMouseDown(ACTMouseEvent evt)
// {
// origin = new Point2D.Double(evt.getX(),evt.getY());
// return super.onMouseDown(evt);
// }
@Override
public boolean onKeyPressed(IKeyEvent evt) {
    GeomFactory builder = model.getGeomFactory();
    if (evt.getCode().equals(builder.getDeleteKey())) {
        StereoMolecule mMol = model.getMolecule();
        boolean found = false;
        for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
            if (mMol.getAtomMapNo(atom) != 0) {
                mMol.setAtomMapNo(atom, 0, false);
                found = true;
            }
        }
        return found;
    }
    return super.onKeyPressed(evt);
}
Also used : GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 8 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class BondHighlightAction method onKeyPressed.

@Override
public boolean onKeyPressed(IKeyEvent evt) {
    int theBond = model.getSelectedBond();
    GeomFactory factory = model.getGeomFactory();
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        if (evt.getCode().equals(factory.getDeleteKey())) {
            if (theBond != -1) {
                mol.deleteBondAndSurrounding(theBond);
                setHighlightBond(mol, -1);
                return true;
            }
        } else {
            if (handleCharacter(evt.getText())) {
                return true;
            }
        }
    }
    return super.onKeyPressed(evt);
}
Also used : GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 9 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory 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)

Aggregations

GeomFactory (com.actelion.research.share.gui.editor.geom.GeomFactory)9 StereoMolecule (com.actelion.research.chem.StereoMolecule)7 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 Point2D (java.awt.geom.Point2D)1