X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fdiagram%2Fhandler%2FTopology.java;h=fd3c516eb509be98c72ca1e991fdb1e5cc1e4bf7;hb=refs%2Fchanges%2F38%2F238%2F2;hp=6a2851ba4fed4aa92178edd67e7ab21276810a80;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/Topology.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/Topology.java index 6a2851ba4..fd3c516eb 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/Topology.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/Topology.java @@ -1,125 +1,125 @@ -/******************************************************************************* - * 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.diagram.handler; - -import java.util.Collection; - -import org.simantics.g2d.diagram.handler.impl.TopologyImpl; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd; -import org.simantics.g2d.element.handler.TerminalTopology; -import org.simantics.g2d.element.handler.impl.ObjectTerminal; - -/** - * - * TODO Remove Connection. Replace with Individual hints. - * - * @see TopologyImpl Default implementation. - * @author Toni Kalajainen - */ -public interface Topology extends DiagramHandler { - - /** - * @See TerminalImpl - * @see ObjectTerminal - */ - public interface Terminal {} - - /** - * @param edge - * @param end Begin or End - * @return null if the specified end of the specified edge is - * not connected - */ - Connection getConnection(IElement edge, EdgeEnd end); - - /** - * Get all the connections attached to the specified terminal of the - * specified node. - * - * @param node - * @param terminal - * @param connections - */ - void getConnections(IElement node, Terminal terminal, Collection connections); - - /** - * Connect one end of a connection to an element terminal. - * - * @param edge the edge to connect to the specified node, must belong to the - * same diagram as the node - * @param end - * @param node the node to connect to the specified edge, must belong to the - * same diagram as the edge - * @param terminal a terminal of node, retrieved using {@link TerminalTopology} - */ - void connect(IElement edge, EdgeEnd end, IElement node, Terminal terminal); - - /** - * Disconnect one end of a connection from an element terminal. - * - * @param edge the edge to connect to the specified node, must belong to the - * same diagram as the node - * @param end the end of the edge to disconnect - * @param node the node to disconnect the specified edge from. Must belong to the - * same diagram as the edge. - * @param terminal a terminal of node, retrieved using {@link TerminalTopology} - */ - void disconnect(IElement edge, EdgeEnd end, IElement node, Terminal terminal); - - /** - * A hint value class for representing a single edge end to node terminal - * connection. - */ - public static class Connection { - public final Terminal terminal; - public final IElement edge; - public final IElement node; - public final EdgeEnd end; - public Connection(IElement edge, EdgeEnd end, IElement node, Terminal terminal) { - assert edge != null; - assert end != null; - assert (terminal == null && node == null) || (node != null && terminal != null); - this.edge = edge; - this.end = end; - this.node = node; - this.terminal = terminal; - } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof Connection)) - return false; - Connection other = (Connection) obj; - return other.terminal == terminal && - other.edge == edge && - other.node == node && - other.end == end; - } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + edge.hashCode(); - result = prime * result + end.hashCode(); - result = prime * result + ((node == null) ? 0 : node.hashCode()); - result = prime * result + ((terminal == null) ? 0 : terminal.hashCode()); - return result; - } - @Override - public String toString() { - return "Topology.Connection[edge=" + edge + ", node=" + node + ", terminal=" + terminal + ", end=" + end + "]"; - } - } - -} +/******************************************************************************* + * 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.diagram.handler; + +import java.util.Collection; + +import org.simantics.g2d.diagram.handler.impl.TopologyImpl; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd; +import org.simantics.g2d.element.handler.TerminalTopology; +import org.simantics.g2d.element.handler.impl.ObjectTerminal; + +/** + * + * TODO Remove Connection. Replace with Individual hints. + * + * @see TopologyImpl Default implementation. + * @author Toni Kalajainen + */ +public interface Topology extends DiagramHandler { + + /** + * @See TerminalImpl + * @see ObjectTerminal + */ + public interface Terminal {} + + /** + * @param edge + * @param end Begin or End + * @return null if the specified end of the specified edge is + * not connected + */ + Connection getConnection(IElement edge, EdgeEnd end); + + /** + * Get all the connections attached to the specified terminal of the + * specified node. + * + * @param node + * @param terminal + * @param connections + */ + void getConnections(IElement node, Terminal terminal, Collection connections); + + /** + * Connect one end of a connection to an element terminal. + * + * @param edge the edge to connect to the specified node, must belong to the + * same diagram as the node + * @param end + * @param node the node to connect to the specified edge, must belong to the + * same diagram as the edge + * @param terminal a terminal of node, retrieved using {@link TerminalTopology} + */ + void connect(IElement edge, EdgeEnd end, IElement node, Terminal terminal); + + /** + * Disconnect one end of a connection from an element terminal. + * + * @param edge the edge to connect to the specified node, must belong to the + * same diagram as the node + * @param end the end of the edge to disconnect + * @param node the node to disconnect the specified edge from. Must belong to the + * same diagram as the edge. + * @param terminal a terminal of node, retrieved using {@link TerminalTopology} + */ + void disconnect(IElement edge, EdgeEnd end, IElement node, Terminal terminal); + + /** + * A hint value class for representing a single edge end to node terminal + * connection. + */ + public static class Connection { + public final Terminal terminal; + public final IElement edge; + public final IElement node; + public final EdgeEnd end; + public Connection(IElement edge, EdgeEnd end, IElement node, Terminal terminal) { + assert edge != null; + assert end != null; + assert (terminal == null && node == null) || (node != null && terminal != null); + this.edge = edge; + this.end = end; + this.node = node; + this.terminal = terminal; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!(obj instanceof Connection)) + return false; + Connection other = (Connection) obj; + return other.terminal == terminal && + other.edge == edge && + other.node == node && + other.end == end; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + edge.hashCode(); + result = prime * result + end.hashCode(); + result = prime * result + ((node == null) ? 0 : node.hashCode()); + result = prime * result + ((terminal == null) ? 0 : terminal.hashCode()); + return result; + } + @Override + public String toString() { + return "Topology.Connection[edge=" + edge + ", node=" + node + ", terminal=" + terminal + ", end=" + end + "]"; + } + } + +}