All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.jetbrains.datalore.vis.svg.SvgTextNode.kt Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
/*
 * Copyright (c) 2019. JetBrains s.r.o.
 * Use of this source code is governed by the MIT license that can be found in the LICENSE file.
 */

package jetbrains.datalore.vis.svg

import jetbrains.datalore.base.observable.collections.list.ObservableArrayList
import jetbrains.datalore.base.observable.collections.list.ObservableList
import jetbrains.datalore.base.observable.property.Property
import jetbrains.datalore.base.observable.property.ValueProperty

class SvgTextNode(text: String) : SvgNode() {

    private val myContent: Property

    init {
        myContent = ValueProperty(text)
    }

    fun textContent(): Property {
        return myContent
    }

    override fun children(): ObservableList {
        return NO_CHILDREN_LIST
    }

    override fun toString(): String {
        return textContent().get()
    }

    companion object {
        private val NO_CHILDREN_LIST: ObservableArrayList = object : ObservableArrayList() {
            override fun checkAdd(index: Int, item: SvgNode) {
                throw UnsupportedOperationException("Cannot add children to SvgTextNode")
            }

            override fun checkRemove(index: Int, item: SvgNode) {
                throw UnsupportedOperationException("Cannot remove children from SvgTextNode")
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy