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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.diagram.handler;
\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
21 * A relationship <em>can</em> also have an inverse relationship but doesn't
\r
26 * Implementations are strongly encouraged to have a <code>toString</code>
\r
27 * that states the name of the relationship.
\r
30 * @author Tuukka Lehtonen
\r
32 public interface Relationship {
\r
35 * @return null if there is no inverse relationship to this
\r
37 Relationship getInverse();
\r
39 // Some standard relationships between elements
\r
42 * A compositional relationship between two elements.
\r
44 Relationship CHILD_OF = new Relationship() {
\r
45 public Relationship getInverse() { return PARENT_OF; }
\r
47 public String toString() { return "CHILD OF"; }
\r
49 Relationship PARENT_OF = new Relationship() {
\r
50 public Relationship getInverse() { return CHILD_OF; }
\r
52 public String toString() { return "PARENT OF"; }
\r
56 * A relationship between two elements without any further semantics.
\r
58 Relationship RELATED_TO = new Relationship() {
\r
59 public Relationship getInverse() { return RELATED_TO; }
\r
61 public String toString() { return "RELATED_TO"; }
\r