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

org.jetbrains.kotlinx.ggdsl.letsplot.layers.density2D.kt Maven / Gradle / Ivy

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

package org.jetbrains.kotlinx.ggdsl.letsplot.layers


//public val DENSITY_2D: LetsPlotGeom = LetsPlotGeom("density_2D")

/*
// todo stats
@PlotDslMarker
// todo move x/y?
<<<<<<< HEAD
class Density2DContext(
    parent: LayerCollectorContext,
=======
public class Density2DContext(
    override var data: MutableNamedData,
>>>>>>> main
    kernel: Kernel?,
    bandWidth: BandWidth?,
    pointsSampled: Int?,
    trim: Boolean?,
    adjust: Double?,
    fullScanMax: Int?,
) : LayerContext(parent) {
    // todo internal
    @PublishedApi
    internal val _x: XAes get() = XAes(this)

    @PublishedApi
    internal val _y: YAes get() = YAes(this)

    public val x: XDummyAes get() = XDummyAes(this)
    public val y: YDummyAes get() = YDummyAes(this)

    public object Statistics {
        public val X: ContourStat.X = ContourStat.X
        public val Y: ContourStat.Y = ContourStat.Y
        public val LEVEL: ContourStat.Level = ContourStat.Level
        public val GROUP: ContourStat.Group = ContourStat.Group
    }

    public val Stat: Statistics = Statistics


    public val alpha: AlphaAes get() = AlphaAes(this)

    // val fillColor get() = FillAes(this)
    public val borderLineWidth: SizeAes get() = SizeAes(this)
    public val borderLineColor: ColorAes get() = ColorAes(this)
    public val borderLineType: LineTypeAes get() = LineTypeAes(this)

    // todo weight
// TODO params

    @PublishedApi
    internal val kernel: KernelAes get() = KernelAes(this)

    @PublishedApi
    internal val bw: BWAes get() = BWAes(this)

    @PublishedApi
    internal val pointsSampled: NumberAes get() = NumberAes(this)

    @PublishedApi
    internal val trim: TrimAes get() = TrimAes(this)

    @PublishedApi
    internal val adjust: AdjustAes get() = AdjustAes(this)

    @PublishedApi
    internal val fullScanMax: FullScanMaxAes get() = FullScanMaxAes(this)

    init {
        kernel?.let {
            kernel(it)
        }
        bandWidth?.let {
            bw(it)
        }
        pointsSampled?.let {
            pointsSampled(it)
        }
        trim?.let {
            trim(it)
        }
        adjust?.let {
            adjust(it)
        }
        fullScanMax?.let {
            fullScanMax(it)
        }
    }


    public inline operator fun  ScalablePositionalAes.invoke(
        stat: ContourStat
    ): ScaledUnspecifiedDefaultPositionalMapping {
        val mapping = ScaledUnspecifiedDefaultPositionalMapping(
            this.name,
            stat.toDataSource().scaled(),
            typeOf()
        )
        context.bindingCollector.mappings[this.name] = mapping
        return mapping
    }


    public inline operator fun 
        MappableNonPositionalAes.invoke(
        stat: ContourStat
    ): ScaledUnspecifiedDefaultNonPositionalMapping {
        val mapping = ScaledUnspecifiedDefaultNonPositionalMapping(
            this.name,
            stat.toDataSource().scaled(),
            typeOf()
        )
        context.bindingCollector.mappings[this.name] = mapping
        return mapping
    }


}

<<<<<<< HEAD
inline fun  PlotContext.density2D(
    sourceX: ColumnPointer,
    sourceY: ColumnPointer,
=======
public inline fun  PlotContext.density2D(
    sourceX: DataSource,
    sourceY: DataSource,
>>>>>>> main
    kernel: Kernel? = null,
    bandWidth: BandWidth? = null,
    pointsSampled: Int? = null,
    trim: Boolean? = null,
    adjust: Double? = null,
    fullScanMax: Int? = null,
    block: Density2DContext.() -> Unit
) {
    layers.add(
        Density2DContext(data, kernel, bandWidth, pointsSampled, trim, adjust, fullScanMax)
            .apply {
                copyFrom(this@density2D)
                _x(sourceX)
                _y(sourceY)
            }
            .apply(block)
            .toLayer(DENSITY_2D)
    )
}

public inline fun  PlotContext.density2D(
    sourceX: Iterable,
    sourceY: Iterable,
    kernel: Kernel? = null,
    bandWidth: BandWidth? = null,
    pointsSampled: Int? = null,
    trim: Boolean? = null,
    adjust: Double? = null,
    fullScanMax: Int? = null,
    block: Density2DContext.() -> Unit
) {
    layers.add(
        Density2DContext(data, kernel, bandWidth, pointsSampled, trim, adjust, fullScanMax)
            .apply {
                copyFrom(this@density2D)
                _x(sourceX)
                _y(sourceY)
            }
            .apply(block)
            .toLayer(DENSITY_2D)
    )
}

 */




© 2015 - 2025 Weber Informatics LLC | Privacy Policy