All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.kandy.dsl.scale.kt Maven / Gradle / Ivy

There is a newer version: 0.7.1-dev-54
Show newest version
/*
* Copyright 2020-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package org.jetbrains.kotlinx.kandy.dsl

import org.jetbrains.kotlinx.kandy.ir.bindings.NonPositionalMappingParameters
import org.jetbrains.kotlinx.kandy.ir.bindings.NonPositionalMappingParametersContinuous
import org.jetbrains.kotlinx.kandy.ir.bindings.PositionalMappingParameters
import org.jetbrains.kotlinx.kandy.ir.bindings.PositionalMappingParametersContinuous
import org.jetbrains.kotlinx.kandy.ir.scale.*

/**
 * Creates a new continuous positional scale (with non-nullable domain).
 *
 * @param DomainType scale domain type.
 * @param limits [ClosedRange] defining the scale domain.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun > PositionalMappingParametersContinuous<*>.continuous(
    limits: ClosedRange,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    limits.start, limits.endInclusive, null, transform
)

/**
 * Creates a new continuous positional scale (with non-nullable domain).
 *
 * @param DomainType scale domain type.
 * @param limits [ClosedRange] defining the scale domain.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun > Scale.Companion.continuousPos(
    limits: ClosedRange,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    limits.start, limits.endInclusive, null, transform
)

/**
 * Creates a new continuous positional scale (with nullable domain).
 *
 * @param DomainType scale domain type.
 * @param limits [ClosedRange] defining the scale domain.
 * @param nullValue value which null is mapped to.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun > PositionalMappingParametersContinuous<*>.continuous(
    limits: ClosedRange,
    nullValue: DomainType? = null,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    limits.start, limits.endInclusive, nullValue, transform
)

/**
 * Creates a new continuous positional scale (with nullable domain).
 *
 * @param DomainType scale domain type.
 * @param limits [ClosedRange] defining the scale domain.
 * @param nullValue value which null is mapped to.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun > Scale.Companion.continuousPos(
    limits: ClosedRange,
    nullValue: DomainType? = null,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    limits.start, limits.endInclusive, nullValue, transform
)

/**
 * Creates a new continuous positional scale (with non-nullable domain).
 *
 * @param DomainType scale domain type.
 * @param min scale domain minimum.
 * @param max scale domain maximum.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun  PositionalMappingParametersContinuous<*>.continuous(
    min: DomainType? = null,
    max: DomainType? = null,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(min, max, null, transform)

/**
 * Creates a new continuous positional scale (with non-nullable domain).
 *
 * @param DomainType scale domain type.
 * @param min scale domain minimum.
 * @param max scale domain maximum.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun  Scale.Companion.continuousPos(
    min: DomainType? = null,
    max: DomainType? = null,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    min, max, null, transform
)

/**
 * Creates a new continuous positional scale (with nullable domain).
 *
 * @param DomainType scale domain type.
 * @param min scale domain minimum.
 * @param max scale domain maximum.
 * @param nullValue value which null is mapped to.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun  PositionalMappingParametersContinuous<*>.continuous(
    min: DomainType? = null,
    max: DomainType? = null,
    nullValue: DomainType? = null,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    min, max, nullValue, transform
)

/**
 * Creates a new continuous positional scale (with nullable domain).
 *
 * @param DomainType scale domain type.
 * @param min scale domain minimum.
 * @param max scale domain maximum.
 * @param nullValue value which null is mapped to.
 * @param transform the transformation of scale.
 * @return new [PositionalContinuousScale] with given limits.
 */
public fun  Scale.Companion.continuousPos(
    min: DomainType? = null,
    max: DomainType? = null,
    nullValue: DomainType? = null,
    transform: PositionalTransform? = null
): PositionalContinuousScale = PositionalContinuousScale(
    min, max, nullValue, transform
)

/**
 * Creates a new categorical positional scale.
 *
 * @param DomainType scale domain type.
 * @param categories [List] defining the scale domain.
 * @return new [PositionalCategoricalScale] with given categories.
 */
public fun  PositionalMappingParameters<*>.categorical(
    categories: List? = null,
): PositionalCategoricalScale = PositionalCategoricalScale(categories)

/**
 * Creates a new categorical positional scale.
 *
 * @param DomainType scale domain type.
 * @param categories [List] defining the scale domain.
 * @return new [PositionalCategoricalScale] with given categories.
 */
public fun  Scale.Companion.categoricalPos(
    categories: List? = null,
): PositionalCategoricalScale = PositionalCategoricalScale(categories)

/**
 * Creates a new continuous non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param range [ClosedRange] defining the scale range.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 * @return new [NonPositionalContinuousScale] with the given range.
 */
public fun , DomainType> NonPositionalMappingParametersContinuous<*, *>.continuous(
    range: ClosedRange,
    nullValue: RangeType? = null,
    transform: NonPositionalTransform? = null
): NonPositionalContinuousScale =
    NonPositionalContinuousScale(
        null, null, range.start, range.endInclusive, nullValue, transform
    )

/**
 * Creates a new continuous non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param range [ClosedRange] defining the scale range.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 * @return new [NonPositionalContinuousScale] with the given range.
 */
public fun , DomainType> Scale.Companion.continuous(
    range: ClosedRange,
    nullValue: RangeType? = null,
    transform: NonPositionalTransform? = null
): NonPositionalContinuousScale =
    NonPositionalContinuousScale(
        null, null, range.start, range.endInclusive, nullValue, transform
    )

/**
 * Creates a new continuous non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param range [ClosedRange] defining the scale range.
 * @param domain [ClosedRange] defining the scale domain.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 * @return new [NonPositionalContinuousScale] with the given domain and range.
 */
public fun , DomainType : Comparable>
        NonPositionalMappingParametersContinuous<*, *>.continuous(
    range: ClosedRange? = null,
    domain: ClosedRange,
    nullValue: RangeType? = null,
    transform: NonPositionalTransform? = null
): NonPositionalContinuousScale =
    NonPositionalContinuousScale(
        domain.start, domain.endInclusive, range?.start, range?.endInclusive, nullValue, transform
    )

/**
 * Creates a new continuous non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param range [ClosedRange] defining the scale range.
 * @param domain [ClosedRange] defining the scale domain.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 * @return new [NonPositionalContinuousScale] with the given domain and range.
 */
public fun , DomainType : Comparable>
        Scale.Companion.continuous(
    range: ClosedRange? = null,
    domain: ClosedRange,
    nullValue: RangeType? = null,
    transform: NonPositionalTransform? = null
): NonPositionalContinuousScale =
    NonPositionalContinuousScale(
        domain.start, domain.endInclusive, range?.start, range?.endInclusive, nullValue, transform
    )

/**
 * Creates a new continuous non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param rangeMin scale range minimum.
 * @param rangeMax scale range maximum.
 * @param domainMin scale domain minimum.
 * @param domainMax scale domain maximum.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 * @return new [NonPositionalContinuousScale] with the given domain and range.
 */
public fun  NonPositionalMappingParametersContinuous<*, *>.continuous(
    rangeMin: RangeType? = null,
    rangeMax: RangeType? = null,
    domainMin: DomainType? = null,
    domainMax: DomainType? = null,
    nullValue: RangeType? = null,
    transform: NonPositionalTransform? = null
): NonPositionalContinuousScale =
    NonPositionalContinuousScale(
        domainMin, domainMax, rangeMin, rangeMax, nullValue, transform
    )

/**
 * Creates a new continuous non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param rangeMin scale range minimum.
 * @param rangeMax scale range maximum.
 * @param domainMin scale domain minimum.
 * @param domainMax scale domain maximum.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 * @return new [NonPositionalContinuousScale] with the given domain and range.
 */
public fun  Scale.Companion.continuous(
    rangeMin: RangeType? = null,
    rangeMax: RangeType? = null,
    domainMin: DomainType? = null,
    domainMax: DomainType? = null,
    nullValue: RangeType? = null,
    transform: NonPositionalTransform? = null
): NonPositionalContinuousScale =
    NonPositionalContinuousScale(
        domainMin, domainMax, rangeMin, rangeMax, nullValue, transform
    )

/**
 * Creates a new categorical non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param range [List] defining the scale range.
 * @param domain [List] defining the scale domain.
 * @return new [NonPositionalCategoricalScale] with given domain and range.
 */
public inline fun  NonPositionalMappingParameters<*, *>.categorical(
    range: List? = null,
    domain: List? = null,
): NonPositionalCategoricalScale =
    NonPositionalCategoricalScale(domain, range)

/**
 * Creates a new categorical non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param range [List] defining the scale range.
 * @param domain [List] defining the scale domain.
 * @return new [NonPositionalCategoricalScale] with given domain and range.
 */
public inline fun  Scale.Companion.categorical(
    range: List? = null,
    domain: List? = null,
): NonPositionalCategoricalScale =
    NonPositionalCategoricalScale(domain, range)

/**
 * Creates a new categorical non-positional scale.
 *
 * @param DomainType scale domain type.
 * @param RangeType type of the scale range.
 * @param categoriesToValues [List] of pairs of category to corresponding value.
 * @return new [NonPositionalCategoricalScale] by domain-to-range correspondence.
 */
public fun  NonPositionalMappingParameters<*, *>.categorical(
    vararg categoriesToValues: Pair,
): NonPositionalCategoricalScale =
    NonPositionalCategoricalScale(
        categoriesToValues.map { it.first },
        categoriesToValues.map { it.second },
    )

/**
 * Creates a new categorical non-positional scale.
 *
 * @param DomainType scale domain type
 * @param RangeType type of the scale range
 * @param categoriesToValues [List] of pairs of category to corresponding value.
 * @return new [NonPositionalCategoricalScale] by domain-to-range correspondence.
 */
public fun  Scale.Companion.categorical(
    vararg categoriesToValues: Pair,
): NonPositionalCategoricalScale =
    NonPositionalCategoricalScale(
        categoriesToValues.map { it.first },
        categoriesToValues.map { it.second },
    )




© 2015 - 2024 Weber Informatics LLC | Privacy Policy