X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felement%2Fhandler%2Fimpl%2FObjectTerminal.java;h=cf80e06f94d6f0f76c93e2711e4552e22c435670;hb=74776fa0c613daf38465901c248433bec99d2c72;hp=1804b154479f4aef28ec971173580e898df16003;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ObjectTerminal.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ObjectTerminal.java index 1804b1544..cf80e06f9 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ObjectTerminal.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ObjectTerminal.java @@ -1,108 +1,108 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g2d.element.handler.impl; - -import java.awt.Shape; -import java.awt.geom.AffineTransform; - -import org.simantics.g2d.diagram.handler.Topology.Terminal; -import org.simantics.g2d.utils.geom.DirectionSet; -import org.simantics.utils.Container; -import org.simantics.utils.DataContainer; - -/** - * An arbitrary object based implementation of the g2d {@link Terminal} - * interface. - * - *

- * Elements that intend to contain terminal and use - * DiagramGraphSynchronizer must use this implementation to - * represent the terminals of the element. - *

- * - *

- * Also contains a relative transformation with respect to its parent, a set of - * allowed drawing directions and a graphical shape to depict the terminal. - *

- * - * @author Tuukka Lehtonen - */ -public abstract class ObjectTerminal implements Terminal { - - private static final Container NO_SHAPE = new DataContainer(null); - - private final Object data; - private final AffineTransform transform; - private final DirectionSet ds; - private final Container shape; - - public ObjectTerminal(Object data, AffineTransform transform, DirectionSet ds, Container shape) { - assert data != null; - this.data = data; - this.transform = transform; - this.ds = ds; - this.shape = shape != null ? shape : NO_SHAPE; - } - - public ObjectTerminal(Object data, AffineTransform transform, DirectionSet ds, Shape shape) { - this(data, transform, ds, new DataContainer(shape)); - } - - public ObjectTerminal(Object data, AffineTransform transform, DirectionSet ds) { - this(data, transform, ds, NO_SHAPE); - } - - public ObjectTerminal(Object data, AffineTransform transform) { - this(data, transform, DirectionSet.ANY, NO_SHAPE); - } - - public ObjectTerminal(Object data) { - this(data, new AffineTransform(), DirectionSet.ANY, NO_SHAPE); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + data + ", " + transform + ", " + shape + "]"; - } - - @Override - public int hashCode() { - return data.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null || getClass() != obj.getClass()) - return false; - ObjectTerminal other = (ObjectTerminal) obj; - return data.equals(other.data); - } - - public Object getData() { - return data; - } - - public AffineTransform getTransform() { - return transform; - } - - public DirectionSet getDirections() { - return ds; - } - - public Shape getShape() { - return shape.get(); - } - +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g2d.element.handler.impl; + +import java.awt.Shape; +import java.awt.geom.AffineTransform; + +import org.simantics.g2d.diagram.handler.Topology.Terminal; +import org.simantics.g2d.utils.geom.DirectionSet; +import org.simantics.utils.Container; +import org.simantics.utils.DataContainer; + +/** + * An arbitrary object based implementation of the g2d {@link Terminal} + * interface. + * + *

+ * Elements that intend to contain terminal and use + * DiagramGraphSynchronizer must use this implementation to + * represent the terminals of the element. + *

+ * + *

+ * Also contains a relative transformation with respect to its parent, a set of + * allowed drawing directions and a graphical shape to depict the terminal. + *

+ * + * @author Tuukka Lehtonen + */ +public abstract class ObjectTerminal implements Terminal { + + private static final Container NO_SHAPE = new DataContainer(null); + + private final Object data; + private final AffineTransform transform; + private final DirectionSet ds; + private final Container shape; + + public ObjectTerminal(Object data, AffineTransform transform, DirectionSet ds, Container shape) { + assert data != null; + this.data = data; + this.transform = transform; + this.ds = ds; + this.shape = shape != null ? shape : NO_SHAPE; + } + + public ObjectTerminal(Object data, AffineTransform transform, DirectionSet ds, Shape shape) { + this(data, transform, ds, new DataContainer(shape)); + } + + public ObjectTerminal(Object data, AffineTransform transform, DirectionSet ds) { + this(data, transform, ds, NO_SHAPE); + } + + public ObjectTerminal(Object data, AffineTransform transform) { + this(data, transform, DirectionSet.ANY, NO_SHAPE); + } + + public ObjectTerminal(Object data) { + this(data, new AffineTransform(), DirectionSet.ANY, NO_SHAPE); + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + data + ", " + transform + ", " + shape + "]"; + } + + @Override + public int hashCode() { + return data.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + ObjectTerminal other = (ObjectTerminal) obj; + return data.equals(other.data); + } + + public Object getData() { + return data; + } + + public AffineTransform getTransform() { + return transform; + } + + public DirectionSet getDirections() { + return ds; + } + + public Shape getShape() { + return shape.get(); + } + } \ No newline at end of file