From cda8d8e76fff895bda60c7c839d5a7c100647665 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 10 Sep 2022 15:20:01 +0300 Subject: [PATCH] Update feature builder AP --- build.gradle.kts | 2 +- maps-kt-compose/build.gradle.kts | 6 ++- .../center/sciprog/maps/compose/MapFeature.kt | 4 +- .../sciprog/maps/compose/MapFeatureBuilder.kt | 39 ++++++++++++++----- maps-kt-scheme/build.gradle.kts | 7 +++- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4ee8bde..daac0ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ val ktorVersion by extra("2.0.3") allprojects { group = "center.sciprog" - version = "0.1.0-SNAPSHOT" + version = "0.1.0-dev-2" } ksciencePublish{ diff --git a/maps-kt-compose/build.gradle.kts b/maps-kt-compose/build.gradle.kts index 116b493..cfb4aac 100644 --- a/maps-kt-compose/build.gradle.kts +++ b/maps-kt-compose/build.gradle.kts @@ -12,7 +12,7 @@ kotlin { explicitApi = org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Warning jvm { compilations.all { - kotlinOptions.jvmTarget = "11" + kotlinOptions.jvmTarget = space.kscience.gradle.KScienceVersions.JVM_TARGET.toString() } } sourceSets { @@ -27,4 +27,8 @@ kotlin { val jvmMain by getting val jvmTest by getting } +} + +java{ + targetCompatibility = space.kscience.gradle.KScienceVersions.JVM_TARGET } \ No newline at end of file diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt index 418b25f..dbd8412 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt @@ -109,8 +109,8 @@ public class MapLineFeature( public class MapArcFeature( public val oval: GmcRectangle, - public val startAngle: Float, - public val endAngle: Float, + public val startAngle: Angle, + public val endAngle: Angle, override val zoomRange: IntRange = defaultZoomRange, public val color: Color = Color.Red, ) : MapFeature { diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt index 508385c..4b2249e 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt @@ -9,9 +9,7 @@ import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp -import center.sciprog.maps.coordinates.Distance -import center.sciprog.maps.coordinates.GeodeticMapCoordinates -import center.sciprog.maps.coordinates.GmcRectangle +import center.sciprog.maps.coordinates.* public typealias FeatureId = String @@ -101,6 +99,27 @@ public fun MapFeatureBuilder.draw( drawFeature: DrawScope.() -> Unit, ): FeatureId = addFeature(id, MapDrawFeature(position.toCoordinates(), zoomRange, drawFeature)) +public fun MapFeatureBuilder.line( + aCoordinates: Gmc, + bCoordinates: Gmc, + zoomRange: IntRange = defaultZoomRange, + color: Color = Color.Red, + id: FeatureId? = null, +): FeatureId = addFeature( + id, + MapLineFeature(aCoordinates, bCoordinates, zoomRange, color) +) + +public fun MapFeatureBuilder.line( + curve: GmcCurve, + zoomRange: IntRange = defaultZoomRange, + color: Color = Color.Red, + id: FeatureId? = null, +): FeatureId = addFeature( + id, + MapLineFeature(curve.forward.coordinates, curve.backward.coordinates, zoomRange, color) +) + public fun MapFeatureBuilder.line( aCoordinates: Pair, bCoordinates: Pair, @@ -114,14 +133,14 @@ public fun MapFeatureBuilder.line( public fun MapFeatureBuilder.arc( oval: GmcRectangle, - startAngle: Number, - endAngle: Number, + startAngle: Angle, + endAngle: Angle, zoomRange: IntRange = defaultZoomRange, color: Color = Color.Red, id: FeatureId? = null, ): FeatureId = addFeature( id, - MapArcFeature(oval, startAngle.toFloat(), endAngle.toFloat(), zoomRange, color) + MapArcFeature(oval, startAngle, endAngle, zoomRange, color) ) public fun MapFeatureBuilder.arc( @@ -136,21 +155,21 @@ public fun MapFeatureBuilder.arc( id, MapArcFeature( GmcRectangle.square(center.toCoordinates(), radius, radius), - startAngle.toFloat(), - endAngle.toFloat(), + startAngle.degrees, + endAngle.degrees, zoomRange, color ) ) public fun MapFeatureBuilder.points( - points: List>, + points: List, zoomRange: IntRange = defaultZoomRange, stroke: Float = 2f, color: Color = Color.Red, pointMode: PointMode = PointMode.Points, id: FeatureId? = null, -): FeatureId = addFeature(id, MapPointsFeature(points.map { it.toCoordinates() }, zoomRange, stroke, color, pointMode)) +): FeatureId = addFeature(id, MapPointsFeature(points, zoomRange, stroke, color, pointMode)) @Composable public fun MapFeatureBuilder.image( diff --git a/maps-kt-scheme/build.gradle.kts b/maps-kt-scheme/build.gradle.kts index d5206ec..ea1d81a 100644 --- a/maps-kt-scheme/build.gradle.kts +++ b/maps-kt-scheme/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.compose.compose +import space.kscience.gradle.KScienceVersions.JVM_TARGET plugins { @@ -9,7 +10,7 @@ plugins { kotlin { jvm { compilations.all { - kotlinOptions.jvmTarget = "11" + kotlinOptions.jvmTarget = JVM_TARGET.toString() } } sourceSets { @@ -26,3 +27,7 @@ kotlin { } } } + +java{ + targetCompatibility = JVM_TARGET +} \ No newline at end of file