commonMain.jetbrains.datalore.plot.builder.layout.PlotAxisLayoutUtil.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) 2022. 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.layout
import jetbrains.datalore.plot.builder.guide.Orientation
import jetbrains.datalore.plot.builder.presentation.LabelSpec
import jetbrains.datalore.plot.builder.theme.AxisTheme
internal object PlotAxisLayoutUtil {
private const val INITIAL_TICK_LABEL_IN_CHARS = "_"
fun initialThickness(
orientation: Orientation,
theme: AxisTheme,
): Double {
if (theme.showTickMarks() || theme.showLabels()) {
val v = theme.tickLabelDistance(orientation.isHorizontal)
return if (theme.showLabels()) {
v + initialTickLabelSize(orientation, PlotLabelSpecFactory.axisTick(theme))
} else {
v
}
}
return 0.0
}
private fun initialTickLabelSize(orientation: Orientation, tickLabelSpec: LabelSpec): Double {
return if (orientation.isHorizontal)
tickLabelSpec.height()
else
tickLabelSpec.width(INITIAL_TICK_LABEL_IN_CHARS)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy