use of com.actelion.research.chem.StereoMolecule 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;
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class SelectionAction method duplicateSelectedOl.
private void duplicateSelectedOl() {
StereoMolecule mMol = model.getMolecule();
int atomCount = 0;
for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
if (mMol.isSelectedAtom(atom)) {
atomCount++;
}
}
int originalAtoms = mMol.getAllAtoms();
int originalBonds = mMol.getAllBonds();
// double[] mX, mY;
// mX = Arrays.copyOf(mX, mX.length + atomCount);
// mY = Arrays.copyOf(mY, mY.length + atomCount);
int[] atomMap = new int[mMol.getAllAtoms()];
int esrGroupCountAND = mMol.renumberESRGroups(Molecule.cESRTypeAnd);
int esrGroupCountOR = mMol.renumberESRGroups(Molecule.cESRTypeOr);
for (int atom = 0; atom < originalAtoms; atom++) {
if (mMol.isSelectedAtom(atom)) {
int newAtom = mMol.getAllAtoms();
// mX[newAtom] = mX[atom];
// mY[newAtom] = mY[atom];
atomMap[atom] = newAtom;
mMol.copyAtom(mMol, atom, esrGroupCountAND, esrGroupCountOR);
}
}
for (int bond = 0; bond < originalBonds; bond++) {
if (mMol.isSelectedBond(bond)) {
mMol.copyBond(mMol, bond, esrGroupCountAND, esrGroupCountOR, atomMap, false);
}
}
for (int atom = 0; atom < originalAtoms; atom++) {
mMol.setAtomSelection(atom, false);
}
for (int atom = originalAtoms; atom < mMol.getAllAtoms(); atom++) {
mMol.setAtomMapNo(atom, 0, false);
}
// if (mDrawingObjectList != null) {
// for (int i = mDrawingObjectList.size() - 1; i >= 0; i--) {
// AbstractDrawingObject object = (AbstractDrawingObject) mDrawingObjectList.get(i);
// if (object.isSelected() && !(object instanceof ReactionArrow)) {
// mDrawingObjectList.add(object.clone());
// }
// }
// }
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class SelectionAction method getCursor.
@Override
public int getCursor() {
int ha = model.getSelectedAtom();
int hb = model.getSelectedBond();
StereoMolecule mol = model.getMolecule();
if (shift && rectangular)
return ICursor.TOOL_SELECTRECTPLUSCURSOR;
if (shift)
return ICursor.TOOL_LASSOPLUSCURSOR;
if (rectangular)
return ICursor.TOOL_SELECTRECTCURSOR;
if (ha != -1 && mol.isSelectedAtom(ha))
return shift ? ICursor.TOOL_HANDPLUSCURSOR : ICursor.TOOL_HANDCURSOR;
if (hb != -1 && mol.isSelectedBond(hb))
return shift ? ICursor.TOOL_HANDPLUSCURSOR : ICursor.TOOL_HANDCURSOR;
if (ha != -1 || hb != -1)
return ICursor.TOOL_POINTERCURSOR;
return ICursor.TOOL_LASSOCURSOR;
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class SelectionAction method duplicateSelected.
private void duplicateSelected() {
StereoMolecule mol = model.getMolecule();
int originalAtoms = mol.getAllAtoms();
int originalBonds = mol.getAllBonds();
int[] atomMap = new int[mol.getAllAtoms()];
int esrGroupCountAND = mol.renumberESRGroups(Molecule.cESRTypeAnd);
int esrGroupCountOR = mol.renumberESRGroups(Molecule.cESRTypeOr);
for (int atom = 0; atom < originalAtoms; atom++) {
if (mol.isSelectedAtom(atom)) {
int newAtom = mol.getAllAtoms();
atomMap[atom] = newAtom;
mol.copyAtom(mol, atom, esrGroupCountAND, esrGroupCountOR);
}
}
for (int bond = 0; bond < originalBonds; bond++) {
if (mol.isSelectedBond(bond)) {
mol.copyBond(mol, bond, esrGroupCountAND, esrGroupCountOR, atomMap, false);
}
}
for (int atom = 0; atom < originalAtoms; atom++) {
mol.setAtomSelection(atom, false);
}
for (int atom = originalAtoms; atom < mol.getAllAtoms(); atom++) {
mol.setAtomMapNo(atom, 0, false);
}
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class SelectionAction method selectRectanglarRegion.
private void selectRectanglarRegion(StereoMolecule mol) {
java.awt.geom.Rectangle2D rc = makeRect(origin, last);
boolean selected = false;
if (mol != null) {
selectAtomsInRectangle(mol, rc);
selected = true;
} else {
StereoMolecule m = model.getMolecule();
deselectAtoms(m);
java.awt.geom.Rectangle2D bounds = factory.getBoundingRect(m);
if (bounds != null && bounds.intersects(rc.getX(), rc.getY(), rc.getWidth(), rc.getHeight())) {
selectRectanglarRegion(m);
// break;
}
}
if (!selected) {
selectDrawingObjectsInRectangle(rc);
}
}
Aggregations