IChemObject singleSelection = getHighlighted( worldCoord,
closestAtom,closestBond );
if (singleSelection == null) {
//we build a phantom ring
IRing ring = this.chemModelRelay.getIChemModel().getBuilder().newInstance(IRing.class,ringSize, "C");
if (addingBenzene) {
ring.getBond(0).setOrder(IBond.Order.DOUBLE);
ring.getBond(2).setOrder(IBond.Order.DOUBLE);
ring.getBond(4).setOrder(IBond.Order.DOUBLE);
}
double bondLength = ((ControllerHub)this.chemModelRelay).calculateAverageBondLength(this.chemModelRelay.getIChemModel().getMoleculeSet());
ringPlacer.placeRing(ring, worldCoord, bondLength, RingPlacer.jcpAngles);
for(IAtom atom : ring.atoms())
this.chemModelRelay.addPhantomAtom(atom);
for(IBond atom : ring.bonds())
this.chemModelRelay.addPhantomBond(atom);
//and look if it would merge somewhere
chemModelRelay.getRenderer().getRenderer2DModel().getMerge().clear();
for(IAtom atom : ring.atoms()){
IAtom closestAtomInRing = this.chemModelRelay.getClosestAtom(atom);
if( closestAtomInRing != null) {
chemModelRelay.getRenderer().getRenderer2DModel().getMerge().put(closestAtomInRing, atom);
}
}