use of com.actelion.research.share.gui.editor.chem.IDrawingObject in project openchemlib by Actelion.
the class SelectionAction method selectDrawingObjectsInRectangle.
private void selectDrawingObjectsInRectangle(java.awt.geom.Rectangle2D rc) {
for (IDrawingObject dw : model.getDrawingObjects()) {
dw.setSelected(false);
java.awt.geom.Rectangle2D r = dw.getBoundingRect();
if (rc.contains(r.getCenterX(), r.getCenterY()))
dw.setSelected(true);
}
}
use of com.actelion.research.share.gui.editor.chem.IDrawingObject 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.share.gui.editor.chem.IDrawingObject in project openchemlib by Actelion.
the class SelectionAction method moveSelectedDrawItems.
private boolean moveSelectedDrawItems(double dx, double dy) {
boolean ok = false;
for (IDrawingObject selectedOne : model.getDrawingObjects()) {
if (selectedOne.isSelected() && selectedOne.isMovable()) {
selectedOne.move((float) -dx, (float) -dy);
ok = true;
}
}
return ok;
}
use of com.actelion.research.share.gui.editor.chem.IDrawingObject in project openchemlib by Actelion.
the class SelectionAction method trackHighLight.
@Override
boolean trackHighLight(java.awt.geom.Point2D pt) {
boolean selected = false;
IDrawingObject lastSelected = model.getSelectedDrawingObject();
java.util.List<IDrawingObject> drawables = model.getDrawingObjects();
model.setSelectedDrawingObject(null);
for (IDrawingObject d : drawables) {
if (d.getBoundingRect().contains(pt.getX(), pt.getY())) {
model.setSelectedDrawingObject(d);
selected = true;
break;
}
}
boolean ok = selected || lastSelected != null || super.trackHighLight(pt);
return ok;
}
use of com.actelion.research.share.gui.editor.chem.IDrawingObject 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);
}
}
Aggregations