saker.build Documentation TaskDoc JavaDoc Packages
public interface TokenStyle
A token style defines how a given source code element should be displayed in the IDE.

Token styles define the style of the displayed font, the colors of the text, and the background color of the text. Styles are defined for applicable themes, which may be light or dark, based on user preferences.

A token style can be defined with multiple applicable themes, in which case the given text style will be applied when any of the theme is selected as current in the user IDE.

The styles and theme are stored as flags in the getStyle() property of the interface. The actual value is a mix of STYLE_ and THEME_ constant flags.

The colors are stored in an integer, in the following packed format: 0xAARRGGBB.
Where AA is alpha, RR is red, GG is green, and BB is blue, on a 0-255 scale.

The 0 (zero) color value is reserved as the default color. The IDE can choose an appropriate color for the given attribute. (See COLOR_UNSPECIFIED)

If an IDE doesn't support a given font style, it won't be applied to it.

Fields
public static final int
The unspecified color constant.
public static final int
Style flag constant for making the text bold.
public static final int
The default style for the text.
public static final int
Style flag constant for making the text italic.
public static final int
Style mask to isolate style related flags.
public static final int
Style flag constant for making the text stroke through.
public static final int
Style flag constant for making the text underlined.
public static final int
Style flag constant for making a style applicable for dark themes.
public static final int
Style flag constant for making a style applicable for light themes.
public static final int
Style mask to isolate theme related flags.
Methods
public static int
argb(int alpha, int r, int g, int b)
Creates a color value.
public boolean
Checks if this token style is the same as the argument.
public int
Gets the background color.
public int
Gets the foreground color (the text color).
public int
Gets the style and theme flags for this style.
public static int
getTheme(int styleflag)
Gets the theme related flags from a style flag.
public int
Gets the has code of the token style.
public static boolean
isDarkTheme(int style)
Checks if the argument style flag is applicable to dark theme.
public static boolean
isLightTheme(int style)
Checks if the argument style flag is applicable to light theme.
public static int
rgb(int r, int g, int b)
Creates a color value with full opacity (255 alpha).
public static final int COLOR_UNSPECIFIED = 0
The unspecified color constant.
public static final int STYLE_BOLD = 1
Style flag constant for making the text bold.
public static final int STYLE_DEFAULT = 0
The default style for the text.

In an IDE it represents text without any artifacts.

public static final int STYLE_ITALIC = 2
Style flag constant for making the text italic.
public static final int STYLE_MASK = 15
Style mask to isolate style related flags.
public static final int STYLE_STRIKETHROUGH = 8
Style flag constant for making the text stroke through.
public static final int STYLE_UNDERLINE = 4
Style flag constant for making the text underlined.
public static final int THEME_DARK = 16
Style flag constant for making a style applicable for dark themes.
public static final int THEME_LIGHT = 32
Style flag constant for making a style applicable for light themes.
public static final int THEME_MASK = 48
Style mask to isolate theme related flags.
public static int argb(int alpha, int r, int g, int b)
Creates a color value.

Only the last byte of the arguments will be used.

alphaThe alpha value.
rThe red value.
gThe green value.
bThe blue value.
The packed color.
public abstract boolean equals(Object obj)
Checks if this token style is the same as the argument.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

true if this object is the same as the obj argument; false otherwise.
public abstract int getBackgroundColor()
Gets the background color.
The color in ARGB packed format.
public abstract int getForegroundColor()
Gets the foreground color (the text color).
The color in ARGB packed format.
public abstract int getStyle()
Gets the style and theme flags for this style.
The style.
public static int getTheme(int styleflag)
Gets the theme related flags from a style flag.

The result may be 0, if no theme is specified in the argument style.

styleflagThe style flag.
The theme.
public abstract int hashCode()
Gets the has code of the token style. The hash code is defined as follows:
 backgroundColor * 31 + foregroundColor * 31 + style * 31
 
Returns a hash code value for the object.This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

a hash code value for this object.
public static boolean isDarkTheme(int style)
Checks if the argument style flag is applicable to dark theme.
styleThe style flags.
true if it contains THEME_DARK.
public static boolean isLightTheme(int style)
Checks if the argument style flag is applicable to light theme.
styleThe style flags.
true if it contains THEME_LIGHT.
public static int rgb(int r, int g, int b)
Creates a color value with full opacity (255 alpha).

Only the last byte of the arguments will be used.

rThe red value.
gThe green value.
bThe blue value.
The packed color.