Class PillPalette

java.lang.Object
org.apache.juneau.console.views.PillPalette

public final class PillPalette extends Object
The categorical pill palette's slot function.

A pill column marked Render.categorical() colours each distinct value from a fixed palette of SIZE colours. The browser picks the slot with the hash documented on slot(String); this class is the same function in Java, for parity tests and for server-side code that wants to know which slot a value gets (for example to build a legend). The renderer does not call it at runtime.

SIZE is part of the colour contract: changing it recolours every categorical value.

Since:
10.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The number of palette slots (theme tokens --jc-pill-cat-1-* through --jc-pill-cat-10-*).
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    slot(String value)
    Returns the palette slot for a value.

    Methods inherited from class java.lang.Object

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

    • SIZE

      public static final int SIZE
      The number of palette slots (theme tokens --jc-pill-cat-1-* through --jc-pill-cat-10-*).
      See Also:
  • Method Details

    • slot

      public static int slot(String value)
      Returns the palette slot for a value.

      FNV-1a, 32-bit, over the UTF-16 code units of the exact string (no case folding, no trimming), then (hash mod SIZE) + 1 with the hash treated as unsigned. Matching is case-sensitive: "Pet" and "PET" are different values with independent slots. A null value hashes as the empty string.

      Reports only the hash slot, never a slot pinned with Render.category(String,int).

      Parameters:
      value - The cell value as displayed. Can be null.
      Returns:
      The slot, from 1 to SIZE inclusive.