]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/routing/Terminal.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / routing / Terminal.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.routing;\r
13 \r
14 import java.awt.geom.Rectangle2D;\r
15 import java.util.Arrays;\r
16 \r
17 public class Terminal {\r
18         public static final double[] ZEROS = new double[] { 0.0, 0.0, 0.0, 0.0 };\r
19         \r
20         public double x;\r
21         public double y;\r
22         public int directions;\r
23         public double[] minDist;\r
24         public Rectangle2D parentObstacle;\r
25         \r
26         public Terminal(double x, double y, int directions, double[] minDist,\r
27             Rectangle2D parentObstacle) {\r
28                 this.x = x;\r
29                 this.y = y;\r
30                 this.directions = directions;\r
31                 this.minDist = minDist;\r
32                 this.parentObstacle = parentObstacle;\r
33         }\r
34 \r
35         @Override\r
36         public int hashCode() {\r
37                 final int prime = 31;\r
38                 int result = 1;\r
39                 result = prime * result + directions;\r
40                 result = prime * result + Arrays.hashCode(minDist);\r
41                 long temp;\r
42                 temp = Double.doubleToLongBits(x);\r
43                 result = prime * result + (int) (temp ^ (temp >>> 32));\r
44                 temp = Double.doubleToLongBits(y);\r
45                 result = prime * result + (int) (temp ^ (temp >>> 32));\r
46                 return result;\r
47         }\r
48 \r
49         @Override\r
50         public boolean equals(Object obj) {\r
51                 if (this == obj)\r
52                         return true;\r
53                 if (obj == null)\r
54                         return false;\r
55                 if (getClass() != obj.getClass())\r
56                         return false;\r
57                 Terminal other = (Terminal) obj;\r
58                 if (directions != other.directions)\r
59                         return false;\r
60                 if (!Arrays.equals(minDist, other.minDist))\r
61                         return false;\r
62                 if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))\r
63                         return false;\r
64                 if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))\r
65                         return false;\r
66                 return true;\r
67         }       \r
68         \r
69         \r
70         \r
71 }\r