X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fg2d%2Fnodes%2Fconnection%2FRemoveLineAction.java;h=c684ea5ff09c32b07e9dfdaf2b6f7af58fbaee55;hb=c684e246101adc478671274a9aae1979bfc02820;hp=b497b869ab4f21d9bc8cc818afa46940d5a18505;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RemoveLineAction.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RemoveLineAction.java index b497b869a..c684ea5ff 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RemoveLineAction.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RemoveLineAction.java @@ -1,69 +1,69 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 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.scenegraph.g2d.nodes.connection; - -import gnu.trove.map.hash.THashMap; - -import org.simantics.diagram.connection.RouteGraph; -import org.simantics.diagram.connection.RouteLine; -import org.simantics.diagram.connection.RouteTerminal; - -/** - * @author Tuukka Lehtonen - */ -public class RemoveLineAction { - - RouteGraph rg; - RouteGraph rgc; - RouteTerminal terminal; - - public RemoveLineAction(RouteGraph rg, RouteGraph rgc, RouteTerminal terminal) { - this.rg = rg; - this.rgc = rgc; - this.terminal = terminal; - } - - public RouteGraph getOriginalRouteGraph() { - return rg; - } - - public RouteGraph getRouteGraph() { - return rgc; - } - - /** - * @param rg - * @param l the route line to remove - * @param x - * @param y - * @return the performed action or null if no action to perform - */ - public static RemoveLineAction perform(RouteGraph rg, RouteLine line, double x, double y) { - // Can't remove segments from connections that have only two terminals. - if (rg.isSimpleConnection() || rg.getTerminals().size() <= 2) - return null; - - THashMap map = new THashMap(); - RouteGraph rgc = rg.copy(map); - RouteLine lc = (RouteLine) map.get(line); - - RouteTerminal terminal = lc.getTerminal(); - if (terminal == null) - return null; - - rgc.disconnect(terminal); - rgc.remove(terminal); - - return new RemoveLineAction(rg, rgc, terminal); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2011 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.scenegraph.g2d.nodes.connection; + +import gnu.trove.map.hash.THashMap; + +import org.simantics.diagram.connection.RouteGraph; +import org.simantics.diagram.connection.RouteLine; +import org.simantics.diagram.connection.RouteTerminal; + +/** + * @author Tuukka Lehtonen + */ +public class RemoveLineAction { + + RouteGraph rg; + RouteGraph rgc; + RouteTerminal terminal; + + public RemoveLineAction(RouteGraph rg, RouteGraph rgc, RouteTerminal terminal) { + this.rg = rg; + this.rgc = rgc; + this.terminal = terminal; + } + + public RouteGraph getOriginalRouteGraph() { + return rg; + } + + public RouteGraph getRouteGraph() { + return rgc; + } + + /** + * @param rg + * @param l the route line to remove + * @param x + * @param y + * @return the performed action or null if no action to perform + */ + public static RemoveLineAction perform(RouteGraph rg, RouteLine line, double x, double y) { + // Can't remove segments from connections that have only two terminals. + if (rg.isSimpleConnection() || rg.getTerminals().size() <= 2) + return null; + + THashMap map = new THashMap(); + RouteGraph rgc = rg.copy(map); + RouteLine lc = (RouteLine) map.get(line); + + RouteTerminal terminal = lc.getTerminal(); + if (terminal == null) + return null; + + rgc.disconnect(terminal); + rgc.remove(terminal); + + return new RemoveLineAction(rg, rgc, terminal); + } + +}