Interface IChemObject

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALIPHATIC
      Flag that is set if a ChemObject is part of an aliphatic chain.
      static int AROMATIC
      Flag is set if ChemObject is part of an aromatic system.
      static int CONJUGATED
      Flag is set if ChemObject is part of a conjugated system.
      static int HYDROGEN_BOND_ACCEPTOR
      Sets to true if the atom is a hydrogen bond acceptor.
      static int HYDROGEN_BOND_DONOR
      Sets to true if the atom is a hydrogen bond donor.
      static int IN_RING
      Flag that is set when the ChemObject is part of a ring.
      static int MAPPED
      Flag is set if a ChemObject is mapped to another ChemObject.
      static int NOT_IN_RING
      Flag that is set when the ChemObject is part of a ring.
      static int PLACED
      Flag that is set if the ChemObject is placed when calculating 2D/3D layouts.
      static int REACTIVE_CENTER
      Flag is set if a ChemObject has reactive center.
      static int SINGLE_OR_DOUBLE
      Flag used for marking uncertainty of the bond order.
      static int TYPEABLE
      Flag is set if an atom could be typed.
      static int VISITED
      Flag is set if ChemObject has been visited.
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method 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.
      void clear​(int flags)
      Clear the provided flags.
      Object clone()
      Returns a deep clone of this IChemObject.
      int flags()
      Access the current value of the flags for this ChemObject.
      boolean getFlag​(int mask)
      Returns the value of a given flag.
      boolean[] getFlags()
      Returns the whole set of flags.
      Number getFlagValue()
      Deprecated.
      used flags()
      String getID()
      Returns the identifier (ID) of this object.
      int getListenerCount()
      Returns the number of ChemObjectListeners registered with this object.
      boolean getNotification()
      Returns the flag that indicates whether notification messages are sent around.
      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.
      boolean is​(int flags)
      Test if a flag(s) are set on this ChemObject.
      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 set​(int flags)
      Set the provided flags.
      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 setNotification​(boolean bool)
      Set a flag to use or not use notification.
      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.
      String toString()
      Returns a one line description of this IChemObject.
    • Field Detail

      • PLACED

        static final int PLACED
        Flag that is set if the ChemObject is placed when calculating 2D/3D layouts.
        See Also:
        Constant Field Values
      • IN_RING

        static final int IN_RING
        Flag that is set when the ChemObject is part of a ring.
        See Also:
        Constant Field Values
      • NOT_IN_RING

        static final int NOT_IN_RING
        Flag that is set when the ChemObject is part of a ring. Note !isInRing() is preferred.
        See Also:
        Constant Field Values
      • ALIPHATIC

        static final int ALIPHATIC
        Flag that is set if a ChemObject is part of an aliphatic chain. Since normally ALIPHATIC = !AROMATIC and AROMATIC = !ALIPHATIC.
        See Also:
        Constant Field Values
      • VISITED

        static final int VISITED
        Flag is set if ChemObject has been visited.
        See Also:
        Constant Field Values
      • AROMATIC

        static final int AROMATIC
        Flag is set if ChemObject is part of an aromatic system.
        See Also:
        Constant Field Values
      • CONJUGATED

        static final int CONJUGATED
        Flag is set if ChemObject is part of a conjugated system.
        See Also:
        Constant Field Values
      • MAPPED

        static final int MAPPED
        Flag is set if a ChemObject is mapped to another ChemObject. It is used for example in subgraph isomorphism search. Note this flag is not currently used.
        See Also:
        Constant Field Values
      • HYDROGEN_BOND_DONOR

        static final int HYDROGEN_BOND_DONOR
        Sets to true if the atom is a hydrogen bond donor.
        See Also:
        Constant Field Values
      • HYDROGEN_BOND_ACCEPTOR

        static final int HYDROGEN_BOND_ACCEPTOR
        Sets to true if the atom is a hydrogen bond acceptor.
        See Also:
        Constant Field Values
      • REACTIVE_CENTER

        static final int REACTIVE_CENTER
        Flag is set if a ChemObject has reactive center. It is used for example in reaction.
        See Also:
        Constant Field Values
      • TYPEABLE

        static final int TYPEABLE
        Flag is set if an atom could be typed.
        See Also:
        Constant Field Values
      • SINGLE_OR_DOUBLE

        static final int SINGLE_OR_DOUBLE
        Flag used for marking uncertainty of the bond order. If used on an
        • IAtomContainer it means that one or several of the bonds have this flag raised (which may indicate aromaticity).
        • IBond it means that it's unclear whether the bond is a single or double bond.
        • IAtom it is a way for the Smiles parser to indicate that this atom was written with a lower case letter, e.g. 'c' rather than 'C'
        See Also:
        Constant Field Values
    • Method Detail

      • getListenerCount

        int getListenerCount()
        Returns the number of ChemObjectListeners registered with this object.
        Returns:
        the number of registered listeners.
      • setNotification

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

        boolean getNotification()
        Returns the flag that indicates whether notification messages are sent around.
        Returns:
        true if messages are sent.
        See Also:
        setNotification(boolean)
      • notifyChanged

        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.
      • notifyChanged

        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.
        Parameters:
        evt - A ChemObjectChangeEvent pointing to the source of where the change happend
      • getProperty

        <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
        
         
        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:
        setProperty(java.lang.Object, java.lang.Object), getProperty(Object, Class), removeProperty(java.lang.Object)
      • getProperty

        <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
        
         
        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:
        getProperty(Object), addProperties(java.util.Map)
      • getID

        String getID()
        Returns the identifier (ID) of this object.
        Returns:
        a String representing the ID value
        See Also:
        setID(java.lang.String)
      • setID

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

        void setFlag​(int mask,
                     boolean value)
        Sets the value of some flag. The flag is a mask from a given CDKConstant (e.g. AROMATIC or VISITED). The flags are intrinsic internal properties and should not be used to store custom values, please use 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);
         
        Parameters:
        mask - flag to set the value for
        value - value to assign to flag
        See Also:
        getFlag(int)
      • getFlag

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

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

        void addProperties​(Map<Object,​Object> properties)
        Add properties to this object, duplicate keys will replace any existing value.
        Parameters:
        properties - a Map specifying the property values
        See Also:
        getProperties()
      • getFlagValue

        @Deprecated
        Number getFlagValue()
        Deprecated.
        used flags()
        Access the internal value used to store the flags. The flags are stored on a single numeric value and are set/cleared.
        Returns:
        numeric representation of the flags
      • set

        void set​(int flags)
        Set the provided flags. Any on-bits in the input parameter are set on in the ChemObject.
        Parameters:
        flags - the flags
      • clear

        void clear​(int flags)
        Clear the provided flags. Any on-bits in the input parameter are set on in the ChemObject.
        Parameters:
        flags - the flags
      • is

        boolean is​(int flags)
        Test if a flag(s) are set on this ChemObject. If multiple flags are provided they must all be set to return true.
        
         atom.set(IS_IN_RING);
         atom.is(IS_IN_RING); // false!
         atom.is(IS_IN_RING+IS_AROMATIC); // false!
         atom.set(IS_AROMATIC);
         atom.is(IS_IN_RING+IS_AROMATIC); // true!
         
        Parameters:
        flags - the flags
      • flags

        int flags()
        Access the current value of the flags for this ChemObject.
        Returns:
        the flag value (32-bit integer)
      • toString

        String toString()
        Returns a one line description of this IChemObject.
        Overrides:
        toString in class Object
        Returns:
        a String representation of this object