Skip to content

Commit 196d56f

Browse files
committed
Get rid of RawSpecFigure.kt
1 parent c096b23 commit 196d56f

33 files changed

+118
-128
lines changed

demo/plot/compose-android-median/src/main/kotlin/demo/plot/ComposeMedianMainActivity.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.compose.ui.text.TextStyle
1818
import androidx.compose.ui.unit.dp
1919
import demo.plot.ui.DemoDropdownMenu
2020
import demo.plot.ui.DemoRadioGroup
21+
import org.jetbrains.letsPlot.Figure
2122
import org.jetbrains.letsPlot.skia.compose.PlotPanel
2223
import org.jetbrains.letsPlot.skia.compose.PlotPanelRaw
2324
import plotSpec.*
@@ -36,7 +37,7 @@ class ComposeMedianMainActivity : ComponentActivity() {
3637
"Violin" to ViolinSpec().createFigure(),
3738
"Markdown" to MarkdownSpec().mpg(),
3839
"BackendError" to IllegalArgumentSpec().createFigure(),
39-
"FrontendError" to FrontendExceptionSpec().createFigure(),
40+
"FrontendError" to FrontendExceptionSpec().createRawSpec(),
4041
)
4142

4243
val preserveAspectRatio = rememberSaveable { mutableStateOf(true) }
@@ -61,9 +62,9 @@ class ComposeMedianMainActivity : ComponentActivity() {
6162
}
6263

6364
val fig = figures[figureIndex.value].second
64-
if (fig is RawSpecFigure) {
65+
if (fig is Map<*, *>) {
6566
PlotPanelRaw(
66-
rawSpec = fig.rawSpec.toMutableMap(),
67+
rawSpec = fig as MutableMap<String, Any>,
6768
preserveAspectRatio = preserveAspectRatio.value,
6869
modifier = Modifier.fillMaxSize(),
6970
errorModifier = Modifier.padding(16.dp),
@@ -72,7 +73,7 @@ class ComposeMedianMainActivity : ComponentActivity() {
7273
messages.forEach { println("[DEMO APP MESSAGE] $it") }
7374
}
7475
)
75-
} else {
76+
} else if (fig is Figure) {
7677
PlotPanel(
7778
figure = fig,
7879
preserveAspectRatio = preserveAspectRatio.value,

demo/plot/compose-desktop/src/main/kotlin/demo/plot/minimal/FrontendExceptionCompose.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fun main() = application {
2626
) {
2727

2828
PlotPanelRaw(
29-
rawSpec = FrontendExceptionSpec().createFigure().rawSpec.toMutableMap(),
29+
rawSpec = FrontendExceptionSpec().createRawSpec(),
3030
modifier = Modifier.fillMaxSize(),
3131
errorModifier = Modifier.padding(16.dp),
3232
errorTextStyle = TextStyle(color = Color(0xFF700000)),

demo/plot/compose-desktop/src/main/kotlin/demo/plot/minimal/MarkdownCompose.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fun main() = application {
2424
) {
2525

2626
PlotPanelRaw(
27-
rawSpec = MarkdownSpec().mpg().rawSpec,
27+
rawSpec = MarkdownSpec().mpg(),
2828
modifier = Modifier.fillMaxSize(),
2929
preserveAspectRatio = true,
3030
) { computationMessages ->

demo/plot/compose-desktop/src/main/kotlin/demo/plot/various/MultiplePlotsWithToolbar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fun main() = application {
3434
}
3535

3636
PlotPanelRaw(
37-
rawSpec = MarkdownSpec().mpg().rawSpec.also { it["ggtoolbar"] = emptyMap<String, Any>() },
37+
rawSpec = MarkdownSpec().mpg().also { it["ggtoolbar"] = emptyMap<String, Any>() },
3838
preserveAspectRatio = false,
3939
modifier = Modifier.fillMaxHeight().weight(1f)
4040
) { computationMessages ->

demo/plot/shared/src/main/kotlin/plotSpec/AutoSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.jetbrains.letsPlot.geom.geomPoint
1212
import org.jetbrains.letsPlot.intern.Plot
1313
import org.jetbrains.letsPlot.letsPlot
1414

15-
class AutoSpec : PlotDemoSpec {
15+
class AutoSpec : PlotDemoFigure {
1616
override fun createFigureList(): List<Figure> {
1717
return listOf(
1818
scatter()

demo/plot/shared/src/main/kotlin/plotSpec/BarPlotSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.jetbrains.letsPlot.letsPlot
1212
import org.jetbrains.letsPlot.scale.scaleFillDiscrete
1313
import org.jetbrains.letsPlot.scale.scaleFillHue
1414

15-
class BarPlotSpec : PlotDemoSpec {
15+
class BarPlotSpec : PlotDemoFigure {
1616
val basic = letsPlot(DATA) +
1717
geomBar(alpha = 0.5) {
1818
x = "time"

demo/plot/shared/src/main/kotlin/plotSpec/CurveSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import org.jetbrains.letsPlot.label.ggtitle
1313
import org.jetbrains.letsPlot.letsPlot
1414
import org.jetbrains.letsPlot.scale.xlim
1515

16-
class CurveSpec : PlotDemoSpec {
16+
class CurveSpec : PlotDemoFigure {
1717

1818
override fun createFigureList(): List<Figure> {
1919

demo/plot/shared/src/main/kotlin/plotSpec/DensitySpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.jetbrains.letsPlot.coord.coordFixed
1212
import org.jetbrains.letsPlot.geom.geomDensity
1313
import org.jetbrains.letsPlot.letsPlot
1414

15-
class DensitySpec : PlotDemoSpec {
15+
class DensitySpec : PlotDemoFigure {
1616
override fun createFigure(): Figure {
1717
val rand = java.util.Random()
1818
val n = 200

demo/plot/shared/src/main/kotlin/plotSpec/FacetWrapSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import org.jetbrains.letsPlot.intern.Plot
1313
import org.jetbrains.letsPlot.letsPlot
1414
import org.jetbrains.letsPlot.themes.themeGrey
1515

16-
class FacetWrapSpec : PlotDemoSpec {
16+
class FacetWrapSpec : PlotDemoFigure {
1717

1818
override fun createFigureList(): List<Figure> {
1919
val oneFacetDef = commonSpecs() + facetWrap(facets = "number of cylinders", format = "{d} cyl")

demo/plot/shared/src/main/kotlin/plotSpec/FrontendExceptionSpec.kt

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
package plotSpec
22

3-
import org.jetbrains.letsPlot.Figure
4-
53
class FrontendExceptionSpec : PlotDemoSpec {
6-
override fun createFigure(): RawSpecFigure {
7-
return RawSpecFigure.fromMap(
8-
mapOf(
9-
"kind" to "plot",
10-
"layers" to listOf(
11-
mapOf(
12-
"geom" to "line",
13-
"data" to mapOf(
14-
"x" to listOf("a", "b", "c", "d"),
15-
"y" to listOf(3, 1, 4, 2)
16-
),
17-
"mapping" to mapOf("x" to "x", "y" to "y"),
18-
"stat" to "summary",
19-
"fun" to "mean",
20-
"data_meta" to mapOf(
21-
"series_annotations" to listOf(
22-
mapOf(
23-
"type" to "datetime",
24-
"column" to "x"
25-
)
4+
override fun createRawSpec(): MutableMap<String, Any> {
5+
return mutableMapOf(
6+
"kind" to "plot",
7+
"layers" to listOf(
8+
mapOf(
9+
"geom" to "line",
10+
"data" to mapOf(
11+
"x" to listOf("a", "b", "c", "d"),
12+
"y" to listOf(3, 1, 4, 2)
13+
),
14+
"mapping" to mapOf("x" to "x", "y" to "y"),
15+
"stat" to "summary",
16+
"fun" to "mean",
17+
"data_meta" to mapOf(
18+
"series_annotations" to listOf(
19+
mapOf(
20+
"type" to "datetime",
21+
"column" to "x"
2622
)
2723
)
2824
)
@@ -31,10 +27,10 @@ class FrontendExceptionSpec : PlotDemoSpec {
3127
)
3228
}
3329

34-
override fun createFigureList(): List<Figure> {
30+
override fun createRawSpecList(): List<MutableMap<String, Any>> {
3531

3632
return listOf(
37-
createFigure(),
33+
createRawSpec(),
3834
)
3935
}
4036

0 commit comments

Comments
 (0)