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

commonMain.org.jetbrains.letsPlot.intern.ThemeOptionsUtil.kt Maven / Gradle / Ivy

There is a newer version: 4.8.0
Show newest version
package org.jetbrains.letsPlot.intern

import org.jetbrains.letsPlot.core.spec.Option
import org.jetbrains.letsPlot.intern.OptionsUtil.mergeOptions

internal object ThemeOptionsUtil {
    fun toSpec(themeOptionList: List): Map? {
        val specList = themeOptionList.map(OptionsMap::toSpec)

        val result: Map? = specList.reduceOrNull() { prev, next ->
            val merged = next[Option.Meta.NAME]?.let {
                // keep the previously specified flavor
                val flavor = prev.filterKeys { it == Option.Theme.FLAVOR }

                // 'named' theme overrides all prev theme options.
                next + flavor
            } ?: mergeOptions(prev, next)

            merged.toMutableMap()
        }
        return result
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy