commonMain.jetbrains.datalore.plot.builder.layout.LegendsBlockInfo.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.layout
import jetbrains.datalore.base.geometry.DoubleRectangle
import jetbrains.datalore.base.geometry.DoubleVector
internal class LegendsBlockInfo(
val boxWithLocationList: List
) {
fun size(): DoubleVector {
var bounds: DoubleRectangle? = null
for (boxWithLocation in boxWithLocationList) {
bounds = bounds?.union(boxWithLocation.bounds()) ?: boxWithLocation.bounds()
}
return bounds?.dimension ?: DoubleVector.ZERO
}
fun moveAll(delta: DoubleVector): LegendsBlockInfo {
val result = ArrayList()
for (boxWithLocation in boxWithLocationList) {
result.add(
LegendBoxesLayout.BoxWithLocation(
boxWithLocation.legendBox,
boxWithLocation.location.add(delta)
)
)
}
val newList = boxWithLocationList.map {
LegendBoxesLayout.BoxWithLocation(it.legendBox, it.location.add(delta))
}
return LegendsBlockInfo(newList)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy