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();
}
}
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 {
}
}
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);
}
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;
}
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;
}
Aggregations