public class Bond
extends java.lang.Object
Constructor and Description |
---|
Bond(Atom atomA,
Atom atomB,
int bondOrder)
Constructs a new bond from a pair of atoms and the bond order of the bond
between them.
|
Bond(Atom atomA,
Atom atomB,
int bondOrder,
boolean addSelfToAtoms)
Constructs a new bond from a pair of atoms and the bond order of the bond
between them.
|
Modifier and Type | Method and Description |
---|---|
void |
addSelfToAtoms()
Adds this Bond to its atoms bond lists.
|
Atom |
getAtomA()
Gets atom 'A' of this bond.
|
Atom |
getAtomB()
Gets atom 'B' of this bond.
|
int |
getBondOrder()
Gets the bond order of this bond.
|
double |
getLength()
Gets the distance between the two atoms of this bond.
|
Atom |
getOther(Atom exclude)
A utility method to get the other atom in a bond, given one of its atoms.
|
java.lang.String |
toString() |
public Bond(Atom atomA, Atom atomB, int bondOrder)
Note that by forming a bond between atoms 'A' and 'B' with this
constructor, atoms 'A' and 'B' will be updated to have this bond in their
list of bonds. If you do not want this automatic updating, instead use
Bond(Atom, Atom, int, boolean)
with the
addSelfToAtoms
flag set to false
.
atomA
- one of the atoms in this bondatomB
- the other atom in this bondbondOrder
- the bond order of this bondpublic Bond(Atom atomA, Atom atomB, int bondOrder, boolean addSelfToAtoms)
atomA
- one of the atoms in this bondatomB
- the other atom in this bondbondOrder
- the bond order of this bondaddSelfToAtoms
- if set to true, this bond, once created, will automatically
add itself to atomA and atomB's bond lists. (If this argument
is set to false, the list returned from
Atom.getBonds()
will not contain this bond.)public void addSelfToAtoms()
Atom.getBonds()
will not
include this bond.
If you created your Bond with the constructor
Bond(Atom, Atom, int)
, this method has already been called for
you and should not be called again.
public Atom getAtomA()
getAtomB()
public Atom getAtomB()
getAtomA()
public Atom getOther(Atom exclude)
atom == bond.getAtomA() ? bond.getAtomB() : bond.getAtomA()
.
Note: Comparison of atoms in this method is done with
==
, not equals
.
exclude
- the atom of the bond to not returnjava.lang.IllegalArgumentException
- if the passed atom is not in this bondpublic int getBondOrder()
public double getLength()
This distance is calculated by Calc.getDistance(Atom, Atom)
, but
this method will suppress the empty threat of a
StructureException
that method makes.
public java.lang.String toString()
toString
in class java.lang.Object