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