]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/IElement.java
Merge commit 'bd5bc6e45f700e755b61bd112631796631330ecb'
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / IElement.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.element;\r
13 \r
14 import org.simantics.g2d.diagram.IDiagram;\r
15 import org.simantics.g2d.element.handler.LifeCycle;\r
16 import org.simantics.g2d.element.impl.Element;\r
17 import org.simantics.utils.datastructures.hints.IHintContext;\r
18 \r
19 /**\r
20  * Element is an object on a diagram. Element is part of one diagram.\r
21  * <p>\r
22  * Element variables describe visual properties of the element.\r
23  * \r
24  * Variables (all of them) may be cloned, and serialized.\r
25  * Do not put non-visualization specific variables in element, e.g. Canvas Specific\r
26  * variables.\r
27  * \r
28  * Use DiagramParticipant to write _canvas_specific_variables_ e.g.\r
29  *      DiagramParticipant dp = ctx.getSingleItem(DiagramParticipant.class);\r
30  *      dp.setElementHint(...);\r
31  *      dp.setDiagramHint(...);\r
32  * \r
33  * Note! all values should be treated as if they are immutable.\r
34  * \r
35  * @see ElementUtils\r
36  * @see Element\r
37  * @author Toni Kalajainen\r
38  * @noimplement This interface is not intended to be implemented by clients.\r
39  */\r
40 public interface IElement extends IHintContext {\r
41 \r
42     /**\r
43      * @return\r
44      */\r
45     ElementClass getElementClass();\r
46 \r
47     /**\r
48      * Returns the diagram this element is directly a part of.\r
49      * \r
50      * @return the diagram\r
51      */\r
52     IDiagram getDiagram();\r
53 \r
54     /**\r
55      * Looks whether this element is a a direct part of a diagram.\r
56      * \r
57      * @return <code>null</code> if not a direct part of a diagram\r
58      */\r
59     IDiagram peekDiagram();\r
60 \r
61     /**\r
62      * (INTERNAL!) Invoked as a notification when this element is added to a\r
63      * diagram or removed from a diagram.\r
64      * \r
65      * @param diagram\r
66      *            diagram or <code>null</code> if the element was removed from a\r
67      *            diagram\r
68      */\r
69     void addedToDiagram(IDiagram diagram);\r
70 \r
71     /**\r
72      * Destroys the element from the world. Notifies all life-cycle handlers\r
73      * through {@link LifeCycle#onElementDestroyed(IElement)} of the event.\r
74      */\r
75     void destroy();\r
76 \r
77     /**\r
78      * Silently disposes of the element without performing any {@link LifeCycle}\r
79      * notifications.\r
80      */\r
81     void dispose();\r
82 \r
83 }\r