]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/INode.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / INode.java
diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/INode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/INode.java
new file mode 100644 (file)
index 0000000..8957d64
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.scenegraph;
+
+import java.io.Serializable;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author J-P Laine\r
+ * \r
+ * @see Node\r
+ * @see ParentNode\r
+ */
+public interface INode extends Serializable {
+    public static enum Location { LOCAL, REMOTE };
+
+    /**\r
+     * Tell the MethodInterceptor to synchronize the given fields after the\r
+     * method call.\r
+     * \r
+     * @author J-P Laine\r
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    public @interface SyncField {
+        String[] value(); // Field name(s)
+    }
+
+    /**\r
+     * Tell the MethodInterceptor to remotely call this method if we are on the\r
+     * client side. Notice that the method type must be void, thus it cannot\r
+     * return value.\r
+     * \r
+     * @author J-P Laine\r
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    public @interface ServerSide {
+    }
+
+    /**\r
+     * Tell the MethodInterceptor to remotely call this method if we are on the\r
+     * server side. Notice that the method type must be void, thus it cannot\r
+     * return value.\r
+     * \r
+     * @author J-P Laine\r
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    public @interface ClientSide {
+    }\r
+\r
+    /**\r
+     * Tag method as setter for a property identified by string. Basically used\r
+     * by the automatic graph to node property synchronizer.\r
+     * \r
+     * @author J-P Laine\r
+     */\r
+    @Retention(RetentionPolicy.RUNTIME)\r
+    @Target(ElementType.METHOD)\r
+    public @interface PropertySetter {\r
+        String value(); // Property name\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @return unique node identifier\r
+     */
+    public Long getId();
+\r
+    /**\r
+     * @return root node of the scene graph or <code>null</code> if this node is\r
+     *         not part of a properly rooted scene graph hierarchy\r
+     */\r
+    public ParentNode<?> getRootNode();\r
+\r
+    /**\r
+     * @return Parent node reference or <code>null</code> if not set\r
+     */
+    public ParentNode<?> getParent();
+\r
+    /**\r
+     * Set parent node. This method is for scene graph internal use only and\r
+     * should not be called outside the scene graph structure. This method\r
+     * simply sets the parent node parent field, and does not affect on parent\r
+     * node (i.e., should be called only from parent node).\r
+     */
+    public void setParent(ParentNode<?> parent);
+\r
+    /**\r
+     * Initialize node. This is called immediately after the node is added to\r
+     * the scene graph tree through any of the node addition methods in\r
+     * {@link ParentNode}.\r
+     * \r
+     * @see ParentNode#addNode(Class)\r
+     * @see ParentNode#addNode(String, Class)\r
+     * @see ParentNode#getOrCreateNode(String, Class)\r
+     */
+    public void init();
+    public void attach();\r
+    \r
+    /**\r
+     * Perform cleanup for this node and for the child nodes. Any resources\r
+     * (including child nodes) related to this node are unusable after this\r
+     * operation. This method is for scene graph internal use only, thus should\r
+     * not be called outside the scene graph structure.\r
+     */
+    public void cleanup();
+\r
+    /**\r
+     * Remove this node and its children from the scene graph.\r
+     */
+    public void remove();
+\r
+    /**\r
+     * Delete this node, and move its children under its parent.\r
+     * \r
+     * <p>\r
+     * Note: this method has no effect if the node has no parent.\r
+     */\r
+    public void delete();\r
+\r
+    /**\r
+     * Append parent node for this node. The new node will be placed between\r
+     * parent node and this node. In order to call this method the node must be\r
+     * a child of another node, hence parent must be not null.\r
+     */\r
+    public <TC> TC appendParent(String id, Class<TC> nc);\r
+
+    @Override
+    public String toString();
+
+    /**\r
+     * @return simple name for this node class\r
+     */\r
+    public String getSimpleClassName();\r
+\r
+}