]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/IElement.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / IElement.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/IElement.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/IElement.java
new file mode 100644 (file)
index 0000000..3deb490
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************\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.g2d.element;\r
+\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.handler.LifeCycle;\r
+import org.simantics.g2d.element.impl.Element;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+\r
+/**\r
+ * Element is an object on a diagram. Element is part of one diagram.\r
+ * <p>\r
+ * Element variables describe visual properties of the element.\r
+ * \r
+ * Variables (all of them) may be cloned, and serialized.\r
+ * Do not put non-visualization specific variables in element, e.g. Canvas Specific\r
+ * variables.\r
+ * \r
+ * Use DiagramParticipant to write _canvas_specific_variables_ e.g.\r
+ *      DiagramParticipant dp = ctx.getSingleItem(DiagramParticipant.class);\r
+ *      dp.setElementHint(...);\r
+ *      dp.setDiagramHint(...);\r
+ * \r
+ * Note! all values should be treated as if they are immutable.\r
+ * \r
+ * @see ElementUtils\r
+ * @see Element\r
+ * @author Toni Kalajainen\r
+ * @noimplement This interface is not intended to be implemented by clients.\r
+ */\r
+public interface IElement extends IHintContext {\r
+\r
+    /**\r
+     * @return\r
+     */\r
+    ElementClass getElementClass();\r
+\r
+    /**\r
+     * Returns the diagram this element is directly a part of.\r
+     * \r
+     * @return the diagram\r
+     */\r
+    IDiagram getDiagram();\r
+\r
+    /**\r
+     * Looks whether this element is a a direct part of a diagram.\r
+     * \r
+     * @return <code>null</code> if not a direct part of a diagram\r
+     */\r
+    IDiagram peekDiagram();\r
+\r
+    /**\r
+     * (INTERNAL!) Invoked as a notification when this element is added to a\r
+     * diagram or removed from a diagram.\r
+     * \r
+     * @param diagram\r
+     *            diagram or <code>null</code> if the element was removed from a\r
+     *            diagram\r
+     */\r
+    void addedToDiagram(IDiagram diagram);\r
+\r
+    /**\r
+     * Destroys the element from the world. Notifies all life-cycle handlers\r
+     * through {@link LifeCycle#onElementDestroyed(IElement)} of the event.\r
+     */\r
+    void destroy();\r
+\r
+    /**\r
+     * Silently disposes of the element without performing any {@link LifeCycle}\r
+     * notifications.\r
+     */\r
+    void dispose();\r
+\r
+}\r