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

commonMain.jetbrains.datalore.plot.builder.defaultTheme.DefaultPanelTheme.kt Maven / Gradle / Ivy

There is a newer version: 4.5.3-alpha1
Show newest version
/*
 * Copyright (c) 2021. 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.defaultTheme

import jetbrains.datalore.base.values.Color
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.Elem
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.PANEL_BKGR_RECT
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.PANEL_BORDER_RECT
import jetbrains.datalore.plot.builder.defaultTheme.values.ThemeOption.RECT
import jetbrains.datalore.plot.builder.presentation.FontFamilyRegistry
import jetbrains.datalore.plot.builder.theme.PanelGridTheme
import jetbrains.datalore.plot.builder.theme.PanelTheme

internal class DefaultPanelTheme(
    options: Map,
    fontFamilyRegistry: FontFamilyRegistry
) : ThemeValuesAccess(options, fontFamilyRegistry), PanelTheme {

    private val gridX = DefaultPanelGridTheme("x", options, fontFamilyRegistry)
    private val gridY = DefaultPanelGridTheme("y", options, fontFamilyRegistry)

    internal val rectKey = listOf(PANEL_BKGR_RECT, RECT)
    internal val borderKey = listOf(PANEL_BORDER_RECT, RECT)

    override fun showRect(): Boolean {
        return !isElemBlank(rectKey)
    }

    override fun rectColor(): Color {
        return getColor(getElemValue(rectKey), Elem.COLOR)
    }

    override fun rectFill(): Color {
        return getColor(getElemValue(rectKey), Elem.FILL)
    }

    override fun rectStrokeWidth(): Double {
        return getNumber(getElemValue(rectKey), Elem.SIZE)
    }

    override fun showBorder() = !isElemBlank(borderKey)

    override fun borderColor() = getColor(getElemValue(borderKey), Elem.COLOR)

    override fun borderWidth() = getNumber(getElemValue(borderKey), Elem.SIZE)

    override fun gridX(flipAxis: Boolean): PanelGridTheme = if (flipAxis) gridY else gridX

    override fun gridY(flipAxis: Boolean): PanelGridTheme = if (flipAxis) gridX else gridY
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy