@Override public IChemObject newTestObject() { return new Crystal(); } });
/** * Constructs a new crystal with zero length cell axis. */ public Crystal() { super(); setZeroAxes(); }
/** * Returns a String representation of this crystal. */ @Override public String toString() { StringBuffer resultString = new StringBuffer(64); resultString.append("Crystal(").append(hashCode()); if (getSpaceGroup() != null) { resultString.append(", SG=").append(getSpaceGroup()); } if (getZ() > 0) { resultString.append(", Z=").append(getZ()); } if (getA() != null) { resultString.append(", a=(").append(aAxis.x).append(", ").append(aAxis.y).append(", ").append(aAxis.z); } if (getB() != null) { resultString.append("), b=(").append(bAxis.x).append(", ").append(bAxis.y).append(", ").append(bAxis.z); } if (getC() != null) { resultString.append("), c=(").append(cAxis.x).append(", ").append(cAxis.y).append(", ").append(cAxis.z); } resultString.append(", ").append(super.toString()); return resultString.toString(); }
/** * Makes a clone of this crystal. * * @return The cloned crystal. */ @Override public ICrystal clone() throws CloneNotSupportedException { Crystal clone = (Crystal) super.clone(); // clone the axes clone.setA(new Vector3d(this.aAxis)); clone.setB(new Vector3d(this.bAxis)); clone.setC(new Vector3d(this.cAxis)); return clone; }
/** * Returns a String representation of this crystal. */ @Override public String toString() { StringBuffer resultString = new StringBuffer(64); resultString.append("Crystal(").append(hashCode()); if (getSpaceGroup() != null) { resultString.append(", SG=").append(getSpaceGroup()); } if (getZ() > 0) { resultString.append(", Z=").append(getZ()); } if (getA() != null) { resultString.append(", a=(").append(aAxis.x).append(", ").append(aAxis.y).append(", ").append(aAxis.z); } if (getB() != null) { resultString.append("), b=(").append(bAxis.x).append(", ").append(bAxis.y).append(", ").append(bAxis.z); } if (getC() != null) { resultString.append("), c=(").append(cAxis.x).append(", ").append(cAxis.y).append(", ").append(cAxis.z); } resultString.append(", ").append(super.toString()); return resultString.toString(); }
/** * Makes a clone of this crystal. * * @return The cloned crystal. */ @Override public ICrystal clone() throws CloneNotSupportedException { Crystal clone = (Crystal) super.clone(); // clone the axes clone.setA(new Vector3d(this.aAxis)); clone.setB(new Vector3d(this.bAxis)); clone.setC(new Vector3d(this.cAxis)); return clone; }
@BeforeClass public static void setUp() { setTestObjectBuilder(new ITestObjectBuilder() { @Override public IChemObject newTestObject() { return new Crystal(); } }); }
/** * Constructs a new crystal with zero length cell axis * and adds the atoms in the AtomContainer as cell content. * * @param container the AtomContainer providing the atoms and bonds */ public Crystal(IAtomContainer container) { super(container); setZeroAxes(); }
@Test public void testCrystal() { ICrystal crystal = new Crystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
/** * Constructs a new crystal with zero length cell axis. */ public Crystal() { super(); setZeroAxes(); }
@Test public void testCMLCrystal() throws Exception { StringWriter writer = new StringWriter(); ICrystal crystal = new Crystal(); IAtom silicon = new Atom("Si"); silicon.setFractionalPoint3d(new Point3d(0.0, 0.0, 0.0)); crystal.addAtom(silicon); crystal.setA(new Vector3d(1.5, 0.0, 0.0)); crystal.setB(new Vector3d(0.0, 2.0, 0.0)); crystal.setC(new Vector3d(0.0, 0.0, 1.5)); CMLWriter cmlWriter = new CMLWriter(writer); cmlWriter.write(crystal); cmlWriter.close(); String cmlContent = writer.toString(); logger.debug("****************************** testCMLCrystal()"); logger.debug(cmlContent); logger.debug("******************************"); Assert.assertTrue(cmlContent.indexOf("</crystal>") != -1); // the cystal info has to be present Assert.assertTrue(cmlContent.indexOf("<atom") != -1); // an Atom has to be present }
/** * Constructs a new crystal with zero length cell axis * and adds the atoms in the AtomContainer as cell content. * * @param container the AtomContainer providing the atoms and bonds */ public Crystal(IAtomContainer container) { super(container); setZeroAxes(); }
@Test public void testCrystal_IAtomContainer() { IAtomContainer acetone = newChemObject().getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new Crystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }