// if merge is set either form a bond or add and form
IAtomContainer removedContainer=null;
if(merge!=null) {
chemModelRelay.getRenderer().getRenderer2DModel().getMerge().remove(merge);
removedContainer = ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), merge);
IBond newBond = chemModelRelay.addBond( newAtom , merge, stereoForNewBond, orderForNewBond );
containerForUndoRedo.addBond(newBond);
} else {
if(start.distance( worldCoord )<getHighlightDistance()) {
if(!newSource) {
IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), newAtom, stereoForNewBond, orderForNewBond, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
containerForUndoRedo.addAtom(undoRedoAtom);
IAtomContainer atomCon =
ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), undoRedoAtom);
containerForUndoRedo.addElectronContainer(atomCon.getConnectedElectronContainersList(undoRedoAtom).get(0));
} else if(makeInitialBond){
IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(
chemModelRelay.getController2DModel().getDrawElement(),
new Point2d(newAtom.getPoint2d().x+1.5,newAtom.getPoint2d().y),
chemModelRelay.getController2DModel().getDrawPseudoAtom());
containerForUndoRedo.addAtom(undoRedoAtom);
containerForUndoRedo.addBond(chemModelRelay.addBond(newAtom, undoRedoAtom, stereoForNewBond, orderForNewBond));
}
}else {
IAtom atom = chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
containerForUndoRedo.addAtom(atom);
IBond newBond = chemModelRelay.addBond( newAtom, atom, stereoForNewBond, orderForNewBond );
containerForUndoRedo.addBond(newBond);
}
}
if (factory != null && handler != null) {