public class BondRef extends Object implements IBond
IBond
indirectly. All
methods are passed through to the referenced bond. The reference can
be used to override the behaviour of the base bond.IBond.Display, IBond.Order, IBond.Stereo
Constructor and Description |
---|
BondRef(IBond bond)
Create a pointer for the provided bond.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(IChemObjectListener col)
Use this to add yourself to this IChemObject as a listener.
|
void |
addProperties(Map<Object,Object> properties)
Add properties to this object, duplicate keys will replace any existing
value.
|
Iterable<IAtom> |
atoms()
Returns the Iterable to atoms making up this bond.
|
IBond |
clone()
Returns a deep clone of this IChemObject.
|
boolean |
compare(Object object)
Compares a bond with this bond.
|
boolean |
contains(IAtom atom)
Returns true if the given atom participates in this bond.
|
IBond |
deref()
Dereference the bond pointer once providing access to the base
bond.
|
static IBond |
deref(IBond bond)
Utility method to dereference an bond pointer.
|
boolean |
equals(Object obj) |
javax.vecmath.Point2d |
get2DCenter()
Returns the geometric 2D center of the bond.
|
javax.vecmath.Point3d |
get3DCenter()
Returns the geometric 3D center of the bond.
|
IAtom |
getAtom(int position)
Returns an Atom from this bond.
|
int |
getAtomCount()
Returns the number of Atoms in this Bond.
|
IAtom |
getBegin()
Access the begin (or first) atom of the bond.
|
IChemObjectBuilder |
getBuilder()
Returns a
IChemObjectBuilder for the data classes that extend
this class. |
IAtom |
getConnectedAtom(IAtom atom)
Returns the other atom in the bond, the atom is connected to the given atom.
|
IAtom[] |
getConnectedAtoms(IAtom atom)
Returns all the atoms in the bond connected to the given atom.
|
IAtomContainer |
getContainer() |
IBond.Display |
getDisplay()
Access the bond display style.
|
Integer |
getElectronCount()
Returns the number of electrons in this electron container.
|
IAtom |
getEnd()
Access the end (or second) atom of the bond.
|
boolean |
getFlag(int mask)
Returns the value of a given flag.
|
boolean[] |
getFlags()
Returns the whole set of flags.
|
Number |
getFlagValue()
Access the internal value used to store the flags.
|
String |
getID()
Returns the identifier (ID) of this object.
|
int |
getIndex() |
int |
getListenerCount()
Returns the number of ChemObjectListeners registered with this object.
|
boolean |
getNotification()
Returns the flag that indicates whether notification messages are sent around.
|
IBond.Order |
getOrder()
Returns the bond order of this bond.
|
IAtom |
getOther(IAtom atom)
Returns the other atom in the bond, the atom is connected to the given atom.This
method is only correct for two-centre bonds, for n-centre bonds the behaviour is undefined
and the more correct
IBond.getConnectedAtoms(IAtom) should be used. |
Map<Object,Object> |
getProperties()
Returns a Map with the IChemObject's properties.
|
<T> T |
getProperty(Object description)
Returns a property for the IChemObject - the object is automatically
cast to the required type.
|
<T> T |
getProperty(Object description,
Class<T> c)
Access a property of the given description and cast the specified class.
|
IBond.Stereo |
getStereo()
Returns the stereo descriptor for this bond.
|
int |
hashCode() |
boolean |
isAromatic()
Access whether this bond has been marked as aromatic.
|
boolean |
isConnectedTo(IBond bond)
Checks whether a bond is connected to another one.
|
boolean |
isInRing()
Access whether this bond has been flagged as in a ring.
|
void |
notifyChanged()
This should be triggered by an method that changes the content of an object
to that the registered listeners can react to it.
|
void |
notifyChanged(IChemObjectChangeEvent evt)
This should be triggered by an method that changes the content of an object
to that the registered listeners can react to it.
|
void |
removeListener(IChemObjectListener col)
Use this to remove a ChemObjectListener from the ListenerList of this
IChemObject.
|
void |
removeProperty(Object description)
Removes a property for a IChemObject.
|
void |
setAtom(IAtom atom,
int position)
Sets an Atom in this bond.
|
void |
setAtoms(IAtom[] atoms)
Sets the array of atoms making up this bond.
|
void |
setDisplay(IBond.Display display)
Set the bond display style.
|
void |
setElectronCount(Integer count)
Sets the number of electrons in this electron container.
|
void |
setFlag(int mask,
boolean value)
Sets the value of some flag.
|
void |
setFlags(boolean[] newFlags)
Sets the whole set of flags.
|
void |
setID(String identifier)
Sets the identifier (ID) of this object.
|
void |
setIsAromatic(boolean arom)
Mark this bond as being aromatic.
|
void |
setIsInRing(boolean ring)
Mark this bond as being in a ring.
|
void |
setNotification(boolean bool)
Set a flag to use or not use notification.
|
void |
setOrder(IBond.Order order)
Sets the bond order of this bond.
|
void |
setProperties(Map<Object,Object> properties)
Set the properties of this object to the provided map (shallow copy).
|
void |
setProperty(Object description,
Object property)
Sets a property for a IChemObject.
|
void |
setStereo(IBond.Stereo stereo)
Sets the stereo descriptor for this bond.
|
String |
toString()
Returns a one line description of this IChemObject.
|
finalize, getClass, notify, notifyAll, wait, wait, wait
addListener, addProperties, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setProperty
getBuilder
public BondRef(IBond bond)
bond
- the bond to referencepublic static IBond deref(IBond bond)
BondRef
it simply returns the input.bond
- the bondpublic IBond deref()
public Integer getElectronCount()
getElectronCount
in interface IElectronContainer
IElectronContainer.setElectronCount(java.lang.Integer)
public void setElectronCount(Integer count)
setElectronCount
in interface IElectronContainer
count
- The number of electrons in this electron container.IElectronContainer.getElectronCount()
public Iterable<IAtom> atoms()
atoms
in interface IBond
IBond.setAtoms(org.openscience.cdk.interfaces.IAtom[])
public void setAtoms(IAtom[] atoms)
setAtoms
in interface IBond
atoms
- An array of atoms that forms this bondIBond.atoms()
public IAtom getBegin()
public IAtom getEnd()
public IAtomContainer getContainer()
getContainer
in interface IBond
public int getAtomCount()
getAtomCount
in interface IBond
public IAtom getAtom(int position)
getAtom
in interface IBond
position
- The position in this bond where the atom isIBond.setAtom(org.openscience.cdk.interfaces.IAtom, int)
public IAtom getConnectedAtom(IAtom atom)
IBond.getConnectedAtoms(IAtom)
should be used.
IAtom beg = bond.getBegin();
IAtom end = bond.getEnd();
// bond.getConnectedAtom(beg) == end
// bond.getConnectedAtom(end) == beg
getConnectedAtom
in interface IBond
atom
- The atom the bond partner is searched ofpublic IAtom getOther(IAtom atom)
IBond.getConnectedAtoms(IAtom)
should be used.
IAtom beg = bond.getBegin();
IAtom end = bond.getEnd();
// bond.getOther(beg) == end
// bond.getOther(end) == beg
public IAtom[] getConnectedAtoms(IAtom atom)
getConnectedAtoms
in interface IBond
atom
- The atoms the bond partner is searched ofpublic boolean contains(IAtom atom)
public void setAtom(IAtom atom, int position)
setAtom
in interface IBond
atom
- The atom to be setposition
- The position in this bond where the atom is to be insertedIBond.getAtom(int)
public IBond.Order getOrder()
getOrder
in interface IBond
org.openscience.cdk.CDKConstants
for predefined values.
,
IBond.setOrder(org.openscience.cdk.interfaces.IBond.Order)
public void setOrder(IBond.Order order)
setOrder
in interface IBond
order
- The bond order to be assigned to this bondfor predefined values.
,
IBond.getOrder()
public IBond.Stereo getStereo()
getStereo
in interface IBond
IBond.setStereo(org.openscience.cdk.interfaces.IBond.Stereo)
public void setStereo(IBond.Stereo stereo)
setStereo
in interface IBond
stereo
- The stereo descriptor to be assigned to this bond.IBond.getStereo()
,
IBond.setDisplay(Display)
public IBond.Display getDisplay()
getDisplay
in interface IBond
public void setDisplay(IBond.Display display)
setDisplay
in interface IBond
display
- the displaypublic javax.vecmath.Point2d get2DCenter()
get2DCenter
in interface IBond
public javax.vecmath.Point3d get3DCenter()
get3DCenter
in interface IBond
public boolean compare(Object object)
public boolean isConnectedTo(IBond bond)
isConnectedTo
in interface IBond
bond
- The bond which is checked to be connect with this onepublic boolean isAromatic()
isAromatic
in interface IBond
IChemObject.getFlag(int)
,
Aromaticity
public void setIsAromatic(boolean arom)
setIsAromatic
in interface IBond
arom
- aromatic statusIChemObject.setFlag(int, boolean)
public boolean isInRing()
isInRing
in interface IBond
IChemObject.getFlag(int)
,
RingSearch
public void setIsInRing(boolean ring)
setIsInRing
in interface IBond
ring
- ring statusIChemObject.setFlag(int, boolean)
public IBond clone() throws CloneNotSupportedException
clone
in interface IBond
clone
in interface IChemObject
CloneNotSupportedException
- if the IChemObject cannot be clonedpublic String toString()
IChemObject
toString
in interface IChemObject
toString
in class Object
public IChemObjectBuilder getBuilder()
IChemObjectBuilder
for the data classes that extend
this class.getBuilder
in interface ICDKObject
IChemObjectBuilder
matching this ICDKObject
public void addListener(IChemObjectListener col)
addListener
in interface IChemObject
col
- the ChemObjectListenerIChemObject.removeListener(org.openscience.cdk.interfaces.IChemObjectListener)
public int getListenerCount()
getListenerCount
in interface IChemObject
public void removeListener(IChemObjectListener col)
removeListener
in interface IChemObject
col
- The ChemObjectListener to be removedIChemObject.addListener(org.openscience.cdk.interfaces.IChemObjectListener)
public void setNotification(boolean bool)
setNotification
in interface IChemObject
bool
- if true, then notification messages are sent.IChemObject.getNotification()
public boolean getNotification()
getNotification
in interface IChemObject
IChemObject.setNotification(boolean)
public void notifyChanged()
notifyChanged
in interface IChemObject
public void notifyChanged(IChemObjectChangeEvent evt)
notifyChanged
in interface IChemObject
evt
- A ChemObjectChangeEvent pointing to the source of where
the change happendpublic void setProperty(Object description, Object property)
setProperty
in interface IChemObject
description
- An object description of the property (most likely a
unique string)property
- An object with the property itselfIChemObject.getProperty(java.lang.Object)
,
IChemObject.removeProperty(java.lang.Object)
public void removeProperty(Object description)
removeProperty
in interface IChemObject
description
- The object description of the property (most likely a
unique string)IChemObject.setProperty(java.lang.Object, java.lang.Object)
,
IChemObject.getProperty(java.lang.Object)
public <T> T getProperty(Object description)
IAtom atom = new Atom("C");
atom.setProperty("number", 1); // set an integer property
// access the property and automatically cast to an int
Integer number = atom.getProperty("number");
// if the method is in a chain or needs to be nested the type
// can be provided
methodAcceptingInt(atom.getProperty("number", Integer.class));
// the type cannot be checked and so...
String number = atom.getProperty("number"); // ClassCastException
// if the type is provided a more meaningful error is thrown
atom.getProperty("number", String.class); // IllegalArgumentException
getProperty
in interface IChemObject
T
- generic return typedescription
- An object description of the property (most likely a
unique string)IChemObject.setProperty(java.lang.Object, java.lang.Object)
,
IChemObject.getProperty(Object, Class)
,
IChemObject.removeProperty(java.lang.Object)
public <T> T getProperty(Object description, Class<T> c)
IAtom atom = new Atom("C");
atom.setProperty("number", 1); // set an integer property
// access the property and automatically cast to an int
Integer number = atom.getProperty("number");
// if the method is in a chain or needs to be nested the type
// can be provided
methodAcceptingInt(atom.getProperty("number", Integer.class));
// the type cannot be checked and so...
String number = atom.getProperty("number"); // ClassCastException
// if the type is provided a more meaningful error is thrown
atom.getProperty("number", String.class); // IllegalArgumentException
getProperty
in interface IChemObject
T
- generic type (of provided class)description
- description of a property (normally a string)c
- type of the value to be returnedIChemObject.getProperty(Object)
,
IChemObject.addProperties(java.util.Map)
public Map<Object,Object> getProperties()
getProperties
in interface IChemObject
IChemObject.addProperties(java.util.Map<java.lang.Object, java.lang.Object>)
public String getID()
getID
in interface IChemObject
IChemObject.setID(java.lang.String)
public void setID(String identifier)
setID
in interface IChemObject
identifier
- a String representing the ID valueIChemObject.getID()
public void setFlag(int mask, boolean value)
CDKConstants.ISAROMATIC
or CDKConstants.VISITED
). The flags are
intrinsic internal properties and should not be used to store custom
values, please use IChemObject.setProperty(Object, Object)
.
// set this chem object to be aromatic
chemObject.setFlag(CDKConstants.ISAROMATIC, Boolean.TRUE);
// ...
// indicate we have visited this chem object
chemObject.setFlag(CDKConstants.VISITED, Boolean.TRUE);
setFlag
in interface IChemObject
mask
- flag to set the value forvalue
- value to assign to flagIChemObject.getFlag(int)
,
CDKConstants
public boolean getFlag(int mask)
CDKConstants.ISAROMATIC
).
if(chemObject.getFlag(CDKConstants.ISAROMATIC)){
// handle aromatic flag on this chem object
}
getFlag
in interface IChemObject
mask
- flag to retrieve the value offlag_type
is setIChemObject.setFlag(int, boolean)
,
CDKConstants
public void setProperties(Map<Object,Object> properties)
setProperties
in interface IChemObject
properties
- map key-value pairspublic void addProperties(Map<Object,Object> properties)
addProperties
in interface IChemObject
properties
- a Map specifying the property valuesIChemObject.getProperties()
public void setFlags(boolean[] newFlags)
IChemObject.setFlag(int, boolean)
for each value in the array and
use CDKConstants.FLAG_MASKS
to look
up the correct mask. If only a single flag is being set it is a lot
faster to use IChemObject.setFlag(int, boolean)
.setFlags
in interface IChemObject
newFlags
- the new flags to set.IChemObject.setFlag(int, boolean)
,
IChemObject.getFlags()
public boolean[] getFlags()
IChemObject.getFlagValue()
if you need all the flags. For individual flags please use IChemObject.getFlag(int)
getFlags
in interface IChemObject
IChemObject.setFlags(boolean[])
,
IChemObject.getFlag(int)
,
IChemObject.getFlagValue()
public Number getFlagValue()
getFlagValue
in interface IChemObject
Copyright © 2022. All rights reserved.