Class BondRef

    • Constructor Detail

      • BondRef

        public BondRef​(IBond bond)
        Create a pointer for the provided bond.
        Parameters:
        bond - the bond to reference
    • Method Detail

      • deref

        public static IBond deref​(IBond bond)
        Utility method to dereference an bond pointer. If the bond is not an BondRef it simply returns the input.
        Parameters:
        bond - the bond
        Returns:
        non-pointer bond
      • deref

        public IBond deref()
        Dereference the bond pointer once providing access to the base bond.
        Returns:
        the bond pointed to
      • setAtoms

        public void setAtoms​(IAtom[] atoms)
        Sets the array of atoms making up this bond.
        Specified by:
        setAtoms in interface IBond
        Parameters:
        atoms - An array of atoms that forms this bond
        See Also:
        IBond.atoms()
      • getBegin

        public IAtom getBegin()
        Access the begin (or first) atom of the bond.
        Specified by:
        getBegin in interface IBond
        Returns:
        the begin atom
      • getEnd

        public IAtom getEnd()
        Access the end (or second) atom of the bond.
        Specified by:
        getEnd in interface IBond
        Returns:
        the end atom
      • getIndex

        public int getIndex()
        Specified by:
        getIndex in interface IBond
      • getAtomCount

        public int getAtomCount()
        Returns the number of Atoms in this Bond.
        Specified by:
        getAtomCount in interface IBond
        Returns:
        The number of Atoms in this Bond
      • getConnectedAtom

        public IAtom getConnectedAtom​(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.

        
         IAtom beg = bond.getBegin();
         IAtom end = bond.getEnd();
         // bond.getConnectedAtom(beg) == end
         // bond.getConnectedAtom(end) == beg
         
        Specified by:
        getConnectedAtom in interface IBond
        Parameters:
        atom - The atom the bond partner is searched of
        Returns:
        the connected atom or null if the given atom is not part of the bond
      • getOther

        public 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.

        
         IAtom beg = bond.getBegin();
         IAtom end = bond.getEnd();
         // bond.getOther(beg) == end
         // bond.getOther(end) == beg
         
        Specified by:
        getOther in interface IBond
        Parameters:
        atom - The atom the bond partner is searched of
        Returns:
        the connected atom or null if the given atom is not part of the bond
      • getConnectedAtoms

        public IAtom[] getConnectedAtoms​(IAtom atom)
        Returns all the atoms in the bond connected to the given atom.
        Specified by:
        getConnectedAtoms in interface IBond
        Parameters:
        atom - The atoms the bond partner is searched of
        Returns:
        the connected atoms or null if the given atom is not part of the bond
      • contains

        public boolean contains​(IAtom atom)
        Returns true if the given atom participates in this bond.
        Specified by:
        contains in interface IBond
        Parameters:
        atom - The atom to be tested if it participates in this bond
        Returns:
        true if the atom participates in this bond
      • setAtom

        public void setAtom​(IAtom atom,
                            int position)
        Sets an Atom in this bond.
        Specified by:
        setAtom in interface IBond
        Parameters:
        atom - The atom to be set
        position - The position in this bond where the atom is to be inserted
        See Also:
        IBond.getAtom(int)
      • getDisplay

        public IBond.Display getDisplay()
        Access the bond display style.
        Specified by:
        getDisplay in interface IBond
        Returns:
        the bond display
      • setDisplay

        public void setDisplay​(IBond.Display display)
        Set the bond display style.
        Specified by:
        setDisplay in interface IBond
        Parameters:
        display - the display
      • get2DCenter

        public javax.vecmath.Point2d get2DCenter()
        Returns the geometric 2D center of the bond.
        Specified by:
        get2DCenter in interface IBond
        Returns:
        The geometric 2D center of the bond
      • get3DCenter

        public javax.vecmath.Point3d get3DCenter()
        Returns the geometric 3D center of the bond.
        Specified by:
        get3DCenter in interface IBond
        Returns:
        The geometric 3D center of the bond
      • compare

        public boolean compare​(Object object)
        Compares a bond with this bond.
        Specified by:
        compare in interface IBond
        Parameters:
        object - Object of type Bond
        Returns:
        Return true, if the bond is equal to this bond
      • isConnectedTo

        public boolean isConnectedTo​(IBond bond)
        Checks whether a bond is connected to another one. This can only be true if the bonds have an Atom in common.
        Specified by:
        isConnectedTo in interface IBond
        Parameters:
        bond - The bond which is checked to be connect with this one
        Returns:
        True, if the bonds share an atom, otherwise false
      • isAromatic

        public boolean isAromatic()
        Access whether this bond has been marked as aromatic. The default value is false and you must explicitly perceive aromaticity with one of the available models.
        Specified by:
        isAromatic in interface IBond
        Returns:
        aromatic status
        See Also:
        IChemObject.getFlag(int), Aromaticity
      • isInRing

        public boolean isInRing()
        Access whether this bond has been flagged as in a ring. The default value is false and you must explicitly find rings first.
        Specified by:
        isInRing in interface IBond
        Returns:
        ring status
        See Also:
        IChemObject.getFlag(int), RingSearch
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Description copied from interface: IChemObject
        Returns a one line description of this IChemObject.
        Specified by:
        toString in interface IChemObject
        Overrides:
        toString in class Object
        Returns:
        a String representation of this object
      • getListenerCount

        public int getListenerCount()
        Returns the number of ChemObjectListeners registered with this object.
        Specified by:
        getListenerCount in interface IChemObject
        Returns:
        the number of registered listeners.
      • setNotification

        public void setNotification​(boolean bool)
        Set a flag to use or not use notification. By default it should be set to true.
        Specified by:
        setNotification in interface IChemObject
        Parameters:
        bool - if true, then notification messages are sent.
        See Also:
        IChemObject.getNotification()
      • notifyChanged

        public 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.
        Specified by:
        notifyChanged in interface IChemObject
      • notifyChanged

        public 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. This is a version of notifyChanged() which allows to propagate a change event while preserving the original origin.
        Specified by:
        notifyChanged in interface IChemObject
        Parameters:
        evt - A ChemObjectChangeEvent pointing to the source of where the change happend
      • getProperty

        public <T> T getProperty​(Object description)
        Returns a property for the IChemObject - the object is automatically cast to the required type. This does however mean if the wrong type is provided then a runtime ClassCastException will be thrown.
        
        
             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
        
         
        Specified by:
        getProperty in interface IChemObject
        Type Parameters:
        T - generic return type
        Parameters:
        description - An object description of the property (most likely a unique string)
        Returns:
        The object containing the property. Returns null if property is not set.
        See Also:
        IChemObject.setProperty(java.lang.Object, java.lang.Object), IChemObject.getProperty(Object, Class), IChemObject.removeProperty(java.lang.Object)
      • getProperty

        public <T> T getProperty​(Object description,
                                 Class<T> c)
        Access a property of the given description and cast the specified class.
        
        
             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
        
         
        Specified by:
        getProperty in interface IChemObject
        Type Parameters:
        T - generic type (of provided class)
        Parameters:
        description - description of a property (normally a string)
        c - type of the value to be returned
        Returns:
        the value stored for the specified description.
        See Also:
        IChemObject.getProperty(Object), IChemObject.addProperties(java.util.Map)
      • setID

        public void setID​(String identifier)
        Sets the identifier (ID) of this object.
        Specified by:
        setID in interface IChemObject
        Parameters:
        identifier - a String representing the ID value
        See Also:
        IChemObject.getID()
      • setFlag

        public void setFlag​(int mask,
                            boolean value)
        Sets the value of some flag. The flag is a mask from a given CDKConstant (e.g. 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);
         
        Specified by:
        setFlag in interface IChemObject
        Parameters:
        mask - flag to set the value for
        value - value to assign to flag
        See Also:
        IChemObject.getFlag(int), CDKConstants
      • getFlag

        public boolean getFlag​(int mask)
        Returns the value of a given flag. The flag is a mask from a given CDKConstant (e.g. CDKConstants.ISAROMATIC).
        
         if(chemObject.getFlag(CDKConstants.ISAROMATIC)){
             // handle aromatic flag on this chem object
         }
         
        Specified by:
        getFlag in interface IChemObject
        Parameters:
        mask - flag to retrieve the value of
        Returns:
        true if the flag flag_type is set
        See Also:
        IChemObject.setFlag(int, boolean), CDKConstants
      • setProperties

        public void setProperties​(Map<Object,​Object> properties)
        Set the properties of this object to the provided map (shallow copy). Any existing properties are removed.
        Specified by:
        setProperties in interface IChemObject
        Parameters:
        properties - map key-value pairs
      • getFlagValue

        public Number getFlagValue()
        Access the internal value used to store the flags. The flags are stored on a single numeric value and are set/cleared.
        Specified by:
        getFlagValue in interface IChemObject
        Returns:
        numeric representation of the flags