commonMain.jetbrains.datalore.plot.builder.guide.LegendBoxSpec.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) 2020. 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.guide
import jetbrains.datalore.base.geometry.DoubleRectangle
import jetbrains.datalore.base.geometry.DoubleVector
import jetbrains.datalore.plot.builder.theme.LegendTheme
abstract class LegendBoxSpec(
val title: String,
val theme: LegendTheme,
val reverse: Boolean
) {
abstract val layout: LegendBoxLayout
val contentOrigin: DoubleVector
private val fullContentExtend: DoubleVector
private val innerOrigin: DoubleVector
private val innerContentExtend: DoubleVector
private val contentSize: DoubleVector
get() = layout.size
val size: DoubleVector
get() = contentSize.add(fullContentExtend)
val innerBounds: DoubleRectangle
get() = DoubleRectangle(innerOrigin, contentSize.add(innerContentExtend))
val contentBounds: DoubleRectangle
get() = DoubleRectangle(contentOrigin, contentSize)
init {
val contentExpand = theme.margin() + theme.padding()
contentOrigin = DoubleVector(contentExpand, contentExpand)
fullContentExtend = DoubleVector(contentExpand * 2, contentExpand * 2)
innerOrigin = DoubleVector(theme.margin(), theme.margin())
innerContentExtend = DoubleVector(theme.padding() * 2, theme.padding() * 2)
}
fun hasTitle(): Boolean {
return title.isNotBlank()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy