]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/content/ResourceTerminal.java
Some enhancements to GraphLayer-related utilities for Diagram layers
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / content / ResourceTerminal.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.diagram.content;
13
14 import java.awt.Shape;
15 import java.awt.geom.AffineTransform;
16
17 import org.simantics.db.Resource;
18 import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;
19 import org.simantics.g2d.diagram.handler.Topology.Terminal;
20 import org.simantics.g2d.element.handler.impl.ObjectTerminal;
21 import org.simantics.g2d.utils.geom.DirectionSet;
22 import org.simantics.utils.Container;
23 import org.simantics.utils.DataContainer;
24
25 /**
26  * A default DB resource based implementation of the g2d {@link Terminal}
27  * interface.
28  * 
29  * <p>
30  * Elements that intend to contain terminal and use
31  * {@link GraphToDiagramSynchronizer} must use this implementation to represent
32  * the terminals of the element.
33  * </p>
34  * 
35  * <p>
36  * Also contains a relative transformation with respect to its parent, a set of
37  * allowed drawing directions and a graphical shape to depict the terminal.
38  * </p>
39  * 
40  * <p>
41  * The specified terminal resource is expected to have at least the following
42  * graph attached to it:
43  * <pre>
44  * specified-resource
45  *     DIAGRAM.HasConnectionVariable
46  *         _ : STRUCTURAL.ConnectionVariable
47  *             STRUCTURAL.Binds TerminalRelation
48  * </pre>
49  * </p>
50  * 
51  * @author Tuukka Lehtonen
52  */
53 public class ResourceTerminal extends ObjectTerminal {
54
55     public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds, Container<Shape> shape) {
56         super(r, transform, ds, shape);
57     }
58
59     public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds, Shape shape) {
60         super(r, transform, ds, new DataContainer<Shape>(shape));
61     }
62
63     public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds) {
64         super(r, transform, ds);
65     }
66
67     public ResourceTerminal(Resource r, AffineTransform transform) {
68         super(r, transform);
69     }
70
71     public ResourceTerminal(Resource r) {
72         super(r, new AffineTransform());
73     }
74
75     public Resource getResource() {
76         return (Resource) getData();
77     }
78
79 }