/** * Convenience method for determing if molecule has coordinates of a given * type. if hasSubMolecules returns true if any submolecules fit * * @param type of coordinates * @return has coords */ public boolean hasCoordinates(CoordinateType type) { boolean has = true; for (CMLAtom atom : getAtoms()) { has = atom.hasCoordinates(type); if (!has) break; } return has; }
/** * Convenience method for determing if molecule has coordinates of a given * type. if hasSubMolecules returns true if any submolecules fit * * @param type of coordinates * @param omitHydrogen akip hydrogens without coordinates * @return has coords */ public boolean hasCoordinates(CoordinateType type, boolean omitHydrogen) { boolean has = true; for (CMLAtom atom : getAtoms()) { if (omitHydrogen && "H".equals(atom.getElementType())) { continue; } has = atom.hasCoordinates(type); if (!has) break; } return has; }
/** * gets Real2 for x2 y2. * * @return the point; null if x2, etc. are unset */ public Real2 getXY2() { if (hasCoordinates(CoordinateType.TWOD)) { return new Real2(this.getX2(), this.getY2()); } return null; }
/** * gets 2D coordinates as a 3D point. * * adds a z coordinate of 0.0. Result is not stored * * @return the point (null if no 2D coordinates) */ public Point3 get2DPoint3() { Point3 point = null; if (hasCoordinates(CoordinateType.TWOD)) { point = new Point3(this.getX2(), this.getY2(), 0.0); } return point; }
/** * gets Point3 for xFract, yFract, zFract. * * @return the point; null if xFract, etc. are unset */ public Point3 getXYZFract() { if (hasCoordinates(CoordinateType.FRACTIONAL)) { return new Point3(this.getXFract(), this.getYFract(), this .getZFract()); } return null; }
/** * gets Point3 for x3, y3, z3. * * @see #getPoint3(CoordinateType) * @return the point; null if x3, etc. are unset */ public Point3 getXYZ3() { if (hasCoordinates(CoordinateType.CARTESIAN)) { return new Point3(this.getX3(), this.getY3(), this.getZ3()); } return null; }
/** * increase x2 and y2 coordinates. * * if x2 or y2 is unset, no action (to avoid a default of zero) * * @param dx * amount to add * @param dy * amount to add */ public void increaseXY2(double dx, double dy) { if (hasCoordinates(CoordinateType.TWOD)) { this.setX2(this.getX2() + dx); this.setY2(this.getY2() + dy); } }
/** gets vector of 3D coordinates. * all atoms must have coordinates * * @param type * @return the vector (null if missing 3D coordinates) */ public Point3Vector getCoordinates3(CoordinateType type) { List<CMLAtom> atoms = this.getAtoms(); Point3Vector p3Vector = new Point3Vector(); boolean ok = true; for (CMLAtom atom : atoms) { if (!atom.hasCoordinates(type)) { ok = false; break; } p3Vector.add(atom.getPoint3(type)); } return (!ok) ? null : p3Vector; }
/** * translate molecule in 2D. * * @param delta2 * add to all 2D coordinates */ public void translate2D(Real2 delta2) { for (CMLAtom atom : getAtoms()) { if (atom.hasCoordinates(CoordinateType.TWOD)) { atom.setX2(atom.getX2() + delta2.x); atom.setY2(atom.getY2() + delta2.y); } } }
/** * increase x3, y3 and z3 coordinates. * * if x3, y3 or z3 is unset, no action * * @param dx * amount to add * @param dy * amount to add * @param dz * amount to add */ public void increaseXYZFract(double dx, double dy, double dz) { if (hasCoordinates(CoordinateType.CARTESIAN)) { this.setXFract(this.getXFract() + dx); this.setYFract(this.getYFract() + dy); this.setZFract(this.getZFract() + dz); } }
/** * increase x3, y3 and z3 coordinates. * * if x3, y3 or z3 is unset, no action * * @param dx * amount to add * @param dy * amount to add * @param dz * amount to add */ public void increaseXYZ3(double dx, double dy, double dz) { if (hasCoordinates(CoordinateType.CARTESIAN)) { this.setX3(this.getX3() + dx); this.setY3(this.getY3() + dy); this.setZ3(this.getZ3() + dz); } }
/** * transforms 2D coordinates of atom. * * if x2 or y2 is unset take no action * * @param t2 * transformation */ public void transform(Transform2 t2) { if (hasCoordinates(CoordinateType.TWOD)) { Real2 xy = new Real2(this.getX2(), this.getY2()); xy.transformBy(t2); this.setX2(xy.getX()); this.setY2(xy.getY()); } }
&& this.hasCoordinates(CoordinateType.TWOD)) { i = (int) (this.getX2() * factor); this.setX2(((double) i) * epsilon); && this.hasCoordinates(CoordinateType.CARTESIAN)) { i = (int) (this.getX3() * factor); this.setX3(((double) i) * epsilon); && this.hasCoordinates(CoordinateType.FRACTIONAL)) { i = (int) (this.getXFract() * factor); this.setXFract(((double) i) * epsilon);