Skip to content

Commit

Permalink
Merge branch 'master' into jitter-seed
Browse files Browse the repository at this point in the history
  • Loading branch information
RYangazov committed Nov 9, 2023
2 parents b610d2e + b8eb778 commit bf28c6f
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 57 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ nexusPublishing {
// "JavaDoc" artifact for all publications.
task jarJavaDocs(type: Jar) {
group project.letsPlotTaskGroup
classifier 'javadoc'
archiveClassifier.set("javadoc")
from("$rootDir/README.md")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object BrowserDemoUtil {
}

private fun projectJs(projectPath: String, projectName: String) =
"${getRootPath()}/$projectPath/build/distributions/$projectName.js"
"${getRootPath()}/$projectPath/build/dist/js/productionExecutable/$projectName.js"

fun mapperDemoHtml(demoProjectPath: String, demoProject: String, callFun: String, title: String): String {
return mapperDemoHtml(demoProjectPath, demoProject, callFun, null, title)
Expand Down
25 changes: 20 additions & 5 deletions demo/livemap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@ plugins {
id "org.jetbrains.kotlin.multiplatform"
}

// KT-55751. MPP / Gradle: Consumable configurations must have unique attributes.
// https://youtrack.jetbrains.com/issue/KT-55751/MPP-Gradle-Consumable-configurations-must-have-unique-attributes
//
def dummyAttribute = Attribute.of("dummyAttribute", String)

kotlin {
jvm("jvmJfx")
jvm("jvmRawJfx")
jvm("jvmRawAwt")
jvm("jvmBrowser")
jvm("jvmJfxPlot")
jvm("jvmJfx") {
attributes.attribute(dummyAttribute, "jvmJfx")
}
jvm("jvmRawJfx") {
attributes.attribute(dummyAttribute, "jvmRawJfx")
}
jvm("jvmRawAwt") {
attributes.attribute(dummyAttribute, "jvmRawAwt")
}
jvm("jvmBrowser") {
attributes.attribute(dummyAttribute, "jvmBrowser")
}
jvm("jvmJfxPlot") {
attributes.attribute(dummyAttribute, "jvmJfxPlot")
}
jvm("jvmBatikPlot")
js {
browser()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@ object BrowserDemoUtil {

private const val ROOT_PROJECT = "lets-plot"
private const val DEMO_PROJECT_PATH = "demo/livemap"
private const val JS_DIST_PATH = "js-package/build/dist/js/productionExecutable"

fun openInBrowser(html: () -> String) {
val outputDir = "$DEMO_PROJECT_PATH/build/dist/js/productionExecutable"
private fun getPlotLibPath(dev: Boolean): String {
val name = "lets-plot.min.js"
val dist = when {
dev -> "js-package/build/dist/js/developmentExecutable"
else -> "js-package/build/dist/js/productionExecutable"
}
return "${BrowserDemoUtil.getRootPath()}/$dist/$name"
}

private fun getDemoDir(dev: Boolean = false) = when {
dev -> "build/dist/js/developmentExecutable"
else -> "build/dist/js/productionExecutable"
}

fun openInBrowser(dev: Boolean = false, html: () -> String) {
val outputDir = "$DEMO_PROJECT_PATH/${getDemoDir(dev)}"

val projectRoot = getProjectRoot()
println("Project root: $projectRoot")
Expand All @@ -46,12 +59,7 @@ object BrowserDemoUtil {
return projectRoot
}

private fun getPlotLibPath(): String {
val name = "lets-plot.min.js"
return "${BrowserDemoUtil.getRootPath()}/$JS_DIST_PATH/$name"
}

fun mapperDemoHtml(demoProject: String, callFun: String, title: String): String {
fun mapperDemoHtml(demoProject: String, callFun: String, title: String, dev: Boolean = false): String {
val mainScript = "$demoProject.js"
val writer = StringWriter().appendHTML().html {
lang = "en"
Expand All @@ -63,7 +71,7 @@ object BrowserDemoUtil {

script {
type = "text/javascript"
src = getPlotLibPath()
src = getPlotLibPath(dev)
}

script {
Expand Down
9 changes: 9 additions & 0 deletions demo/livemap/src/jvmBrowserMain/profiling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To profile JS with Chrome DevTools and to see real function names in the profiler you need to:
- build `js-package` module using Gradle task `js-package:jsBrowserDevelopmentWebpack`
- build `demo-livemap` module using Gradle task `demo-livemap:jsBrowserDevelopmentRun`

Open a `.kt` file with demo that you want to profile. Set the parameter `dev=true` for two functions:
- `BrowserDemoUtil.openInBrowser(dev = true)`
- `BrowserDemoUtil.mapperDemoHtml(DEMO_PROJECT, CALL_FUN, DEMO_TITLE, dev = true)`

Now you can run the demo and profile it in Chrome DevTools.
13 changes: 11 additions & 2 deletions demo/plot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ plugins {
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

// KT-55751. MPP / Gradle: Consumable configurations must have unique attributes.
// https://youtrack.jetbrains.com/issue/KT-55751/MPP-Gradle-Consumable-configurations-must-have-unique-attributes
//
def dummyAttribute = Attribute.of("dummyAttribute", String)

kotlin {
jvm("jvmBatik")
jvm("jvmJfx")
jvm("jvmBrowser")
jvm("jvmJfx") {
attributes.attribute(dummyAttribute, "jvmJfx")
}
jvm("jvmBrowser") {
attributes.attribute(dummyAttribute, "jvmBrowser")
}
js() {
browser()
binaries.executable()
Expand Down
13 changes: 11 additions & 2 deletions demo/svg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ plugins {
id "org.jetbrains.kotlin.multiplatform"
}

// KT-55751. MPP / Gradle: Consumable configurations must have unique attributes.
// https://youtrack.jetbrains.com/issue/KT-55751/MPP-Gradle-Consumable-configurations-must-have-unique-attributes
//
def dummyAttribute = Attribute.of("dummyAttribute", String)

kotlin {
jvm("jvmBatik")
jvm("jvmJfx")
jvm("jvmBrowser") // generates index.html and opens it in browser
jvm("jvmJfx") {
attributes.attribute(dummyAttribute, "jvmJfx")
}
jvm("jvmBrowser") { // generates index.html and opens it in browser
attributes.attribute(dummyAttribute, "jvmBrowser")
}
js() {
browser()
binaries.executable()
Expand Down
1 change: 1 addition & 0 deletions future_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
### Changed

### Fixed
- geom_livemap: fix missing styles (e.g. road outline on high zooms) [[#926](https://github.com/JetBrains/lets-plot/issues/926)].
- Jitter reproducibility in geom_jitter, position_jitter, position_jitterdodge [[#911](https://github.com/JetBrains/lets-plot/issues/911)].
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
kotlin.code.style=official


kotlin_version=1.9.10
kotlin_version=1.9.20
kotlinLogging_version=2.0.5

kotlinx_html_version=0.7.3
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\:https://services.gradle.org/distributions/gradle-7.6.2-bin.zip
distributionUrl=https\:https://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

package org.jetbrains.letsPlot.livemap.mapengine.basemap.vector

import org.jetbrains.letsPlot.commons.intern.async.Async
import org.jetbrains.letsPlot.commons.geometry.DoubleRectangle
import org.jetbrains.letsPlot.commons.geometry.DoubleVector
import org.jetbrains.letsPlot.commons.intern.async.Async
import org.jetbrains.letsPlot.commons.values.Color
import org.jetbrains.letsPlot.core.canvas.Canvas
import org.jetbrains.letsPlot.core.canvas.Context2d
Expand Down Expand Up @@ -35,7 +35,6 @@ internal class TileDataRendererImpl(
for (rule in rules) {
if (rule.predicate(feature, zoom)) {
featuresByRule.getOrPut(rule, ::ArrayList).add(feature)
break
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package org.jetbrains.letsPlot.core.spec

import org.jetbrains.letsPlot.core.plot.base.Aes
import org.jetbrains.letsPlot.core.plot.base.GeomKind
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption.ELEMENT_BLANK_SHORTHAND
import org.jetbrains.letsPlot.core.plot.builder.defaultTheme.values.ThemeOption

object Option {

Expand Down Expand Up @@ -670,11 +670,128 @@ object Option {
}

object Theme {
// All other options were moved to
// org.jetbrains.letsPlot.core.plot.builder.theme2.values.ThemeOption
// Common
const val TITLE = ThemeOption.TITLE
const val TEXT = ThemeOption.TEXT
const val LINE = ThemeOption.LINE
const val RECT = ThemeOption.RECT

const val PLOT_BKGR_RECT = ThemeOption.PLOT_BKGR_RECT
const val PLOT_TITLE = ThemeOption.PLOT_TITLE
const val PLOT_SUBTITLE = ThemeOption.PLOT_SUBTITLE
const val PLOT_CAPTION = ThemeOption.PLOT_CAPTION
const val PLOT_MESSAGE = ThemeOption.PLOT_MESSAGE
const val PLOT_MARGIN = ThemeOption.PLOT_MARGIN

// Axis
const val AXIS = ThemeOption.AXIS

const val AXIS_ONTOP = ThemeOption.AXIS_ONTOP
const val AXIS_ONTOP_X = ThemeOption.AXIS_ONTOP_X
const val AXIS_ONTOP_Y = ThemeOption.AXIS_ONTOP_Y

const val AXIS_TITLE = ThemeOption.AXIS_TITLE
const val AXIS_TITLE_X = ThemeOption.AXIS_TITLE_X
const val AXIS_TITLE_Y = ThemeOption.AXIS_TITLE_Y

const val AXIS_TEXT = ThemeOption.AXIS_TEXT
const val AXIS_TEXT_X = ThemeOption.AXIS_TEXT_X
const val AXIS_TEXT_Y = ThemeOption.AXIS_TEXT_Y

const val AXIS_TICKS = ThemeOption.AXIS_TICKS
const val AXIS_TICKS_X = ThemeOption.AXIS_TICKS_X
const val AXIS_TICKS_Y = ThemeOption.AXIS_TICKS_Y

const val AXIS_TICKS_LENGTH = ThemeOption.AXIS_TICKS_LENGTH
const val AXIS_TICKS_LENGTH_X = ThemeOption.AXIS_TICKS_LENGTH_X
const val AXIS_TICKS_LENGTH_Y = ThemeOption.AXIS_TICKS_LENGTH_Y

const val AXIS_LINE = ThemeOption.AXIS_LINE
const val AXIS_LINE_X = ThemeOption.AXIS_LINE_X
const val AXIS_LINE_Y = ThemeOption.AXIS_LINE_Y

const val AXIS_TOOLTIP = ThemeOption.AXIS_TOOLTIP
const val AXIS_TOOLTIP_X = ThemeOption.AXIS_TOOLTIP_X
const val AXIS_TOOLTIP_Y = ThemeOption.AXIS_TOOLTIP_Y

const val AXIS_TOOLTIP_TEXT = ThemeOption.AXIS_TOOLTIP_TEXT
const val AXIS_TOOLTIP_TEXT_X = ThemeOption.AXIS_TOOLTIP_TEXT_X
const val AXIS_TOOLTIP_TEXT_Y = ThemeOption.AXIS_TOOLTIP_TEXT_Y

// Panel
const val PANEL_BKGR_RECT = ThemeOption.PANEL_BKGR_RECT
const val PANEL_BORDER_RECT = ThemeOption.PANEL_BORDER_RECT

// Panel grid
const val PANEL_GRID = ThemeOption.PANEL_GRID
const val PANEL_GRID_MAJOR = ThemeOption.PANEL_GRID_MAJOR
const val PANEL_GRID_MINOR = ThemeOption.PANEL_GRID_MINOR
const val PANEL_GRID_MAJOR_X = ThemeOption.PANEL_GRID_MAJOR_X
const val PANEL_GRID_MINOR_X = ThemeOption.PANEL_GRID_MINOR_X
const val PANEL_GRID_MAJOR_Y = ThemeOption.PANEL_GRID_MAJOR_Y
const val PANEL_GRID_MINOR_Y = ThemeOption.PANEL_GRID_MINOR_Y

// Facet
const val FACET_STRIP_BGR_RECT = ThemeOption.FACET_STRIP_BGR_RECT
const val FACET_STRIP_TEXT = ThemeOption.FACET_STRIP_TEXT

// Legend
const val LEGEND_BKGR_RECT = ThemeOption.LEGEND_BKGR_RECT
const val LEGEND_TEXT = ThemeOption.LEGEND_TEXT
const val LEGEND_TITLE = ThemeOption.LEGEND_TITLE
const val LEGEND_POSITION = ThemeOption.LEGEND_POSITION
const val LEGEND_JUSTIFICATION = ThemeOption.LEGEND_JUSTIFICATION
const val LEGEND_DIRECTION = ThemeOption.LEGEND_DIRECTION

// Tooltip
const val TOOLTIP_RECT = ThemeOption.TOOLTIP_RECT
const val TOOLTIP_TEXT = ThemeOption.TOOLTIP_TEXT
const val TOOLTIP_TITLE_TEXT = ThemeOption.TOOLTIP_TITLE_TEXT

const val GEOM = ThemeOption.GEOM
const val FLAVOR = ThemeOption.FLAVOR

// view element
const val ELEMENT_BLANK = ELEMENT_BLANK_SHORTHAND
const val ELEMENT_BLANK = ThemeOption.ELEMENT_BLANK_SHORTHAND
object Elem {
const val BLANK = ThemeOption.Elem.BLANK
const val FILL = ThemeOption.Elem.FILL
const val COLOR = ThemeOption.Elem.COLOR
const val SIZE = ThemeOption.Elem.SIZE
const val FONT_FAMILY = ThemeOption.Elem.FONT_FAMILY
const val FONT_FACE = ThemeOption.Elem.FONT_FACE
const val HJUST = ThemeOption.Elem.HJUST
const val VJUST = ThemeOption.Elem.VJUST
const val ANGLE = ThemeOption.Elem.ANGLE
const val MARGIN = ThemeOption.Elem.MARGIN
}

object Name {
// ggplot2 themes
const val R_GREY = ThemeOption.Name.R_GREY
const val R_LIGHT = ThemeOption.Name.R_LIGHT
const val R_CLASSIC = ThemeOption.Name.R_CLASSIC
const val R_MINIMAL = ThemeOption.Name.R_MINIMAL
const val R_BW = ThemeOption.Name.R_BW

// lets-plot themes
const val LP_MINIMAL = ThemeOption.Name.LP_MINIMAL
const val LP_NONE = ThemeOption.Name.LP_NONE
}

object Flavor {
const val DARCULA = ThemeOption.Flavor.DARCULA
const val SOLARIZED_LIGHT = ThemeOption.Flavor.SOLARIZED_LIGHT
const val SOLARIZED_DARK = ThemeOption.Flavor.SOLARIZED_DARK
const val HIGH_CONTRAST_LIGHT = ThemeOption.Flavor.HIGH_CONTRAST_LIGHT
const val HIGH_CONTRAST_DARK = ThemeOption.Flavor.HIGH_CONTRAST_DARK
}

object Geom {
const val PEN = ThemeOption.Geom.PEN
const val PAPER = ThemeOption.Geom.PAPER
const val BRUSH = ThemeOption.Geom.BRUSH
}
}

object GeomName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,13 @@ class AesOptionConversion(colorConverter: ColorOptionConverter) {
return converterMap[aes]
}

fun <T> apply(aes: Aes<T>, optionValue: Any): T? {
fun <T> apply(aes: Aes<T>, optionValue: Any?): T? {
val converter = getConverter(aes)
return converter(optionValue)
}

fun <T> applyToList(aes: Aes<T>, optionValues: List<*>): List<T?> {
val converter = getConverter(aes)
val result = ArrayList<T?>()
for (optionValue in optionValues) {
result.add(converter(optionValue!!))
}
return result
}

fun has(aes: Aes<*>): Boolean {
return converterMap.containsKey(aes)
return optionValues.map { apply(aes, it) }
}

companion object {
Expand Down
Loading

0 comments on commit bf28c6f

Please sign in to comment.