commonMain.jetbrains.datalore.plot.builder.defaultTheme.DefaultAxisTheme.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) 2021. 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.builder.defaultTheme
import jetbrains.datalore.base.values.Color
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_LINE
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_TEXT
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_TICKS
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_TICKS_LENGTH
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_TITLE
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_TOOLTIP
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.AXIS_TOOLTIP_TEXT
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.Elem
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.LINE
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.RECT
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.TEXT
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.TITLE
import jetbrains.datalore.plot.builder.theme.AxisTheme
internal class DefaultAxisTheme(
axis: String,
options: Map
) : ThemeValuesAccess(options), AxisTheme {
private val suffix = "_$axis"
internal val lineKey = listOf(AXIS_LINE + suffix, AXIS_LINE, AXIS + suffix, AXIS, LINE)
internal val textKey = listOf(AXIS_TEXT + suffix, AXIS_TEXT, AXIS + suffix, AXIS, TEXT)
internal val titleKey = listOf(AXIS_TITLE + suffix, AXIS_TITLE, AXIS + suffix, AXIS, TITLE, TEXT)
internal val tickKey = listOf(AXIS_TICKS + suffix, AXIS_TICKS, AXIS + suffix, AXIS, LINE)
internal val tickLengthKey = listOf(AXIS_TICKS_LENGTH + suffix, AXIS_TICKS_LENGTH)
internal val tooltipKey = listOf(AXIS_TOOLTIP + suffix, AXIS_TOOLTIP, RECT)
internal val tooltipFillKey = tooltipKey + lineKey
internal val tooltipTextKey = listOf(AXIS_TOOLTIP_TEXT + suffix, AXIS_TOOLTIP_TEXT)
// Inherits from the tooltip rect stroke color.
internal val tooltipTextColorKey = tooltipTextKey + tooltipKey
override fun showLine(): Boolean {
return !isElemBlank(lineKey)
}
override fun showTickMarks(): Boolean {
return !isElemBlank(tickKey)
}
override fun showLabels(): Boolean {
return !isElemBlank(textKey)
}
override fun showTitle(): Boolean {
return !isElemBlank(titleKey)
}
override fun showTooltip(): Boolean {
return !isElemBlank(tooltipKey)
}
override fun titleColor(): Color {
return getColor(getElemValue(titleKey), Elem.COLOR)
}
override fun lineWidth(): Double {
return getNumber(getElemValue(lineKey), Elem.SIZE)
}
override fun lineColor(): Color {
return getColor(getElemValue(lineKey), Elem.COLOR)
}
override fun tickMarkWidth(): Double {
return getNumber(getElemValue(tickKey), Elem.SIZE)
}
override fun tickMarkLength(): Double {
return getNumber(tickLengthKey)
}
override fun tickMarkColor(): Color {
return getColor(getElemValue(tickKey), Elem.COLOR)
}
override fun labelColor(): Color {
return getColor(getElemValue(textKey), Elem.COLOR)
}
override fun tooltipFill(): Color {
return getColor(getElemValue(tooltipFillKey), Elem.FILL)
}
override fun tooltipColor(): Color {
return getColor(getElemValue(tooltipKey), Elem.COLOR)
}
override fun tooltipStrokeWidth(): Double {
return getNumber(getElemValue(tooltipKey), Elem.SIZE)
}
override fun tooltipTextColor(): Color {
return getColor(getElemValue(tooltipTextColorKey), Elem.COLOR)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy