Class ColorPalette


  • public class ColorPalette
    extends java.lang.Object
    Color palette
    • Field Detail

      • terminal

        private final Terminal terminal
      • distanceName

        private java.lang.String distanceName
      • osc4

        private boolean osc4
      • palette

        private int[] palette
    • Constructor Detail

      • ColorPalette

        public ColorPalette()
      • ColorPalette

        public ColorPalette​(Terminal terminal)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • ColorPalette

        public ColorPalette​(Terminal terminal,
                            java.lang.String distance)
                     throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getDistanceName

        public java.lang.String getDistanceName()
        Get the name of the distance to use for rounding colors.
        Returns:
        the name of the color distance
      • setDistance

        public void setDistance​(java.lang.String name)
        Set the name of the color distance to use when rounding RGB colors to the palette.
        Parameters:
        name - the name of the color distance
      • canChange

        public boolean canChange()
        Check if the terminal has the capability to change colors.
        Returns:
        true if the terminal can change colors
      • loadPalette

        public boolean loadPalette()
                            throws java.io.IOException
        Load the palette from the terminal. If the palette has already been loaded, subsequent calls will simply return true.
        Returns:
        true if the palette has been successfully loaded.
        Throws:
        java.io.IOException
      • loadPalette

        protected void loadPalette​(boolean doLoad)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • getLength

        public int getLength()
        Get the palette length
        Returns:
        the palette length
      • getColor

        public int getColor​(int index)
        Get a specific color in the palette
        Parameters:
        index - the index of the color
        Returns:
        the color at the given index
      • setColor

        public void setColor​(int index,
                             int color)
        Change the color of the palette
        Parameters:
        index - the index of the color
        color - the new color value
      • isReal

        public boolean isReal()
      • round

        public int round​(int r,
                         int g,
                         int b)
      • round

        public int round​(int col)
      • doLoad

        private static int[] doLoad​(Terminal terminal)
                             throws java.io.IOException
        Throws:
        java.io.IOException