use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.
the class AtomHighlightAction method showAtomQFDialog.
private boolean showAtomQFDialog(int atom) {
GeomFactory factory = model.getGeomFactory();
StereoMolecule mol = model.getMolecule();
if (mol != null) {
IAtomQueryFeaturesDialog dlg = factory.createAtomQueryFeatureDialog(/*new AtomQueryFeaturesDialog*/
mol, atom);
return dlg.doModalAt(lastHightlightPoint.getX(), lastHightlightPoint.getY()) == DialogResult.IDOK;
}
return false;
}
use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.
the class AtomMapAction method paint.
// private void assistedMap(int atom)
// {
// StereoMolecule mol = model.getSelectedMolecule();
// int freeMapNo = model.getNextMapNo();
// if (mol != null) {
// StereoMolecule source = model.getFragmentAt(firstPoint, false);
// StereoMolecule target = model.getFragmentAt(lastPoint, false);
// if (target != null && target != source) {
// int dest = mol.findAtom((int) lastPoint.getX(), (int) lastPoint.getY());
// if (dest != -1) {
// mol.setAtomMapNo(atom, freeMapNo, false);
// mol.setAtomMapNo(dest, freeMapNo, false);
// }
// model.tryAutoMapReaction();
// }
// }
// }
//
@Override
public boolean paint(IDrawContext ctx) {
boolean ok = false;
ctx.save();
if (model.isReaction()) {
StereoMolecule mol = model.getMolecule();
if (firstPoint != null && lastPoint != null) {
StereoMolecule source = model.getFragmentAt(firstPoint, false);
StereoMolecule target = model.getFragmentAt(lastPoint, false);
if (target != null && target != source) {
int theAtom = mol.findAtom((float) lastPoint.getX(), (float) lastPoint.getY());
if (theAtom != -1)
drawAtomHighlight(ctx, mol, theAtom);
}
// ctx.setStroke(IColor.RED);
GeomFactory builder = model.getGeomFactory();
ctx.setStroke(builder.getMapToolColor());
ctx.drawLine(firstPoint.getX(), firstPoint.getY(), lastPoint.getX(), lastPoint.getY());
} else if (secondAtom != -1) {
drawAtomHighlight(ctx, mol, secondAtom);
}
}
ok = super.paint(ctx);
ctx.restore();
return ok;
}
use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.
the class BondHighlightAction method showBondQFDialog.
private boolean showBondQFDialog(int bond) {
StereoMolecule mol = model.getMolecule();
if (mol != null) {
GeomFactory factory = model.getGeomFactory();
IBondQueryFeaturesDialog dlg = factory.createBondFeaturesDialog(/*new BondQueryFeaturesDialog(*/
mol, bond);
return dlg.doModalAt(lastHightlightPoint.getX(), lastHightlightPoint.getY()) == DialogResult.IDOK;
}
return false;
}
use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.
the class ArrowAction method onMouseMove.
@Override
public boolean onMouseMove(IMouseEvent ev, boolean drag) {
if (drag) {
GeomFactory factory = model.getGeomFactory();
last = new Point2D.Double(ev.getX(), ev.getY());
java.awt.geom.Rectangle2D r = new java.awt.geom.Rectangle2D.Double((int) Math.min(last.getX(), origin.getX()), (int) last.getY(), (int) Math.abs(last.getX() - origin.getX()), 0);
// IRectangle2D r = builder.createRectangle(
// (int) Math.min(last.getX(), origin.getX()),
// (int) last.getY(),
// (int) Math.abs(last.getX() - origin.getX()),
// 2);
arrow = factory.createArrow(r);
return true;
}
// To change body of implemented methods use File | Settings | File Templates.
return false;
}
use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.
the class AtomHighlightAction method handleCharacter.
private boolean handleCharacter(StereoMolecule mol, int theAtom, IKeyEvent evt) {
GeomFactory factory = model.getGeomFactory();
StringBuilder keyStrokeBuffer = model.getKeyStrokeBuffer();
boolean isFirst = (keyStrokeBuffer.length() == 0);
String code = evt.getText();
char c = code != null && code.length() > 0 ? code.charAt(0) : 0;
if (evt.getCode().equals(factory.getDeleteKey())) {
if (theAtom != -1) {
mol.deleteAtom(theAtom);
setHighlightAtom(mol, -1);
return true;
} else {
if (mol.deleteSelectedAtoms()) {
return true;
}
}
} else if (!isFirst && evt.getCode().equals(factory.getEscapeKey())) {
keyStrokeBuffer.setLength(0);
return true;
} else if (!isFirst && evt.getCode().equals(factory.getBackSpaceKey())) {
keyStrokeBuffer.setLength(keyStrokeBuffer.length() - 1);
return true;
} else if (evt.getCode().equals(factory.getEnterKey())) {
expandAtomKeyStrokes(mol, theAtom, keyStrokeBuffer.toString());
keyStrokeBuffer.setLength(0);
return true;
} else if (isFirst && c > 48 && c <= 57) {
addChain(mol, theAtom, c - 47);
return true;
} else if ((c > 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || (c == '-')) {
keyStrokeBuffer.append(c);
return true;
}
return false;
}
Aggregations