Class Position

 1  
 2  
 3  
 4 /*
 5  * Copyright (c) 2016 Vivid Solutions.
 6  *
 7  * All rights reserved. This program and the accompanying materials
 8  * are made available under the terms of the Eclipse Public License 2.0
 9  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
10  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
11  * and the Eclipse Distribution License is available at
12  *
13  * http://www.eclipse.org/org/documents/edl-v10.php.
14  */
15 package org.locationtech.jts.geomgraph;
16  
17 /**
18  * A Position indicates the position of a Location relative to a graph component
19  * (Node, Edge, or Area).
20  * @version 1.7
21  */
22 public class Position {
23  
24   /** An indicator that a Location is <i>on</i> a GraphComponent */
25   public static final int ON      = 0;
26   /** An indicator that a Location is to the <i>left</i> of a GraphComponent */  
27   public static final int LEFT    = 1;
28   /** An indicator that a Location is to the <i>right</i> of a GraphComponent */  
29   public static final int RIGHT   = 2;
30   /**
31    * Returns LEFT if the position is RIGHT, RIGHT if the position is LEFT, or the position
32    * otherwise.
33    */
34   public static final int opposite(int position)
35   {
36     if (position == LEFT) return RIGHT;
37     if (position == RIGHT) return LEFT;
38     return position;
39   }
40 }
41