private static boolean checkAbbreviationHighlight ( IAtomContainer container , Sgroup sgroup ) { assert sgroup . getType ( ) == SgroupType . CtabAbbreviation ; Set < IAtom > sgroupAtoms = sgroup . getAtoms ( ) ; int atomHighlight = 0 ; int bondHighlight = 0 ; int numSgroupAtoms = sgroupAtoms . size ( ) ; int numSgroupBonds = 0 ; Color color = null ; Color refcolor = null ; for ( IAtom atom : sgroupAtoms ) { if ( ( color = atom . getProperty ( StandardGenerator . HIGHLIGHT_COLOR ) ) != null ) { atomHighlight ++ ; if ( refcolor == null ) refcolor = color ; else if ( ! color . equals ( refcolor ) ) return false ; // multi-colored } else if ( atomHighlight != 0 ) { return false ; // fail fast } } for ( IBond bond : container . bonds ( ) ) { IAtom beg = bond . getBegin ( ) ; IAtom end = bond . getEnd ( ) ; if ( sgroupAtoms . contains ( beg ) && sgroupAtoms . contains ( end ) ) { numSgroupBonds ++ ; if ( ( color = bond . getProperty ( StandardGenerator . HIGHLIGHT_COLOR ) ) != null ) { bondHighlight ++ ; if ( refcolor == null ) refcolor = color ; else if ( ! color . equals ( refcolor ) ) return false ; // multi-colored } else if ( bondHighlight != 0 ) { return false ; // fail fast } } } return atomHighlight + bondHighlight == 0 || ( atomHighlight == numSgroupAtoms && bondHighlight == numSgroupBonds ) ; }
Checks whether the given abbreviation Sgroup either has no highlight or is fully highlighted . If an abbreviation is partially highlighted we don t want to contract it as this would hide the part being highlighted .