Skip to main content

Class: G3XUnitFormatter

Defined in: src/workingtitle-instruments-g3x-touch/html_ui/Shared/Graphics/Text/G3XUnitFormatter.ts:11

A utility class for creating G3X Touch unit formatters.

Each unit formatter is a function which generates output strings from input measurement units.

Constructors​

Constructor​

new G3XUnitFormatter(): G3XUnitFormatter

Returns​

G3XUnitFormatter

Methods​

create()​

static create(defaultString): (unit) => string

Defined in: src/workingtitle-instruments-g3x-touch/html_ui/Shared/Graphics/Text/G3XUnitFormatter.ts:202

Creates a function which formats measurement units to G3X-style strings representing their abbreviated names.

Parameters​

ParameterTypeDefault valueDescription
defaultStringstring''The string to output when the input unit cannot be formatted. Defaults to the empty string.

Returns​

A function which formats measurement units to G3X-style strings representing their abbreviated names.

(unit): string

Parameters​
ParameterType
unitUnit<any>
Returns​

string


createBasic()​

static createBasic(defaultString): (unit) => string

Defined in: src/workingtitle-instruments-g3x-touch/html_ui/Shared/Graphics/Text/G3XUnitFormatter.ts:211

Creates a function which formats measurement units to basic-style strings representing their abbreviated names.

Parameters​

ParameterTypeDefault valueDescription
defaultStringstring''The string to output when the input unit cannot be formatted. Defaults to the empty string.

Returns​

A function which formats measurement units to basic-style strings representing their abbreviated names.

(unit): string

Parameters​
ParameterType
unitUnit<any>
Returns​

string


getBasicUnitTextMap()​

static getBasicUnitTextMap(): Readonly<Partial<Record<string, Readonly<Partial<Record<string, string>>>>>>

Defined in: src/workingtitle-instruments-g3x-touch/html_ui/Shared/Graphics/Text/G3XUnitFormatter.ts:229

Gets a mapping of unit family and name to basic-style text used by G3XUnitFormatter to format units. The returned object maps unit families to objects that map unit names within each family to formatted text.

Returns​

Readonly<Partial<Record<string, Readonly<Partial<Record<string, string>>>>>>

A mapping of unit family and name to basic-style text used by G3XUnitFormatter to format units.


getUnitTextMap()​

static getUnitTextMap(): Readonly<Partial<Record<string, Readonly<Partial<Record<string, string>>>>>>

Defined in: src/workingtitle-instruments-g3x-touch/html_ui/Shared/Graphics/Text/G3XUnitFormatter.ts:220

Gets a mapping of unit family and name to G3X-style text used by G3XUnitFormatter to format units. The returned object maps unit families to objects that map unit names within each family to formatted text.

Returns​

Readonly<Partial<Record<string, Readonly<Partial<Record<string, string>>>>>>

A mapping of unit family and name to G3X-style text used by G3XUnitFormatter to format units.