]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/Relationship.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / handler / Relationship.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.diagram.handler;\r
13 \r
14 \r
15 /**\r
16  * Defines the meaning of the relationship which must either remain internal\r
17  * to a specific implementation or be published as API of an implementation\r
18  * of this handler.\r
19  * \r
20  * <p>\r
21  * A relationship <em>can</em> also have an inverse relationship but doesn't\r
22  * have to.\r
23  * </p>\r
24  * \r
25  * <p>\r
26  * Implementations are strongly encouraged to have a <code>toString</code>\r
27  * that states the name of the relationship.\r
28  * </p>\r
29  * \r
30  * @author Tuukka Lehtonen\r
31  */\r
32 public interface Relationship {\r
33 \r
34     /**\r
35      * @return null if there is no inverse relationship to this\r
36      */\r
37     Relationship getInverse();\r
38 \r
39     // Some standard relationships between elements\r
40 \r
41     /**\r
42      * A compositional relationship between two elements. \r
43      */\r
44     Relationship CHILD_OF = new Relationship() {\r
45         public Relationship getInverse() { return PARENT_OF; }\r
46         @Override\r
47         public String toString() { return "CHILD OF"; }\r
48     };\r
49     Relationship PARENT_OF = new Relationship() {\r
50         public Relationship getInverse() { return CHILD_OF; }\r
51         @Override\r
52         public String toString() { return "PARENT OF"; }\r
53     };\r
54 \r
55     /**\r
56      * A relationship between two elements without any further semantics.\r
57      */\r
58     Relationship RELATED_TO = new Relationship() {\r
59         public Relationship getInverse() { return RELATED_TO; }\r
60         @Override\r
61         public String toString() { return "RELATED_TO"; }\r
62     };\r
63 \r
64 }