Skip to content

Commit

Permalink
DataForge 0.7.1 and other version updates
Browse files Browse the repository at this point in the history
  • Loading branch information
altavir committed Dec 5, 2023
1 parent fbb402d commit 5955129
Show file tree
Hide file tree
Showing 36 changed files with 88 additions and 88 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ plugins {
// id("org.jetbrains.kotlinx.kover") version "0.5.0"
}

val dataforgeVersion by extra("0.6.2")
val dataforgeVersion by extra("0.7.1")
val fxVersion by extra("11")

allprojects {
group = "space.kscience"
version = "0.3.0-dev-16"
version = "0.3.0-dev-17"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ class GDMLVisionTest {
val child = cubes[Name.of("composite-000","segment-0")]
assertNotNull(child)
child.properties.setValue(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue())
assertEquals("red", child.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).string)
assertEquals("red", child.properties[SolidMaterial.MATERIAL_COLOR_KEY].string)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Model(val manager: VisionManager) {

fun reset() {
map.values.forEach {
it.properties.setMeta(SolidMaterial.MATERIAL_COLOR_KEY, null)
it.properties[SolidMaterial.MATERIAL_COLOR_KEY] = null
}
tracks.children.clear()
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ org.gradle.jvmargs=-Xmx4G

org.jetbrains.compose.experimental.jscanvas.enabled=true

toolsVersion=0.15.0-kotlin-1.9.20
toolsVersion=0.15.2-kotlin-1.9.21
#kotlin.experimental.tryK2=true
#kscience.wasm.disabled=true
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\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public fun RBuilder.visionPropertyEditor(
this.descriptor = descriptor
this.scope = vision.manager?.context ?: error("Orphan vision could not be observed")
this.getPropertyState = { name ->
val ownMeta = vision.properties.own?.getMeta(name)
val ownMeta = vision.properties.own?.get(name)
if (ownMeta != null && !ownMeta.isEmpty()) {
EditorPropertyState.Defined
} else if (vision.properties.root().getValue(name) != null) {
Expand Down
3 changes: 2 additions & 1 deletion ui/compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

plugins {
id("space.kscience.gradle.mpp")
id("org.jetbrains.compose") version "1.5.10"
alias(spclibs.plugins.compose)
// id("org.jetbrains.compose") version "1.5.11"
// id("com.android.library")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import org.jetbrains.compose.web.dom.Text
import space.kscience.dataforge.meta.MutableMeta
import space.kscience.dataforge.meta.ObservableMutableMeta
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.descriptors.get
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.remove
import space.kscience.dataforge.names.*
import space.kscience.visionforge.hidden
Expand Down Expand Up @@ -104,7 +103,7 @@ public fun PropertyEditor(
Text(token)
}

if (!name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) {
if (!name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) {
Div({
style {
width(160.px)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.w3c.dom.HTMLOptionElement
import org.w3c.dom.asList
import space.kscience.dataforge.meta.*
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.descriptors.allowedValues
import space.kscience.visionforge.Colors
import space.kscience.visionforge.widgetType
Expand Down Expand Up @@ -199,7 +199,7 @@ public fun RangeValueChooser(


FlexRow {
if (descriptor?.valueRequirement != ValueRequirement.REQUIRED) {
if (descriptor?.valueRestriction != ValueRestriction.REQUIRED) {
Input(type = InputType.Checkbox) {
if (!rangeDisabled) defaultChecked()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import react.dom.attrs
import space.kscience.dataforge.meta.MutableMeta
import space.kscience.dataforge.meta.ObservableMutableMeta
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.descriptors.get
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.remove
import space.kscience.dataforge.names.*
import space.kscience.visionforge.hidden
Expand Down Expand Up @@ -146,7 +145,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
}
+token
}
if (!props.name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) {
if (!props.name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) {
styledDiv {
css {
//+TreeStyles.resizeableInput
Expand Down Expand Up @@ -185,7 +184,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
}
+"\u00D7"
attrs {
if (editorPropertyState!= EditorPropertyState.Defined) {
if (editorPropertyState != EditorPropertyState.Defined) {
disabled = true
} else {
onClickFunction = removeClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import react.dom.attrs
import react.fc
import react.useState
import space.kscience.dataforge.meta.asValue
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.double
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.string
Expand Down Expand Up @@ -43,7 +43,7 @@ public val RangeValueChooser: FC<ValueChooserProps> = fc("RangeValueChooser") {
}

flexRow {
if (props.descriptor?.valueRequirement != ValueRequirement.REQUIRED) {
if (props.descriptor?.valueRestriction != ValueRestriction.REQUIRED) {
styledInput(type = InputType.checkBox) {
attrs {
defaultChecked = rangeDisabled.not()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlin.jvm.JvmInline
@JvmInline
public value class StyleSheet(private val owner: Vision) {

private val styleNode: Meta get() = owner.properties.getMeta(STYLESHEET_KEY)
private val styleNode: Meta get() = owner.properties[STYLESHEET_KEY]

public val items: Map<NameToken, Meta> get() = styleNode.items

Expand All @@ -23,7 +23,7 @@ public value class StyleSheet(private val owner: Vision) {
* Define a style without notifying owner
*/
public fun define(key: String, style: Meta?) {
owner.properties.setMeta(STYLESHEET_KEY + key, style)
owner.properties[STYLESHEET_KEY + key] = style
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public fun Vision.useStyle(name: String, notify: Boolean = true) {
* Resolve a style with given name for given [Vision]. The style is not necessarily applied to this [Vision].
*/
public fun Vision.getStyle(name: String): Meta? =
properties.own?.getMeta(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name)
properties.own?.get(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name)

/**
* Resolve a property from all styles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import space.kscience.dataforge.meta.asValue
import space.kscience.dataforge.meta.boolean
import space.kscience.dataforge.meta.descriptors.Described
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.misc.Type
import space.kscience.dataforge.misc.DfType
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.asName
import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties
Expand All @@ -19,7 +19,7 @@ import space.kscience.visionforge.Vision.Companion.TYPE
/**
* A root type for display hierarchy
*/
@Type(TYPE)
@DfType(TYPE)
public interface Vision : Described {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public interface VisionProperties : MetaProvider {
* @param inherit toggles parent node property lookup. Null means inference from descriptor.
* @param includeStyles toggles inclusion of properties from styles.
*/
public fun getMeta(
public fun get(
name: Name,
inherit: Boolean?,
includeStyles: Boolean? = null,
): Meta

override fun getMeta(name: Name): Meta? = getMeta(name, null, null)
override fun get(name: Name): Meta? = get(name, null, null)


public val changes: Flow<Name>
Expand All @@ -54,7 +54,7 @@ public interface VisionProperties : MetaProvider {

public interface MutableVisionProperties : VisionProperties, MutableMetaProvider {

override fun getMeta(
override fun get(
name: Name,
inherit: Boolean?,
includeStyles: Boolean?,
Expand All @@ -65,7 +65,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider
includeStyles,
)

public fun setMeta(
public fun set(
name: Name,
node: Meta?,
notify: Boolean,
Expand All @@ -77,10 +77,10 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider
notify: Boolean,
)

override fun getMeta(name: Name): MutableMeta = getMeta(name, null, null)
override fun get(name: Name): MutableMeta = get(name, null, null)

override fun setMeta(name: Name, node: Meta?) {
setMeta(name, node, true)
override fun set(name: Name, node: Meta?) {
set(name, node, true)
}

override fun setValue(name: Name, value: Value?) {
Expand All @@ -89,7 +89,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider
}

public fun MutableVisionProperties.remove(name: Name) {
setMeta(name, null)
set(name, null)
}

public fun MutableVisionProperties.remove(name: String) {
Expand All @@ -114,7 +114,7 @@ private class VisionPropertiesItem(

override val items: Map<NameToken, MutableMeta>
get() {
val metaKeys = properties.own?.getMeta(nodeName)?.items?.keys ?: emptySet()
val metaKeys = properties.own?.get(nodeName)?.items?.keys ?: emptySet()
val descriptorKeys = descriptor?.children?.map { NameToken(it.key) } ?: emptySet()
val defaultKeys = default?.get(nodeName)?.items?.keys ?: emptySet()
val inheritFlag = descriptor?.inherited ?: inherit
Expand Down Expand Up @@ -148,8 +148,8 @@ private class VisionPropertiesItem(
default
)

override fun setMeta(name: Name, node: Meta?) {
properties.setMeta(nodeName + name, node)
override fun set(name: Name, node: Meta?) {
properties[nodeName + name] = node
}

override fun toString(): String = Meta.toString(this)
Expand Down Expand Up @@ -202,16 +202,16 @@ public abstract class AbstractVisionProperties(
return descriptor?.defaultValue
}

override fun setMeta(name: Name, node: Meta?, notify: Boolean) {
override fun set(name: Name, node: Meta?, notify: Boolean) {
//ignore if the value is the same as existing
if (own?.getMeta(name) == node) return
if (own?.get(name) == node) return

if (name.isEmpty()) {
properties = node?.asMutableMeta()
} else if (node == null) {
properties?.setMeta(name, node)
properties?.set(name, node)
} else {
getOrCreateProperties().setMeta(name, node)
getOrCreateProperties()[name] = node
}
if (notify) {
invalidate(name)
Expand All @@ -223,7 +223,7 @@ public abstract class AbstractVisionProperties(
if (own?.getValue(name) == value) return

if (value == null) {
properties?.getMeta(name)?.value = null
properties?.get(name)?.value = null
} else {
getOrCreateProperties().setValue(name, value)
}
Expand Down Expand Up @@ -272,11 +272,11 @@ public fun VisionProperties.getValue(
/**
* Get [Vision] property using key as a String
*/
public fun VisionProperties.getMeta(
public fun VisionProperties.get(
name: String,
inherit: Boolean? = null,
includeStyles: Boolean? = null,
): Meta = getMeta(name.parseAsName(), inherit, includeStyles)
): Meta = get(name.parseAsName(), inherit, includeStyles)

/**
* The root property node with given inheritance and style flags
Expand All @@ -286,17 +286,17 @@ public fun VisionProperties.getMeta(
public fun MutableVisionProperties.root(
inherit: Boolean? = null,
includeStyles: Boolean? = null,
): MutableMeta = getMeta(Name.EMPTY, inherit, includeStyles)
): MutableMeta = get(Name.EMPTY, inherit, includeStyles)


/**
* Get [Vision] property using key as a String
*/
public fun MutableVisionProperties.getMeta(
public fun MutableVisionProperties.get(
name: String,
inherit: Boolean? = null,
includeStyles: Boolean? = null,
): MutableMeta = getMeta(name.parseAsName(), inherit, includeStyles)
): MutableMeta = get(name.parseAsName(), inherit, includeStyles)

//
//public operator fun MutableVisionProperties.set(name: Name, value: Number): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public fun Vision.flowProperty(
includeStyles: Boolean? = null,
): Flow<Meta> = flow {
//Pass initial value.
emit(properties.getMeta(propertyName, inherit, includeStyles))
emit(properties.get(propertyName, inherit, includeStyles))
properties.changes.collect { name ->
if (name.startsWith(propertyName)) {
emit(properties.getMeta(propertyName, inherit, includeStyles))
emit(properties.get(propertyName, inherit, includeStyles))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public fun Vision.useProperty(
callback: (Meta) -> Unit,
): Job {
//Pass initial value.
callback(properties.getMeta(propertyName, inherit, includeStyles))
callback(properties.get(propertyName, inherit, includeStyles))
return properties.changes.onEach { name ->
if (name.startsWith(propertyName)) {
callback(properties.getMeta(propertyName, inherit, includeStyles))
callback(properties.get(propertyName, inherit, includeStyles))
}
}.launchIn(scope ?: error("Orphan Vision can't observe properties"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class VisionPropertyTest {
@Test
fun testPropertyEdit() {
val vision = manager.group()
vision.properties.getMeta("fff.ddd").apply {
vision.properties.get("fff.ddd").apply {
value = 2.asValue()
}
assertEquals(2, vision.properties.getValue("fff.ddd")?.int)
Expand All @@ -50,7 +50,7 @@ internal class VisionPropertyTest {
@Test
fun testPropertyUpdate() {
val vision = manager.group()
vision.properties.getMeta("fff").updateWith(TestScheme) {
vision.properties.get("fff").updateWith(TestScheme) {
ddd = 2
}
assertEquals(2, vision.properties.getValue("fff.ddd")?.int)
Expand Down Expand Up @@ -85,7 +85,7 @@ internal class VisionPropertyTest {

child.properties.remove("test")

assertEquals(11, child.properties.getMeta("test", inherit = true).int)
assertEquals(11, child.properties.get("test", inherit = true).int)
// assertEquals(11, deferred.await()?.int)
// assertEquals(2, callCounter)
subscription.cancel()
Expand Down
Loading

0 comments on commit 5955129

Please sign in to comment.