X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram.connection%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fconnection%2FRoutePoint.java;fp=bundles%2Forg.simantics.diagram.connection%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fconnection%2FRoutePoint.java;h=70450e9666ab394a7b095d5fc79934796629dd96;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RoutePoint.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RoutePoint.java new file mode 100644 index 000000000..70450e966 --- /dev/null +++ b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RoutePoint.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 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.diagram.connection; + +import gnu.trove.map.hash.THashMap; + +import java.util.Comparator; + +public abstract class RoutePoint { + + public static final Comparator X_COMPARATOR = new Comparator() { + @Override + public int compare(RoutePoint a, RoutePoint b) { + return Double.compare(a.x, b.x); + } + }; + + public static final Comparator Y_COMPARATOR = new Comparator() { + @Override + public int compare(RoutePoint a, RoutePoint b) { + return Double.compare(a.y, b.y); + } + }; + + double x; + double y; + + public RoutePoint() { + } + + public RoutePoint(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + void removeFromOther(RouteLine routeLine) { + } + + public boolean isNear(double x2, double y2, double tolerance) { + double dx = x2-x; + double dy = y2-y; + + return dx*dx + dy*dy <= tolerance*tolerance; + } + + abstract RoutePoint copy(THashMap map); + + + public void setX(double x) { + this.x = x; + } + + public void setY(double y) { + this.y = y; + } +}