<commit_before>package com.almasb.fxgl.entity.components

import com.almasb.fxgl.core.View
import com.almasb.fxgl.entity.EntityView
import com.almasb.fxgl.entity.component.Component
import com.almasb.fxgl.entity.component.CoreComponent
import javafx.beans.property.*
import javafx.event.EventHandler
import javafx.scene.Group
import javafx.scene.Node
import javafx.scene.input.MouseEvent
import javafx.scene.layout.Pane
import javafx.scene.transform.Rotate
import javafx.scene.transform.Scale

/**
 *
 * @author <NAME> (<EMAIL>)
 */
@CoreComponent
class ViewComponent
@JvmOverloads constructor(initialView: View = EmptyView): Component() {

    /**
     * Only the first child is used when calling setView.
     * The other children can be used by systems such as debug bbox as necessary.
     */
    val parent = Group()

    val z: ReadOnlyIntegerProperty = ReadOnlyIntegerWrapper(0)

    @get:JvmName("opacityProperty")
    val opacityProp = SimpleDoubleProperty(1.0)

    var opacity: Double
        get() = opacityProp.value
        set(value) { opacityProp.value = value }

    private val propView: ObjectProperty<View> = SimpleObjectProperty<View>(initialView)

    var view: View
        get() = propView.value
        set(value) {

            if (parent.children.isEmpty()) {
                parent.children += value.node
            } else {
                parent.children[0] = value.node
            }

            propView.value = value
        }

    private val entityView by lazy { EntityView() }

    private val listeners = arrayListOf<ClickListener>()

    private val onClickListener = EventHandler<MouseEvent> { listeners.forEach { it.onClick() } }

    init {
        parent.opacityProperty().bind(opacityProp)

        parent.addEventHandler(MouseEvent.MOUSE_CLICKED, onClickListener)
    }

    fun setViewFromNode(node: Node) {
        entityView.clearChildren()
        entityView.addNode(node)
<commit_msg>effects now will not apply to other children of view component, only to the 0th element<commit_after>package com.almasb.fxgl.entity.components

import com.almasb.fxgl.core.View
import com.almasb.fxgl.entity.EntityView
import com.almasb.fxgl.entity.component.Component
import com.almasb.fxgl.entity.component.CoreComponent
import javafx.beans.property.*
import javafx.event.EventHandler
import javafx.scene.Group
import javafx.scene.Node
import javafx.scene.input.MouseEvent
import javafx.scene.layout.Pane
import javafx.scene.transform.Rotate
import javafx.scene.transform.Scale

/**
 *
 * @author <NAME> (<EMAIL>)
 */
@CoreComponent
class ViewComponent
@JvmOverloads constructor(initialView: View = EmptyView): Component() {

    /**
     * Only the first child is used when calling setView.
     * The other children can be used by systems such as debug bbox as necessary.
     */
    val parent = Group()

    val z: ReadOnlyIntegerProperty = ReadOnlyIntegerWrapper(0)

    @get:JvmName("opacityProperty")
    val opacityProp = SimpleDoubleProperty(1.0)

    var opacity: Double
        get() = opacityProp.value
        set(value) { opacityProp.value = value }

    private val propView: ObjectProperty<View> = SimpleObjectProperty<View>(initialView)

    var view: View
        get() = propView.value
        set(value) {

            if (parent.children.isEmpty()) {
                parent.children += value.node
            } else {
                parent.children[0] = value.node
            }

            propView.value?.node?.opacityProperty()?.unbind()

            propView.value = value

            // we only apply effects to the first child aka game view
            // so debug views stay unaffected
            propView.value.node.opacityProperty().bind(opacityProp)
        }

    /**
     * "Parent" of views created from Node since Node is not subtype of View.
     */
    private val entityView by lazy { EntityView() }

    private val listeners = arrayListOf<ClickListener>()

    private val onClickListener = EventHandler<MouseEvent> { listeners.forEach { it.onClick() } }

    init {
        parent.addEventHandler(MouseEvent.MOUSE_CLICKED, onClickListener)
    }

    fun setViewFromNode(node: Node) {
        entityView.clearChildren()
        entityView.addNode(node)

{'fraction_non_alphanumeric': 0.0956542276806802, 'fraction_numerical': 0.0021256495040151155, 'mean_word_length': 2.976525821596244, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2500269', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1169, 'n_words': 293}