diff --git a/connector/src/main/java/devtoolsfx/connector/LocalElement.java b/connector/src/main/java/devtoolsfx/connector/LocalElement.java index 78735eb..d1e1c2f 100644 --- a/connector/src/main/java/devtoolsfx/connector/LocalElement.java +++ b/connector/src/main/java/devtoolsfx/connector/LocalElement.java @@ -4,15 +4,16 @@ import devtoolsfx.scenegraph.*; import devtoolsfx.util.ClassInfoCache; import devtoolsfx.util.SceneUtils; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; import javafx.scene.Node; import javafx.stage.Window; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - /** * The {@link Element} implementation that directly wraps a link to the scene graph * node and must not leak the JVM process (e.g. by transferring it via the network). @@ -25,6 +26,7 @@ public final class LocalElement implements Element { private final Vertex vertex; private final @Nullable NodeProperties nodeProperties; private final @Nullable WindowProperties windowProperties; + private final Map properties = new ConcurrentHashMap<>(); private final @Nullable Node node; private LocalElement(int uid, @@ -89,6 +91,11 @@ public boolean hasChildren() { return windowProperties; } + @Override + public Map getProperties() { + return this.properties; + } + @Override public boolean isWindowElement() { return windowProperties != null; diff --git a/connector/src/main/java/devtoolsfx/scenegraph/Element.java b/connector/src/main/java/devtoolsfx/scenegraph/Element.java index a1d22ba..66006cf 100644 --- a/connector/src/main/java/devtoolsfx/scenegraph/Element.java +++ b/connector/src/main/java/devtoolsfx/scenegraph/Element.java @@ -1,7 +1,7 @@ package devtoolsfx.scenegraph; import java.util.List; - +import java.util.Map; import javafx.scene.Node; import javafx.stage.Window; import org.jspecify.annotations.NullMarked; @@ -58,6 +58,17 @@ public interface Element { @Nullable WindowProperties getWindowProperties(); + /** + * Returns the map of properties associated with this element. + *

+ * This map can be used to store user-defined data or metadata related to + * the element. The returned map is mutable, and callers may add, modify, + * or remove entries as needed. + * + * @return a mutable map of user-defined properties + */ + Map getProperties(); + /** * Checks whether the element is a wrapper around {@link Node}. */ diff --git a/gui/src/main/java/devtoolsfx/gui/util/DummyElement.java b/gui/src/main/java/devtoolsfx/gui/util/DummyElement.java index 0945c80..8694046 100644 --- a/gui/src/main/java/devtoolsfx/gui/util/DummyElement.java +++ b/gui/src/main/java/devtoolsfx/gui/util/DummyElement.java @@ -4,11 +4,12 @@ import devtoolsfx.scenegraph.Element; import devtoolsfx.scenegraph.NodeProperties; import devtoolsfx.scenegraph.WindowProperties; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.List; - /** * Dummy class to represent the root of a scene graph element tree. */ @@ -17,6 +18,8 @@ public final class DummyElement implements Element { private final String name; + private final Map properties = new ConcurrentHashMap<>(); + public DummyElement(String name) { this.name = name; } @@ -61,6 +64,11 @@ public boolean hasChildren() { return null; } + @Override + public Map getProperties() { + return this.properties; + } + @Override public boolean isWindowElement() { return false;