commonMain.jetbrains.datalore.plot.config.CoordConfig.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lets-plot-common Show documentation
Show all versions of lets-plot-common Show documentation
Lets-Plot JVM package without rendering part
/*
* Copyright (c) 2019. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.plot.config
import jetbrains.datalore.plot.builder.coord.CoordProvider
import jetbrains.datalore.plot.config.Option.Coord.FLIPPED
class CoordConfig private constructor(
private val name: String,
options: Map,
private val defaultCoordProvider: CoordProvider
) : OptionsAccessor(options) {
companion object {
fun create(coordOpts: Any?, defaultCoordProvider: CoordProvider): CoordProvider {
if (coordOpts == null) return defaultCoordProvider
val coordName = when (coordOpts) {
is Map<*, *> -> ConfigUtil.featureName(coordOpts)
else -> coordOpts.toString()
}
@Suppress("UNCHECKED_CAST")
val options: Map = when (coordOpts) {
is Map<*, *> -> coordOpts as Map
else -> emptyMap()
}
return when (coordName) {
Option.CoordName.FLIP -> {
// Flip the 'default' coord system.
val withFlip = options + mapOf(FLIPPED to true)
CoordProto.createCoordProvider(defaultCoordProvider, over(withFlip))
}
else -> {
CoordProto.createCoordProvider(coordName, over(options))
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy