Class CDK2DAtomColors

  • All Implemented Interfaces:
    Serializable, IAtomColorer

    public class CDK2DAtomColors
    extends Object
    implements IAtomColorer, Serializable
    Gives a short table of atom colors for 2D display. The coloring is loosely based on Jmol CPK. The internal color map can be modified by invoking the set method. For convenience the set method returns the colorer instance for chaining.
    
     IAtomColorer colorer = new CDK2DAtomColors().set("H", Color.LIGHT_GRAY)
                                                 .set("O", Color.RED.lighter());
     
    See Also:
    CPK coloring, Jmol, Colors, Serialized Form
    Source code:
    main
    Belongs to CDK module:
    render
    • Constructor Detail

      • CDK2DAtomColors

        public CDK2DAtomColors()
    • Method Detail

      • getAtomColor

        public Color getAtomColor​(IAtom atom)
        Returns the color for a certain atom type.
        Specified by:
        getAtomColor in interface IAtomColorer
        Parameters:
        atom - the atom whose color is desired
        Returns:
        the color of the specified atom
      • getAtomColor

        public Color getAtomColor​(IAtom atom,
                                  Color defaultColor)
        Returns the color for a certain atom type, and uses the given default color if it fails to identify the atom type.
        Specified by:
        getAtomColor in interface IAtomColorer
        Parameters:
        atom - the atom in question
        defaultColor - the color to use if the atom type of this atom cannot be identified
        Returns:
        the color of the specified atom