]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/routing/algorithm1/Penalty.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / routing / algorithm1 / Penalty.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.routing.algorithm1;
13
14 import org.simantics.g2d.routing.algorithm1.StaticRouter.Cost;
15
16 public class Penalty {
17         static final double BEND_PENALTY = 1.0;
18         static final double CONNECTION_MARGINAL = 10.0;
19         static final Cost INFINITE_COST = new Cost(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
20         
21         static final Penalty OBSTACLE_PENALTY = new Penalty(20.0, 0.0);
22         static final Penalty CONNECTION_SIDE_PENALTY = new Penalty(10.0, 0.0);
23         static final Penalty CONNECTION_CROSS_PENALTY = new Penalty(0.4, 2*CONNECTION_MARGINAL);
24         
25         double penalty;
26         double minDistance;     
27         
28         public Penalty(double penalty, double minDistance) {
29                 this.penalty = penalty;
30                 this.minDistance = minDistance;
31         }
32         
33         @Override
34         public int hashCode() {
35                 final int prime = 31;
36                 int result = 1;
37                 long temp;
38                 temp = Double.doubleToLongBits(minDistance);
39                 result = prime * result + (int) (temp ^ (temp >>> 32));
40                 temp = Double.doubleToLongBits(penalty);
41                 result = prime * result + (int) (temp ^ (temp >>> 32));
42                 return result;
43         }
44         @Override
45         public boolean equals(Object obj) {
46                 if (this == obj)
47                         return true;
48                 if (obj == null)
49                         return false;
50                 if (getClass() != obj.getClass())
51                         return false;
52                 Penalty other = (Penalty) obj;
53                 if (Double.doubleToLongBits(minDistance) != Double
54                         .doubleToLongBits(other.minDistance))
55                         return false;
56                 if (Double.doubleToLongBits(penalty) != Double
57                         .doubleToLongBits(other.penalty))
58                         return false;
59                 return true;
60         }
61         
62         
63 }