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 'linetype' for theme elements #1072

Merged
merged 14 commits into from
Apr 3, 2024
Merged
Prev Previous commit
Next Next commit
For plot_background.
  • Loading branch information
OLarionova-HORIS committed Apr 2, 2024
commit cf3624e9c4357b6fda30b69a2eda252ad7fee993
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ package org.jetbrains.letsPlot.core.plot.base.theme
import org.jetbrains.letsPlot.commons.values.Color
import org.jetbrains.letsPlot.core.plot.base.layout.TextJustification
import org.jetbrains.letsPlot.core.plot.base.layout.Thickness
import org.jetbrains.letsPlot.core.plot.base.render.linetype.LineType

interface PlotTheme {
fun showBackground(): Boolean
fun showMessage(): Boolean
fun backgroundColor(): Color
fun backgroundFill(): Color
fun backgroundStrokeWidth(): Double
fun backgroundRectLineType(): LineType
fun titleStyle(): ThemeTextStyle
fun subtitleStyle(): ThemeTextStyle
fun captionStyle(): ThemeTextStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.jetbrains.letsPlot.core.plot.base.layout.TextJustification.Companion.
import org.jetbrains.letsPlot.core.plot.base.layout.TextJustification.Companion.applyJustification
import org.jetbrains.letsPlot.core.plot.base.layout.Thickness
import org.jetbrains.letsPlot.core.plot.base.render.svg.MultilineLabel
import org.jetbrains.letsPlot.core.plot.base.render.svg.StrokeDashArraySupport
import org.jetbrains.letsPlot.core.plot.base.render.svg.SvgComponent
import org.jetbrains.letsPlot.core.plot.base.render.svg.Text.HorizontalAnchor
import org.jetbrains.letsPlot.core.plot.base.render.svg.Text.VerticalAnchor
Expand Down Expand Up @@ -251,7 +252,9 @@ class PlotSvgComponent constructor(
backgroundBorder.apply {
fillColor().set(Color.TRANSPARENT)
strokeColor().set(plotTheme.backgroundColor())
strokeWidth().set(plotTheme.backgroundStrokeWidth())
val width = plotTheme.backgroundStrokeWidth()
strokeWidth().set(width)
StrokeDashArraySupport.apply(this, width, plotTheme.backgroundRectLineType())
d().set(SvgPathDataBuilder().rect(backgroundRect).build())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.jetbrains.letsPlot.core.plot.builder.defaultTheme

import org.jetbrains.letsPlot.commons.values.Color
import org.jetbrains.letsPlot.core.plot.base.layout.TextJustification
import org.jetbrains.letsPlot.core.plot.base.render.linetype.LineType
import org.jetbrains.letsPlot.core.plot.base.theme.PlotTheme
import org.jetbrains.letsPlot.core.plot.base.theme.ThemeTextStyle
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem
Expand Down Expand Up @@ -49,6 +50,10 @@ internal class DefaultPlotTheme(
return getNumber(getElemValue(backgroundKey), Elem.SIZE)
}

override fun backgroundRectLineType(): LineType {
return getLineType(getElemValue(backgroundKey))
}

override fun titleStyle(): ThemeTextStyle {
return getTextStyle(getElemValue(titleKey))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem.BLANK
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem.COLOR
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem.FILL
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem.LINETYPE
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem.Margin
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.Elem.SIZE
import org.jetbrains.letsPlot.core.plot.builder.presentation.DefaultFontFamilyRegistry
Expand Down Expand Up @@ -67,6 +68,7 @@ class DefaultTheme internal constructor(
FILL to containerTheme.plot.backgroundFill(),
COLOR to this.plot.backgroundColor(),
SIZE to this.plot.backgroundStrokeWidth(),
LINETYPE to this.plot.backgroundRectLineType()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CompositeFigureSvgComponent constructor(
strokeColor().set(plotTheme.backgroundColor())
val width = plotTheme.backgroundStrokeWidth()
strokeWidth().set(width)
StrokeDashArraySupport.apply(this, width, plotTheme.backgroundStrokeLineType())
StrokeDashArraySupport.apply(this, width, plotTheme.backgroundRectLineType())
})
}
}
Expand Down