Package org.jline.utils
Class ColorPalette
- java.lang.Object
-
- org.jline.utils.ColorPalette
-
public class ColorPalette extends java.lang.Object
Color palette
-
-
Field Summary
Fields Modifier and Type Field Description static ColorPalette
DEFAULT
static java.lang.String
XTERM_INITC
-
Constructor Summary
Constructors Constructor Description ColorPalette()
ColorPalette(Terminal terminal)
ColorPalette(Terminal terminal, java.lang.String distance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canChange()
Check if the terminal has the capability to change colors.int
getColor(int index)
Get a specific color in the paletteprotected org.jline.utils.Colors.Distance
getDist()
java.lang.String
getDistanceName()
Get the name of the distance to use for rounding colors.int
getLength()
Get the palette lengthboolean
isReal()
boolean
loadPalette()
Load the palette from the terminal.protected void
loadPalette(boolean doLoad)
int
round(int col)
int
round(int r, int g, int b)
void
setColor(int index, int color)
Change the color of the palettevoid
setDistance(java.lang.String name)
Set the name of the color distance to use when rounding RGB colors to the palette.java.lang.String
toString()
-
-
-
Field Detail
-
XTERM_INITC
public static final java.lang.String XTERM_INITC
- See Also:
- Constant Field Values
-
DEFAULT
public static final ColorPalette DEFAULT
-
-
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 returntrue
.- 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 colorcolor
- the new color value
-
isReal
public boolean isReal()
-
round
public int round(int r, int g, int b)
-
round
public int round(int col)
-
getDist
protected org.jline.utils.Colors.Distance getDist()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-