All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.jetbrains.datalore.plot.builder.layout.LegendsBlockInfo.kt Maven / Gradle / Ivy

There is a newer version: 4.5.3-alpha1
Show newest version
/*
 * 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