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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.routing.algorithm1;
\r
14 import org.simantics.g2d.routing.algorithm1.StaticRouter.Cost;
\r
16 public class Penalty {
\r
17 static final double BEND_PENALTY = 1.0;
\r
18 static final double CONNECTION_MARGINAL = 10.0;
\r
19 static final Cost INFINITE_COST = new Cost(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
\r
21 static final Penalty OBSTACLE_PENALTY = new Penalty(20.0, 0.0);
\r
22 static final Penalty CONNECTION_SIDE_PENALTY = new Penalty(10.0, 0.0);
\r
23 static final Penalty CONNECTION_CROSS_PENALTY = new Penalty(0.4, 2*CONNECTION_MARGINAL);
\r
26 double minDistance;
\r
28 public Penalty(double penalty, double minDistance) {
\r
29 this.penalty = penalty;
\r
30 this.minDistance = minDistance;
\r
34 public int hashCode() {
\r
35 final int prime = 31;
\r
38 temp = Double.doubleToLongBits(minDistance);
\r
39 result = prime * result + (int) (temp ^ (temp >>> 32));
\r
40 temp = Double.doubleToLongBits(penalty);
\r
41 result = prime * result + (int) (temp ^ (temp >>> 32));
\r
45 public boolean equals(Object obj) {
\r
50 if (getClass() != obj.getClass())
\r
52 Penalty other = (Penalty) obj;
\r
53 if (Double.doubleToLongBits(minDistance) != Double
\r
54 .doubleToLongBits(other.minDistance))
\r
56 if (Double.doubleToLongBits(penalty) != Double
\r
57 .doubleToLongBits(other.penalty))
\r