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