Skip to main content

Overview

The ModelScaler interface defines how a model’s scale is calculated. Scalers can be constant values, derived from entity attributes, or composites of multiple scalers. They are serializable to JSON for configuration purposes.

Interface Definition

Core Methods

name()

Returns the name of this scaler type.
Returns: The scaler type name (e.g., “default”, “entity”, “value”, “composite”)

scale()

Calculates the scale for a given tracker.
Parameters:
  • tracker - The tracker instance to calculate scale for
Returns: The calculated scale factor

data()

Returns the configuration data for this scaler as a JSON element.
Returns: The configuration data, or null if none

Static Factory Methods

defaultScaler()

Returns the default scaler (constant 1.0).
Returns: A scaler that always returns 1.0 Example:

entity()

Returns a scaler that uses the entity’s scale attribute.
Returns: A scaler based on entity scale Example:

value()

Returns a constant value scaler.
Parameters:
  • value - The constant scale value
Returns: A scaler that always returns the specified value Example:

composite()

Creates a composite scaler that multiplies the results of multiple scalers.
Parameters:
  • scalers - The scalers to combine
Returns: A composite scaler that multiplies all child scaler results Example:

deserialize()

Deserializes a scaler from a JSON object.
Parameters:
  • element - The JSON object containing scaler configuration
Returns: The deserialized scaler, or the default scaler if invalid Example:

Instance Methods

multiply()

Multiplies this scaler by a constant value.
Parameters:
  • value - The multiplier
Returns: A new composite scaler Example:

composite()

Multiplies this scaler by another scaler.
Parameters:
  • scaler - The other scaler to multiply with
Returns: A new composite scaler Example:

serialize()

Serializes this scaler to a JSON object.
Returns: The JSON representation of this scaler Example:

Nested Interfaces

Getter

Functional interface for calculating scale values.
Constants:
  • DEFAULT - Returns 1.0
  • ENTITY - Returns entity scale attribute

Builder

Builder interface for creating Getters from JSON.

Usage Example

JSON Format

Scalers are serialized using the following JSON format:
For composite scalers:

Extending ModelScaler

You can register custom scaler types using the Deserializer:

See Also