Search in sources :

Example 46 with StereoMolecule

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

the class BondBaseAction method drawBondLine.

private void drawBondLine(IDrawContext ctx) {
    java.awt.geom.Point2D point = origin;
    if (point != null && last != null) {
        int atom = getAtomAt(point);
        StereoMolecule mol = model.getMoleculeAt(point, true);
        if (mol != null && atom != -1) {
            point = new Point2D.Double(mol.getAtomX(atom), mol.getAtomY(atom));
        }
        ctx.save();
        ctx.drawLine(point.getX(), point.getY(), last.getX(), last.getY());
        ctx.restore();
    }
}
Also used : Point2D(java.awt.geom.Point2D) Point2D(java.awt.geom.Point2D) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 47 with StereoMolecule

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

the class BondBaseAction method onAddBond.

public void onAddBond(int srcAtom, int targetAtom) {
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        int bondType = getBondType();
        if (bondType == Molecule.cBondTypeSingle)
            bondType = mol.suggestBondType(srcAtom, targetAtom);
        mol.addBond(srcAtom, targetAtom, bondType);
        mol.ensureHelperArrays(Molecule.cHelperNeighbours);
    } else {
    }
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 48 with StereoMolecule

use of com.actelion.research.chem.StereoMolecule 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 49 with StereoMolecule

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

the class BondHighlightAction method trackHighLight.

@Override
boolean trackHighLight(java.awt.geom.Point2D pt) {
    int lastAtom = model.getSelectedAtom();
    int lastBond = model.getSelectedBond();
    lastHightlightPoint = pt;
    StereoMolecule mol = model.getMoleculeAt(pt, true);
    if (super.trackHighLight(pt)) {
        setHighlightBond(null, -1);
        return true;
    }
    int bond = getBondAt(mol, pt);
    if (bond >= 0) {
        setHighlightBond(mol, bond);
        setHighlightAtom(mol, -1);
        return true;
    }
    boolean update = lastAtom != -1 || lastBond != bond;
    setHighlightBond(null, -1);
    setHighlightAtom(null, -1);
    return update;
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 50 with StereoMolecule

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

the class ChangeAtomAction method onMouseUp.

@Override
public boolean onMouseUp(IMouseEvent evt) {
    model.pushUndo();
    int theAtom = model.getSelectedAtom();
    java.awt.geom.Point2D pt = new Point2D.Double(evt.getX(), evt.getY());
    StereoMolecule mol = model.getMolecule();
    if (theAtom != -1) {
        mol.setAtomicNo(theAtom, theAtomNo);
    } else {
        int atom = mol.addAtom((float) pt.getX(), (float) pt.getY());
        mol.setAtomicNo(atom, theAtomNo);
    }
    setHighlightAtom(mol, -1);
    return true;
}
Also used : Point2D(java.awt.geom.Point2D) 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