@Test public void testGetRelevantReaction_IChemModel_IAtom() { IReaction r = ChemModelManipulator.getRelevantReaction(chemModel, atomInMol1); Assert.assertNotNull(r); Assert.assertEquals(reaction, r); }
public void mouseClickedUp(Point2d worldCoord){ JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel(); double dH = model.getHighlightDistance() / model.getScale(); IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord); IAtom endAtom = null; if(closestAtom != null && closestAtom.getPoint2d().distance(worldCoord) < dH) endAtom = chemModelRelay.getClosestAtom(worldCoord); if(endAtom!=null && startAtom!=null){ IMapping mapping = startAtom.getBuilder().newInstance(IMapping.class,startAtom, endAtom); // ok, now figure out if they are in one reaction IReaction reaction1 = ChemModelManipulator.getRelevantReaction(chemModelRelay.getIChemModel(), startAtom); IReaction reaction2 = ChemModelManipulator.getRelevantReaction(chemModelRelay.getIChemModel(), endAtom); if (reaction1 != null && reaction2 != null && reaction1 == reaction2) { ((IReaction)reaction1).addMapping(mapping); }else{ //TODO what to do? message box? that would be a swing component } } startAtom = null; }