X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felement%2Fhandler%2Fimpl%2FTerminals.java;h=ca8518e6c38a5863267edb63b4f5336a01fdfe1b;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=139e76dfa6abcd9cd5943e811d7e5831cbc1447b;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/Terminals.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/Terminals.java index 139e76dfa..ca8518e6c 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/Terminals.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/Terminals.java @@ -1,92 +1,92 @@ -/******************************************************************************* - * 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 gnu.trove.map.hash.THashMap; - -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import org.simantics.g2d.diagram.handler.Topology.Terminal; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.TerminalLayout; -import org.simantics.g2d.element.handler.TerminalTopology; -import org.simantics.g2d.utils.geom.DirectionSet; - -/** - * @author Tuukka Lehtonen - */ -public class Terminals implements TerminalLayout, TerminalTopology { - - private static final long serialVersionUID = -6532093690907028016L; - - private final Map terminalMap = new THashMap(); - private final ArrayList terminals = new ArrayList(); - - public Terminals(Collection ts) { - for (ObjectTerminal ti : ts) { - terminals.add(ti); - terminalMap.put(ti, ti); - } - } - - @Override - public AffineTransform getTerminalPosition(IElement node, Terminal t) { - ObjectTerminal ti = terminalMap.get(t); - if (ti == null) - return null; - return new AffineTransform(ti.getTransform()); - } - - @Override - public void getTerminals(IElement e, Collection result) { - result.addAll(terminals); - } - - @Override - public boolean getTerminalDirection(IElement node, Terminal t, DirectionSet directions) { - ObjectTerminal ti = terminalMap.get(t); - if (ti == null) - return false; - directions.addAll(ti.getDirections()); - return true; - } - - @Override - public Shape getTerminalShape(IElement node, Terminal t) { - ObjectTerminal ti = terminalMap.get(t); - if (ti == null) - return null; - return ti.getShape(); - } - - @Override - public int hashCode() { - return terminalMap.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Terminals other = (Terminals) obj; - return terminalMap.equals(other.terminalMap); - } - +/******************************************************************************* + * 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 gnu.trove.map.hash.THashMap; + +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import org.simantics.g2d.diagram.handler.Topology.Terminal; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.TerminalLayout; +import org.simantics.g2d.element.handler.TerminalTopology; +import org.simantics.g2d.utils.geom.DirectionSet; + +/** + * @author Tuukka Lehtonen + */ +public class Terminals implements TerminalLayout, TerminalTopology { + + private static final long serialVersionUID = -6532093690907028016L; + + private final Map terminalMap = new THashMap(); + private final ArrayList terminals = new ArrayList(); + + public Terminals(Collection ts) { + for (ObjectTerminal ti : ts) { + terminals.add(ti); + terminalMap.put(ti, ti); + } + } + + @Override + public AffineTransform getTerminalPosition(IElement node, Terminal t) { + ObjectTerminal ti = terminalMap.get(t); + if (ti == null) + return null; + return new AffineTransform(ti.getTransform()); + } + + @Override + public void getTerminals(IElement e, Collection result) { + result.addAll(terminals); + } + + @Override + public boolean getTerminalDirection(IElement node, Terminal t, DirectionSet directions) { + ObjectTerminal ti = terminalMap.get(t); + if (ti == null) + return false; + directions.addAll(ti.getDirections()); + return true; + } + + @Override + public Shape getTerminalShape(IElement node, Terminal t) { + ObjectTerminal ti = terminalMap.get(t); + if (ti == null) + return null; + return ti.getShape(); + } + + @Override + public int hashCode() { + return terminalMap.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Terminals other = (Terminals) obj; + return terminalMap.equals(other.terminalMap); + } + } \ No newline at end of file