visionforge/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt

66 lines
1.8 KiB
Kotlin
Raw Normal View History

2023-07-19 22:25:32 +03:00
package space.kscience.visionforge.jupyter
2021-03-07 16:19:43 +03:00
2023-07-19 22:25:32 +03:00
import kotlinx.html.*
2021-12-31 13:59:27 +03:00
import org.jetbrains.kotlinx.jupyter.api.libraries.resources
2021-05-05 15:28:06 +03:00
import space.kscience.dataforge.context.Context
2021-03-07 16:19:43 +03:00
import space.kscience.dataforge.misc.DFExperimental
2021-02-23 21:47:18 +03:00
import space.kscience.gdml.Gdml
2021-03-07 16:19:43 +03:00
import space.kscience.plotly.Plot
2023-07-19 22:25:32 +03:00
import space.kscience.tables.*
2021-03-07 16:19:43 +03:00
import space.kscience.visionforge.gdml.toVision
2023-07-19 22:25:32 +03:00
import space.kscience.visionforge.markup.MarkupPlugin
2021-05-05 15:28:06 +03:00
import space.kscience.visionforge.plotly.PlotlyPlugin
2021-06-05 22:31:16 +03:00
import space.kscience.visionforge.plotly.asVision
2021-03-07 16:19:43 +03:00
import space.kscience.visionforge.solid.Solids
2023-07-19 22:25:32 +03:00
import space.kscience.visionforge.tables.TableVisionPlugin
import space.kscience.visionforge.tables.toVision
2022-12-06 15:54:34 +03:00
import space.kscience.visionforge.visionManager
2021-02-23 21:47:18 +03:00
2023-07-19 22:25:32 +03:00
2021-02-24 18:26:15 +03:00
@DFExperimental
2023-07-19 22:25:32 +03:00
public class JupyterCommonIntegration : VisionForgeIntegration(CONTEXT.visionManager) {
2021-05-05 15:28:06 +03:00
2022-01-02 14:28:24 +03:00
override fun Builder.afterLoaded() {
2023-07-19 22:25:32 +03:00
2021-12-31 13:59:27 +03:00
resources {
2023-07-19 22:25:32 +03:00
js("three") {
classPath("js/visionforge-jupyter-common.js")
2021-12-31 13:59:27 +03:00
}
}
2021-02-23 21:47:18 +03:00
2021-02-24 22:48:17 +03:00
import(
"space.kscience.gdml.*",
2021-03-07 16:19:43 +03:00
"space.kscience.visionforge.solid.*",
2023-07-19 22:25:32 +03:00
"space.kscience.tables.*",
"space.kscience.dataforge.meta.*",
2021-02-24 22:48:17 +03:00
)
2021-02-23 21:47:18 +03:00
render<Gdml> { gdmlModel ->
2022-01-02 14:28:24 +03:00
handler.produceHtml {
vision { gdmlModel.toVision() }
2021-02-24 18:26:15 +03:00
}
2021-02-23 21:47:18 +03:00
}
2023-07-19 22:25:32 +03:00
render<Table<*>> { table ->
handler.produceHtml {
vision { table.toVision() }
}
}
2021-02-23 21:47:18 +03:00
render<Plot> { plot ->
2022-01-02 14:28:24 +03:00
handler.produceHtml {
vision { plot.asVision() }
2021-02-23 21:47:18 +03:00
}
}
}
2023-07-19 22:25:32 +03:00
public companion object {
private val CONTEXT: Context = Context("Jupyter-common") {
plugin(Solids)
plugin(PlotlyPlugin)
plugin(TableVisionPlugin)
plugin(MarkupPlugin)
}
}
2021-02-23 21:47:18 +03:00
}