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.diagram.content;
\r
14 import java.awt.Shape;
\r
15 import java.awt.geom.AffineTransform;
\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
26 * A default DB resource based implementation of the g2d {@link Terminal}
\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
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
41 * The specified terminal resource is expected to have at least the following
\r
42 * graph attached to it:
\r
44 * specified-resource
\r
45 * DIAGRAM.HasConnectionVariable
\r
46 * _ : STRUCTURAL.ConnectionVariable
\r
47 * STRUCTURAL.Binds TerminalRelation
\r
51 * @author Tuukka Lehtonen
\r
53 public class ResourceTerminal extends ObjectTerminal {
\r
55 public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds, Container<Shape> shape) {
\r
56 super(r, transform, ds, shape);
\r
59 public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds, Shape shape) {
\r
60 super(r, transform, ds, new DataContainer<Shape>(shape));
\r
63 public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds) {
\r
64 super(r, transform, ds);
\r
67 public ResourceTerminal(Resource r, AffineTransform transform) {
\r
68 super(r, transform);
\r
71 public ResourceTerminal(Resource r) {
\r
72 super(r, new AffineTransform());
\r
75 public Resource getResource() {
\r
76 return (Resource) getData();
\r