commonMain.jetbrains.datalore.plot.builder.PlotSvgRoot.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plot-builder-portable-js Show documentation
Show all versions of plot-builder-portable-js Show documentation
The Let-Plot Kotlin API depends on this artifact.
The 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
import jetbrains.datalore.base.geometry.DoubleRectangle
import jetbrains.datalore.base.geometry.DoubleVector
import jetbrains.datalore.base.values.SomeFig
import jetbrains.datalore.plot.base.render.svg.SvgUID
import jetbrains.datalore.plot.builder.presentation.Style
import jetbrains.datalore.vis.svg.SvgCssResource
import jetbrains.datalore.vis.svg.SvgGElement
/**
* This class only handles static SVG. (no interactions)
*/
class PlotSvgRoot constructor(
val plot: PlotSvgComponent,
val liveMapCursorServiceConfig: Any?,
origin: DoubleVector
) : FigureSvgRoot(DoubleRectangle(origin, plot.figureSize)) {
val liveMapFigures: List
get() = plot.liveMapFigures
val isLiveMap: Boolean
get() = plot.liveMapFigures.isNotEmpty()
private val decorationLayerId = SvgUID.get(DECORATION_LAYER_ID_PREFIX)
val decorationLayer = SvgGElement().apply {
id().set(decorationLayerId)
}
protected override fun buildFigureContent() {
val id = SvgUID.get(PLOT_ID_PREFIX)
svg.setStyle(object : SvgCssResource {
override fun css(): String {
return Style.generateCSS(plot.styleSheet, id, decorationLayerId)
}
})
plot.rootGroup.id().set(id)
// Notes on plot background.
// (No more actual as the background rect is now added in PlotSvgComponent)
// 1.
// Batik doesn't seem to support any styling (via 'style' element or 'style' attribute)
// of root