Class AbstractAlignmentStyler

  • Direct Known Subclasses:
    SimpleAlignmentStyler

    public abstract class AbstractAlignmentStyler
    extends java.lang.Object

    Abstract implementation of AlignmentStyler, contains utility methods for generating a set of HTML styles from a list of RGB colours.

    Thus getAlignmentStyles() is implemented and all that remains to be implemented is the getStyle method.

     Primary author -
                     Colin Hardman      (CAT)
     Other authors  -
                     Tim Dilks          (CAT)
                     Simon Brocklehurst (CAT)
                     Stuart Johnston    (CAT)
                     Lawerence Bower    (CAT)
                     Derek Crockford    (CAT)
                     Neil Benn          (CAT)
    
     Copyright 2001 Cambridge Antibody Technology Group plc.
     

    This code released to the biojava project, May 2001 under the LGPL license.

    Version:
    1.0
    Author:
    Cambridge Antibody Technology Group plc, Greg Cox
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int iNumberOfColours
      The number of unique colours.
      protected java.util.HashMap oColourClassMap
      Stores mapping from a Colour to a FONT Class.
      protected java.util.HashMap oColourMap
      Map between Char and the Colour class.
      protected java.util.HashSet oColourSet
      Store the unique colours for markup.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addStyle​(java.lang.String poChar, java.lang.String poColour)
      Add a colour style to this Styler.
      java.lang.String getAlignmentStyles()
      Returns a fragment of HTML that defines the FONT styles to be used in the alignment markup.
      protected java.lang.String getColourClass​(java.lang.String poColour)
      Returns the colour class for the specified colour (in hex).
      abstract void getStyle​(java.lang.String poFirst, java.lang.String poSecond, java.lang.String[] poStyleHolder)
      Return the styles for the two aligned characters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • oColourSet

        protected java.util.HashSet oColourSet
        Store the unique colours for markup.
      • oColourClassMap

        protected java.util.HashMap oColourClassMap

        Stores mapping from a Colour to a FONT Class.

        For example:

        
         Key      Value
         ---      -----
         #000000  C1-S
        
         

      • iNumberOfColours

        protected int iNumberOfColours
        The number of unique colours.
      • oColourMap

        protected java.util.HashMap oColourMap

        Map between Char and the Colour class.

        Eg.

        
         Key      Value
         ---      -----
         A        C1-S
        
         

    • Constructor Detail

      • AbstractAlignmentStyler

        public AbstractAlignmentStyler()
    • Method Detail

      • getAlignmentStyles

        public java.lang.String getAlignmentStyles()

        Returns a fragment of HTML that defines the FONT styles to be used in the alignment markup.

        For example:

         FONT.C2-S{background-color:#FFFC50;color:#000000}
         FONT.C4-S{background-color:#FC50FF;color:#000000}
         FONT.C3-S{background-color:#FF7272;color:#000000}
         FONT.C0-S{background-color:#50FF78;color:#000000}
         FONT.C1-S{background-color:#FFCA50;color:#000000}
         FONT.C5-S{background-color:#A5A5FF;color:#000000}
         

        Returns:
        String - the HTML
      • getStyle

        public abstract void getStyle​(java.lang.String poFirst,
                                      java.lang.String poSecond,
                                      java.lang.String[] poStyleHolder)

        Return the styles for the two aligned characters. (in the form of predefined font classes).

        Null is acceptable value for no style.

        Parameters:
        poFirst - - the first char in the alignment
        poSecond - - the second char in the alignment
        poStyleHolder - - an array to hold the styles, [0] = first etc
      • addStyle

        public void addStyle​(java.lang.String poChar,
                             java.lang.String poColour)
        Add a colour style to this Styler.
        Parameters:
        poChar - the char for which this colour applies.
        poColour - the color in hex eg 'FFA2A2' for a nice red ( R = FF, G = A2 and B = A2 )
      • getColourClass

        protected java.lang.String getColourClass​(java.lang.String poColour)

        Returns the colour class for the specified colour (in hex). If one is not already defined for that colour then a new class is created and returned.

        Colour specification is R G B in hex ie FF00FF is r = 255, g = 0, b = 255.

        Parameters:
        poColour - - a colour, eg 'C8FFC8'
        Returns:
        String - the colour class, eg 'C1-S'