Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add element_geom(pen, brush, paper) #836

Merged
merged 15 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add theme keys for 'pen', 'brush', 'paper'. Add ColorTheme to access …
…these values.
  • Loading branch information
OLarionova-HORIS committed Aug 4, 2023
commit 05282e513c87a32808d257f558cd2e0459cc9eb4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2023. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

package org.jetbrains.letsPlot.core.plot.base.theme

import org.jetbrains.letsPlot.commons.values.Color

interface ColorTheme {
fun pen(): Color
fun brush(): Color
fun paper(): Color
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ interface Theme {
fun tooltips(): TooltipsTheme

fun geometries(geomKind: GeomKind): GeomTheme

fun colors(): ColorTheme
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2023. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

package org.jetbrains.letsPlot.core.plot.builder.defaultTheme

import org.jetbrains.letsPlot.core.plot.base.theme.ColorTheme
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.GEOM
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Geom.BRUSH
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Geom.PAPER
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Geom.PEN
import org.jetbrains.letsPlot.core.plot.builder.presentation.FontFamilyRegistry

internal class DefaultColorTheme(
options: Map<String, Any>,
fontFamilyRegistry: FontFamilyRegistry
) : ThemeValuesAccess(options, fontFamilyRegistry), ColorTheme {

private val geomElem = getElemValue(listOf(GEOM))

override fun pen() = getColor(geomElem, PEN)

override fun brush() = getColor(geomElem, BRUSH)

override fun paper() = getColor(geomElem, PAPER)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class DefaultTheme(
private val facets = DefaultFacetsTheme(options, fontFamilyRegistry)
private val plot = DefaultPlotTheme(options, fontFamilyRegistry)
private val tooltips = DefaultTooltipsTheme(options, fontFamilyRegistry)

private val geometries: MutableMap<GeomKind, GeomTheme> = HashMap()
private val colors = DefaultColorTheme(options, fontFamilyRegistry)

override fun horizontalAxis(flipAxis: Boolean): AxisTheme = if (flipAxis) axisY else axisX

Expand All @@ -50,6 +50,8 @@ class DefaultTheme(
DefaultGeomTheme.forGeomKind(geomKind, themeSettings)
}

override fun colors(): ColorTheme = colors

companion object {
// For demo and tests
fun minimal2() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ object ThemeOption {
const val TOOLTIP_TEXT = "tooltip_text"
const val TOOLTIP_TITLE_TEXT = "tooltip_title_text"

const val GEOM = "geom"

// view element
val ELEMENT_BLANK = mapOf(Elem.BLANK to true)
const val ELEMENT_BLANK_SHORTHAND = "blank"
Expand Down Expand Up @@ -135,6 +137,13 @@ object ThemeOption {
const val HIGH_CONTRAST_DARK = "high_contrast_dark"
}

object Geom {
// Named colors
const val PEN = "pen"
const val PAPER = "paper"
const val BRUSH = "brush"
}

internal object ForTest {
val themeNames = listOf(
Name.R_GREY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ open class ThemeValuesBase : ThemeValues(VALUES) {

TOOLTIP_TITLE_TEXT to mapOf(
Elem.FONT_FACE to FontFace.BOLD,
),

// Named colors
GEOM to mapOf(
Geom.PEN to DARK_GREY,
Geom.PAPER to Color.WHITE,
Geom.BRUSH to Color.PACIFIC_BLUE
)
)
}
Expand Down