Class SimplePalette

  • All Implemented Interfaces:
    Palette
    Direct Known Subclasses:
    MedianCutPalette

    public class SimplePalette
    extends java.lang.Object
    implements Palette
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int[] palette  
    • Constructor Summary

      Constructors 
      Constructor Description
      SimplePalette​(int[] palette)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getEntry​(int index)
      Looks up the color for a given palette index.
      int getPaletteIndex​(int rgb)
      Looks up the palette index for a given color.
      int length()
      The number of entries in the palette.
      • Methods inherited from class java.lang.Object

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

      • palette

        private final int[] palette
    • Constructor Detail

      • SimplePalette

        public SimplePalette​(int[] palette)
    • Method Detail

      • getPaletteIndex

        public int getPaletteIndex​(int rgb)
        Description copied from interface: Palette
        Looks up the palette index for a given color.
        Specified by:
        getPaletteIndex in interface Palette
        Parameters:
        rgb - the color to look up
        Returns:
        the palette index
      • getEntry

        public int getEntry​(int index)
        Description copied from interface: Palette
        Looks up the color for a given palette index.
        Specified by:
        getEntry in interface Palette
        Parameters:
        index - the palette index to look up
        Returns:
        the color in ARGB format
      • length

        public int length()
        Description copied from interface: Palette
        The number of entries in the palette.
        Specified by:
        length in interface Palette
        Returns:
        the number of palette entries