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