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
Use color.paper() in GeomContext.
  • Loading branch information
OLarionova-HORIS committed Aug 4, 2023
commit eed03e854ff595c66f1f8204b4899f4bbc352f21
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EmptyGeomContext : GeomContext {
override val flipped: Boolean = false
override val targetCollector: GeomTargetCollector = NullGeomTargetCollector()
override val annotations: Annotations? = null
override val plotBackground: Color = Color.WHITE
override val backgroundColor: Color = Color.WHITE

override fun getResolution(aes: org.jetbrains.letsPlot.core.plot.base.Aes<Double>): Double {
throw IllegalStateException("Not available in an empty geom context")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface GeomContext {
val flipped: Boolean
val targetCollector: GeomTargetCollector
val annotations: Annotations?
val plotBackground: Color
val backgroundColor: Color

// ToDo: Just positional resolution along x or y-axis. Also, its now equal to "data resolution". No need to compute it in 'Aesthetics'.
fun getResolution(aes: Aes<Double>): Double
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PieGeom : GeomBase(), WithWidth, WithHeight {
root.appendNodes(pieSectors.map(::buildSvgArcs))
if (spacerWidth > 0) {
root.appendNodes(
buildSvgSpacerLines(pieSectors, width = spacerWidth, color = spacerColor ?: ctx.plotBackground)
buildSvgSpacerLines(pieSectors, width = spacerWidth, color = spacerColor ?: ctx.backgroundColor)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object BogusContext : GeomContext {
get() = error("Not available in a bogus geom context")
override val annotations: Annotations
get() = error("Not available in a bogus geom context")
override val plotBackground: Color
override val backgroundColor: Color
get() = error("Not available in a bogus geom context")

override fun getResolution(aes: Aes<Double>): Double {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object DemoAndTest {
coord = coord,
flippedAxis = flippedAxis,
targetCollector = targetCollector,
plotBackground = plotBackground
backgroundColor = plotBackground
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GeomContextBuilder : ImmutableGeomContext.Builder {
private var geomTargetCollector: GeomTargetCollector = NullGeomTargetCollector()
private var fontFamilyRegistry: FontFamilyRegistry? = null
private var annotations: Annotations? = null
private var plotBackground: Color = Color.WHITE
private var backgroundColor: Color = Color.WHITE

constructor()

Expand All @@ -39,7 +39,7 @@ class GeomContextBuilder : ImmutableGeomContext.Builder {
aesBounds = ctx._aesBounds
geomTargetCollector = ctx.targetCollector
annotations = ctx.annotations
plotBackground = ctx.plotBackground
backgroundColor = ctx.backgroundColor
}

override fun flipped(flipped: Boolean): ImmutableGeomContext.Builder {
Expand Down Expand Up @@ -77,8 +77,8 @@ class GeomContextBuilder : ImmutableGeomContext.Builder {
return this
}

override fun plotBackground(color: Color): ImmutableGeomContext.Builder {
this.plotBackground = color
override fun backgroundColor(color: Color): ImmutableGeomContext.Builder {
this.backgroundColor = color
return this
}

Expand All @@ -95,7 +95,7 @@ class GeomContextBuilder : ImmutableGeomContext.Builder {
override val flipped: Boolean = b.flipped
override val targetCollector = b.geomTargetCollector
override val annotations = b.annotations
override val plotBackground = b.plotBackground
override val backgroundColor = b.backgroundColor

private val fontFamilyRegistry: FontFamilyRegistry? = b.fontFamilyRegistry

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ImmutableGeomContext : GeomContext {

fun annotations(annotations: Annotations?): Builder

fun plotBackground(color: Color): Builder
fun backgroundColor(color: Color): Builder

fun build(): ImmutableGeomContext
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ internal class SquareFrameOfReference(
coord,
flipAxis,
targetCollector,
theme.plot().backgroundFill()
theme.colors().paper()
)

val geomBounds = layoutInfo.geomInnerBounds
Expand Down Expand Up @@ -272,7 +272,7 @@ internal class SquareFrameOfReference(
coord: CoordinateSystem,
flippedAxis: Boolean,
targetCollector: GeomTargetCollector,
plotBackground: Color
backgroundColor: Color
): SvgComponent {
val rendererData = LayerRendererUtil.createLayerRendererData(layer)

Expand Down Expand Up @@ -311,7 +311,7 @@ internal class SquareFrameOfReference(
.geomTargetCollector(targetCollector)
.fontFamilyRegistry(layer.fontFamilyRegistry)
.annotations(rendererData.annotations)
.plotBackground(plotBackground)
.backgroundColor(backgroundColor)
.build()

val pos = rendererData.pos
Expand Down