1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.content;
14 import java.awt.Shape;
15 import java.awt.geom.AffineTransform;
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;
26 * A default DB resource based implementation of the g2d {@link Terminal}
30 * Elements that intend to contain terminal and use
31 * {@link GraphToDiagramSynchronizer} must use this implementation to represent
32 * the terminals of the element.
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.
41 * The specified terminal resource is expected to have at least the following
42 * graph attached to it:
45 * DIAGRAM.HasConnectionVariable
46 * _ : STRUCTURAL.ConnectionVariable
47 * STRUCTURAL.Binds TerminalRelation
51 * @author Tuukka Lehtonen
53 public class ResourceTerminal extends ObjectTerminal {
55 public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds, Container<Shape> shape) {
56 super(r, transform, ds, shape);
59 public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds, Shape shape) {
60 super(r, transform, ds, new DataContainer<Shape>(shape));
63 public ResourceTerminal(Resource r, AffineTransform transform, DirectionSet ds) {
64 super(r, transform, ds);
67 public ResourceTerminal(Resource r, AffineTransform transform) {
71 public ResourceTerminal(Resource r) {
72 super(r, new AffineTransform());
75 public Resource getResource() {
76 return (Resource) getData();