Class ChooserMetrics

java.lang.Object
com.iizigo.prop.editor.color.swt.ChooserMetrics

public final class ChooserMetrics extends Object
The size arithmetic of the SWT color chooser (CC-COLOR-CHOOSER-SWT-PANELS, 2026-10-10). Every size is in SWT points: SWT scales them by the monitor's zoom, so no zoom arithmetic happens here. The one input is the height of the dialog font's metrics (ApplicationUI.fontCY, 15 points for the standard Windows dialog font), from which the swatch cell follows (ruling SC-D-2 of CC-FIX-COLOR-CHOOSER: 10 points at 15).

Pure functions, tested headless.

Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The gap between two cells, in points.
    static final int
    The largest swatch cell as a multiple of the cell at the dialog font (cellSize(int)): the Swatches tab grows its cells with its size up to three times that cell, 30 points at the reference font (CC-FIX-SWATCHES-SCALE, 2026-10-28), so that a maximized dialog does not make tiles of a palette.
    static final int
    The smallest swatch cell, in points.
    static final int
    The swatch cell at the reference font height, in points.
    static final int
    The side of the color diagrams at the reference font height, in points.
    static final int
    The reference height of the dialog font's metrics in points (Segoe UI 9 pt: 15).
    static final int
    The width of the hue strip at the reference font height, in points.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    cellSize(int fontHeight)
    Gets the swatch cell size for a dialog font height: the reference cell of 10 at the reference height of 15 points, proportional otherwise, never below MIN_CELL.
    static int
    gridExtent(int cells, int cellSize)
    Gets the extent of a grid of cells along one axis: the cells with the gaps between them.
    static int
    pitch(int cellSize)
    Gets the pitch of a grid: a cell and its gap.
    static int
    scaled(int reference, int fontHeight)
    Scales a reference size (at the reference font height) to a font height, at least 1.
  • Field Details

    • REFERENCE_CELL

      public static final int REFERENCE_CELL
      The swatch cell at the reference font height, in points.
      See Also:
    • REFERENCE_FONT_HEIGHT

      public static final int REFERENCE_FONT_HEIGHT
      The reference height of the dialog font's metrics in points (Segoe UI 9 pt: 15).
      See Also:
    • MIN_CELL

      public static final int MIN_CELL
      The smallest swatch cell, in points.
      See Also:
    • MAX_CELL_SCALE

      public static final int MAX_CELL_SCALE
      The largest swatch cell as a multiple of the cell at the dialog font (cellSize(int)): the Swatches tab grows its cells with its size up to three times that cell, 30 points at the reference font (CC-FIX-SWATCHES-SCALE, 2026-10-28), so that a maximized dialog does not make tiles of a palette.
      See Also:
    • GAP

      public static final int GAP
      The gap between two cells, in points.
      See Also:
    • REFERENCE_DIAGRAM

      public static final int REFERENCE_DIAGRAM
      The side of the color diagrams at the reference font height, in points.
      See Also:
    • REFERENCE_STRIP

      public static final int REFERENCE_STRIP
      The width of the hue strip at the reference font height, in points.
      See Also:
  • Method Details

    • cellSize

      public static int cellSize(int fontHeight)
      Gets the swatch cell size for a dialog font height: the reference cell of 10 at the reference height of 15 points, proportional otherwise, never below MIN_CELL.
      Parameters:
      fontHeight - The height of the dialog font's metrics in points (fontCY), a value below 1 for the reference.
      Returns:
      The cell size in points.
    • pitch

      public static int pitch(int cellSize)
      Gets the pitch of a grid: a cell and its gap.
    • gridExtent

      public static int gridExtent(int cells, int cellSize)
      Gets the extent of a grid of cells along one axis: the cells with the gaps between them.
      Parameters:
      cells - The number of cells.
      cellSize - The cell size.
    • scaled

      public static int scaled(int reference, int fontHeight)
      Scales a reference size (at the reference font height) to a font height, at least 1.
      Parameters:
      reference - The size at the reference font height.
      fontHeight - The height of the dialog font's metrics, a value below 1 for the reference.