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

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

/*
 * 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.geometry.DoubleRectangle
import jetbrains.datalore.base.observable.property.Property

abstract class SvgGraphicsElement : SvgStylableElement() {

    companion object {

        private val POINTER_EVENTS: SvgAttributeSpec =
            SvgAttributeSpec.createSpec("pointer-events")
        val OPACITY: SvgAttributeSpec =
            SvgAttributeSpec.createSpec("opacity")
        val VISIBILITY: SvgAttributeSpec =
            SvgAttributeSpec.createSpec("visibility")
        val CLIP_PATH: SvgAttributeSpec =
            SvgAttributeSpec.createSpec("clip-path")

        // Only for JFX. Workaround for implementation complexity of CLIP_PATH.
        val CLIP_BOUNDS_JFX: SvgAttributeSpec =
            SvgAttributeSpec.createSpec("clip-bounds-jfx")
    }


    fun pointerEvents(): Property {
        return getAttribute(POINTER_EVENTS)
    }

    fun opacity(): Property {
        return getAttribute(OPACITY)
    }

    fun visibility(): Property {
        return getAttribute(VISIBILITY)
    }

    fun clipPath(): Property {
        return getAttribute(CLIP_PATH)
    }

    enum class PointerEvents(private val myAttributeString: String) {
        VISIBLE_PAINTED("visiblePainted"),
        VISIBLE_FILL("visibleFill"),
        VISIBLE_STROKE("visibleStroke"),
        VISIBLE("visible"),
        PAINTED("painted"),
        FILL("fill"),
        STROKE("stroke"),
        ALL("all"),
        NONE("none"),
        INHERIT("inherit");

        override fun toString(): String {
            return myAttributeString
        }
    }

    enum class Visibility(private val myAttrString: String) {
        VISIBLE("visible"),
        HIDDEN("hidden"),
        COLLAPSE("collapse"),
        INHERIT("inherit");

        override fun toString(): String {
            return myAttrString
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy