Skip to content

Commit d5b5275

Browse files
Upgraded Kotlin to v2.1.0. Major reorganization of demo modules. Fixed browser demos failing to start due to an unexpected PWD environment variable value (observed on Ubuntu)
1 parent 4e2551f commit d5b5275

File tree

592 files changed

+1087
-1070
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

592 files changed

+1087
-1070
lines changed

canvas/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
kotlin("multiplatform")
88
}
99

10-
val kotlinLoggingVersion = extra["kotlinLogging_version"] as String
10+
val kotlinLoggingVersion = project.extra["kotlinLogging_version"] as String
1111

1212
kotlin {
1313
js {

commons/build.gradle.kts

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ plugins {
88
}
99

1010

11-
val mockkVersion = extra["mockk_version"] as String
12-
val kotlinLoggingVersion = extra["kotlinLogging_version"] as String
13-
val kotlinxCoroutinesVersion = extra["kotlinx_coroutines_version"] as String
14-
val hamcrestVersion = extra["hamcrest_version"] as String
15-
val mockitoVersion = extra["mockito_version"] as String
16-
val assertjVersion = extra["assertj_version"] as String
11+
val mockkVersion = project.extra["mockk_version"] as String
12+
val kotlinLoggingVersion = project.extra["kotlinLogging_version"] as String
13+
val kotlinxCoroutinesVersion = project.extra["kotlinx_coroutines_version"] as String
14+
val hamcrestVersion = project.extra["hamcrest_version"] as String
15+
val mockitoVersion = project.extra["mockito_version"] as String
16+
val assertjVersion = project.extra["assertj_version"] as String
1717

1818
kotlin {
1919
// Enable the default target hierarchy:

datamodel/build.gradle.kts

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ plugins {
77
kotlin("multiplatform")
88
}
99

10-
val mockkVersion = extra["mockk_version"] as String
11-
val kotlinLoggingVersion = extra["kotlinLogging_version"] as String
12-
val hamcrestVersion = extra["hamcrest_version"] as String
13-
val mockitoVersion = extra["mockito_version"] as String
14-
val assertjVersion = extra["assertj_version"] as String
10+
val mockkVersion = project.extra["mockk_version"] as String
11+
val kotlinLoggingVersion = project.extra["kotlinLogging_version"] as String
12+
val hamcrestVersion = project.extra["hamcrest_version"] as String
13+
val mockitoVersion = project.extra["mockito_version"] as String
14+
val assertjVersion = project.extra["assertj_version"] as String
1515

1616
kotlin {
1717
jvm()

demo/common-jfx/build.gradle.kts

-41
This file was deleted.

demo/common-jvm-util/build.gradle.kts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2023. JetBrains s.r.o.
3+
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
4+
*/
5+
6+
plugins {
7+
kotlin("jvm")
8+
}
9+
10+
val kotlinxHtmlVersion = project.extra["kotlinx_html_version"] as String
11+
12+
dependencies {
13+
implementation(kotlin("stdlib-jdk8"))
14+
implementation(kotlin("stdlib-common"))
15+
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:${kotlinxHtmlVersion}")
16+
17+
implementation(project(":commons"))
18+
implementation(project(":datamodel"))
19+
implementation(project(":plot-stem"))
20+
implementation(project(":plot-builder"))
21+
implementation(project(":platf-awt"))
22+
implementation(project(":platf-batik"))
23+
implementation(project(":platf-jfx-swing"))
24+
}

demo/common-batik/src/jvmMain/kotlin/demo/common/batik/demoUtils/PlotObjectsDemoWindowBatik.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/batik/PlotObjectsDemoWindowBatik.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.batik.demoUtils
6+
package demo.common.util.demoUtils.batik
77

8+
import demo.common.util.demoUtils.swing.PlotObjectsDemoWindowBase
9+
import org.jetbrains.letsPlot.batik.plot.util.BatikMapperComponent
810
import org.jetbrains.letsPlot.commons.geometry.DoubleVector
911
import org.jetbrains.letsPlot.commons.registration.DisposingHub
1012
import org.jetbrains.letsPlot.core.plot.builder.PlotContainer
1113
import org.jetbrains.letsPlot.core.plot.builder.PlotSvgComponent
1214
import org.jetbrains.letsPlot.core.plot.builder.PlotSvgRoot
13-
import demo.common.util.demoUtils.swing.PlotObjectsDemoWindowBase
14-
import org.jetbrains.letsPlot.batik.plot.util.BatikMapperComponent
1515
import java.awt.Dimension
1616
import javax.swing.JComponent
1717

demo/common-batik/src/jvmMain/kotlin/demo/common/batik/demoUtils/PlotResizableDemoWindowBatik.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/batik/PlotResizableDemoWindowBatik.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.batik.demoUtils
6+
package demo.common.util.demoUtils.batik
77

88
import demo.common.util.demoUtils.swing.PlotResizableDemoWindowBase
99
import org.jetbrains.letsPlot.awt.plot.component.PlotComponentProvider

demo/common-batik/src/jvmMain/kotlin/demo/common/batik/demoUtils/PlotSpecsDemoWindowBatik.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/batik/PlotSpecsDemoWindowBatik.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/*
2-
* Copyright (c) 2023. JetBrains s.r.o.
2+
* Copyright (c) 2024. JetBrains s.r.o.
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.batik.demoUtils
6+
package demo.common.util.demoUtils.batik
77

88
import demo.common.util.demoUtils.swing.PlotSpecsDemoWindowBase
99
import org.jetbrains.letsPlot.batik.plot.component.DefaultPlotPanelBatik
1010
import org.jetbrains.letsPlot.core.util.MonolithicCommon
1111
import java.awt.Color
12-
import java.awt.Component
1312
import java.awt.Dimension
1413
import javax.swing.JComponent
1514

@@ -45,7 +44,7 @@ class PlotSpecsDemoWindowBatik(
4544
plotPanel.preferredSize = it
4645
}
4746

48-
plotPanel.alignmentX = Component.CENTER_ALIGNMENT
47+
plotPanel.alignmentX = CENTER_ALIGNMENT
4948
return plotPanel
5049
}
5150
}

demo/common-batik/src/jvmMain/kotlin/demo/common/batik/demoUtils/SvgViewerDemoWindowBatik.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/batik/SvgViewerDemoWindowBatik.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.batik.demoUtils
6+
package demo.common.util.demoUtils.batik
77

88
import demo.common.util.demoUtils.swing.SvgViewerDemoWindowBase
99
import org.jetbrains.letsPlot.batik.plot.util.BatikMapperComponent

demo/common-util/src/jvmMain/kotlin/demo/common/util/demoUtils/browser/BrowserDemoUtil.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/browser/BrowserDemoUtil.kt

+19-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import java.awt.Desktop
1111
import java.io.File
1212
import java.io.FileWriter
1313
import java.io.StringWriter
14+
import java.nio.file.Path
15+
import kotlin.io.path.Path
1416

1517
object BrowserDemoUtil {
18+
private const val ROOT_DEMO_DIR_NAME = "demo"
1619
private const val ROOT_PROJECT = "lets-plot"
1720
private const val ROOT_ELEMENT_ID = "root"
1821

@@ -55,12 +58,25 @@ object BrowserDemoUtil {
5558

5659
fun getRootPath(): String {
5760
// works when launching from IDEA
61+
// [UPD]: on linux PWD points to user home dir
5862
val projectRoot = System.getenv()["PWD"] ?: throw IllegalStateException("'PWD' env variable is not defined")
5963

60-
if (!projectRoot.contains(ROOT_PROJECT)) {
61-
throw IllegalStateException("'PWD' is not pointing to $ROOT_PROJECT : $projectRoot")
64+
if (projectRoot.contains(ROOT_PROJECT)) {
65+
return projectRoot
6266
}
63-
return projectRoot
67+
68+
val userDir = Path(System.getProperty("user.dir"))
69+
70+
var curDir: Path? = userDir
71+
while (curDir != null) {
72+
if (curDir.endsWith(ROOT_DEMO_DIR_NAME)) {
73+
return curDir.parent.toString()
74+
} else {
75+
curDir = curDir.parent
76+
}
77+
}
78+
79+
throw IllegalStateException("'PWD' is not pointing to $ROOT_PROJECT : $projectRoot. \nTODO: use getProperty('user.dir')")
6480
}
6581

6682
fun getPlotLibPath(dev: Boolean? = null): String {

demo/common-jfx/src/jvmMain/kotlin/demo/common/jfx/demoUtils/PlotObjectsDemoWindowJfx.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/jfx/PlotObjectsDemoWindowJfx.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.jfx.demoUtils
6+
package demo.common.util.demoUtils.jfx
77

8+
import demo.common.util.demoUtils.swing.PlotObjectsDemoWindowBase
89
import org.jetbrains.letsPlot.commons.geometry.DoubleVector
910
import org.jetbrains.letsPlot.commons.registration.DisposingHub
1011
import org.jetbrains.letsPlot.core.plot.builder.PlotContainer
1112
import org.jetbrains.letsPlot.core.plot.builder.PlotSvgComponent
1213
import org.jetbrains.letsPlot.core.plot.builder.PlotSvgRoot
13-
import demo.common.util.demoUtils.swing.PlotObjectsDemoWindowBase
1414
import org.jetbrains.letsPlot.jfx.plot.util.SceneMapperJfxPanel
1515
import java.awt.Dimension
1616
import javax.swing.JComponent

demo/common-jfx/src/jvmMain/kotlin/demo/common/jfx/demoUtils/PlotResizableDemoWindowJfx.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/jfx/PlotResizableDemoWindowJfx.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.jfx.demoUtils
6+
package demo.common.util.demoUtils.jfx
77

88
import demo.common.util.demoUtils.swing.PlotResizableDemoWindowBase
99
import org.jetbrains.letsPlot.awt.plot.component.PlotComponentProvider

demo/common-jfx/src/jvmMain/kotlin/demo/common/jfx/demoUtils/PlotSpecsDemoWindowJfx.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/jfx/PlotSpecsDemoWindowJfx.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/*
2-
* Copyright (c) 2023. JetBrains s.r.o.
2+
* Copyright (c) 2024. JetBrains s.r.o.
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.jfx.demoUtils
6+
package demo.common.util.demoUtils.jfx
77

88
import demo.common.util.demoUtils.swing.PlotSpecsDemoWindowBase
99
import org.jetbrains.letsPlot.core.util.MonolithicCommon
1010
import org.jetbrains.letsPlot.jfx.plot.component.DefaultPlotPanelJfx
1111
import java.awt.Color
12-
import java.awt.Component
1312
import java.awt.Dimension
1413
import javax.swing.JComponent
1514

@@ -45,7 +44,7 @@ class PlotSpecsDemoWindowJfx(
4544
plotPanel.preferredSize = it
4645
}
4746

48-
plotPanel.alignmentX = Component.CENTER_ALIGNMENT
47+
plotPanel.alignmentX = CENTER_ALIGNMENT
4948
return plotPanel
5049
}
5150
}

demo/common-jfx/src/jvmMain/kotlin/demo/common/jfx/demoUtils/SvgViewerDemoWindowJfx.kt renamed to demo/common-jvm-util/src/main/kotlin/demo/common/util/demoUtils/jfx/SvgViewerDemoWindowJfx.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

6-
package demo.common.jfx.demoUtils
6+
package demo.common.util.demoUtils.jfx
77

88
import demo.common.util.demoUtils.swing.SvgViewerDemoWindowBase
99
import org.jetbrains.letsPlot.datamodel.svg.dom.SvgSvgElement

demo/common-batik/build.gradle.kts renamed to demo/common-livemap/build.gradle.kts

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023. JetBrains s.r.o.
2+
* Copyright (c) 2024. JetBrains s.r.o.
33
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
44
*/
55

@@ -9,8 +9,13 @@ plugins {
99

1010
kotlin {
1111
jvm()
12+
js {
13+
browser()
14+
binaries.executable()
15+
}
1216

13-
val batikVersion = extra["batik_version"] as String
17+
// Fix "The Default Kotlin Hierarchy Template was not applied to 'project'..." warning
18+
applyDefaultHierarchyTemplate()
1419

1520
sourceSets {
1621
commonMain {
@@ -22,18 +27,11 @@ kotlin {
2227
implementation(project(":plot-base"))
2328
implementation(project(":plot-builder"))
2429
implementation(project(":plot-stem"))
25-
}
26-
}
27-
jvmMain {
28-
dependencies {
29-
implementation(kotlin("stdlib-jdk8"))
30-
3130
implementation(project(":canvas"))
32-
implementation(project(":platf-awt"))
33-
implementation(project(":platf-batik"))
34-
implementation(project(":demo-common-util"))
35-
36-
implementation("org.apache.xmlgraphics:batik-codec:${batikVersion}")
31+
implementation(project(":gis"))
32+
implementation(project(":livemap"))
33+
implementation(project(":plot-livemap"))
34+
implementation(project(":demo-and-test-shared"))
3735
}
3836
}
3937
}

demo/livemap/src/commonMain/kotlin/demo/livemap/canvasDemo/DrawImageAndClearRectDemoModel.kt renamed to demo/common-livemap/src/commonMain/kotlin/demo/livemap/canvasDemo/DrawImageAndClearRectDemoModel.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
package demo.livemap.canvasDemo
77

8-
import org.jetbrains.letsPlot.commons.intern.async.Async
98
import org.jetbrains.letsPlot.commons.geometry.DoubleRectangle
10-
import org.jetbrains.letsPlot.commons.values.Color
9+
import org.jetbrains.letsPlot.commons.intern.async.Async
1110
import org.jetbrains.letsPlot.core.canvas.Canvas
1211

1312
const val dataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAABhWlDQ1BJQ0" +

demo/livemap/src/commonMain/kotlin/demo/livemap/canvasDemo/SaveRestoreDemoModel.kt renamed to demo/common-livemap/src/commonMain/kotlin/demo/livemap/canvasDemo/SaveRestoreDemoModel.kt

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package demo.livemap.canvasDemo
77

88
import org.jetbrains.letsPlot.commons.values.Color
99
import org.jetbrains.letsPlot.core.canvas.*
10-
import org.jetbrains.letsPlot.core.canvas.*
1110

1211
class SaveRestoreDemoModel(canvas: Canvas) {
1312
init {

demo/livemap/src/commonMain/kotlin/demo/livemap/canvasDemo/TextAlignAndBaselineDemoModel.kt renamed to demo/common-livemap/src/commonMain/kotlin/demo/livemap/canvasDemo/TextAlignAndBaselineDemoModel.kt

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package demo.livemap.canvasDemo
77

88
import org.jetbrains.letsPlot.commons.values.Color
99
import org.jetbrains.letsPlot.core.canvas.*
10-
import org.jetbrains.letsPlot.core.canvas.*
1110
import kotlin.math.PI
1211

1312
class TextAlignAndBaselineDemoModel(canvas: Canvas) {

demo/livemap/src/commonMain/kotlin/demo/livemap/demo/DemoModelBase.kt renamed to demo/common-livemap/src/commonMain/kotlin/demo/livemap/demo/DemoModelBase.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
package demo.livemap.demo
77

8-
import org.jetbrains.letsPlot.commons.intern.async.Asyncs
98
import org.jetbrains.letsPlot.commons.geometry.DoubleVector
9+
import org.jetbrains.letsPlot.commons.intern.async.Asyncs
1010
import org.jetbrains.letsPlot.commons.registration.Registration
1111
import org.jetbrains.letsPlot.core.canvas.CanvasControl
1212
import org.jetbrains.letsPlot.livemap.LiveMapLocation

demo/common-util/build.gradle.kts renamed to demo/common-plot/build.gradle.kts

+3-14
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,17 @@ kotlin {
1313
browser()
1414
}
1515

16-
val kotlinxHtmlVersion = extra["kotlinx_html_version"] as String
17-
1816
sourceSets {
1917
commonMain {
2018
dependencies {
2119
implementation(kotlin("stdlib-common"))
2220

2321
implementation(project(":commons"))
2422
implementation(project(":datamodel"))
23+
implementation(project(":plot-base"))
2524
implementation(project(":plot-builder"))
26-
}
27-
}
28-
jvmMain {
29-
dependencies {
30-
implementation(kotlin("stdlib-jdk8"))
31-
32-
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:${kotlinxHtmlVersion}")
33-
}
34-
}
35-
jsMain {
36-
dependencies {
37-
implementation(kotlin("stdlib-js"))
25+
implementation(project(":plot-stem"))
26+
implementation(project(":demo-and-test-shared"))
3827
}
3928
}
4029
}

0 commit comments

Comments
 (0)