BasicAtomGenerator implements IGenerator<IAtomContainer> { protected boolean showCarbon(IAtom carbonAtom, IAtomContainer container, RendererModel model) { if ((Boolean) model.get(KekuleStructure.class)) return true; if (carbonAtom.getFormalCharge() != 0) return true; int connectedBondCount = container.getConnectedBondsList(carbonAtom).size(); if (connectedBondCount < 1) return true; if ((Boolean) model.get(ShowEndCarbons.class) && connectedBondCount == 1) return true; if (carbonAtom.getProperty(ProblemMarker.ERROR_MARKER) != null) return true; if (container.getConnectedSingleElectronsCount(carbonAtom) > 0) return true; return false; } BasicAtomGenerator(); @Override IRenderingElement generate(IAtomContainer container, RendererModel model); IRenderingElement generate(IAtomContainer atomContainer, IAtom atom, RendererModel model); IRenderingElement generateCompactElement(IAtom atom, RendererModel model); AtomSymbolElement generateElement(IAtom atom, int alignment, RendererModel model); @Override List<IGeneratorParameter<?>> getParameters();  }
@Test public void showCarbon_KekuleTest() { IAtomContainer atomContainer = super.makeCCC(); IAtom carbon = atomContainer.getAtom(1); model.set(KekuleStructure.class, true); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }
@Test public void showCarbon_FormalChargeTest() { IAtomContainer atomContainer = super.makeCCC(); IAtom carbon = atomContainer.getAtom(1); carbon.setFormalCharge(1); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }
@Test public void showCarbon_SingleCarbonTest() { IAtomContainer atomContainer = super.makeSingleAtom("C"); IAtom carbon = atomContainer.getAtom(0); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }
@Test public void showCarbon_ShowEndCarbonsTest() { IAtomContainer atomContainer = super.makeCCC(); IAtom carbon = atomContainer.getAtom(0); model.set(ShowEndCarbons.class, true); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }
@Test public void showCarbon_ErrorMarker() { IAtomContainer atomContainer = super.makeCCC(); IAtom carbon = atomContainer.getAtom(1); ProblemMarker.markWithError(carbon); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }
@Test public void showCarbon_ConnectedSingleElectrons() { IAtomContainer atomContainer = super.makeCCC(); IAtom carbon = atomContainer.getAtom(1); atomContainer.addSingleElectron(1); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }